From 6beae4e657431902c32cb8edcbf6d5bee090028a Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Sun, 8 Nov 2009 13:27:17 +0000 Subject: [PATCH] update openswan to 2.6.23, convert to netdev_ops for 2.6.30+ kernels SVN-Revision: 18343 --- net/openswan/Makefile | 4 +- net/openswan/patches/130-netdev_ops.patch | 273 ++++++++++++++++++++++ 2 files changed, 275 insertions(+), 2 deletions(-) create mode 100644 net/openswan/patches/130-netdev_ops.patch diff --git a/net/openswan/Makefile b/net/openswan/Makefile index 12788a1b4..cff42e0f6 100644 --- a/net/openswan/Makefile +++ b/net/openswan/Makefile @@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=openswan -PKG_VERSION:=2.6.22 +PKG_VERSION:=2.6.23 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.openswan.org/download -PKG_MD5SUM:= +PKG_MD5SUM:=c83053471e639bf3b97e3cf7796b7e83 include $(INCLUDE_DIR)/package.mk diff --git a/net/openswan/patches/130-netdev_ops.patch b/net/openswan/patches/130-netdev_ops.patch new file mode 100644 index 000000000..830804e4d --- /dev/null +++ b/net/openswan/patches/130-netdev_ops.patch @@ -0,0 +1,273 @@ +diff -urN openswan-2.6.23/linux/net/ipsec/ipsec_mast.c openswan-2.6.23.new/linux/net/ipsec/ipsec_mast.c +--- openswan-2.6.23/linux/net/ipsec/ipsec_mast.c 2009-09-09 02:42:54.000000000 +0200 ++++ openswan-2.6.23.new/linux/net/ipsec/ipsec_mast.c 2009-11-08 14:20:37.000000000 +0100 +@@ -643,6 +643,18 @@ + return NOTIFY_DONE; + } + ++ ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++static const struct net_device_ops ipsec_mast_ops = { ++ .ndo_open = ipsec_mast_open, ++ .ndo_stop = ipsec_mast_close, ++ .ndo_start_xmit = ipsec_mast_start_xmit, ++ .ndo_get_stats = ipsec_mast_get_stats, ++ .ndo_do_ioctl = ipsec_mast_ioctl, ++ .ndo_neigh_setup = ipsec_mast_neigh_setup_dev, ++}; ++#endif ++ + /* + * Called when an ipsec mast device is initialized. + * The ipsec mast device structure is passed to us. +@@ -657,12 +669,17 @@ + "allocating %lu bytes initialising device: %s\n", + (unsigned long) sizeof(struct mastpriv), + dev->name ? dev->name : "NULL"); +- ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + /* Add our mast functions to the device */ + dev->open = ipsec_mast_open; + dev->stop = ipsec_mast_close; + dev->hard_start_xmit = ipsec_mast_start_xmit; + dev->get_stats = ipsec_mast_get_stats; ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ dev->netdev_ops = &ipsec_mast_ops; ++#endif ++#endif + #ifdef alloc_netdev + dev->destructor = free_netdev; + #endif +@@ -677,9 +694,11 @@ + for(i = 0; i < sizeof(zeroes); i++) { + ((__u8*)(zeroes))[i] = 0; + } +- ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + dev->set_multicast_list = NULL; + dev->do_ioctl = ipsec_mast_ioctl; ++#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) + dev->header_ops = NULL; + #else +@@ -687,8 +706,10 @@ + dev->rebuild_header = NULL; + dev->header_cache_update= NULL; + #endif ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + dev->set_mac_address = NULL; + dev->neigh_setup = ipsec_mast_neigh_setup_dev; ++#endif + dev->hard_header_len = 8+20+20+8; + dev->mtu = 0; + dev->addr_len = 0; +@@ -719,6 +740,9 @@ + struct net_device *im; + int vifentry; + char name[IFNAMSIZ]; ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ struct net_device_ops *im_ops; ++#endif + + if(vifnum > IPSEC_NUM_IFMAX) { + return -ENOENT; +@@ -750,8 +774,14 @@ + memset((caddr_t)im, 0, sizeof(struct net_device)); + memcpy(im->name, name, IFNAMSIZ); + #endif +- ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + im->init = ipsec_mast_probe; ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ im_ops = (struct net_device_ops *)im->netdev_ops; ++ im_ops->ndo_init = ipsec_mast_probe; ++#endif ++#endif + + if(register_netdev(im) != 0) { + printk(KERN_ERR "ipsec_mast: failed to register %s\n", +diff -urN openswan-2.6.23/linux/net/ipsec/ipsec_rcv.c openswan-2.6.23.new/linux/net/ipsec/ipsec_rcv.c +--- openswan-2.6.23/linux/net/ipsec/ipsec_rcv.c 2009-09-09 02:42:54.000000000 +0200 ++++ openswan-2.6.23.new/linux/net/ipsec/ipsec_rcv.c 2009-11-08 14:16:26.000000000 +0100 +@@ -482,9 +482,15 @@ + irs->ipsp->ips_out->name); + } + skb->dev = irs->ipsp->ips_out; +- ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + if(skb->dev && skb->dev->get_stats) { + struct net_device_stats *stats = skb->dev->get_stats(skb->dev); ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ if(skb->dev && skb->dev->netdev_ops->ndo_get_stats) { ++ struct net_device_stats *stats = skb->dev->netdev_ops->ndo_get_stats(skb->dev); ++#endif ++#endif + irs->stats = stats; + } + } +diff -urN openswan-2.6.23/linux/net/ipsec/ipsec_tunnel.c openswan-2.6.23.new/linux/net/ipsec/ipsec_tunnel.c +--- openswan-2.6.23/linux/net/ipsec/ipsec_tunnel.c 2009-09-09 02:42:54.000000000 +0200 ++++ openswan-2.6.23.new/linux/net/ipsec/ipsec_tunnel.c 2009-11-08 14:14:38.000000000 +0100 +@@ -3,7 +3,7 @@ + * Copyright (C) 1996, 1997 John Ioannidis. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Richard Guy Briggs. + * +- * OCF/receive state machine written by ++ * OCF/receive statet machine written by + * David McCullough + * Copyright (C) 2004-2005 Intel Corporation. All Rights Reserved. + * +@@ -1098,6 +1098,10 @@ + { + int i; + struct ipsecpriv *prv = netdev_priv(dev); ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ struct net_device_ops *dev_ops; ++ struct net_device_ops *physdev_ops; ++#endif + + if(dev == NULL) { + KLIPS_PRINT(debug_tunnel & DB_TN_REVEC, +@@ -1113,11 +1117,17 @@ + dev->name ? dev->name : "NULL"); + return -ENODATA; + } +- ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + dev->set_mac_address = ipsec_tunnel_set_mac_address; + prv->dev = physdev; + prv->hard_start_xmit = physdev->hard_start_xmit; + prv->get_stats = physdev->get_stats; ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ dev_ops = (struct net_device_ops *)dev->netdev_ops; ++ dev_ops->ndo_set_mac_address = ipsec_tunnel_set_mac_address; ++#endif ++#endif + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) + if (physdev->header_ops) { +@@ -1152,18 +1162,34 @@ + } else + dev->header_cache_update = NULL; + #endif +- ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + if (physdev->set_mac_address) { + prv->set_mac_address = physdev->set_mac_address; + dev->set_mac_address = ipsec_tunnel_set_mac_address; + } else + dev->set_mac_address = NULL; +- ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ physdev_ops = (struct net_device_ops *)physdev->netdev_ops; ++ if (physdev_ops->ndo_set_mac_address) { ++ prv->set_mac_address = physdev_ops->ndo_set_mac_address; ++ dev_ops->ndo_set_mac_address = ipsec_tunnel_set_mac_address; ++ } else ++ dev_ops->ndo_set_mac_address = NULL; ++#endif ++#endif ++ + dev->hard_header_len = physdev->hard_header_len; + + #ifdef NET_21 + /* prv->neigh_setup = physdev->neigh_setup; */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + dev->neigh_setup = ipsec_tunnel_neigh_setup_dev; ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++#endif ++ dev_ops->ndo_neigh_setup = ipsec_tunnel_neigh_setup_dev; ++#endif + #endif /* NET_21 */ + dev->mtu = 16260; /* 0xfff0; */ /* dev->mtu; */ + prv->mtu = physdev->mtu; +@@ -1602,6 +1628,16 @@ + * Called when an ipsec tunnel device is initialized. + * The ipsec tunnel device structure is passed to us. + */ ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++static const struct net_device_ops ipsec_tunnel_netdev_ops = { ++ .ndo_open = ipsec_tunnel_open, ++ .ndo_stop = ipsec_tunnel_close, ++ .ndo_start_xmit = ipsec_tunnel_start_xmit, ++ .ndo_get_stats = ipsec_tunnel_get_stats, ++ .ndo_do_ioctl = ipsec_tunnel_ioctl, ++ .ndo_neigh_setup = ipsec_tunnel_neigh_setup_dev, ++}; ++#endif + + int + ipsec_tunnel_init(struct net_device *dev) +@@ -1614,12 +1650,17 @@ + (unsigned long) sizeof(struct ipsecpriv), + dev->name ? dev->name : "NULL"); + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + /* Add our tunnel functions to the device */ + dev->open = ipsec_tunnel_open; + dev->stop = ipsec_tunnel_close; + dev->hard_start_xmit = ipsec_tunnel_start_xmit; + dev->get_stats = ipsec_tunnel_get_stats; +- ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ dev->netdev_ops = &ipsec_tunnel_netdev_ops; ++#endif ++#endif + #ifndef alloc_netdev + dev->priv = kmalloc(sizeof(struct ipsecpriv), GFP_KERNEL); + if (dev->priv == NULL) +@@ -1637,8 +1678,10 @@ + skb_queue_head_init(&dev->buffs[i]); + #endif /* !NET_21 */ + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + dev->set_multicast_list = NULL; + dev->do_ioctl = ipsec_tunnel_ioctl; ++#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) + dev->header_ops = NULL; + #else +@@ -1653,7 +1696,9 @@ + + #ifdef NET_21 + /* prv->neigh_setup = NULL; */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + dev->neigh_setup = ipsec_tunnel_neigh_setup_dev; ++#endif + #endif /* NET_21 */ + dev->hard_header_len = 0; + dev->mtu = 0; +@@ -1695,7 +1740,9 @@ + char name[IFNAMSIZ]; + struct net_device *dev_ipsec; + int vifentry; +- ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ struct net_device_ops *dev_ops; ++#endif + if(ifnum > IPSEC_NUM_IFMAX) { + return -ENOENT; + } +@@ -1747,7 +1794,14 @@ + dev_ipsec->next = NULL; + #endif + #endif /* alloc_netdev */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) + dev_ipsec->init = &ipsec_tunnel_probe; ++#else ++#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) ++ dev_ops = (struct net_device_ops *)dev_ipsec->netdev_ops; ++ dev_ops->ndo_init = &ipsec_tunnel_probe; ++#endif ++#endif + KLIPS_PRINT(debug_tunnel & DB_TN_INIT, + "klips_debug:ipsec_tunnel_init_devices: " + "registering device %s\n", -- 2.30.2