]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
can: gw: indicate and count deleted frames due to misconfiguration
authorOliver Hartkopp <socketcan@hartkopp.net>
Thu, 17 Jan 2013 17:43:46 +0000 (18:43 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Sat, 26 Jan 2013 15:59:02 +0000 (16:59 +0100)
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>
include/uapi/linux/can/gw.h
net/can/gw.c

index 0505c7f8621338ecd12df9dd044e307077d26b9b..ae07bec74f4bfb6d772c5d596ac08a06a1c28d35 100644 (file)
@@ -44,6 +44,7 @@ enum {
        CGW_SRC_IF,     /* ifindex of source network interface */
        CGW_DST_IF,     /* ifindex of destination network interface */
        CGW_FILTER,     /* specify struct can_filter on source CAN device */
+       CGW_DELETED,    /* number of deleted CAN frames (see max_hops param) */
        __CGW_MAX
 };
 
index 4216a80618cb435279b67042ee8d8851423474b7..acdd4656cc3bef2d7e6f2b73436b6fd019b2cc66 100644 (file)
@@ -131,6 +131,7 @@ struct cgw_job {
        struct rcu_head rcu;
        u32 handled_frames;
        u32 dropped_frames;
+       u32 deleted_frames;
        struct cf_mod mod;
        union {
                /* CAN frame data source */
@@ -367,8 +368,11 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data)
 
        BUG_ON(skb->ip_summed != CHECKSUM_UNNECESSARY);
 
-       if (cgw_hops(skb) >= max_hops)
+       if (cgw_hops(skb) >= max_hops) {
+               /* indicate deleted frames due to misconfiguration */
+               gwj->deleted_frames++;
                return;
+       }
 
        if (!(gwj->dst.dev->flags & IFF_UP)) {
                gwj->dropped_frames++;
@@ -500,6 +504,11 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj, int type,
                        goto cancel;
        }
 
+       if (gwj->deleted_frames) {
+               if (nla_put_u32(skb, CGW_DELETED, gwj->deleted_frames) < 0)
+                       goto cancel;
+       }
+
        /* check non default settings of attributes */
 
        if (gwj->mod.modtype.and) {
@@ -799,6 +808,7 @@ static int cgw_create_job(struct sk_buff *skb,  struct nlmsghdr *nlh,
 
        gwj->handled_frames = 0;
        gwj->dropped_frames = 0;
+       gwj->deleted_frames = 0;
        gwj->flags = r->flags;
        gwj->gwtype = r->gwtype;