]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/net/can/gw.c
Add kernel version depency for Kernel 3.1.x which extended __rtnl_register().
[socketcan-devel.git] / kernel / 2.6 / net / can / gw.c
index 5e2a459869f1b44e47f08fb955f0f11848f4f556..0c9f869d6c774f54cead2676d01c0641c32d5e0c 100644 (file)
@@ -821,10 +821,8 @@ static int cgw_create_job(struct sk_buff *skb,  struct nlmsghdr *nlh,
        if (!gwj->src.dev)
                goto out;
 
-       if (gwj->src.dev->type != ARPHRD_CAN)
-               goto put_src_out;
-
-       if (gwj->src.dev->header_ops)
+       /* check for CAN netdev not using header_ops - see gw_rcv() */
+       if (gwj->src.dev->type != ARPHRD_CAN || gwj->src.dev->header_ops)
                goto put_src_out;
 
        gwj->dst.dev = dev_get_by_index(&init_net, gwj->ccgw.dst_idx);
@@ -832,10 +830,8 @@ static int cgw_create_job(struct sk_buff *skb,  struct nlmsghdr *nlh,
        if (!gwj->dst.dev)
                goto put_src_out;
 
-       if (gwj->dst.dev->type != ARPHRD_CAN)
-               goto put_src_dst_out;
-
-       if (gwj->dst.dev->header_ops)
+       /* check for CAN netdev not using header_ops - see gw_rcv() */
+       if (gwj->dst.dev->type != ARPHRD_CAN || gwj->dst.dev->header_ops)
                goto put_src_dst_out;
 
        ASSERT_RTNL();
@@ -940,15 +936,24 @@ static __init int cgw_module_init(void)
        notifier.notifier_call = cgw_notifier;
        register_netdevice_notifier(&notifier);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
+       if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
+#else
        if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs)) {
+#endif
                unregister_netdevice_notifier(&notifier);
                kmem_cache_destroy(cgw_cache);
                return -ENOBUFS;
        }
 
        /* Only the first call to __rtnl_register can fail */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
+       __rtnl_register(PF_CAN, RTM_NEWROUTE, cgw_create_job, NULL, NULL);
+       __rtnl_register(PF_CAN, RTM_DELROUTE, cgw_remove_job, NULL, NULL);
+#else
        __rtnl_register(PF_CAN, RTM_NEWROUTE, cgw_create_job, NULL);
        __rtnl_register(PF_CAN, RTM_DELROUTE, cgw_remove_job, NULL);
+#endif
 
        return 0;
 }