Skip to content

Commit 0c3b34d

Browse files
laoardavem330
authored andcommitted
net: tracepoint: exposing sk_faimily in tracepoint inet_sock_set_state
As of now, there're two sk_family are traced with sock:inet_sock_set_state, which are AF_INET and AF_INET6. So the sk_family are exposed as well. Then we can conveniently use it to do the filter. Both sk_family and sk_protocol are showed in the printk message, so we need not expose them as tracepoint arguments. Suggested-by: Brendan Gregg <[email protected]> Suggested-by: Song Liu <[email protected]> Signed-off-by: Yafang Shao <[email protected]> Reviewed-by: Song Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 23fe846 commit 0c3b34d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

include/trace/events/sock.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
#include <linux/ipv6.h>
1212
#include <linux/tcp.h>
1313

14-
/* The protocol traced by sock_set_state */
14+
#define family_names \
15+
EM(AF_INET) \
16+
EMe(AF_INET6)
17+
18+
/* The protocol traced by inet_sock_set_state */
1519
#define inet_protocol_names \
1620
EM(IPPROTO_TCP) \
1721
EM(IPPROTO_DCCP) \
@@ -37,6 +41,7 @@
3741
#define EM(a) TRACE_DEFINE_ENUM(a);
3842
#define EMe(a) TRACE_DEFINE_ENUM(a);
3943

44+
family_names
4045
inet_protocol_names
4146
tcp_state_names
4247

@@ -45,6 +50,9 @@ tcp_state_names
4550
#define EM(a) { a, #a },
4651
#define EMe(a) { a, #a }
4752

53+
#define show_family_name(val) \
54+
__print_symbolic(val, family_names)
55+
4856
#define show_inet_protocol_name(val) \
4957
__print_symbolic(val, inet_protocol_names)
5058

@@ -118,6 +126,7 @@ TRACE_EVENT(inet_sock_set_state,
118126
__field(int, newstate)
119127
__field(__u16, sport)
120128
__field(__u16, dport)
129+
__field(__u16, family)
121130
__field(__u8, protocol)
122131
__array(__u8, saddr, 4)
123132
__array(__u8, daddr, 4)
@@ -134,6 +143,7 @@ TRACE_EVENT(inet_sock_set_state,
134143
__entry->oldstate = oldstate;
135144
__entry->newstate = newstate;
136145

146+
__entry->family = sk->sk_family;
137147
__entry->protocol = sk->sk_protocol;
138148
__entry->sport = ntohs(inet->inet_sport);
139149
__entry->dport = ntohs(inet->inet_dport);
@@ -160,7 +170,8 @@ TRACE_EVENT(inet_sock_set_state,
160170
}
161171
),
162172

163-
TP_printk("protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
173+
TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
174+
show_family_name(__entry->family),
164175
show_inet_protocol_name(__entry->protocol),
165176
__entry->sport, __entry->dport,
166177
__entry->saddr, __entry->daddr,

0 commit comments

Comments
 (0)