diff options
Diffstat (limited to 'kernel/driver/gre.c')
-rw-r--r-- | kernel/driver/gre.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/kernel/driver/gre.c b/kernel/driver/gre.c index 485da85..77886d5 100644 --- a/kernel/driver/gre.c +++ b/kernel/driver/gre.c @@ -1,6 +1,6 @@ #include <linux/module.h> #include <linux/kernel.h> -#include <linux/kmod.h> +#include <linux/init.h> #include <linux/skbuff.h> #include <linux/in.h> #include <linux/netdevice.h> @@ -12,7 +12,7 @@ struct gre_protocol *gre_proto[GREPROTO_MAX] ____cacheline_aligned_in_smp; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -static rwlock_t chan_lock=RW_LOCK_UNLOCKED; +static rwlock_t gre_proto_lock=RW_LOCK_UNLOCKED; #else static DEFINE_SPINLOCK(gre_proto_lock); #endif @@ -47,6 +47,7 @@ int gre_add_protocol(struct gre_protocol *proto, u8 version) return ret; } + int gre_del_protocol(struct gre_protocol *proto, u8 version) { if (version >= GREPROTO_MAX) @@ -82,6 +83,7 @@ out_err_unlock: out_err: return -EINVAL; } + static int gre_rcv(struct sk_buff *skb) { u8 ver; @@ -125,6 +127,7 @@ drop_nolock: kfree_skb(skb); return NET_RX_DROP; } + static void gre_err(struct sk_buff *skb, u32 info) { u8 ver; @@ -166,30 +169,45 @@ drop_nolock: kfree_skb(skb); } - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static struct inet_protocol net_gre_protocol = { + .handler = gre_rcv, + .err_handler = gre_err, + .protocol = IPPROTO_GRE, + .name = "GRE", +}; +#else static struct net_protocol net_gre_protocol = { .handler = gre_rcv, - .err_handler = gre_err, + .err_handler = gre_err, #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24) .netns_ok=1, #endif }; +#endif static int __init gre_init(void) { printk(KERN_INFO "GRE over IPv4 demultiplexor driver"); - + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + inet_add_protocol(&net_gre_protocol); +#else if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) { printk(KERN_INFO "gre: can't add protocol\n"); return -EAGAIN; } - +#endif return 0; } static void __exit gre_exit(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + inet_del_protocol(&net_gre_protocol); +#else inet_del_protocol(&net_gre_protocol, IPPROTO_GRE); +#endif } module_init(gre_init); @@ -200,4 +218,3 @@ MODULE_AUTHOR("Kozlov D. (xeb@mail.ru)"); MODULE_LICENSE("GPL"); EXPORT_SYMBOL_GPL(gre_add_protocol); EXPORT_SYMBOL_GPL(gre_del_protocol); - |