9ea2f38f5e7527ff52ba8c9918024dbaf57644a9
[openwrt/svn-archive/archive.git] / net / openswan / patches / 130-netdev_ops.patch
1 diff -urN openswan-2.6.23/linux/net/ipsec/ipsec_mast.c openswan-2.6.23.new/linux/net/ipsec/ipsec_mast.c
2 --- openswan-2.6.23/linux/net/ipsec/ipsec_mast.c 2009-09-09 02:42:54.000000000 +0200
3 +++ openswan-2.6.23.new/linux/net/ipsec/ipsec_mast.c 2009-11-08 14:20:37.000000000 +0100
4 @@ -643,6 +643,18 @@
5 return NOTIFY_DONE;
6 }
7
8 +
9 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
10 +static const struct net_device_ops ipsec_mast_ops = {
11 + .ndo_open = ipsec_mast_open,
12 + .ndo_stop = ipsec_mast_close,
13 + .ndo_start_xmit = ipsec_mast_start_xmit,
14 + .ndo_get_stats = ipsec_mast_get_stats,
15 + .ndo_do_ioctl = ipsec_mast_ioctl,
16 + .ndo_neigh_setup = ipsec_mast_neigh_setup_dev,
17 +};
18 +#endif
19 +
20 /*
21 * Called when an ipsec mast device is initialized.
22 * The ipsec mast device structure is passed to us.
23 @@ -657,12 +669,17 @@
24 "allocating %lu bytes initialising device: %s\n",
25 (unsigned long) sizeof(struct mastpriv),
26 dev->name ? dev->name : "NULL");
27 -
28 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
29 /* Add our mast functions to the device */
30 dev->open = ipsec_mast_open;
31 dev->stop = ipsec_mast_close;
32 dev->hard_start_xmit = ipsec_mast_start_xmit;
33 dev->get_stats = ipsec_mast_get_stats;
34 +#else
35 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
36 + dev->netdev_ops = &ipsec_mast_ops;
37 +#endif
38 +#endif
39 #ifdef alloc_netdev
40 dev->destructor = free_netdev;
41 #endif
42 @@ -677,9 +694,11 @@
43 for(i = 0; i < sizeof(zeroes); i++) {
44 ((__u8*)(zeroes))[i] = 0;
45 }
46 -
47 +
48 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
49 dev->set_multicast_list = NULL;
50 dev->do_ioctl = ipsec_mast_ioctl;
51 +#endif
52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
53 dev->header_ops = NULL;
54 #else
55 @@ -687,8 +706,10 @@
56 dev->rebuild_header = NULL;
57 dev->header_cache_update= NULL;
58 #endif
59 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
60 dev->set_mac_address = NULL;
61 dev->neigh_setup = ipsec_mast_neigh_setup_dev;
62 +#endif
63 dev->hard_header_len = 8+20+20+8;
64 dev->mtu = 0;
65 dev->addr_len = 0;
66 @@ -719,6 +740,9 @@
67 struct net_device *im;
68 int vifentry;
69 char name[IFNAMSIZ];
70 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
71 + struct net_device_ops *im_ops;
72 +#endif
73
74 if(vifnum > IPSEC_NUM_IFMAX) {
75 return -ENOENT;
76 @@ -750,8 +774,14 @@
77 memset((caddr_t)im, 0, sizeof(struct net_device));
78 memcpy(im->name, name, IFNAMSIZ);
79 #endif
80 -
81 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
82 im->init = ipsec_mast_probe;
83 +#else
84 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
85 + im_ops = (struct net_device_ops *)im->netdev_ops;
86 + im_ops->ndo_init = ipsec_mast_probe;
87 +#endif
88 +#endif
89
90 if(register_netdev(im) != 0) {
91 printk(KERN_ERR "ipsec_mast: failed to register %s\n",
92 diff -urN openswan-2.6.23/linux/net/ipsec/ipsec_rcv.c openswan-2.6.23.new/linux/net/ipsec/ipsec_rcv.c
93 --- openswan-2.6.23/linux/net/ipsec/ipsec_rcv.c 2009-09-09 02:42:54.000000000 +0200
94 +++ openswan-2.6.23.new/linux/net/ipsec/ipsec_rcv.c 2009-11-08 14:16:26.000000000 +0100
95 @@ -482,9 +482,15 @@
96 irs->ipsp->ips_out->name);
97 }
98 skb->dev = irs->ipsp->ips_out;
99 -
100 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
101 if(skb->dev && skb->dev->get_stats) {
102 struct net_device_stats *stats = skb->dev->get_stats(skb->dev);
103 +#else
104 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
105 + if(skb->dev && skb->dev->netdev_ops->ndo_get_stats) {
106 + struct net_device_stats *stats = skb->dev->netdev_ops->ndo_get_stats(skb->dev);
107 +#endif
108 +#endif
109 irs->stats = stats;
110 }
111 }
112 diff -urN openswan-2.6.23/linux/net/ipsec/ipsec_tunnel.c openswan-2.6.23.new/linux/net/ipsec/ipsec_tunnel.c
113 --- openswan-2.6.23/linux/net/ipsec/ipsec_tunnel.c 2009-09-09 02:42:54.000000000 +0200
114 +++ openswan-2.6.23.new/linux/net/ipsec/ipsec_tunnel.c 2009-11-08 14:14:38.000000000 +0100
115 @@ -3,7 +3,7 @@
116 * Copyright (C) 1996, 1997 John Ioannidis.
117 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Richard Guy Briggs.
118 *
119 - * OCF/receive state machine written by
120 + * OCF/receive statet machine written by
121 * David McCullough <dmccullough@cyberguard.com>
122 * Copyright (C) 2004-2005 Intel Corporation. All Rights Reserved.
123 *
124 @@ -1098,6 +1098,10 @@
125 {
126 int i;
127 struct ipsecpriv *prv = netdev_priv(dev);
128 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
129 + struct net_device_ops *dev_ops;
130 + struct net_device_ops *physdev_ops;
131 +#endif
132
133 if(dev == NULL) {
134 KLIPS_PRINT(debug_tunnel & DB_TN_REVEC,
135 @@ -1113,11 +1117,17 @@
136 dev->name ? dev->name : "NULL");
137 return -ENODATA;
138 }
139 -
140 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
141 dev->set_mac_address = ipsec_tunnel_set_mac_address;
142 prv->dev = physdev;
143 prv->hard_start_xmit = physdev->hard_start_xmit;
144 prv->get_stats = physdev->get_stats;
145 +#else
146 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
147 + dev_ops = (struct net_device_ops *)dev->netdev_ops;
148 + dev_ops->ndo_set_mac_address = ipsec_tunnel_set_mac_address;
149 +#endif
150 +#endif
151
152 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
153 if (physdev->header_ops) {
154 @@ -1152,18 +1162,34 @@
155 } else
156 dev->header_cache_update = NULL;
157 #endif
158 -
159 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
160 if (physdev->set_mac_address) {
161 prv->set_mac_address = physdev->set_mac_address;
162 dev->set_mac_address = ipsec_tunnel_set_mac_address;
163 } else
164 dev->set_mac_address = NULL;
165 -
166 +#else
167 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
168 + physdev_ops = (struct net_device_ops *)physdev->netdev_ops;
169 + if (physdev_ops->ndo_set_mac_address) {
170 + prv->set_mac_address = physdev_ops->ndo_set_mac_address;
171 + dev_ops->ndo_set_mac_address = ipsec_tunnel_set_mac_address;
172 + } else
173 + dev_ops->ndo_set_mac_address = NULL;
174 +#endif
175 +#endif
176 +
177 dev->hard_header_len = physdev->hard_header_len;
178
179 #ifdef NET_21
180 /* prv->neigh_setup = physdev->neigh_setup; */
181 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
182 dev->neigh_setup = ipsec_tunnel_neigh_setup_dev;
183 +#else
184 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
185 +#endif
186 + dev_ops->ndo_neigh_setup = ipsec_tunnel_neigh_setup_dev;
187 +#endif
188 #endif /* NET_21 */
189 dev->mtu = 16260; /* 0xfff0; */ /* dev->mtu; */
190 prv->mtu = physdev->mtu;
191 @@ -1602,6 +1628,16 @@
192 * Called when an ipsec tunnel device is initialized.
193 * The ipsec tunnel device structure is passed to us.
194 */
195 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
196 +static const struct net_device_ops ipsec_tunnel_netdev_ops = {
197 + .ndo_open = ipsec_tunnel_open,
198 + .ndo_stop = ipsec_tunnel_close,
199 + .ndo_start_xmit = ipsec_tunnel_start_xmit,
200 + .ndo_get_stats = ipsec_tunnel_get_stats,
201 + .ndo_do_ioctl = ipsec_tunnel_ioctl,
202 + .ndo_neigh_setup = ipsec_tunnel_neigh_setup_dev,
203 +};
204 +#endif
205
206 int
207 ipsec_tunnel_init(struct net_device *dev)
208 @@ -1614,12 +1650,17 @@
209 (unsigned long) sizeof(struct ipsecpriv),
210 dev->name ? dev->name : "NULL");
211
212 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
213 /* Add our tunnel functions to the device */
214 dev->open = ipsec_tunnel_open;
215 dev->stop = ipsec_tunnel_close;
216 dev->hard_start_xmit = ipsec_tunnel_start_xmit;
217 dev->get_stats = ipsec_tunnel_get_stats;
218 -
219 +#else
220 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
221 + dev->netdev_ops = &ipsec_tunnel_netdev_ops;
222 +#endif
223 +#endif
224 #ifndef alloc_netdev
225 dev->priv = kmalloc(sizeof(struct ipsecpriv), GFP_KERNEL);
226 if (dev->priv == NULL)
227 @@ -1637,8 +1678,10 @@
228 skb_queue_head_init(&dev->buffs[i]);
229 #endif /* !NET_21 */
230
231 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
232 dev->set_multicast_list = NULL;
233 dev->do_ioctl = ipsec_tunnel_ioctl;
234 +#endif
235 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
236 dev->header_ops = NULL;
237 #else
238 @@ -1653,7 +1696,9 @@
239
240 #ifdef NET_21
241 /* prv->neigh_setup = NULL; */
242 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
243 dev->neigh_setup = ipsec_tunnel_neigh_setup_dev;
244 +#endif
245 #endif /* NET_21 */
246 dev->hard_header_len = 0;
247 dev->mtu = 0;
248 @@ -1695,7 +1740,9 @@
249 char name[IFNAMSIZ];
250 struct net_device *dev_ipsec;
251 int vifentry;
252 -
253 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
254 + struct net_device_ops *dev_ops;
255 +#endif
256 if(ifnum > IPSEC_NUM_IFMAX) {
257 return -ENOENT;
258 }
259 @@ -1747,7 +1794,14 @@
260 dev_ipsec->next = NULL;
261 #endif
262 #endif /* alloc_netdev */
263 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
264 dev_ipsec->init = &ipsec_tunnel_probe;
265 +#else
266 +#if !(defined CONFIG_COMPAT_NET_DEV_OPS) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
267 + dev_ops = (struct net_device_ops *)dev_ipsec->netdev_ops;
268 + dev_ops->ndo_init = &ipsec_tunnel_probe;
269 +#endif
270 +#endif
271 KLIPS_PRINT(debug_tunnel & DB_TN_INIT,
272 "klips_debug:ipsec_tunnel_init_devices: "
273 "registering device %s\n",