]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
cangw: Do not use skb->sk to detect already routed CAN frames.
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Thu, 9 Dec 2010 18:58:59 +0000 (18:58 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Thu, 9 Dec 2010 18:58:59 +0000 (18:58 +0000)
As the latest changes to the can-gw have shown, the use of skb->sk created
several problems and still looks like a bad hack.

While checking the struct skbuff for usable containers to detect routed CAN-
frames that do not interfere with other sophisticated network technique, the
pointers to the [transport|network|mac]_header looked interesting.

So we mark routed frames by setting some mac header length which is not
relevant for the CAN frames located in the skb->data section.

As dev->header_ops is not set in CAN netdevices no one is ever accessing the
various header offsets in the CAN skbuffs anyway. E.g. using the packet socket
to read CAN frames is still working after this change to gw.c .

git-svn-id: svn://svn.berlios.de//socketcan/trunk@1225 030b6a49-0b11-0410-94ab-b0dab22257f2

kernel/2.6/net/can/gw.c

index e451b090288e2ba1f8d575ddd605e1b278a791a8..c1c5a5dcaa9da710959b383b106114b26f3a0b64 100644 (file)
@@ -63,7 +63,7 @@
 #include <socketcan/can/version.h> /* for RCSID. Removed by mkpatch script */
 RCSID("$Id$");
 
-#define CAN_GW_VERSION "20101205"
+#define CAN_GW_VERSION "20101209"
 static __initdata const char banner[] =
        KERN_INFO "can: netlink gateway (rev " CAN_GW_VERSION ")\n";
 
@@ -77,8 +77,6 @@ static struct notifier_block notifier;
 
 static struct kmem_cache *cgw_cache __read_mostly;
 
-static struct sock gw_dummy_sk;
-
 /* structure that contains the (on-the-fly) CAN frame modifications */
 struct cf_mod {
        struct {
@@ -346,8 +344,8 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data)
        struct sk_buff *nskb;
        int modidx = 0;
 
-       /* do not handle already routed frames */
-       if (skb->sk == &gw_dummy_sk)
+       /* do not handle already routed frames - see comment below */
+       if (skb_mac_header_was_set(skb))
                return;
 
        if (!(gwj->dst.dev->flags & IFF_UP)) {
@@ -371,8 +369,15 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data)
                return;
        }
 
-       /* mark routed frames with a 'special' sk value */
-       nskb->sk = &gw_dummy_sk;
+       /*
+        * Mark routed frames by setting some mac header length which is
+        * not relevant for the CAN frames located in the skb->data section.
+        *
+        * As dev->header_ops is not set in CAN netdevices no one is ever
+        * accessing the various header offsets in the CAN skbuffs anyway.
+        * E.g. using the packet socket to read CAN frames is still working.
+        */
+       skb_set_mac_header(nskb, 8);
        nskb->dev = gwj->dst.dev;
 
        /* pointer to modifiable CAN frame */
@@ -929,11 +934,6 @@ static __init int cgw_module_init(void)
        notifier.notifier_call = cgw_notifier;
        register_netdevice_notifier(&notifier);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
-       /* initialize struct for dev_pick_tx() */
-       sk_tx_queue_clear(&gw_dummy_sk);
-#endif
-
        if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs)) {
                unregister_netdevice_notifier(&notifier);
                kmem_cache_destroy(cgw_cache);