diff options
| author | Yafang Shao <laoar.shao@gmail.com> | 2018-01-07 01:31:47 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2018-01-08 14:32:45 -0500 |
| commit | 0c3b34d804947fef7fb9e74912b7b7563729231e (patch) | |
| tree | aa02a016d596614cd3af0dd4df456bf3e9987e17 | |
| parent | 23fe846f9a48d5375722b3bd060e0a02ad1ca7f1 (diff) | |
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 <brendan.d.gregg@gmail.com>
Suggested-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Reviewed-by: Song Liu <songliubraving@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/trace/events/sock.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/include/trace/events/sock.h b/include/trace/events/sock.h index 3537c5f34d77..3176a3931107 100644 --- a/include/trace/events/sock.h +++ b/include/trace/events/sock.h | |||
| @@ -11,7 +11,11 @@ | |||
| 11 | #include <linux/ipv6.h> | 11 | #include <linux/ipv6.h> |
| 12 | #include <linux/tcp.h> | 12 | #include <linux/tcp.h> |
| 13 | 13 | ||
| 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 */ | ||
| 15 | #define inet_protocol_names \ | 19 | #define inet_protocol_names \ |
| 16 | EM(IPPROTO_TCP) \ | 20 | EM(IPPROTO_TCP) \ |
| 17 | EM(IPPROTO_DCCP) \ | 21 | EM(IPPROTO_DCCP) \ |
| @@ -37,6 +41,7 @@ | |||
| 37 | #define EM(a) TRACE_DEFINE_ENUM(a); | 41 | #define EM(a) TRACE_DEFINE_ENUM(a); |
| 38 | #define EMe(a) TRACE_DEFINE_ENUM(a); | 42 | #define EMe(a) TRACE_DEFINE_ENUM(a); |
| 39 | 43 | ||
| 44 | family_names | ||
| 40 | inet_protocol_names | 45 | inet_protocol_names |
| 41 | tcp_state_names | 46 | tcp_state_names |
| 42 | 47 | ||
| @@ -45,6 +50,9 @@ tcp_state_names | |||
| 45 | #define EM(a) { a, #a }, | 50 | #define EM(a) { a, #a }, |
| 46 | #define EMe(a) { a, #a } | 51 | #define EMe(a) { a, #a } |
| 47 | 52 | ||
| 53 | #define show_family_name(val) \ | ||
| 54 | __print_symbolic(val, family_names) | ||
| 55 | |||
| 48 | #define show_inet_protocol_name(val) \ | 56 | #define show_inet_protocol_name(val) \ |
| 49 | __print_symbolic(val, inet_protocol_names) | 57 | __print_symbolic(val, inet_protocol_names) |
| 50 | 58 | ||
| @@ -118,6 +126,7 @@ TRACE_EVENT(inet_sock_set_state, | |||
| 118 | __field(int, newstate) | 126 | __field(int, newstate) |
| 119 | __field(__u16, sport) | 127 | __field(__u16, sport) |
| 120 | __field(__u16, dport) | 128 | __field(__u16, dport) |
| 129 | __field(__u16, family) | ||
| 121 | __field(__u8, protocol) | 130 | __field(__u8, protocol) |
| 122 | __array(__u8, saddr, 4) | 131 | __array(__u8, saddr, 4) |
| 123 | __array(__u8, daddr, 4) | 132 | __array(__u8, daddr, 4) |
| @@ -134,6 +143,7 @@ TRACE_EVENT(inet_sock_set_state, | |||
| 134 | __entry->oldstate = oldstate; | 143 | __entry->oldstate = oldstate; |
| 135 | __entry->newstate = newstate; | 144 | __entry->newstate = newstate; |
| 136 | 145 | ||
| 146 | __entry->family = sk->sk_family; | ||
| 137 | __entry->protocol = sk->sk_protocol; | 147 | __entry->protocol = sk->sk_protocol; |
| 138 | __entry->sport = ntohs(inet->inet_sport); | 148 | __entry->sport = ntohs(inet->inet_sport); |
| 139 | __entry->dport = ntohs(inet->inet_dport); | 149 | __entry->dport = ntohs(inet->inet_dport); |
| @@ -160,7 +170,8 @@ TRACE_EVENT(inet_sock_set_state, | |||
| 160 | } | 170 | } |
| 161 | ), | 171 | ), |
| 162 | 172 | ||
| 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), | ||
| 164 | show_inet_protocol_name(__entry->protocol), | 175 | show_inet_protocol_name(__entry->protocol), |
| 165 | __entry->sport, __entry->dport, | 176 | __entry->sport, __entry->dport, |
| 166 | __entry->saddr, __entry->daddr, | 177 | __entry->saddr, __entry->daddr, |
