diff options
author | Oliver Hartkopp <socketcan@hartkopp.net> | 2013-01-17 12:43:46 -0500 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2013-01-26 10:59:02 -0500 |
commit | e6afa00a1409bc3bceed9ccb33111519463dfe7b (patch) | |
tree | 90a039fdf39a111f7f9510ff012808277a0f2a65 /net/can | |
parent | be286bafe1f4069094865264f29805854c5788bf (diff) |
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.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'net/can')
-rw-r--r-- | net/can/gw.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/net/can/gw.c b/net/can/gw.c index 4216a80618cb..acdd4656cc3b 100644 --- a/net/can/gw.c +++ b/net/can/gw.c | |||
@@ -131,6 +131,7 @@ struct cgw_job { | |||
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) | |||
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, | |||
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, | |||
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 | ||