1 #undef TRACE_SYSTEM 2 #define TRACE_SYSTEM neigh 3 4 #if !defined(_TRACE_NEIGH_H) || defined(TRACE_HEADER_MULTI_READ) 5 #define _TRACE_NEIGH_H 6 7 #include <linux/skbuff.h> 8 #include <linux/netdevice.h> 9 #include <linux/tracepoint.h> 10 #include <net/neighbour.h> 11 12 #define neigh_state_str(state) \ 13 __print_symbolic(state, \ 14 { NUD_INCOMPLETE, "incomplete" }, \ 15 { NUD_REACHABLE, "reachable" }, \ 16 { NUD_STALE, "stale" }, \ 17 { NUD_DELAY, "delay" }, \ 18 { NUD_PROBE, "probe" }, \ 19 { NUD_FAILED, "failed" }, \ 20 { NUD_NOARP, "noarp" }, \ 21 { NUD_PERMANENT, "permanent"}) 22 23 TRACE_EVENT(neigh_create, 24 25 TP_PROTO(struct neigh_table *tbl, struct net_device *dev, 26 const void *pkey, const struct neighbour *n, 27 bool exempt_from_gc), 28 29 TP_ARGS(tbl, dev, pkey, n, exempt_from_gc), 30 31 TP_STRUCT__entry( 32 __field(u32, family) 33 __dynamic_array(char, dev, IFNAMSIZ ) 34 __field(int, entries) 35 __field(u8, created) 36 __field(u8, gc_exempt) 37 __array(u8, primary_key4, 4) 38 __array(u8, primary_key6, 16) 39 ), 40 41 TP_fast_assign( 42 struct in6_addr *pin6; 43 __be32 *p32; 44 45 __entry->family = tbl->family; 46 __assign_str(dev, (dev ? dev->name : "NULL")); 47 __entry->entries = atomic_read(&tbl->gc_entries); 48 __entry->created = n != NULL; 49 __entry->gc_exempt = exempt_from_gc; 50 pin6 = (struct in6_addr *)__entry->primary_key6; 51 p32 = (__be32 *)__entry->primary_key4; 52 53 if (tbl->family == AF_INET) 54 *p32 = *(__be32 *)pkey; 55 else 56 *p32 = 0; 57 58 #if IS_ENABLED(CONFIG_IPV6) 59 if (tbl->family == AF_INET6) { 60 pin6 = (struct in6_addr *)__entry->primary_key6; 61 *pin6 = *(struct in6_addr *)pkey; 62 } 63 #endif 64 ), 65 66 TP_printk("family %d dev %s entries %d primary_key4 %pI4 primary_key6 %pI6c created %d gc_exempt %d", 67 __entry->family, __get_str(dev), __entry->entries, 68 __entry->primary_key4, __entry->primary_key6, 69 __entry->created, __entry->gc_exempt) 70 ); 71 72 TRACE_EVENT(neigh_update, 73 74 TP_PROTO(struct neighbour *n, const u8 *lladdr, u8 new, 75 u32 flags, u32 nlmsg_pid), 76 77 TP_ARGS(n, lladdr, new, flags, nlmsg_pid), 78 79 TP_STRUCT__entry( 80 __field(u32, family) 81 __string(dev, (n->dev ? n->dev->name : "NULL")) 82 __array(u8, lladdr, MAX_ADDR_LEN) 83 __field(u8, lladdr_len) 84 __field(u8, flags) 85 __field(u8, nud_state) 86 __field(u8, type) 87 __field(u8, dead) 88 __field(int, refcnt) 89 __array(__u8, primary_key4, 4) 90 __array(__u8, primary_key6, 16) 91 __field(unsigned long, confirmed) 92 __field(unsigned long, updated) 93 __field(unsigned long, used) 94 __array(u8, new_lladdr, MAX_ADDR_LEN) 95 __field(u8, new_state) 96 __field(u32, update_flags) 97 __field(u32, pid) 98 ), 99 100 TP_fast_assign( 101 int lladdr_len = (n->dev ? n->dev->addr_len : MAX_ADDR_LEN); 102 struct in6_addr *pin6; 103 __be32 *p32; 104 105 __entry->family = n->tbl->family; 106 __assign_str(dev, (n->dev ? n->dev->name : "NULL")); 107 __entry->lladdr_len = lladdr_len; 108 memcpy(__entry->lladdr, n->ha, lladdr_len); 109 __entry->flags = n->flags; 110 __entry->nud_state = n->nud_state; 111 __entry->type = n->type; 112 __entry->dead = n->dead; 113 __entry->refcnt = refcount_read(&n->refcnt); 114 pin6 = (struct in6_addr *)__entry->primary_key6; 115 p32 = (__be32 *)__entry->primary_key4; 116 117 if (n->tbl->family == AF_INET) 118 *p32 = *(__be32 *)n->primary_key; 119 else 120 *p32 = 0; 121 122 #if IS_ENABLED(CONFIG_IPV6) 123 if (n->tbl->family == AF_INET6) { 124 pin6 = (struct in6_addr *)__entry->primary_key6; 125 *pin6 = *(struct in6_addr *)n->primary_key; 126 } else 127 #endif 128 { 129 ipv6_addr_set_v4mapped(*p32, pin6); 130 } 131 __entry->confirmed = n->confirmed; 132 __entry->updated = n->updated; 133 __entry->used = n->used; 134 if (lladdr) 135 memcpy(__entry->new_lladdr, lladdr, lladdr_len); 136 __entry->new_state = new; 137 __entry->update_flags = flags; 138 __entry->pid = nlmsg_pid; 139 ), 140 141 TP_printk("family %d dev %s lladdr %s flags %02x nud_state %s type %02x " 142 "dead %d refcnt %d primary_key4 %pI4 primary_key6 %pI6c " 143 "confirmed %lu updated %lu used %lu new_lladdr %s " 144 "new_state %s update_flags %02x pid %d", 145 __entry->family, __get_str(dev), 146 __print_hex_str(__entry->lladdr, __entry->lladdr_len), 147 __entry->flags, neigh_state_str(__entry->nud_state), 148 __entry->type, __entry->dead, __entry->refcnt, 149 __entry->primary_key4, __entry->primary_key6, 150 __entry->confirmed, __entry->updated, __entry->used, 151 __print_hex_str(__entry->new_lladdr, __entry->lladdr_len), 152 neigh_state_str(__entry->new_state), 153 __entry->update_flags, __entry->pid) 154 ); 155 156 DECLARE_EVENT_CLASS(neigh__update, 157 TP_PROTO(struct neighbour *n, int err), 158 TP_ARGS(n, err), 159 TP_STRUCT__entry( 160 __field(u32, family) 161 __string(dev, (n->dev ? n->dev->name : "NULL")) 162 __array(u8, lladdr, MAX_ADDR_LEN) 163 __field(u8, lladdr_len) 164 __field(u8, flags) 165 __field(u8, nud_state) 166 __field(u8, type) 167 __field(u8, dead) 168 __field(int, refcnt) 169 __array(__u8, primary_key4, 4) 170 __array(__u8, primary_key6, 16) 171 __field(unsigned long, confirmed) 172 __field(unsigned long, updated) 173 __field(unsigned long, used) 174 __field(u32, err) 175 ), 176 177 TP_fast_assign( 178 int lladdr_len = (n->dev ? n->dev->addr_len : MAX_ADDR_LEN); 179 struct in6_addr *pin6; 180 __be32 *p32; 181 182 __entry->family = n->tbl->family; 183 __assign_str(dev, (n->dev ? n->dev->name : "NULL")); 184 __entry->lladdr_len = lladdr_len; 185 memcpy(__entry->lladdr, n->ha, lladdr_len); 186 __entry->flags = n->flags; 187 __entry->nud_state = n->nud_state; 188 __entry->type = n->type; 189 __entry->dead = n->dead; 190 __entry->refcnt = refcount_read(&n->refcnt); 191 pin6 = (struct in6_addr *)__entry->primary_key6; 192 p32 = (__be32 *)__entry->primary_key4; 193 194 if (n->tbl->family == AF_INET) 195 *p32 = *(__be32 *)n->primary_key; 196 else 197 *p32 = 0; 198 199 #if IS_ENABLED(CONFIG_IPV6) 200 if (n->tbl->family == AF_INET6) { 201 pin6 = (struct in6_addr *)__entry->primary_key6; 202 *pin6 = *(struct in6_addr *)n->primary_key; 203 } else 204 #endif 205 { 206 ipv6_addr_set_v4mapped(*p32, pin6); 207 } 208 209 __entry->confirmed = n->confirmed; 210 __entry->updated = n->updated; 211 __entry->used = n->used; 212 __entry->err = err; 213 ), 214 215 TP_printk("family %d dev %s lladdr %s flags %02x nud_state %s type %02x " 216 "dead %d refcnt %d primary_key4 %pI4 primary_key6 %pI6c " 217 "confirmed %lu updated %lu used %lu err %d", 218 __entry->family, __get_str(dev), 219 __print_hex_str(__entry->lladdr, __entry->lladdr_len), 220 __entry->flags, neigh_state_str(__entry->nud_state), 221 __entry->type, __entry->dead, __entry->refcnt, 222 __entry->primary_key4, __entry->primary_key6, 223 __entry->confirmed, __entry->updated, __entry->used, 224 __entry->err) 225 ); 226 227 DEFINE_EVENT(neigh__update, neigh_update_done, 228 TP_PROTO(struct neighbour *neigh, int err), 229 TP_ARGS(neigh, err) 230 ); 231 232 DEFINE_EVENT(neigh__update, neigh_timer_handler, 233 TP_PROTO(struct neighbour *neigh, int err), 234 TP_ARGS(neigh, err) 235 ); 236 237 DEFINE_EVENT(neigh__update, neigh_event_send_done, 238 TP_PROTO(struct neighbour *neigh, int err), 239 TP_ARGS(neigh, err) 240 ); 241 242 DEFINE_EVENT(neigh__update, neigh_event_send_dead, 243 TP_PROTO(struct neighbour *neigh, int err), 244 TP_ARGS(neigh, err) 245 ); 246 247 DEFINE_EVENT(neigh__update, neigh_cleanup_and_release, 248 TP_PROTO(struct neighbour *neigh, int rc), 249 TP_ARGS(neigh, rc) 250 ); 251 252 #endif /* _TRACE_NEIGH_H */ 253 254 /* This part must be outside protection */ 255 #include <trace/define_trace.h> 256