History

can: gw: indicate and count deleted frames due to misconfiguration

Add a statistic counter to detect deleted frames due to misconfiguration with a new read-only CGW_DELETED netlink attribute for the CAN gateway.

Oliver Hartkopp committed 13 years ago

Commit e6afa001 parent be286ba2 files · +12 −1Browse files

Unified · Split

2 files
  1. include/uapi/linux/can/gw.h +1 −0
  2. net/can/gw.c +11 −1
include/uapi/linux/can/gw.h+1−0
@@ -44,6 +44,7 @@ enum { · 43 unmodified lines
44 CGW_SRC_IF, /* ifindex of source network interface */44 CGW_SRC_IF, /* ifindex of source network interface */
45 CGW_DST_IF, /* ifindex of destination network interface */45 CGW_DST_IF, /* ifindex of destination network interface */
46 CGW_FILTER, /* specify struct can_filter on source CAN device */46 CGW_FILTER, /* specify struct can_filter on source CAN device */
47 CGW_DELETED, /* number of deleted CAN frames (see max_hops param) */
47 __CGW_MAX48 __CGW_MAX
48};49};
49 50
net/can/gw.c+11−1
@@ -131,6 +131,7 @@ struct cgw_job { · 130 unmodified lines
131 struct rcu_head rcu;131 struct rcu_head rcu;
132 u32 handled_frames;132 u32 handled_frames;
133 u32 dropped_frames;133 u32 dropped_frames;
134 u32 deleted_frames;
134 struct cf_mod mod;135 struct cf_mod mod;
135 union {136 union {
136 /* CAN frame data source */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 BUG_ON(skb->ip_summed != CHECKSUM_UNNECESSARY);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 return;374 return;
375 }
372 376
373 if (!(gwj->dst.dev->flags & IFF_UP)) {377 if (!(gwj->dst.dev->flags & IFF_UP)) {
374 gwj->dropped_frames++;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 goto cancel;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 /* check non default settings of attributes */512 /* check non default settings of attributes */
504 513
505 if (gwj->mod.modtype.and) {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 gwj->handled_frames = 0;809 gwj->handled_frames = 0;
801 gwj->dropped_frames = 0;810 gwj->dropped_frames = 0;
811 gwj->deleted_frames = 0;
802 gwj->flags = r->flags;812 gwj->flags = r->flags;
803 gwj->gwtype = r->gwtype;813 gwj->gwtype = r->gwtype;
804 814