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
4444 CGW_SRC_IF, /* ifindex of source network interface */
4545 CGW_DST_IF, /* ifindex of destination network interface */
4646 CGW_FILTER, /* specify struct can_filter on source CAN device */
47+ CGW_DELETED, /* number of deleted CAN frames (see max_hops param) */
4748 __CGW_MAX
4849 };
4950
net/can/gw.c+11−1
@@ -131,6 +131,7 @@ struct cgw_job { · 130 unmodified lines
131131 struct rcu_head rcu;
132132 u32 handled_frames;
133133 u32 dropped_frames;
134+ u32 deleted_frames;
134135 struct cf_mod mod;
135136 union {
136137 /* CAN frame data source */
@@ -367,8 +368,11 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data) · 230 unmodified lines
367368
368369 BUG_ON(skb->ip_summed != CHECKSUM_UNNECESSARY);
369370
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++;
371374 return;
375+ }
372376
373377 if (!(gwj->dst.dev->flags & IFF_UP)) {
374378 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
500504 goto cancel;
501505 }
502506
507+ if (gwj->deleted_frames) {
508+ if (nla_put_u32(skb, CGW_DELETED, gwj->deleted_frames) < 0)
509+ goto cancel;
510+ }
511+
503512 /* check non default settings of attributes */
504513
505514 if (gwj->mod.modtype.and) {
@@ -799,6 +808,7 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh, · 293 unmodified lines
799808
800809 gwj->handled_frames = 0;
801810 gwj->dropped_frames = 0;
811+ gwj->deleted_frames = 0;
802812 gwj->flags = r->flags;
803813 gwj->gwtype = r->gwtype;
804814