Add a statistic counter to detect deleted frames due to misconfiguration with a new read-only CGW_DELETED netlink attribute for the CAN gateway.
Unified · Split
| @@ -44,6 +44,7 @@ enum { · 43 unmodified lines | ||
| 44 | 44 | CGW_SRC_IF, /* ifindex of source network interface */ |
| 45 | 45 | CGW_DST_IF, /* ifindex of destination network interface */ |
| 46 | 46 | CGW_FILTER, /* specify struct can_filter on source CAN device */ |
| 47 | + CGW_DELETED, /* number of deleted CAN frames (see max_hops param) */ | |
| 47 | 48 | __CGW_MAX |
| 48 | 49 | }; |
| 49 | 50 | |
| @@ -131,6 +131,7 @@ struct cgw_job { · 130 unmodified lines | ||
| 131 | 131 | struct rcu_head rcu; |
| 132 | 132 | u32 handled_frames; |
| 133 | 133 | u32 dropped_frames; |
| 134 | + u32 deleted_frames; | |
| 134 | 135 | struct cf_mod mod; |
| 135 | 136 | union { |
| 136 | 137 | /* CAN frame data source */ |
| @@ -367,8 +368,11 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data) · 230 unmodified lines | ||
| 367 | 368 | |
| 368 | 369 | BUG_ON(skb->ip_summed != CHECKSUM_UNNECESSARY); |
| 369 | 370 | |
| 370 | − if (cgw_hops(skb) >= max_hops) | |
| 371 | + if (cgw_hops(skb) >= max_hops) { | |
| 372 | + /* indicate deleted frames due to misconfiguration */ | |
| 373 | + gwj->deleted_frames++; | |
| 371 | 374 | return; |
| 375 | + } | |
| 372 | 376 | |
| 373 | 377 | if (!(gwj->dst.dev->flags & IFF_UP)) { |
| 374 | 378 | gwj->dropped_frames++; |
| @@ -500,6 +504,11 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj, int type, · 125 unmodified lines | ||
| 500 | 504 | goto cancel; |
| 501 | 505 | } |
| 502 | 506 | |
| 507 | + if (gwj->deleted_frames) { | |
| 508 | + if (nla_put_u32(skb, CGW_DELETED, gwj->deleted_frames) < 0) | |
| 509 | + goto cancel; | |
| 510 | + } | |
| 511 | + | |
| 503 | 512 | /* check non default settings of attributes */ |
| 504 | 513 | |
| 505 | 514 | if (gwj->mod.modtype.and) { |
| @@ -799,6 +808,7 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh, · 293 unmodified lines | ||
| 799 | 808 | |
| 800 | 809 | gwj->handled_frames = 0; |
| 801 | 810 | gwj->dropped_frames = 0; |
| 811 | + gwj->deleted_frames = 0; | |
| 802 | 812 | gwj->flags = r->flags; |
| 803 | 813 | gwj->gwtype = r->gwtype; |
| 804 | 814 | |