diff options
Diffstat (limited to 'net/ipv6')
30 files changed, 436 insertions, 293 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 147588f4c7c0..84127d854cfc 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -6,8 +6,6 @@ | |||
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> | 7 | * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> |
8 | * | 8 | * |
9 | * $Id: addrconf.c,v 1.69 2001/10/31 21:55:54 davem Exp $ | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
13 | * as published by the Free Software Foundation; either version | 11 | * as published by the Free Software Foundation; either version |
@@ -231,6 +229,12 @@ static inline int addrconf_qdisc_ok(struct net_device *dev) | |||
231 | return (dev->qdisc != &noop_qdisc); | 229 | return (dev->qdisc != &noop_qdisc); |
232 | } | 230 | } |
233 | 231 | ||
232 | /* Check if a route is valid prefix route */ | ||
233 | static inline int addrconf_is_prefix_route(const struct rt6_info *rt) | ||
234 | { | ||
235 | return ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0); | ||
236 | } | ||
237 | |||
234 | static void addrconf_del_timer(struct inet6_ifaddr *ifp) | 238 | static void addrconf_del_timer(struct inet6_ifaddr *ifp) |
235 | { | 239 | { |
236 | if (del_timer(&ifp->timer)) | 240 | if (del_timer(&ifp->timer)) |
@@ -344,6 +348,8 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev) | |||
344 | kfree(ndev); | 348 | kfree(ndev); |
345 | return NULL; | 349 | return NULL; |
346 | } | 350 | } |
351 | if (ndev->cnf.forwarding) | ||
352 | dev_disable_lro(dev); | ||
347 | /* We refer to the device */ | 353 | /* We refer to the device */ |
348 | dev_hold(dev); | 354 | dev_hold(dev); |
349 | 355 | ||
@@ -438,6 +444,8 @@ static void dev_forward_change(struct inet6_dev *idev) | |||
438 | if (!idev) | 444 | if (!idev) |
439 | return; | 445 | return; |
440 | dev = idev->dev; | 446 | dev = idev->dev; |
447 | if (idev->cnf.forwarding) | ||
448 | dev_disable_lro(dev); | ||
441 | if (dev && (dev->flags & IFF_MULTICAST)) { | 449 | if (dev && (dev->flags & IFF_MULTICAST)) { |
442 | if (idev->cnf.forwarding) | 450 | if (idev->cnf.forwarding) |
443 | ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters); | 451 | ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters); |
@@ -483,12 +491,14 @@ static void addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old) | |||
483 | if (p == &net->ipv6.devconf_dflt->forwarding) | 491 | if (p == &net->ipv6.devconf_dflt->forwarding) |
484 | return; | 492 | return; |
485 | 493 | ||
494 | rtnl_lock(); | ||
486 | if (p == &net->ipv6.devconf_all->forwarding) { | 495 | if (p == &net->ipv6.devconf_all->forwarding) { |
487 | __s32 newf = net->ipv6.devconf_all->forwarding; | 496 | __s32 newf = net->ipv6.devconf_all->forwarding; |
488 | net->ipv6.devconf_dflt->forwarding = newf; | 497 | net->ipv6.devconf_dflt->forwarding = newf; |
489 | addrconf_forward_change(net, newf); | 498 | addrconf_forward_change(net, newf); |
490 | } else if ((!*p) ^ (!old)) | 499 | } else if ((!*p) ^ (!old)) |
491 | dev_forward_change((struct inet6_dev *)table->extra1); | 500 | dev_forward_change((struct inet6_dev *)table->extra1); |
501 | rtnl_unlock(); | ||
492 | 502 | ||
493 | if (*p) | 503 | if (*p) |
494 | rt6_purge_dflt_routers(net); | 504 | rt6_purge_dflt_routers(net); |
@@ -777,7 +787,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp) | |||
777 | ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len); | 787 | ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len); |
778 | rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1); | 788 | rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1); |
779 | 789 | ||
780 | if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) { | 790 | if (rt && addrconf_is_prefix_route(rt)) { |
781 | if (onlink == 0) { | 791 | if (onlink == 0) { |
782 | ip6_del_rt(rt); | 792 | ip6_del_rt(rt); |
783 | rt = NULL; | 793 | rt = NULL; |
@@ -958,7 +968,8 @@ static inline int ipv6_saddr_preferred(int type) | |||
958 | return 0; | 968 | return 0; |
959 | } | 969 | } |
960 | 970 | ||
961 | static int ipv6_get_saddr_eval(struct ipv6_saddr_score *score, | 971 | static int ipv6_get_saddr_eval(struct net *net, |
972 | struct ipv6_saddr_score *score, | ||
962 | struct ipv6_saddr_dst *dst, | 973 | struct ipv6_saddr_dst *dst, |
963 | int i) | 974 | int i) |
964 | { | 975 | { |
@@ -1037,7 +1048,8 @@ static int ipv6_get_saddr_eval(struct ipv6_saddr_score *score, | |||
1037 | break; | 1048 | break; |
1038 | case IPV6_SADDR_RULE_LABEL: | 1049 | case IPV6_SADDR_RULE_LABEL: |
1039 | /* Rule 6: Prefer matching label */ | 1050 | /* Rule 6: Prefer matching label */ |
1040 | ret = ipv6_addr_label(&score->ifa->addr, score->addr_type, | 1051 | ret = ipv6_addr_label(net, |
1052 | &score->ifa->addr, score->addr_type, | ||
1041 | score->ifa->idev->dev->ifindex) == dst->label; | 1053 | score->ifa->idev->dev->ifindex) == dst->label; |
1042 | break; | 1054 | break; |
1043 | #ifdef CONFIG_IPV6_PRIVACY | 1055 | #ifdef CONFIG_IPV6_PRIVACY |
@@ -1091,7 +1103,7 @@ int ipv6_dev_get_saddr(struct net_device *dst_dev, | |||
1091 | dst.addr = daddr; | 1103 | dst.addr = daddr; |
1092 | dst.ifindex = dst_dev ? dst_dev->ifindex : 0; | 1104 | dst.ifindex = dst_dev ? dst_dev->ifindex : 0; |
1093 | dst.scope = __ipv6_addr_src_scope(dst_type); | 1105 | dst.scope = __ipv6_addr_src_scope(dst_type); |
1094 | dst.label = ipv6_addr_label(daddr, dst_type, dst.ifindex); | 1106 | dst.label = ipv6_addr_label(net, daddr, dst_type, dst.ifindex); |
1095 | dst.prefs = prefs; | 1107 | dst.prefs = prefs; |
1096 | 1108 | ||
1097 | hiscore->rule = -1; | 1109 | hiscore->rule = -1; |
@@ -1159,8 +1171,8 @@ int ipv6_dev_get_saddr(struct net_device *dst_dev, | |||
1159 | for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) { | 1171 | for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) { |
1160 | int minihiscore, miniscore; | 1172 | int minihiscore, miniscore; |
1161 | 1173 | ||
1162 | minihiscore = ipv6_get_saddr_eval(hiscore, &dst, i); | 1174 | minihiscore = ipv6_get_saddr_eval(net, hiscore, &dst, i); |
1163 | miniscore = ipv6_get_saddr_eval(score, &dst, i); | 1175 | miniscore = ipv6_get_saddr_eval(net, score, &dst, i); |
1164 | 1176 | ||
1165 | if (minihiscore > miniscore) { | 1177 | if (minihiscore > miniscore) { |
1166 | if (i == IPV6_SADDR_RULE_SCOPE && | 1178 | if (i == IPV6_SADDR_RULE_SCOPE && |
@@ -1788,7 +1800,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len) | |||
1788 | rt = rt6_lookup(dev_net(dev), &pinfo->prefix, NULL, | 1800 | rt = rt6_lookup(dev_net(dev), &pinfo->prefix, NULL, |
1789 | dev->ifindex, 1); | 1801 | dev->ifindex, 1); |
1790 | 1802 | ||
1791 | if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) { | 1803 | if (rt && addrconf_is_prefix_route(rt)) { |
1792 | /* Autoconf prefix route */ | 1804 | /* Autoconf prefix route */ |
1793 | if (valid_lft == 0) { | 1805 | if (valid_lft == 0) { |
1794 | ip6_del_rt(rt); | 1806 | ip6_del_rt(rt); |
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c index 9bfa8846f262..08909039d87b 100644 --- a/net/ipv6/addrlabel.c +++ b/net/ipv6/addrlabel.c | |||
@@ -29,6 +29,9 @@ | |||
29 | */ | 29 | */ |
30 | struct ip6addrlbl_entry | 30 | struct ip6addrlbl_entry |
31 | { | 31 | { |
32 | #ifdef CONFIG_NET_NS | ||
33 | struct net *lbl_net; | ||
34 | #endif | ||
32 | struct in6_addr prefix; | 35 | struct in6_addr prefix; |
33 | int prefixlen; | 36 | int prefixlen; |
34 | int ifindex; | 37 | int ifindex; |
@@ -46,6 +49,16 @@ static struct ip6addrlbl_table | |||
46 | u32 seq; | 49 | u32 seq; |
47 | } ip6addrlbl_table; | 50 | } ip6addrlbl_table; |
48 | 51 | ||
52 | static inline | ||
53 | struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl) | ||
54 | { | ||
55 | #ifdef CONFIG_NET_NS | ||
56 | return lbl->lbl_net; | ||
57 | #else | ||
58 | return &init_net; | ||
59 | #endif | ||
60 | } | ||
61 | |||
49 | /* | 62 | /* |
50 | * Default policy table (RFC3484 + extensions) | 63 | * Default policy table (RFC3484 + extensions) |
51 | * | 64 | * |
@@ -65,7 +78,7 @@ static struct ip6addrlbl_table | |||
65 | 78 | ||
66 | #define IPV6_ADDR_LABEL_DEFAULT 0xffffffffUL | 79 | #define IPV6_ADDR_LABEL_DEFAULT 0xffffffffUL |
67 | 80 | ||
68 | static const __initdata struct ip6addrlbl_init_table | 81 | static const __net_initdata struct ip6addrlbl_init_table |
69 | { | 82 | { |
70 | const struct in6_addr *prefix; | 83 | const struct in6_addr *prefix; |
71 | int prefixlen; | 84 | int prefixlen; |
@@ -108,6 +121,9 @@ static const __initdata struct ip6addrlbl_init_table | |||
108 | /* Object management */ | 121 | /* Object management */ |
109 | static inline void ip6addrlbl_free(struct ip6addrlbl_entry *p) | 122 | static inline void ip6addrlbl_free(struct ip6addrlbl_entry *p) |
110 | { | 123 | { |
124 | #ifdef CONFIG_NET_NS | ||
125 | release_net(p->lbl_net); | ||
126 | #endif | ||
111 | kfree(p); | 127 | kfree(p); |
112 | } | 128 | } |
113 | 129 | ||
@@ -128,10 +144,13 @@ static inline void ip6addrlbl_put(struct ip6addrlbl_entry *p) | |||
128 | } | 144 | } |
129 | 145 | ||
130 | /* Find label */ | 146 | /* Find label */ |
131 | static int __ip6addrlbl_match(struct ip6addrlbl_entry *p, | 147 | static int __ip6addrlbl_match(struct net *net, |
148 | struct ip6addrlbl_entry *p, | ||
132 | const struct in6_addr *addr, | 149 | const struct in6_addr *addr, |
133 | int addrtype, int ifindex) | 150 | int addrtype, int ifindex) |
134 | { | 151 | { |
152 | if (!net_eq(ip6addrlbl_net(p), net)) | ||
153 | return 0; | ||
135 | if (p->ifindex && p->ifindex != ifindex) | 154 | if (p->ifindex && p->ifindex != ifindex) |
136 | return 0; | 155 | return 0; |
137 | if (p->addrtype && p->addrtype != addrtype) | 156 | if (p->addrtype && p->addrtype != addrtype) |
@@ -141,19 +160,21 @@ static int __ip6addrlbl_match(struct ip6addrlbl_entry *p, | |||
141 | return 1; | 160 | return 1; |
142 | } | 161 | } |
143 | 162 | ||
144 | static struct ip6addrlbl_entry *__ipv6_addr_label(const struct in6_addr *addr, | 163 | static struct ip6addrlbl_entry *__ipv6_addr_label(struct net *net, |
164 | const struct in6_addr *addr, | ||
145 | int type, int ifindex) | 165 | int type, int ifindex) |
146 | { | 166 | { |
147 | struct hlist_node *pos; | 167 | struct hlist_node *pos; |
148 | struct ip6addrlbl_entry *p; | 168 | struct ip6addrlbl_entry *p; |
149 | hlist_for_each_entry_rcu(p, pos, &ip6addrlbl_table.head, list) { | 169 | hlist_for_each_entry_rcu(p, pos, &ip6addrlbl_table.head, list) { |
150 | if (__ip6addrlbl_match(p, addr, type, ifindex)) | 170 | if (__ip6addrlbl_match(net, p, addr, type, ifindex)) |
151 | return p; | 171 | return p; |
152 | } | 172 | } |
153 | return NULL; | 173 | return NULL; |
154 | } | 174 | } |
155 | 175 | ||
156 | u32 ipv6_addr_label(const struct in6_addr *addr, int type, int ifindex) | 176 | u32 ipv6_addr_label(struct net *net, |
177 | const struct in6_addr *addr, int type, int ifindex) | ||
157 | { | 178 | { |
158 | u32 label; | 179 | u32 label; |
159 | struct ip6addrlbl_entry *p; | 180 | struct ip6addrlbl_entry *p; |
@@ -161,7 +182,7 @@ u32 ipv6_addr_label(const struct in6_addr *addr, int type, int ifindex) | |||
161 | type &= IPV6_ADDR_MAPPED | IPV6_ADDR_COMPATv4 | IPV6_ADDR_LOOPBACK; | 182 | type &= IPV6_ADDR_MAPPED | IPV6_ADDR_COMPATv4 | IPV6_ADDR_LOOPBACK; |
162 | 183 | ||
163 | rcu_read_lock(); | 184 | rcu_read_lock(); |
164 | p = __ipv6_addr_label(addr, type, ifindex); | 185 | p = __ipv6_addr_label(net, addr, type, ifindex); |
165 | label = p ? p->label : IPV6_ADDR_LABEL_DEFAULT; | 186 | label = p ? p->label : IPV6_ADDR_LABEL_DEFAULT; |
166 | rcu_read_unlock(); | 187 | rcu_read_unlock(); |
167 | 188 | ||
@@ -174,7 +195,8 @@ u32 ipv6_addr_label(const struct in6_addr *addr, int type, int ifindex) | |||
174 | } | 195 | } |
175 | 196 | ||
176 | /* allocate one entry */ | 197 | /* allocate one entry */ |
177 | static struct ip6addrlbl_entry *ip6addrlbl_alloc(const struct in6_addr *prefix, | 198 | static struct ip6addrlbl_entry *ip6addrlbl_alloc(struct net *net, |
199 | const struct in6_addr *prefix, | ||
178 | int prefixlen, int ifindex, | 200 | int prefixlen, int ifindex, |
179 | u32 label) | 201 | u32 label) |
180 | { | 202 | { |
@@ -216,6 +238,9 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(const struct in6_addr *prefix, | |||
216 | newp->addrtype = addrtype; | 238 | newp->addrtype = addrtype; |
217 | newp->label = label; | 239 | newp->label = label; |
218 | INIT_HLIST_NODE(&newp->list); | 240 | INIT_HLIST_NODE(&newp->list); |
241 | #ifdef CONFIG_NET_NS | ||
242 | newp->lbl_net = hold_net(net); | ||
243 | #endif | ||
219 | atomic_set(&newp->refcnt, 1); | 244 | atomic_set(&newp->refcnt, 1); |
220 | return newp; | 245 | return newp; |
221 | } | 246 | } |
@@ -237,6 +262,7 @@ static int __ip6addrlbl_add(struct ip6addrlbl_entry *newp, int replace) | |||
237 | hlist_for_each_entry_safe(p, pos, n, | 262 | hlist_for_each_entry_safe(p, pos, n, |
238 | &ip6addrlbl_table.head, list) { | 263 | &ip6addrlbl_table.head, list) { |
239 | if (p->prefixlen == newp->prefixlen && | 264 | if (p->prefixlen == newp->prefixlen && |
265 | net_eq(ip6addrlbl_net(p), ip6addrlbl_net(newp)) && | ||
240 | p->ifindex == newp->ifindex && | 266 | p->ifindex == newp->ifindex && |
241 | ipv6_addr_equal(&p->prefix, &newp->prefix)) { | 267 | ipv6_addr_equal(&p->prefix, &newp->prefix)) { |
242 | if (!replace) { | 268 | if (!replace) { |
@@ -261,7 +287,8 @@ out: | |||
261 | } | 287 | } |
262 | 288 | ||
263 | /* add a label */ | 289 | /* add a label */ |
264 | static int ip6addrlbl_add(const struct in6_addr *prefix, int prefixlen, | 290 | static int ip6addrlbl_add(struct net *net, |
291 | const struct in6_addr *prefix, int prefixlen, | ||
265 | int ifindex, u32 label, int replace) | 292 | int ifindex, u32 label, int replace) |
266 | { | 293 | { |
267 | struct ip6addrlbl_entry *newp; | 294 | struct ip6addrlbl_entry *newp; |
@@ -274,7 +301,7 @@ static int ip6addrlbl_add(const struct in6_addr *prefix, int prefixlen, | |||
274 | (unsigned int)label, | 301 | (unsigned int)label, |
275 | replace); | 302 | replace); |
276 | 303 | ||
277 | newp = ip6addrlbl_alloc(prefix, prefixlen, ifindex, label); | 304 | newp = ip6addrlbl_alloc(net, prefix, prefixlen, ifindex, label); |
278 | if (IS_ERR(newp)) | 305 | if (IS_ERR(newp)) |
279 | return PTR_ERR(newp); | 306 | return PTR_ERR(newp); |
280 | spin_lock(&ip6addrlbl_table.lock); | 307 | spin_lock(&ip6addrlbl_table.lock); |
@@ -286,7 +313,8 @@ static int ip6addrlbl_add(const struct in6_addr *prefix, int prefixlen, | |||
286 | } | 313 | } |
287 | 314 | ||
288 | /* remove a label */ | 315 | /* remove a label */ |
289 | static int __ip6addrlbl_del(const struct in6_addr *prefix, int prefixlen, | 316 | static int __ip6addrlbl_del(struct net *net, |
317 | const struct in6_addr *prefix, int prefixlen, | ||
290 | int ifindex) | 318 | int ifindex) |
291 | { | 319 | { |
292 | struct ip6addrlbl_entry *p = NULL; | 320 | struct ip6addrlbl_entry *p = NULL; |
@@ -300,6 +328,7 @@ static int __ip6addrlbl_del(const struct in6_addr *prefix, int prefixlen, | |||
300 | 328 | ||
301 | hlist_for_each_entry_safe(p, pos, n, &ip6addrlbl_table.head, list) { | 329 | hlist_for_each_entry_safe(p, pos, n, &ip6addrlbl_table.head, list) { |
302 | if (p->prefixlen == prefixlen && | 330 | if (p->prefixlen == prefixlen && |
331 | net_eq(ip6addrlbl_net(p), net) && | ||
303 | p->ifindex == ifindex && | 332 | p->ifindex == ifindex && |
304 | ipv6_addr_equal(&p->prefix, prefix)) { | 333 | ipv6_addr_equal(&p->prefix, prefix)) { |
305 | hlist_del_rcu(&p->list); | 334 | hlist_del_rcu(&p->list); |
@@ -311,7 +340,8 @@ static int __ip6addrlbl_del(const struct in6_addr *prefix, int prefixlen, | |||
311 | return ret; | 340 | return ret; |
312 | } | 341 | } |
313 | 342 | ||
314 | static int ip6addrlbl_del(const struct in6_addr *prefix, int prefixlen, | 343 | static int ip6addrlbl_del(struct net *net, |
344 | const struct in6_addr *prefix, int prefixlen, | ||
315 | int ifindex) | 345 | int ifindex) |
316 | { | 346 | { |
317 | struct in6_addr prefix_buf; | 347 | struct in6_addr prefix_buf; |
@@ -324,13 +354,13 @@ static int ip6addrlbl_del(const struct in6_addr *prefix, int prefixlen, | |||
324 | 354 | ||
325 | ipv6_addr_prefix(&prefix_buf, prefix, prefixlen); | 355 | ipv6_addr_prefix(&prefix_buf, prefix, prefixlen); |
326 | spin_lock(&ip6addrlbl_table.lock); | 356 | spin_lock(&ip6addrlbl_table.lock); |
327 | ret = __ip6addrlbl_del(&prefix_buf, prefixlen, ifindex); | 357 | ret = __ip6addrlbl_del(net, &prefix_buf, prefixlen, ifindex); |
328 | spin_unlock(&ip6addrlbl_table.lock); | 358 | spin_unlock(&ip6addrlbl_table.lock); |
329 | return ret; | 359 | return ret; |
330 | } | 360 | } |
331 | 361 | ||
332 | /* add default label */ | 362 | /* add default label */ |
333 | static __init int ip6addrlbl_init(void) | 363 | static int __net_init ip6addrlbl_net_init(struct net *net) |
334 | { | 364 | { |
335 | int err = 0; | 365 | int err = 0; |
336 | int i; | 366 | int i; |
@@ -338,7 +368,8 @@ static __init int ip6addrlbl_init(void) | |||
338 | ADDRLABEL(KERN_DEBUG "%s()\n", __func__); | 368 | ADDRLABEL(KERN_DEBUG "%s()\n", __func__); |
339 | 369 | ||
340 | for (i = 0; i < ARRAY_SIZE(ip6addrlbl_init_table); i++) { | 370 | for (i = 0; i < ARRAY_SIZE(ip6addrlbl_init_table); i++) { |
341 | int ret = ip6addrlbl_add(ip6addrlbl_init_table[i].prefix, | 371 | int ret = ip6addrlbl_add(net, |
372 | ip6addrlbl_init_table[i].prefix, | ||
342 | ip6addrlbl_init_table[i].prefixlen, | 373 | ip6addrlbl_init_table[i].prefixlen, |
343 | 0, | 374 | 0, |
344 | ip6addrlbl_init_table[i].label, 0); | 375 | ip6addrlbl_init_table[i].label, 0); |
@@ -349,11 +380,32 @@ static __init int ip6addrlbl_init(void) | |||
349 | return err; | 380 | return err; |
350 | } | 381 | } |
351 | 382 | ||
383 | static void __net_exit ip6addrlbl_net_exit(struct net *net) | ||
384 | { | ||
385 | struct ip6addrlbl_entry *p = NULL; | ||
386 | struct hlist_node *pos, *n; | ||
387 | |||
388 | /* Remove all labels belonging to the exiting net */ | ||
389 | spin_lock(&ip6addrlbl_table.lock); | ||
390 | hlist_for_each_entry_safe(p, pos, n, &ip6addrlbl_table.head, list) { | ||
391 | if (net_eq(ip6addrlbl_net(p), net)) { | ||
392 | hlist_del_rcu(&p->list); | ||
393 | ip6addrlbl_put(p); | ||
394 | } | ||
395 | } | ||
396 | spin_unlock(&ip6addrlbl_table.lock); | ||
397 | } | ||
398 | |||
399 | static struct pernet_operations ipv6_addr_label_ops = { | ||
400 | .init = ip6addrlbl_net_init, | ||
401 | .exit = ip6addrlbl_net_exit, | ||
402 | }; | ||
403 | |||
352 | int __init ipv6_addr_label_init(void) | 404 | int __init ipv6_addr_label_init(void) |
353 | { | 405 | { |
354 | spin_lock_init(&ip6addrlbl_table.lock); | 406 | spin_lock_init(&ip6addrlbl_table.lock); |
355 | 407 | ||
356 | return ip6addrlbl_init(); | 408 | return register_pernet_subsys(&ipv6_addr_label_ops); |
357 | } | 409 | } |
358 | 410 | ||
359 | static const struct nla_policy ifal_policy[IFAL_MAX+1] = { | 411 | static const struct nla_policy ifal_policy[IFAL_MAX+1] = { |
@@ -371,9 +423,6 @@ static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
371 | u32 label; | 423 | u32 label; |
372 | int err = 0; | 424 | int err = 0; |
373 | 425 | ||
374 | if (net != &init_net) | ||
375 | return 0; | ||
376 | |||
377 | err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy); | 426 | err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy); |
378 | if (err < 0) | 427 | if (err < 0) |
379 | return err; | 428 | return err; |
@@ -385,7 +434,7 @@ static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
385 | return -EINVAL; | 434 | return -EINVAL; |
386 | 435 | ||
387 | if (ifal->ifal_index && | 436 | if (ifal->ifal_index && |
388 | !__dev_get_by_index(&init_net, ifal->ifal_index)) | 437 | !__dev_get_by_index(net, ifal->ifal_index)) |
389 | return -EINVAL; | 438 | return -EINVAL; |
390 | 439 | ||
391 | if (!tb[IFAL_ADDRESS]) | 440 | if (!tb[IFAL_ADDRESS]) |
@@ -403,12 +452,12 @@ static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
403 | 452 | ||
404 | switch(nlh->nlmsg_type) { | 453 | switch(nlh->nlmsg_type) { |
405 | case RTM_NEWADDRLABEL: | 454 | case RTM_NEWADDRLABEL: |
406 | err = ip6addrlbl_add(pfx, ifal->ifal_prefixlen, | 455 | err = ip6addrlbl_add(net, pfx, ifal->ifal_prefixlen, |
407 | ifal->ifal_index, label, | 456 | ifal->ifal_index, label, |
408 | nlh->nlmsg_flags & NLM_F_REPLACE); | 457 | nlh->nlmsg_flags & NLM_F_REPLACE); |
409 | break; | 458 | break; |
410 | case RTM_DELADDRLABEL: | 459 | case RTM_DELADDRLABEL: |
411 | err = ip6addrlbl_del(pfx, ifal->ifal_prefixlen, | 460 | err = ip6addrlbl_del(net, pfx, ifal->ifal_prefixlen, |
412 | ifal->ifal_index); | 461 | ifal->ifal_index); |
413 | break; | 462 | break; |
414 | default: | 463 | default: |
@@ -458,12 +507,10 @@ static int ip6addrlbl_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
458 | int idx = 0, s_idx = cb->args[0]; | 507 | int idx = 0, s_idx = cb->args[0]; |
459 | int err; | 508 | int err; |
460 | 509 | ||
461 | if (net != &init_net) | ||
462 | return 0; | ||
463 | |||
464 | rcu_read_lock(); | 510 | rcu_read_lock(); |
465 | hlist_for_each_entry_rcu(p, pos, &ip6addrlbl_table.head, list) { | 511 | hlist_for_each_entry_rcu(p, pos, &ip6addrlbl_table.head, list) { |
466 | if (idx >= s_idx) { | 512 | if (idx >= s_idx && |
513 | net_eq(ip6addrlbl_net(p), net)) { | ||
467 | if ((err = ip6addrlbl_fill(skb, p, | 514 | if ((err = ip6addrlbl_fill(skb, p, |
468 | ip6addrlbl_table.seq, | 515 | ip6addrlbl_table.seq, |
469 | NETLINK_CB(cb->skb).pid, | 516 | NETLINK_CB(cb->skb).pid, |
@@ -499,9 +546,6 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, | |||
499 | struct ip6addrlbl_entry *p; | 546 | struct ip6addrlbl_entry *p; |
500 | struct sk_buff *skb; | 547 | struct sk_buff *skb; |
501 | 548 | ||
502 | if (net != &init_net) | ||
503 | return 0; | ||
504 | |||
505 | err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy); | 549 | err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy); |
506 | if (err < 0) | 550 | if (err < 0) |
507 | return err; | 551 | return err; |
@@ -513,7 +557,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, | |||
513 | return -EINVAL; | 557 | return -EINVAL; |
514 | 558 | ||
515 | if (ifal->ifal_index && | 559 | if (ifal->ifal_index && |
516 | !__dev_get_by_index(&init_net, ifal->ifal_index)) | 560 | !__dev_get_by_index(net, ifal->ifal_index)) |
517 | return -EINVAL; | 561 | return -EINVAL; |
518 | 562 | ||
519 | if (!tb[IFAL_ADDRESS]) | 563 | if (!tb[IFAL_ADDRESS]) |
@@ -524,7 +568,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, | |||
524 | return -EINVAL; | 568 | return -EINVAL; |
525 | 569 | ||
526 | rcu_read_lock(); | 570 | rcu_read_lock(); |
527 | p = __ipv6_addr_label(addr, ipv6_addr_type(addr), ifal->ifal_index); | 571 | p = __ipv6_addr_label(net, addr, ipv6_addr_type(addr), ifal->ifal_index); |
528 | if (p && ip6addrlbl_hold(p)) | 572 | if (p && ip6addrlbl_hold(p)) |
529 | p = NULL; | 573 | p = NULL; |
530 | lseq = ip6addrlbl_table.seq; | 574 | lseq = ip6addrlbl_table.seq; |
@@ -552,7 +596,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, | |||
552 | goto out; | 596 | goto out; |
553 | } | 597 | } |
554 | 598 | ||
555 | err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid); | 599 | err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).pid); |
556 | out: | 600 | out: |
557 | return err; | 601 | return err; |
558 | } | 602 | } |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index e84b3fd17fb4..3ce8d2f318c6 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -7,8 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Adapted from linux/net/ipv4/af_inet.c | 8 | * Adapted from linux/net/ipv4/af_inet.c |
9 | * | 9 | * |
10 | * $Id: af_inet6.c,v 1.66 2002/02/01 22:01:04 davem Exp $ | ||
11 | * | ||
12 | * Fixes: | 10 | * Fixes: |
13 | * piggy, Karl Knutson : Socket protocol table | 11 | * piggy, Karl Knutson : Socket protocol table |
14 | * Hideaki YOSHIFUJI : sin6_scope_id support | 12 | * Hideaki YOSHIFUJI : sin6_scope_id support |
@@ -373,7 +371,7 @@ int inet6_release(struct socket *sock) | |||
373 | 371 | ||
374 | EXPORT_SYMBOL(inet6_release); | 372 | EXPORT_SYMBOL(inet6_release); |
375 | 373 | ||
376 | int inet6_destroy_sock(struct sock *sk) | 374 | void inet6_destroy_sock(struct sock *sk) |
377 | { | 375 | { |
378 | struct ipv6_pinfo *np = inet6_sk(sk); | 376 | struct ipv6_pinfo *np = inet6_sk(sk); |
379 | struct sk_buff *skb; | 377 | struct sk_buff *skb; |
@@ -391,8 +389,6 @@ int inet6_destroy_sock(struct sock *sk) | |||
391 | 389 | ||
392 | if ((opt = xchg(&np->opt, NULL)) != NULL) | 390 | if ((opt = xchg(&np->opt, NULL)) != NULL) |
393 | sock_kfree_s(sk, opt, opt->tot_len); | 391 | sock_kfree_s(sk, opt, opt->tot_len); |
394 | |||
395 | return 0; | ||
396 | } | 392 | } |
397 | 393 | ||
398 | EXPORT_SYMBOL_GPL(inet6_destroy_sock); | 394 | EXPORT_SYMBOL_GPL(inet6_destroy_sock); |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 0f0f94a40335..f7b535dec860 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: datagram.c,v 1.24 2002/02/01 22:01:04 davem Exp $ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU General Public License | 9 | * modify it under the terms of the GNU General Public License |
12 | * as published by the Free Software Foundation; either version | 10 | * as published by the Free Software Foundation; either version |
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 3cd1c993d52b..602ea826f0a5 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c | |||
@@ -7,8 +7,6 @@ | |||
7 | * Andi Kleen <ak@muc.de> | 7 | * Andi Kleen <ak@muc.de> |
8 | * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> | 8 | * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> |
9 | * | 9 | * |
10 | * $Id: exthdrs.c,v 1.13 2001/06/19 15:58:56 davem Exp $ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 11 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version | 12 | * as published by the Free Software Foundation; either version |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index d42dd16d3487..399d41f65437 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: icmp.c,v 1.38 2002/02/08 03:57:19 davem Exp $ | ||
9 | * | ||
10 | * Based on net/ipv4/icmp.c | 8 | * Based on net/ipv4/icmp.c |
11 | * | 9 | * |
12 | * RFC 1885 | 10 | * RFC 1885 |
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 580014aea4d6..a9cc8ab33a49 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -68,7 +68,7 @@ struct sock *__inet6_lookup_established(struct net *net, | |||
68 | /* Optimize here for direct hit, only listening connections can | 68 | /* Optimize here for direct hit, only listening connections can |
69 | * have wildcards anyways. | 69 | * have wildcards anyways. |
70 | */ | 70 | */ |
71 | unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport); | 71 | unsigned int hash = inet6_ehashfn(net, daddr, hnum, saddr, sport); |
72 | struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); | 72 | struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); |
73 | rwlock_t *lock = inet_ehash_lockp(hashinfo, hash); | 73 | rwlock_t *lock = inet_ehash_lockp(hashinfo, hash); |
74 | 74 | ||
@@ -104,7 +104,8 @@ struct sock *inet6_lookup_listener(struct net *net, | |||
104 | int score, hiscore = 0; | 104 | int score, hiscore = 0; |
105 | 105 | ||
106 | read_lock(&hashinfo->lhash_lock); | 106 | read_lock(&hashinfo->lhash_lock); |
107 | sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { | 107 | sk_for_each(sk, node, |
108 | &hashinfo->listening_hash[inet_lhashfn(net, hnum)]) { | ||
108 | if (net_eq(sock_net(sk), net) && inet_sk(sk)->num == hnum && | 109 | if (net_eq(sock_net(sk), net) && inet_sk(sk)->num == hnum && |
109 | sk->sk_family == PF_INET6) { | 110 | sk->sk_family == PF_INET6) { |
110 | const struct ipv6_pinfo *np = inet6_sk(sk); | 111 | const struct ipv6_pinfo *np = inet6_sk(sk); |
@@ -165,14 +166,14 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, | |||
165 | const struct in6_addr *saddr = &np->daddr; | 166 | const struct in6_addr *saddr = &np->daddr; |
166 | const int dif = sk->sk_bound_dev_if; | 167 | const int dif = sk->sk_bound_dev_if; |
167 | const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport); | 168 | const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport); |
168 | const unsigned int hash = inet6_ehashfn(daddr, lport, saddr, | 169 | struct net *net = sock_net(sk); |
170 | const unsigned int hash = inet6_ehashfn(net, daddr, lport, saddr, | ||
169 | inet->dport); | 171 | inet->dport); |
170 | struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); | 172 | struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); |
171 | rwlock_t *lock = inet_ehash_lockp(hinfo, hash); | 173 | rwlock_t *lock = inet_ehash_lockp(hinfo, hash); |
172 | struct sock *sk2; | 174 | struct sock *sk2; |
173 | const struct hlist_node *node; | 175 | const struct hlist_node *node; |
174 | struct inet_timewait_sock *tw; | 176 | struct inet_timewait_sock *tw; |
175 | struct net *net = sock_net(sk); | ||
176 | 177 | ||
177 | prefetch(head->chain.first); | 178 | prefetch(head->chain.first); |
178 | write_lock(lock); | 179 | write_lock(lock); |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 1ee4fa17c129..4de2b9efcacb 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: ip6_fib.c,v 1.25 2001/10/31 21:55:55 davem Exp $ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU General Public License | 9 | * modify it under the terms of the GNU General Public License |
12 | * as published by the Free Software Foundation; either version | 10 | * as published by the Free Software Foundation; either version |
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 17eb48b8e329..34e5a96623ae 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c | |||
@@ -6,8 +6,6 @@ | |||
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * Ian P. Morris <I.P.Morris@soton.ac.uk> | 7 | * Ian P. Morris <I.P.Morris@soton.ac.uk> |
8 | * | 8 | * |
9 | * $Id: ip6_input.c,v 1.19 2000/12/13 18:31:50 davem Exp $ | ||
10 | * | ||
11 | * Based in linux/net/ipv4/ip_input.c | 9 | * Based in linux/net/ipv4/ip_input.c |
12 | * | 10 | * |
13 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 48cdce9c696c..fd7cd1bfe151 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: ip6_output.c,v 1.34 2002/02/01 22:01:04 davem Exp $ | ||
9 | * | ||
10 | * Based on linux/net/ipv4/ip_output.c | 8 | * Based on linux/net/ipv4/ip_output.c |
11 | * | 9 | * |
12 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
@@ -409,6 +407,9 @@ int ip6_forward(struct sk_buff *skb) | |||
409 | if (ipv6_devconf.forwarding == 0) | 407 | if (ipv6_devconf.forwarding == 0) |
410 | goto error; | 408 | goto error; |
411 | 409 | ||
410 | if (skb_warn_if_lro(skb)) | ||
411 | goto drop; | ||
412 | |||
412 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) { | 413 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) { |
413 | IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_INDISCARDS); | 414 | IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_INDISCARDS); |
414 | goto drop; | 415 | goto drop; |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 2bda3ba100b1..17c7b098cdb0 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -6,8 +6,6 @@ | |||
6 | * Ville Nuorvala <vnuorval@tcs.hut.fi> | 6 | * Ville Nuorvala <vnuorval@tcs.hut.fi> |
7 | * Yasuyuki Kozakai <kozakai@linux-ipv6.org> | 7 | * Yasuyuki Kozakai <kozakai@linux-ipv6.org> |
8 | * | 8 | * |
9 | * $Id$ | ||
10 | * | ||
11 | * Based on: | 9 | * Based on: |
12 | * linux/net/ipv6/sit.c and linux/net/ipv4/ipip.c | 10 | * linux/net/ipv6/sit.c and linux/net/ipv4/ipip.c |
13 | * | 11 | * |
@@ -711,7 +709,7 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, | |||
711 | } | 709 | } |
712 | 710 | ||
713 | if (!ip6_tnl_rcv_ctl(t)) { | 711 | if (!ip6_tnl_rcv_ctl(t)) { |
714 | t->stat.rx_dropped++; | 712 | t->dev->stats.rx_dropped++; |
715 | read_unlock(&ip6_tnl_lock); | 713 | read_unlock(&ip6_tnl_lock); |
716 | goto discard; | 714 | goto discard; |
717 | } | 715 | } |
@@ -728,8 +726,8 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, | |||
728 | 726 | ||
729 | dscp_ecn_decapsulate(t, ipv6h, skb); | 727 | dscp_ecn_decapsulate(t, ipv6h, skb); |
730 | 728 | ||
731 | t->stat.rx_packets++; | 729 | t->dev->stats.rx_packets++; |
732 | t->stat.rx_bytes += skb->len; | 730 | t->dev->stats.rx_bytes += skb->len; |
733 | netif_rx(skb); | 731 | netif_rx(skb); |
734 | read_unlock(&ip6_tnl_lock); | 732 | read_unlock(&ip6_tnl_lock); |
735 | return 0; | 733 | return 0; |
@@ -849,7 +847,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, | |||
849 | __u32 *pmtu) | 847 | __u32 *pmtu) |
850 | { | 848 | { |
851 | struct ip6_tnl *t = netdev_priv(dev); | 849 | struct ip6_tnl *t = netdev_priv(dev); |
852 | struct net_device_stats *stats = &t->stat; | 850 | struct net_device_stats *stats = &t->dev->stats; |
853 | struct ipv6hdr *ipv6h = ipv6_hdr(skb); | 851 | struct ipv6hdr *ipv6h = ipv6_hdr(skb); |
854 | struct ipv6_tel_txoption opt; | 852 | struct ipv6_tel_txoption opt; |
855 | struct dst_entry *dst; | 853 | struct dst_entry *dst; |
@@ -1043,11 +1041,11 @@ static int | |||
1043 | ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) | 1041 | ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) |
1044 | { | 1042 | { |
1045 | struct ip6_tnl *t = netdev_priv(dev); | 1043 | struct ip6_tnl *t = netdev_priv(dev); |
1046 | struct net_device_stats *stats = &t->stat; | 1044 | struct net_device_stats *stats = &t->dev->stats; |
1047 | int ret; | 1045 | int ret; |
1048 | 1046 | ||
1049 | if (t->recursion++) { | 1047 | if (t->recursion++) { |
1050 | t->stat.collisions++; | 1048 | stats->collisions++; |
1051 | goto tx_err; | 1049 | goto tx_err; |
1052 | } | 1050 | } |
1053 | 1051 | ||
@@ -1289,19 +1287,6 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1289 | } | 1287 | } |
1290 | 1288 | ||
1291 | /** | 1289 | /** |
1292 | * ip6_tnl_get_stats - return the stats for tunnel device | ||
1293 | * @dev: virtual device associated with tunnel | ||
1294 | * | ||
1295 | * Return: stats for device | ||
1296 | **/ | ||
1297 | |||
1298 | static struct net_device_stats * | ||
1299 | ip6_tnl_get_stats(struct net_device *dev) | ||
1300 | { | ||
1301 | return &(((struct ip6_tnl *)netdev_priv(dev))->stat); | ||
1302 | } | ||
1303 | |||
1304 | /** | ||
1305 | * ip6_tnl_change_mtu - change mtu manually for tunnel device | 1290 | * ip6_tnl_change_mtu - change mtu manually for tunnel device |
1306 | * @dev: virtual device associated with tunnel | 1291 | * @dev: virtual device associated with tunnel |
1307 | * @new_mtu: the new mtu | 1292 | * @new_mtu: the new mtu |
@@ -1334,7 +1319,6 @@ static void ip6_tnl_dev_setup(struct net_device *dev) | |||
1334 | dev->uninit = ip6_tnl_dev_uninit; | 1319 | dev->uninit = ip6_tnl_dev_uninit; |
1335 | dev->destructor = free_netdev; | 1320 | dev->destructor = free_netdev; |
1336 | dev->hard_start_xmit = ip6_tnl_xmit; | 1321 | dev->hard_start_xmit = ip6_tnl_xmit; |
1337 | dev->get_stats = ip6_tnl_get_stats; | ||
1338 | dev->do_ioctl = ip6_tnl_ioctl; | 1322 | dev->do_ioctl = ip6_tnl_ioctl; |
1339 | dev->change_mtu = ip6_tnl_change_mtu; | 1323 | dev->change_mtu = ip6_tnl_change_mtu; |
1340 | 1324 | ||
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 14796181e8b5..90e763073dc5 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c | |||
@@ -388,8 +388,8 @@ static int pim6_rcv(struct sk_buff *skb) | |||
388 | skb->ip_summed = 0; | 388 | skb->ip_summed = 0; |
389 | skb->pkt_type = PACKET_HOST; | 389 | skb->pkt_type = PACKET_HOST; |
390 | dst_release(skb->dst); | 390 | dst_release(skb->dst); |
391 | ((struct net_device_stats *)netdev_priv(reg_dev))->rx_bytes += skb->len; | 391 | reg_dev->stats.rx_bytes += skb->len; |
392 | ((struct net_device_stats *)netdev_priv(reg_dev))->rx_packets++; | 392 | reg_dev->stats.rx_packets++; |
393 | skb->dst = NULL; | 393 | skb->dst = NULL; |
394 | nf_reset(skb); | 394 | nf_reset(skb); |
395 | netif_rx(skb); | 395 | netif_rx(skb); |
@@ -409,26 +409,20 @@ static struct inet6_protocol pim6_protocol = { | |||
409 | static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) | 409 | static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) |
410 | { | 410 | { |
411 | read_lock(&mrt_lock); | 411 | read_lock(&mrt_lock); |
412 | ((struct net_device_stats *)netdev_priv(dev))->tx_bytes += skb->len; | 412 | dev->stats.tx_bytes += skb->len; |
413 | ((struct net_device_stats *)netdev_priv(dev))->tx_packets++; | 413 | dev->stats.tx_packets++; |
414 | ip6mr_cache_report(skb, reg_vif_num, MRT6MSG_WHOLEPKT); | 414 | ip6mr_cache_report(skb, reg_vif_num, MRT6MSG_WHOLEPKT); |
415 | read_unlock(&mrt_lock); | 415 | read_unlock(&mrt_lock); |
416 | kfree_skb(skb); | 416 | kfree_skb(skb); |
417 | return 0; | 417 | return 0; |
418 | } | 418 | } |
419 | 419 | ||
420 | static struct net_device_stats *reg_vif_get_stats(struct net_device *dev) | ||
421 | { | ||
422 | return (struct net_device_stats *)netdev_priv(dev); | ||
423 | } | ||
424 | |||
425 | static void reg_vif_setup(struct net_device *dev) | 420 | static void reg_vif_setup(struct net_device *dev) |
426 | { | 421 | { |
427 | dev->type = ARPHRD_PIMREG; | 422 | dev->type = ARPHRD_PIMREG; |
428 | dev->mtu = 1500 - sizeof(struct ipv6hdr) - 8; | 423 | dev->mtu = 1500 - sizeof(struct ipv6hdr) - 8; |
429 | dev->flags = IFF_NOARP; | 424 | dev->flags = IFF_NOARP; |
430 | dev->hard_start_xmit = reg_vif_xmit; | 425 | dev->hard_start_xmit = reg_vif_xmit; |
431 | dev->get_stats = reg_vif_get_stats; | ||
432 | dev->destructor = free_netdev; | 426 | dev->destructor = free_netdev; |
433 | } | 427 | } |
434 | 428 | ||
@@ -436,9 +430,7 @@ static struct net_device *ip6mr_reg_vif(void) | |||
436 | { | 430 | { |
437 | struct net_device *dev; | 431 | struct net_device *dev; |
438 | 432 | ||
439 | dev = alloc_netdev(sizeof(struct net_device_stats), "pim6reg", | 433 | dev = alloc_netdev(0, "pim6reg", reg_vif_setup); |
440 | reg_vif_setup); | ||
441 | |||
442 | if (dev == NULL) | 434 | if (dev == NULL) |
443 | return NULL; | 435 | return NULL; |
444 | 436 | ||
@@ -1248,7 +1240,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int | |||
1248 | 1240 | ||
1249 | #endif | 1241 | #endif |
1250 | /* | 1242 | /* |
1251 | * Spurious command, or MRT_VERSION which you cannot | 1243 | * Spurious command, or MRT6_VERSION which you cannot |
1252 | * set. | 1244 | * set. |
1253 | */ | 1245 | */ |
1254 | default: | 1246 | default: |
@@ -1377,8 +1369,8 @@ static int ip6mr_forward2(struct sk_buff *skb, struct mfc6_cache *c, int vifi) | |||
1377 | if (vif->flags & MIFF_REGISTER) { | 1369 | if (vif->flags & MIFF_REGISTER) { |
1378 | vif->pkt_out++; | 1370 | vif->pkt_out++; |
1379 | vif->bytes_out += skb->len; | 1371 | vif->bytes_out += skb->len; |
1380 | ((struct net_device_stats *)netdev_priv(vif->dev))->tx_bytes += skb->len; | 1372 | vif->dev->stats.tx_bytes += skb->len; |
1381 | ((struct net_device_stats *)netdev_priv(vif->dev))->tx_packets++; | 1373 | vif->dev->stats.tx_packets++; |
1382 | ip6mr_cache_report(skb, vifi, MRT6MSG_WHOLEPKT); | 1374 | ip6mr_cache_report(skb, vifi, MRT6MSG_WHOLEPKT); |
1383 | kfree_skb(skb); | 1375 | kfree_skb(skb); |
1384 | return 0; | 1376 | return 0; |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 86e28a75267f..030c0c956f9d 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
@@ -7,8 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Based on linux/net/ipv4/ip_sockglue.c | 8 | * Based on linux/net/ipv4/ip_sockglue.c |
9 | * | 9 | * |
10 | * $Id: ipv6_sockglue.c,v 1.41 2002/02/01 22:01:04 davem Exp $ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 11 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version | 12 | * as published by the Free Software Foundation; either version |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index fd632dd7f98d..bd2fe4cfafa7 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: mcast.c,v 1.40 2002/02/08 03:57:19 davem Exp $ | ||
9 | * | ||
10 | * Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c | 8 | * Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c |
11 | * | 9 | * |
12 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
@@ -164,7 +162,6 @@ static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml, | |||
164 | ((MLDV2_MASK(value, nbmant) | (1<<(nbmant))) << \ | 162 | ((MLDV2_MASK(value, nbmant) | (1<<(nbmant))) << \ |
165 | (MLDV2_MASK((value) >> (nbmant), nbexp) + (nbexp)))) | 163 | (MLDV2_MASK((value) >> (nbmant), nbexp) + (nbexp)))) |
166 | 164 | ||
167 | #define MLDV2_QQIC(value) MLDV2_EXP(0x80, 4, 3, value) | ||
168 | #define MLDV2_MRC(value) MLDV2_EXP(0x8000, 12, 3, value) | 165 | #define MLDV2_MRC(value) MLDV2_EXP(0x8000, 12, 3, value) |
169 | 166 | ||
170 | #define IPV6_MLD_MAX_MSF 64 | 167 | #define IPV6_MLD_MAX_MSF 64 |
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig index 6cae5475737e..689dec899c57 100644 --- a/net/ipv6/netfilter/Kconfig +++ b/net/ipv6/netfilter/Kconfig | |||
@@ -208,5 +208,17 @@ config IP6_NF_RAW | |||
208 | If you want to compile it as a module, say M here and read | 208 | If you want to compile it as a module, say M here and read |
209 | <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. | 209 | <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. |
210 | 210 | ||
211 | # security table for MAC policy | ||
212 | config IP6_NF_SECURITY | ||
213 | tristate "Security table" | ||
214 | depends on IP6_NF_IPTABLES | ||
215 | depends on SECURITY | ||
216 | default m if NETFILTER_ADVANCED=n | ||
217 | help | ||
218 | This option adds a `security' table to iptables, for use | ||
219 | with Mandatory Access Control (MAC) policy. | ||
220 | |||
221 | If unsure, say N. | ||
222 | |||
211 | endmenu | 223 | endmenu |
212 | 224 | ||
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile index fbf2c14ed887..3f17c948eefb 100644 --- a/net/ipv6/netfilter/Makefile +++ b/net/ipv6/netfilter/Makefile | |||
@@ -8,6 +8,7 @@ obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o | |||
8 | obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o | 8 | obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o |
9 | obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o | 9 | obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o |
10 | obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o | 10 | obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o |
11 | obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o | ||
11 | 12 | ||
12 | # objects for l3 independent conntrack | 13 | # objects for l3 independent conntrack |
13 | nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o | 14 | nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o |
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c index 2eff3ae8977d..1b8815f6153d 100644 --- a/net/ipv6/netfilter/ip6_queue.c +++ b/net/ipv6/netfilter/ip6_queue.c | |||
@@ -159,7 +159,6 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp) | |||
159 | case IPQ_COPY_META: | 159 | case IPQ_COPY_META: |
160 | case IPQ_COPY_NONE: | 160 | case IPQ_COPY_NONE: |
161 | size = NLMSG_SPACE(sizeof(*pmsg)); | 161 | size = NLMSG_SPACE(sizeof(*pmsg)); |
162 | data_len = 0; | ||
163 | break; | 162 | break; |
164 | 163 | ||
165 | case IPQ_COPY_PACKET: | 164 | case IPQ_COPY_PACKET: |
@@ -226,8 +225,6 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp) | |||
226 | return skb; | 225 | return skb; |
227 | 226 | ||
228 | nlmsg_failure: | 227 | nlmsg_failure: |
229 | if (skb) | ||
230 | kfree_skb(skb); | ||
231 | *errp = -EINVAL; | 228 | *errp = -EINVAL; |
232 | printk(KERN_ERR "ip6_queue: error creating packet message\n"); | 229 | printk(KERN_ERR "ip6_queue: error creating packet message\n"); |
233 | return NULL; | 230 | return NULL; |
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c new file mode 100644 index 000000000000..063a3d9c3c67 --- /dev/null +++ b/net/ipv6/netfilter/ip6table_security.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * "security" table for IPv6 | ||
3 | * | ||
4 | * This is for use by Mandatory Access Control (MAC) security models, | ||
5 | * which need to be able to manage security policy in separate context | ||
6 | * to DAC. | ||
7 | * | ||
8 | * Based on iptable_mangle.c | ||
9 | * | ||
10 | * Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling | ||
11 | * Copyright (C) 2000-2004 Netfilter Core Team <coreteam <at> netfilter.org> | ||
12 | * Copyright (C) 2008 Red Hat, Inc., James Morris <jmorris <at> redhat.com> | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/netfilter_ipv6/ip6_tables.h> | ||
20 | |||
21 | MODULE_LICENSE("GPL"); | ||
22 | MODULE_AUTHOR("James Morris <jmorris <at> redhat.com>"); | ||
23 | MODULE_DESCRIPTION("ip6tables security table, for MAC rules"); | ||
24 | |||
25 | #define SECURITY_VALID_HOOKS (1 << NF_INET_LOCAL_IN) | \ | ||
26 | (1 << NF_INET_FORWARD) | \ | ||
27 | (1 << NF_INET_LOCAL_OUT) | ||
28 | |||
29 | static struct | ||
30 | { | ||
31 | struct ip6t_replace repl; | ||
32 | struct ip6t_standard entries[3]; | ||
33 | struct ip6t_error term; | ||
34 | } initial_table __initdata = { | ||
35 | .repl = { | ||
36 | .name = "security", | ||
37 | .valid_hooks = SECURITY_VALID_HOOKS, | ||
38 | .num_entries = 4, | ||
39 | .size = sizeof(struct ip6t_standard) * 3 + sizeof(struct ip6t_error), | ||
40 | .hook_entry = { | ||
41 | [NF_INET_LOCAL_IN] = 0, | ||
42 | [NF_INET_FORWARD] = sizeof(struct ip6t_standard), | ||
43 | [NF_INET_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2, | ||
44 | }, | ||
45 | .underflow = { | ||
46 | [NF_INET_LOCAL_IN] = 0, | ||
47 | [NF_INET_FORWARD] = sizeof(struct ip6t_standard), | ||
48 | [NF_INET_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2, | ||
49 | }, | ||
50 | }, | ||
51 | .entries = { | ||
52 | IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ | ||
53 | IP6T_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ | ||
54 | IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ | ||
55 | }, | ||
56 | .term = IP6T_ERROR_INIT, /* ERROR */ | ||
57 | }; | ||
58 | |||
59 | static struct xt_table security_table = { | ||
60 | .name = "security", | ||
61 | .valid_hooks = SECURITY_VALID_HOOKS, | ||
62 | .lock = __RW_LOCK_UNLOCKED(security_table.lock), | ||
63 | .me = THIS_MODULE, | ||
64 | .af = AF_INET6, | ||
65 | }; | ||
66 | |||
67 | static unsigned int | ||
68 | ip6t_local_in_hook(unsigned int hook, | ||
69 | struct sk_buff *skb, | ||
70 | const struct net_device *in, | ||
71 | const struct net_device *out, | ||
72 | int (*okfn)(struct sk_buff *)) | ||
73 | { | ||
74 | return ip6t_do_table(skb, hook, in, out, | ||
75 | init_net.ipv6.ip6table_security); | ||
76 | } | ||
77 | |||
78 | static unsigned int | ||
79 | ip6t_forward_hook(unsigned int hook, | ||
80 | struct sk_buff *skb, | ||
81 | const struct net_device *in, | ||
82 | const struct net_device *out, | ||
83 | int (*okfn)(struct sk_buff *)) | ||
84 | { | ||
85 | return ip6t_do_table(skb, hook, in, out, | ||
86 | init_net.ipv6.ip6table_security); | ||
87 | } | ||
88 | |||
89 | static unsigned int | ||
90 | ip6t_local_out_hook(unsigned int hook, | ||
91 | struct sk_buff *skb, | ||
92 | const struct net_device *in, | ||
93 | const struct net_device *out, | ||
94 | int (*okfn)(struct sk_buff *)) | ||
95 | { | ||
96 | /* TBD: handle short packets via raw socket */ | ||
97 | return ip6t_do_table(skb, hook, in, out, | ||
98 | init_net.ipv6.ip6table_security); | ||
99 | } | ||
100 | |||
101 | static struct nf_hook_ops ip6t_ops[] __read_mostly = { | ||
102 | { | ||
103 | .hook = ip6t_local_in_hook, | ||
104 | .owner = THIS_MODULE, | ||
105 | .pf = PF_INET6, | ||
106 | .hooknum = NF_INET_LOCAL_IN, | ||
107 | .priority = NF_IP6_PRI_SECURITY, | ||
108 | }, | ||
109 | { | ||
110 | .hook = ip6t_forward_hook, | ||
111 | .owner = THIS_MODULE, | ||
112 | .pf = PF_INET6, | ||
113 | .hooknum = NF_INET_FORWARD, | ||
114 | .priority = NF_IP6_PRI_SECURITY, | ||
115 | }, | ||
116 | { | ||
117 | .hook = ip6t_local_out_hook, | ||
118 | .owner = THIS_MODULE, | ||
119 | .pf = PF_INET6, | ||
120 | .hooknum = NF_INET_LOCAL_OUT, | ||
121 | .priority = NF_IP6_PRI_SECURITY, | ||
122 | }, | ||
123 | }; | ||
124 | |||
125 | static int __net_init ip6table_security_net_init(struct net *net) | ||
126 | { | ||
127 | net->ipv6.ip6table_security = | ||
128 | ip6t_register_table(net, &security_table, &initial_table.repl); | ||
129 | |||
130 | if (IS_ERR(net->ipv6.ip6table_security)) | ||
131 | return PTR_ERR(net->ipv6.ip6table_security); | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | static void __net_exit ip6table_security_net_exit(struct net *net) | ||
137 | { | ||
138 | ip6t_unregister_table(net->ipv6.ip6table_security); | ||
139 | } | ||
140 | |||
141 | static struct pernet_operations ip6table_security_net_ops = { | ||
142 | .init = ip6table_security_net_init, | ||
143 | .exit = ip6table_security_net_exit, | ||
144 | }; | ||
145 | |||
146 | static int __init ip6table_security_init(void) | ||
147 | { | ||
148 | int ret; | ||
149 | |||
150 | ret = register_pernet_subsys(&ip6table_security_net_ops); | ||
151 | if (ret < 0) | ||
152 | return ret; | ||
153 | |||
154 | ret = nf_register_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops)); | ||
155 | if (ret < 0) | ||
156 | goto cleanup_table; | ||
157 | |||
158 | return ret; | ||
159 | |||
160 | cleanup_table: | ||
161 | unregister_pernet_subsys(&ip6table_security_net_ops); | ||
162 | return ret; | ||
163 | } | ||
164 | |||
165 | static void __exit ip6table_security_fini(void) | ||
166 | { | ||
167 | nf_unregister_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops)); | ||
168 | unregister_pernet_subsys(&ip6table_security_net_ops); | ||
169 | } | ||
170 | |||
171 | module_init(ip6table_security_init); | ||
172 | module_exit(ip6table_security_fini); | ||
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c index ee713b03e9ec..14d47d833545 100644 --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | |||
@@ -89,9 +89,8 @@ static int icmpv6_packet(struct nf_conn *ct, | |||
89 | means this will only run once even if count hits zero twice | 89 | means this will only run once even if count hits zero twice |
90 | (theoretically possible with SMP) */ | 90 | (theoretically possible with SMP) */ |
91 | if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) { | 91 | if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) { |
92 | if (atomic_dec_and_test(&ct->proto.icmp.count) | 92 | if (atomic_dec_and_test(&ct->proto.icmp.count)) |
93 | && del_timer(&ct->timeout)) | 93 | nf_ct_kill_acct(ct, ctinfo, skb); |
94 | ct->timeout.function((unsigned long)ct); | ||
95 | } else { | 94 | } else { |
96 | atomic_inc(&ct->proto.icmp.count); | 95 | atomic_inc(&ct->proto.icmp.count); |
97 | nf_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb); | 96 | nf_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb); |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index df0736a4cafa..cbc7e514d3ec 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -7,8 +7,6 @@ | |||
7 | * PROC file system. This is very similar to the IPv4 version, | 7 | * PROC file system. This is very similar to the IPv4 version, |
8 | * except it reports the sockets in the INET6 address family. | 8 | * except it reports the sockets in the INET6 address family. |
9 | * | 9 | * |
10 | * Version: $Id: proc.c,v 1.17 2002/02/01 22:01:04 davem Exp $ | ||
11 | * | ||
12 | * Authors: David S. Miller (davem@caip.rutgers.edu) | 10 | * Authors: David S. Miller (davem@caip.rutgers.edu) |
13 | * YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 11 | * YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> |
14 | * | 12 | * |
diff --git a/net/ipv6/protocol.c b/net/ipv6/protocol.c index f929f47b925e..9ab789159913 100644 --- a/net/ipv6/protocol.c +++ b/net/ipv6/protocol.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * | 5 | * |
6 | * PF_INET6 protocol dispatch tables. | 6 | * PF_INET6 protocol dispatch tables. |
7 | * | 7 | * |
8 | * Version: $Id: protocol.c,v 1.10 2001/05/18 02:25:49 davem Exp $ | ||
9 | * | ||
10 | * Authors: Pedro Roque <roque@di.fc.ul.pt> | 8 | * Authors: Pedro Roque <roque@di.fc.ul.pt> |
11 | * | 9 | * |
12 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 3aee12310d94..34cfb3f41c2c 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -7,8 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Adapted from linux/net/ipv4/raw.c | 8 | * Adapted from linux/net/ipv4/raw.c |
9 | * | 9 | * |
10 | * $Id: raw.c,v 1.51 2002/02/01 22:01:04 davem Exp $ | ||
11 | * | ||
12 | * Fixes: | 10 | * Fixes: |
13 | * Hideaki YOSHIFUJI : sin6_scope_id support | 11 | * Hideaki YOSHIFUJI : sin6_scope_id support |
14 | * YOSHIFUJI,H.@USAGI : raw checksum (RFC2292(bis) compliance) | 12 | * YOSHIFUJI,H.@USAGI : raw checksum (RFC2292(bis) compliance) |
@@ -1164,13 +1162,13 @@ static void rawv6_close(struct sock *sk, long timeout) | |||
1164 | sk_common_release(sk); | 1162 | sk_common_release(sk); |
1165 | } | 1163 | } |
1166 | 1164 | ||
1167 | static int raw6_destroy(struct sock *sk) | 1165 | static void raw6_destroy(struct sock *sk) |
1168 | { | 1166 | { |
1169 | lock_sock(sk); | 1167 | lock_sock(sk); |
1170 | ip6_flush_pending_frames(sk); | 1168 | ip6_flush_pending_frames(sk); |
1171 | release_sock(sk); | 1169 | release_sock(sk); |
1172 | 1170 | ||
1173 | return inet6_destroy_sock(sk); | 1171 | inet6_destroy_sock(sk); |
1174 | } | 1172 | } |
1175 | 1173 | ||
1176 | static int rawv6_init_sk(struct sock *sk) | 1174 | static int rawv6_init_sk(struct sock *sk) |
@@ -1253,7 +1251,7 @@ static int raw6_seq_show(struct seq_file *seq, void *v) | |||
1253 | "local_address " | 1251 | "local_address " |
1254 | "remote_address " | 1252 | "remote_address " |
1255 | "st tx_queue rx_queue tr tm->when retrnsmt" | 1253 | "st tx_queue rx_queue tr tm->when retrnsmt" |
1256 | " uid timeout inode drops\n"); | 1254 | " uid timeout inode ref pointer drops\n"); |
1257 | else | 1255 | else |
1258 | raw6_sock_seq_show(seq, v, raw_seq_private(seq)->bucket); | 1256 | raw6_sock_seq_show(seq, v, raw_seq_private(seq)->bucket); |
1259 | return 0; | 1257 | return 0; |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index a60d7d129713..6ab957ec2dd6 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: reassembly.c,v 1.26 2001/03/07 22:00:57 davem Exp $ | ||
9 | * | ||
10 | * Based on: net/ipv4/ip_fragment.c | 8 | * Based on: net/ipv4/ip_fragment.c |
11 | * | 9 | * |
12 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
@@ -634,7 +632,7 @@ static struct inet6_protocol frag_protocol = | |||
634 | }; | 632 | }; |
635 | 633 | ||
636 | #ifdef CONFIG_SYSCTL | 634 | #ifdef CONFIG_SYSCTL |
637 | static struct ctl_table ip6_frags_ctl_table[] = { | 635 | static struct ctl_table ip6_frags_ns_ctl_table[] = { |
638 | { | 636 | { |
639 | .ctl_name = NET_IPV6_IP6FRAG_HIGH_THRESH, | 637 | .ctl_name = NET_IPV6_IP6FRAG_HIGH_THRESH, |
640 | .procname = "ip6frag_high_thresh", | 638 | .procname = "ip6frag_high_thresh", |
@@ -660,6 +658,10 @@ static struct ctl_table ip6_frags_ctl_table[] = { | |||
660 | .proc_handler = &proc_dointvec_jiffies, | 658 | .proc_handler = &proc_dointvec_jiffies, |
661 | .strategy = &sysctl_jiffies, | 659 | .strategy = &sysctl_jiffies, |
662 | }, | 660 | }, |
661 | { } | ||
662 | }; | ||
663 | |||
664 | static struct ctl_table ip6_frags_ctl_table[] = { | ||
663 | { | 665 | { |
664 | .ctl_name = NET_IPV6_IP6FRAG_SECRET_INTERVAL, | 666 | .ctl_name = NET_IPV6_IP6FRAG_SECRET_INTERVAL, |
665 | .procname = "ip6frag_secret_interval", | 667 | .procname = "ip6frag_secret_interval", |
@@ -672,21 +674,20 @@ static struct ctl_table ip6_frags_ctl_table[] = { | |||
672 | { } | 674 | { } |
673 | }; | 675 | }; |
674 | 676 | ||
675 | static int ip6_frags_sysctl_register(struct net *net) | 677 | static int ip6_frags_ns_sysctl_register(struct net *net) |
676 | { | 678 | { |
677 | struct ctl_table *table; | 679 | struct ctl_table *table; |
678 | struct ctl_table_header *hdr; | 680 | struct ctl_table_header *hdr; |
679 | 681 | ||
680 | table = ip6_frags_ctl_table; | 682 | table = ip6_frags_ns_ctl_table; |
681 | if (net != &init_net) { | 683 | if (net != &init_net) { |
682 | table = kmemdup(table, sizeof(ip6_frags_ctl_table), GFP_KERNEL); | 684 | table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL); |
683 | if (table == NULL) | 685 | if (table == NULL) |
684 | goto err_alloc; | 686 | goto err_alloc; |
685 | 687 | ||
686 | table[0].data = &net->ipv6.frags.high_thresh; | 688 | table[0].data = &net->ipv6.frags.high_thresh; |
687 | table[1].data = &net->ipv6.frags.low_thresh; | 689 | table[1].data = &net->ipv6.frags.low_thresh; |
688 | table[2].data = &net->ipv6.frags.timeout; | 690 | table[2].data = &net->ipv6.frags.timeout; |
689 | table[3].mode &= ~0222; | ||
690 | } | 691 | } |
691 | 692 | ||
692 | hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table); | 693 | hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table); |
@@ -703,7 +704,7 @@ err_alloc: | |||
703 | return -ENOMEM; | 704 | return -ENOMEM; |
704 | } | 705 | } |
705 | 706 | ||
706 | static void ip6_frags_sysctl_unregister(struct net *net) | 707 | static void ip6_frags_ns_sysctl_unregister(struct net *net) |
707 | { | 708 | { |
708 | struct ctl_table *table; | 709 | struct ctl_table *table; |
709 | 710 | ||
@@ -711,13 +712,36 @@ static void ip6_frags_sysctl_unregister(struct net *net) | |||
711 | unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr); | 712 | unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr); |
712 | kfree(table); | 713 | kfree(table); |
713 | } | 714 | } |
715 | |||
716 | static struct ctl_table_header *ip6_ctl_header; | ||
717 | |||
718 | static int ip6_frags_sysctl_register(void) | ||
719 | { | ||
720 | ip6_ctl_header = register_net_sysctl_rotable(net_ipv6_ctl_path, | ||
721 | ip6_frags_ctl_table); | ||
722 | return ip6_ctl_header == NULL ? -ENOMEM : 0; | ||
723 | } | ||
724 | |||
725 | static void ip6_frags_sysctl_unregister(void) | ||
726 | { | ||
727 | unregister_net_sysctl_table(ip6_ctl_header); | ||
728 | } | ||
714 | #else | 729 | #else |
715 | static inline int ip6_frags_sysctl_register(struct net *net) | 730 | static inline int ip6_frags_ns_sysctl_register(struct net *net) |
716 | { | 731 | { |
717 | return 0; | 732 | return 0; |
718 | } | 733 | } |
719 | 734 | ||
720 | static inline void ip6_frags_sysctl_unregister(struct net *net) | 735 | static inline void ip6_frags_ns_sysctl_unregister(struct net *net) |
736 | { | ||
737 | } | ||
738 | |||
739 | static inline int ip6_frags_sysctl_register(void) | ||
740 | { | ||
741 | return 0; | ||
742 | } | ||
743 | |||
744 | static inline void ip6_frags_sysctl_unregister(void) | ||
721 | { | 745 | { |
722 | } | 746 | } |
723 | #endif | 747 | #endif |
@@ -730,12 +754,12 @@ static int ipv6_frags_init_net(struct net *net) | |||
730 | 754 | ||
731 | inet_frags_init_net(&net->ipv6.frags); | 755 | inet_frags_init_net(&net->ipv6.frags); |
732 | 756 | ||
733 | return ip6_frags_sysctl_register(net); | 757 | return ip6_frags_ns_sysctl_register(net); |
734 | } | 758 | } |
735 | 759 | ||
736 | static void ipv6_frags_exit_net(struct net *net) | 760 | static void ipv6_frags_exit_net(struct net *net) |
737 | { | 761 | { |
738 | ip6_frags_sysctl_unregister(net); | 762 | ip6_frags_ns_sysctl_unregister(net); |
739 | inet_frags_exit_net(&net->ipv6.frags, &ip6_frags); | 763 | inet_frags_exit_net(&net->ipv6.frags, &ip6_frags); |
740 | } | 764 | } |
741 | 765 | ||
@@ -752,7 +776,13 @@ int __init ipv6_frag_init(void) | |||
752 | if (ret) | 776 | if (ret) |
753 | goto out; | 777 | goto out; |
754 | 778 | ||
755 | register_pernet_subsys(&ip6_frags_ops); | 779 | ret = ip6_frags_sysctl_register(); |
780 | if (ret) | ||
781 | goto err_sysctl; | ||
782 | |||
783 | ret = register_pernet_subsys(&ip6_frags_ops); | ||
784 | if (ret) | ||
785 | goto err_pernet; | ||
756 | 786 | ||
757 | ip6_frags.hashfn = ip6_hashfn; | 787 | ip6_frags.hashfn = ip6_hashfn; |
758 | ip6_frags.constructor = ip6_frag_init; | 788 | ip6_frags.constructor = ip6_frag_init; |
@@ -765,11 +795,18 @@ int __init ipv6_frag_init(void) | |||
765 | inet_frags_init(&ip6_frags); | 795 | inet_frags_init(&ip6_frags); |
766 | out: | 796 | out: |
767 | return ret; | 797 | return ret; |
798 | |||
799 | err_pernet: | ||
800 | ip6_frags_sysctl_unregister(); | ||
801 | err_sysctl: | ||
802 | inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); | ||
803 | goto out; | ||
768 | } | 804 | } |
769 | 805 | ||
770 | void ipv6_frag_exit(void) | 806 | void ipv6_frag_exit(void) |
771 | { | 807 | { |
772 | inet_frags_fini(&ip6_frags); | 808 | inet_frags_fini(&ip6_frags); |
809 | ip6_frags_sysctl_unregister(); | ||
773 | unregister_pernet_subsys(&ip6_frags_ops); | 810 | unregister_pernet_subsys(&ip6_frags_ops); |
774 | inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); | 811 | inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); |
775 | } | 812 | } |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 7ff687020fa9..751e98f9b8b4 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: route.c,v 1.56 2001/10/31 21:55:55 davem Exp $ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU General Public License | 9 | * modify it under the terms of the GNU General Public License |
12 | * as published by the Free Software Foundation; either version | 10 | * as published by the Free Software Foundation; either version |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 32e871a6c25a..b7a50e968506 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -6,8 +6,6 @@ | |||
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> | 7 | * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> |
8 | * | 8 | * |
9 | * $Id: sit.c,v 1.53 2001/09/25 05:09:53 davem Exp $ | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
13 | * as published by the Free Software Foundation; either version | 11 | * as published by the Free Software Foundation; either version |
@@ -493,13 +491,13 @@ static int ipip6_rcv(struct sk_buff *skb) | |||
493 | 491 | ||
494 | if ((tunnel->dev->priv_flags & IFF_ISATAP) && | 492 | if ((tunnel->dev->priv_flags & IFF_ISATAP) && |
495 | !isatap_chksrc(skb, iph, tunnel)) { | 493 | !isatap_chksrc(skb, iph, tunnel)) { |
496 | tunnel->stat.rx_errors++; | 494 | tunnel->dev->stats.rx_errors++; |
497 | read_unlock(&ipip6_lock); | 495 | read_unlock(&ipip6_lock); |
498 | kfree_skb(skb); | 496 | kfree_skb(skb); |
499 | return 0; | 497 | return 0; |
500 | } | 498 | } |
501 | tunnel->stat.rx_packets++; | 499 | tunnel->dev->stats.rx_packets++; |
502 | tunnel->stat.rx_bytes += skb->len; | 500 | tunnel->dev->stats.rx_bytes += skb->len; |
503 | skb->dev = tunnel->dev; | 501 | skb->dev = tunnel->dev; |
504 | dst_release(skb->dst); | 502 | dst_release(skb->dst); |
505 | skb->dst = NULL; | 503 | skb->dst = NULL; |
@@ -539,7 +537,7 @@ static inline __be32 try_6to4(struct in6_addr *v6dst) | |||
539 | static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | 537 | static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) |
540 | { | 538 | { |
541 | struct ip_tunnel *tunnel = netdev_priv(dev); | 539 | struct ip_tunnel *tunnel = netdev_priv(dev); |
542 | struct net_device_stats *stats = &tunnel->stat; | 540 | struct net_device_stats *stats = &tunnel->dev->stats; |
543 | struct iphdr *tiph = &tunnel->parms.iph; | 541 | struct iphdr *tiph = &tunnel->parms.iph; |
544 | struct ipv6hdr *iph6 = ipv6_hdr(skb); | 542 | struct ipv6hdr *iph6 = ipv6_hdr(skb); |
545 | u8 tos = tunnel->parms.iph.tos; | 543 | u8 tos = tunnel->parms.iph.tos; |
@@ -553,7 +551,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
553 | int addr_type; | 551 | int addr_type; |
554 | 552 | ||
555 | if (tunnel->recursion++) { | 553 | if (tunnel->recursion++) { |
556 | tunnel->stat.collisions++; | 554 | stats->collisions++; |
557 | goto tx_error; | 555 | goto tx_error; |
558 | } | 556 | } |
559 | 557 | ||
@@ -620,20 +618,20 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
620 | .oif = tunnel->parms.link, | 618 | .oif = tunnel->parms.link, |
621 | .proto = IPPROTO_IPV6 }; | 619 | .proto = IPPROTO_IPV6 }; |
622 | if (ip_route_output_key(dev_net(dev), &rt, &fl)) { | 620 | if (ip_route_output_key(dev_net(dev), &rt, &fl)) { |
623 | tunnel->stat.tx_carrier_errors++; | 621 | stats->tx_carrier_errors++; |
624 | goto tx_error_icmp; | 622 | goto tx_error_icmp; |
625 | } | 623 | } |
626 | } | 624 | } |
627 | if (rt->rt_type != RTN_UNICAST) { | 625 | if (rt->rt_type != RTN_UNICAST) { |
628 | ip_rt_put(rt); | 626 | ip_rt_put(rt); |
629 | tunnel->stat.tx_carrier_errors++; | 627 | stats->tx_carrier_errors++; |
630 | goto tx_error_icmp; | 628 | goto tx_error_icmp; |
631 | } | 629 | } |
632 | tdev = rt->u.dst.dev; | 630 | tdev = rt->u.dst.dev; |
633 | 631 | ||
634 | if (tdev == dev) { | 632 | if (tdev == dev) { |
635 | ip_rt_put(rt); | 633 | ip_rt_put(rt); |
636 | tunnel->stat.collisions++; | 634 | stats->collisions++; |
637 | goto tx_error; | 635 | goto tx_error; |
638 | } | 636 | } |
639 | 637 | ||
@@ -643,7 +641,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
643 | mtu = skb->dst ? dst_mtu(skb->dst) : dev->mtu; | 641 | mtu = skb->dst ? dst_mtu(skb->dst) : dev->mtu; |
644 | 642 | ||
645 | if (mtu < 68) { | 643 | if (mtu < 68) { |
646 | tunnel->stat.collisions++; | 644 | stats->collisions++; |
647 | ip_rt_put(rt); | 645 | ip_rt_put(rt); |
648 | goto tx_error; | 646 | goto tx_error; |
649 | } | 647 | } |
@@ -920,11 +918,6 @@ done: | |||
920 | return err; | 918 | return err; |
921 | } | 919 | } |
922 | 920 | ||
923 | static struct net_device_stats *ipip6_tunnel_get_stats(struct net_device *dev) | ||
924 | { | ||
925 | return &(((struct ip_tunnel*)netdev_priv(dev))->stat); | ||
926 | } | ||
927 | |||
928 | static int ipip6_tunnel_change_mtu(struct net_device *dev, int new_mtu) | 921 | static int ipip6_tunnel_change_mtu(struct net_device *dev, int new_mtu) |
929 | { | 922 | { |
930 | if (new_mtu < IPV6_MIN_MTU || new_mtu > 0xFFF8 - sizeof(struct iphdr)) | 923 | if (new_mtu < IPV6_MIN_MTU || new_mtu > 0xFFF8 - sizeof(struct iphdr)) |
@@ -938,7 +931,6 @@ static void ipip6_tunnel_setup(struct net_device *dev) | |||
938 | dev->uninit = ipip6_tunnel_uninit; | 931 | dev->uninit = ipip6_tunnel_uninit; |
939 | dev->destructor = free_netdev; | 932 | dev->destructor = free_netdev; |
940 | dev->hard_start_xmit = ipip6_tunnel_xmit; | 933 | dev->hard_start_xmit = ipip6_tunnel_xmit; |
941 | dev->get_stats = ipip6_tunnel_get_stats; | ||
942 | dev->do_ioctl = ipip6_tunnel_ioctl; | 934 | dev->do_ioctl = ipip6_tunnel_ioctl; |
943 | dev->change_mtu = ipip6_tunnel_change_mtu; | 935 | dev->change_mtu = ipip6_tunnel_change_mtu; |
944 | 936 | ||
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index 3804dcbbfab0..5c99274558bf 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c | |||
@@ -37,6 +37,10 @@ static ctl_table ipv6_table_template[] = { | |||
37 | .mode = 0644, | 37 | .mode = 0644, |
38 | .proc_handler = &proc_dointvec | 38 | .proc_handler = &proc_dointvec |
39 | }, | 39 | }, |
40 | { .ctl_name = 0 } | ||
41 | }; | ||
42 | |||
43 | static ctl_table ipv6_table[] = { | ||
40 | { | 44 | { |
41 | .ctl_name = NET_IPV6_MLD_MAX_MSF, | 45 | .ctl_name = NET_IPV6_MLD_MAX_MSF, |
42 | .procname = "mld_max_msf", | 46 | .procname = "mld_max_msf", |
@@ -80,12 +84,6 @@ static int ipv6_sysctl_net_init(struct net *net) | |||
80 | 84 | ||
81 | ipv6_table[2].data = &net->ipv6.sysctl.bindv6only; | 85 | ipv6_table[2].data = &net->ipv6.sysctl.bindv6only; |
82 | 86 | ||
83 | /* We don't want this value to be per namespace, it should be global | ||
84 | to all namespaces, so make it read-only when we are not in the | ||
85 | init network namespace */ | ||
86 | if (net != &init_net) | ||
87 | ipv6_table[3].mode = 0444; | ||
88 | |||
89 | net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path, | 87 | net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path, |
90 | ipv6_table); | 88 | ipv6_table); |
91 | if (!net->ipv6.sysctl.table) | 89 | if (!net->ipv6.sysctl.table) |
@@ -126,12 +124,29 @@ static struct pernet_operations ipv6_sysctl_net_ops = { | |||
126 | .exit = ipv6_sysctl_net_exit, | 124 | .exit = ipv6_sysctl_net_exit, |
127 | }; | 125 | }; |
128 | 126 | ||
127 | static struct ctl_table_header *ip6_header; | ||
128 | |||
129 | int ipv6_sysctl_register(void) | 129 | int ipv6_sysctl_register(void) |
130 | { | 130 | { |
131 | return register_pernet_subsys(&ipv6_sysctl_net_ops); | 131 | int err = -ENOMEM;; |
132 | |||
133 | ip6_header = register_net_sysctl_rotable(net_ipv6_ctl_path, ipv6_table); | ||
134 | if (ip6_header == NULL) | ||
135 | goto out; | ||
136 | |||
137 | err = register_pernet_subsys(&ipv6_sysctl_net_ops); | ||
138 | if (err) | ||
139 | goto err_pernet; | ||
140 | out: | ||
141 | return err; | ||
142 | |||
143 | err_pernet: | ||
144 | unregister_net_sysctl_table(ip6_header); | ||
145 | goto out; | ||
132 | } | 146 | } |
133 | 147 | ||
134 | void ipv6_sysctl_unregister(void) | 148 | void ipv6_sysctl_unregister(void) |
135 | { | 149 | { |
150 | unregister_net_sysctl_table(ip6_header); | ||
136 | unregister_pernet_subsys(&ipv6_sysctl_net_ops); | 151 | unregister_pernet_subsys(&ipv6_sysctl_net_ops); |
137 | } | 152 | } |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 40ea9c36d24b..30dbab7cc3cc 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: tcp_ipv6.c,v 1.144 2002/02/01 22:01:04 davem Exp $ | ||
9 | * | ||
10 | * Based on: | 8 | * Based on: |
11 | * linux/net/ipv4/tcp.c | 9 | * linux/net/ipv4/tcp.c |
12 | * linux/net/ipv4/tcp_input.c | 10 | * linux/net/ipv4/tcp_input.c |
@@ -72,8 +70,6 @@ | |||
72 | 70 | ||
73 | static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb); | 71 | static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb); |
74 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); | 72 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); |
75 | static void tcp_v6_send_check(struct sock *sk, int len, | ||
76 | struct sk_buff *skb); | ||
77 | 73 | ||
78 | static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); | 74 | static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); |
79 | 75 | ||
@@ -82,6 +78,12 @@ static struct inet_connection_sock_af_ops ipv6_specific; | |||
82 | #ifdef CONFIG_TCP_MD5SIG | 78 | #ifdef CONFIG_TCP_MD5SIG |
83 | static struct tcp_sock_af_ops tcp_sock_ipv6_specific; | 79 | static struct tcp_sock_af_ops tcp_sock_ipv6_specific; |
84 | static struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific; | 80 | static struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific; |
81 | #else | ||
82 | static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk, | ||
83 | struct in6_addr *addr) | ||
84 | { | ||
85 | return NULL; | ||
86 | } | ||
85 | #endif | 87 | #endif |
86 | 88 | ||
87 | static void tcp_v6_hash(struct sock *sk) | 89 | static void tcp_v6_hash(struct sock *sk) |
@@ -736,78 +738,34 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval, | |||
736 | static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | 738 | static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, |
737 | struct in6_addr *saddr, | 739 | struct in6_addr *saddr, |
738 | struct in6_addr *daddr, | 740 | struct in6_addr *daddr, |
739 | struct tcphdr *th, int protocol, | 741 | struct tcphdr *th, unsigned int tcplen) |
740 | unsigned int tcplen) | ||
741 | { | 742 | { |
742 | struct scatterlist sg[4]; | ||
743 | __u16 data_len; | ||
744 | int block = 0; | ||
745 | __sum16 cksum; | ||
746 | struct tcp_md5sig_pool *hp; | 743 | struct tcp_md5sig_pool *hp; |
747 | struct tcp6_pseudohdr *bp; | 744 | struct tcp6_pseudohdr *bp; |
748 | struct hash_desc *desc; | ||
749 | int err; | 745 | int err; |
750 | unsigned int nbytes = 0; | ||
751 | 746 | ||
752 | hp = tcp_get_md5sig_pool(); | 747 | hp = tcp_get_md5sig_pool(); |
753 | if (!hp) { | 748 | if (!hp) { |
754 | printk(KERN_WARNING "%s(): hash pool not found...\n", __func__); | 749 | printk(KERN_WARNING "%s(): hash pool not found...\n", __func__); |
755 | goto clear_hash_noput; | 750 | goto clear_hash_noput; |
756 | } | 751 | } |
752 | |||
757 | bp = &hp->md5_blk.ip6; | 753 | bp = &hp->md5_blk.ip6; |
758 | desc = &hp->md5_desc; | ||
759 | 754 | ||
760 | /* 1. TCP pseudo-header (RFC2460) */ | 755 | /* 1. TCP pseudo-header (RFC2460) */ |
761 | ipv6_addr_copy(&bp->saddr, saddr); | 756 | ipv6_addr_copy(&bp->saddr, saddr); |
762 | ipv6_addr_copy(&bp->daddr, daddr); | 757 | ipv6_addr_copy(&bp->daddr, daddr); |
763 | bp->len = htonl(tcplen); | 758 | bp->len = htonl(tcplen); |
764 | bp->protocol = htonl(protocol); | 759 | bp->protocol = htonl(IPPROTO_TCP); |
765 | |||
766 | sg_init_table(sg, 4); | ||
767 | 760 | ||
768 | sg_set_buf(&sg[block++], bp, sizeof(*bp)); | 761 | err = tcp_calc_md5_hash(md5_hash, key, sizeof(*bp), |
769 | nbytes += sizeof(*bp); | 762 | th, tcplen, hp); |
770 | 763 | ||
771 | /* 2. TCP header, excluding options */ | 764 | if (err) |
772 | cksum = th->check; | ||
773 | th->check = 0; | ||
774 | sg_set_buf(&sg[block++], th, sizeof(*th)); | ||
775 | nbytes += sizeof(*th); | ||
776 | |||
777 | /* 3. TCP segment data (if any) */ | ||
778 | data_len = tcplen - (th->doff << 2); | ||
779 | if (data_len > 0) { | ||
780 | u8 *data = (u8 *)th + (th->doff << 2); | ||
781 | sg_set_buf(&sg[block++], data, data_len); | ||
782 | nbytes += data_len; | ||
783 | } | ||
784 | |||
785 | /* 4. shared key */ | ||
786 | sg_set_buf(&sg[block++], key->key, key->keylen); | ||
787 | nbytes += key->keylen; | ||
788 | |||
789 | sg_mark_end(&sg[block - 1]); | ||
790 | |||
791 | /* Now store the hash into the packet */ | ||
792 | err = crypto_hash_init(desc); | ||
793 | if (err) { | ||
794 | printk(KERN_WARNING "%s(): hash_init failed\n", __func__); | ||
795 | goto clear_hash; | ||
796 | } | ||
797 | err = crypto_hash_update(desc, sg, nbytes); | ||
798 | if (err) { | ||
799 | printk(KERN_WARNING "%s(): hash_update failed\n", __func__); | ||
800 | goto clear_hash; | ||
801 | } | ||
802 | err = crypto_hash_final(desc, md5_hash); | ||
803 | if (err) { | ||
804 | printk(KERN_WARNING "%s(): hash_final failed\n", __func__); | ||
805 | goto clear_hash; | 765 | goto clear_hash; |
806 | } | ||
807 | 766 | ||
808 | /* Reset header, and free up the crypto */ | 767 | /* Free up the crypto pool */ |
809 | tcp_put_md5sig_pool(); | 768 | tcp_put_md5sig_pool(); |
810 | th->check = cksum; | ||
811 | out: | 769 | out: |
812 | return 0; | 770 | return 0; |
813 | clear_hash: | 771 | clear_hash: |
@@ -821,8 +779,7 @@ static int tcp_v6_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | |||
821 | struct sock *sk, | 779 | struct sock *sk, |
822 | struct dst_entry *dst, | 780 | struct dst_entry *dst, |
823 | struct request_sock *req, | 781 | struct request_sock *req, |
824 | struct tcphdr *th, int protocol, | 782 | struct tcphdr *th, unsigned int tcplen) |
825 | unsigned int tcplen) | ||
826 | { | 783 | { |
827 | struct in6_addr *saddr, *daddr; | 784 | struct in6_addr *saddr, *daddr; |
828 | 785 | ||
@@ -835,7 +792,7 @@ static int tcp_v6_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, | |||
835 | } | 792 | } |
836 | return tcp_v6_do_calc_md5_hash(md5_hash, key, | 793 | return tcp_v6_do_calc_md5_hash(md5_hash, key, |
837 | saddr, daddr, | 794 | saddr, daddr, |
838 | th, protocol, tcplen); | 795 | th, tcplen); |
839 | } | 796 | } |
840 | 797 | ||
841 | static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | 798 | static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) |
@@ -844,43 +801,12 @@ static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | |||
844 | struct tcp_md5sig_key *hash_expected; | 801 | struct tcp_md5sig_key *hash_expected; |
845 | struct ipv6hdr *ip6h = ipv6_hdr(skb); | 802 | struct ipv6hdr *ip6h = ipv6_hdr(skb); |
846 | struct tcphdr *th = tcp_hdr(skb); | 803 | struct tcphdr *th = tcp_hdr(skb); |
847 | int length = (th->doff << 2) - sizeof (*th); | ||
848 | int genhash; | 804 | int genhash; |
849 | u8 *ptr; | ||
850 | u8 newhash[16]; | 805 | u8 newhash[16]; |
851 | 806 | ||
852 | hash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr); | 807 | hash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr); |
808 | hash_location = tcp_parse_md5sig_option(th); | ||
853 | 809 | ||
854 | /* If the TCP option is too short, we can short cut */ | ||
855 | if (length < TCPOLEN_MD5SIG) | ||
856 | return hash_expected ? 1 : 0; | ||
857 | |||
858 | /* parse options */ | ||
859 | ptr = (u8*)(th + 1); | ||
860 | while (length > 0) { | ||
861 | int opcode = *ptr++; | ||
862 | int opsize; | ||
863 | |||
864 | switch(opcode) { | ||
865 | case TCPOPT_EOL: | ||
866 | goto done_opts; | ||
867 | case TCPOPT_NOP: | ||
868 | length--; | ||
869 | continue; | ||
870 | default: | ||
871 | opsize = *ptr++; | ||
872 | if (opsize < 2 || opsize > length) | ||
873 | goto done_opts; | ||
874 | if (opcode == TCPOPT_MD5SIG) { | ||
875 | hash_location = ptr; | ||
876 | goto done_opts; | ||
877 | } | ||
878 | } | ||
879 | ptr += opsize - 2; | ||
880 | length -= opsize; | ||
881 | } | ||
882 | |||
883 | done_opts: | ||
884 | /* do we have a hash as expected? */ | 810 | /* do we have a hash as expected? */ |
885 | if (!hash_expected) { | 811 | if (!hash_expected) { |
886 | if (!hash_location) | 812 | if (!hash_location) |
@@ -910,8 +836,7 @@ done_opts: | |||
910 | genhash = tcp_v6_do_calc_md5_hash(newhash, | 836 | genhash = tcp_v6_do_calc_md5_hash(newhash, |
911 | hash_expected, | 837 | hash_expected, |
912 | &ip6h->saddr, &ip6h->daddr, | 838 | &ip6h->saddr, &ip6h->daddr, |
913 | th, sk->sk_protocol, | 839 | th, skb->len); |
914 | skb->len); | ||
915 | if (genhash || memcmp(hash_location, newhash, 16) != 0) { | 840 | if (genhash || memcmp(hash_location, newhash, 16) != 0) { |
916 | if (net_ratelimit()) { | 841 | if (net_ratelimit()) { |
917 | printk(KERN_INFO "MD5 Hash %s for " | 842 | printk(KERN_INFO "MD5 Hash %s for " |
@@ -1051,7 +976,7 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) | |||
1051 | tcp_v6_do_calc_md5_hash((__u8 *)&opt[1], key, | 976 | tcp_v6_do_calc_md5_hash((__u8 *)&opt[1], key, |
1052 | &ipv6_hdr(skb)->daddr, | 977 | &ipv6_hdr(skb)->daddr, |
1053 | &ipv6_hdr(skb)->saddr, | 978 | &ipv6_hdr(skb)->saddr, |
1054 | t1, IPPROTO_TCP, tot_len); | 979 | t1, tot_len); |
1055 | } | 980 | } |
1056 | #endif | 981 | #endif |
1057 | 982 | ||
@@ -1088,8 +1013,8 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) | |||
1088 | kfree_skb(buff); | 1013 | kfree_skb(buff); |
1089 | } | 1014 | } |
1090 | 1015 | ||
1091 | static void tcp_v6_send_ack(struct tcp_timewait_sock *tw, | 1016 | static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts, |
1092 | struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts) | 1017 | struct tcp_md5sig_key *key) |
1093 | { | 1018 | { |
1094 | struct tcphdr *th = tcp_hdr(skb), *t1; | 1019 | struct tcphdr *th = tcp_hdr(skb), *t1; |
1095 | struct sk_buff *buff; | 1020 | struct sk_buff *buff; |
@@ -1098,22 +1023,6 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw, | |||
1098 | struct sock *ctl_sk = net->ipv6.tcp_sk; | 1023 | struct sock *ctl_sk = net->ipv6.tcp_sk; |
1099 | unsigned int tot_len = sizeof(struct tcphdr); | 1024 | unsigned int tot_len = sizeof(struct tcphdr); |
1100 | __be32 *topt; | 1025 | __be32 *topt; |
1101 | #ifdef CONFIG_TCP_MD5SIG | ||
1102 | struct tcp_md5sig_key *key; | ||
1103 | struct tcp_md5sig_key tw_key; | ||
1104 | #endif | ||
1105 | |||
1106 | #ifdef CONFIG_TCP_MD5SIG | ||
1107 | if (!tw && skb->sk) { | ||
1108 | key = tcp_v6_md5_do_lookup(skb->sk, &ipv6_hdr(skb)->daddr); | ||
1109 | } else if (tw && tw->tw_md5_keylen) { | ||
1110 | tw_key.key = tw->tw_md5_key; | ||
1111 | tw_key.keylen = tw->tw_md5_keylen; | ||
1112 | key = &tw_key; | ||
1113 | } else { | ||
1114 | key = NULL; | ||
1115 | } | ||
1116 | #endif | ||
1117 | 1026 | ||
1118 | if (ts) | 1027 | if (ts) |
1119 | tot_len += TCPOLEN_TSTAMP_ALIGNED; | 1028 | tot_len += TCPOLEN_TSTAMP_ALIGNED; |
@@ -1157,7 +1066,7 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw, | |||
1157 | tcp_v6_do_calc_md5_hash((__u8 *)topt, key, | 1066 | tcp_v6_do_calc_md5_hash((__u8 *)topt, key, |
1158 | &ipv6_hdr(skb)->daddr, | 1067 | &ipv6_hdr(skb)->daddr, |
1159 | &ipv6_hdr(skb)->saddr, | 1068 | &ipv6_hdr(skb)->saddr, |
1160 | t1, IPPROTO_TCP, tot_len); | 1069 | t1, tot_len); |
1161 | } | 1070 | } |
1162 | #endif | 1071 | #endif |
1163 | 1072 | ||
@@ -1193,16 +1102,17 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb) | |||
1193 | struct inet_timewait_sock *tw = inet_twsk(sk); | 1102 | struct inet_timewait_sock *tw = inet_twsk(sk); |
1194 | struct tcp_timewait_sock *tcptw = tcp_twsk(sk); | 1103 | struct tcp_timewait_sock *tcptw = tcp_twsk(sk); |
1195 | 1104 | ||
1196 | tcp_v6_send_ack(tcptw, skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, | 1105 | tcp_v6_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, |
1197 | tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, | 1106 | tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, |
1198 | tcptw->tw_ts_recent); | 1107 | tcptw->tw_ts_recent, tcp_twsk_md5_key(tcptw)); |
1199 | 1108 | ||
1200 | inet_twsk_put(tw); | 1109 | inet_twsk_put(tw); |
1201 | } | 1110 | } |
1202 | 1111 | ||
1203 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) | 1112 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) |
1204 | { | 1113 | { |
1205 | tcp_v6_send_ack(NULL, skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent); | 1114 | tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent, |
1115 | tcp_v6_md5_do_lookup(skb->sk, &ipv6_hdr(skb)->daddr)); | ||
1206 | } | 1116 | } |
1207 | 1117 | ||
1208 | 1118 | ||
@@ -1960,7 +1870,7 @@ static int tcp_v6_init_sock(struct sock *sk) | |||
1960 | return 0; | 1870 | return 0; |
1961 | } | 1871 | } |
1962 | 1872 | ||
1963 | static int tcp_v6_destroy_sock(struct sock *sk) | 1873 | static void tcp_v6_destroy_sock(struct sock *sk) |
1964 | { | 1874 | { |
1965 | #ifdef CONFIG_TCP_MD5SIG | 1875 | #ifdef CONFIG_TCP_MD5SIG |
1966 | /* Clean up the MD5 key list */ | 1876 | /* Clean up the MD5 key list */ |
@@ -1968,7 +1878,7 @@ static int tcp_v6_destroy_sock(struct sock *sk) | |||
1968 | tcp_v6_clear_md5_list(sk); | 1878 | tcp_v6_clear_md5_list(sk); |
1969 | #endif | 1879 | #endif |
1970 | tcp_v4_destroy_sock(sk); | 1880 | tcp_v4_destroy_sock(sk); |
1971 | return inet6_destroy_sock(sk); | 1881 | inet6_destroy_sock(sk); |
1972 | } | 1882 | } |
1973 | 1883 | ||
1974 | #ifdef CONFIG_PROC_FS | 1884 | #ifdef CONFIG_PROC_FS |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index dd309626ae9a..f91e1df0d25e 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -7,8 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Based on linux/ipv4/udp.c | 8 | * Based on linux/ipv4/udp.c |
9 | * | 9 | * |
10 | * $Id: udp.c,v 1.65 2002/02/01 22:01:04 davem Exp $ | ||
11 | * | ||
12 | * Fixes: | 10 | * Fixes: |
13 | * Hideaki YOSHIFUJI : sin6_scope_id support | 11 | * Hideaki YOSHIFUJI : sin6_scope_id support |
14 | * YOSHIFUJI Hideaki @USAGI and: Support IPV6_V6ONLY socket option, which | 12 | * YOSHIFUJI Hideaki @USAGI and: Support IPV6_V6ONLY socket option, which |
@@ -67,7 +65,7 @@ static struct sock *__udp6_lib_lookup(struct net *net, | |||
67 | int badness = -1; | 65 | int badness = -1; |
68 | 66 | ||
69 | read_lock(&udp_hash_lock); | 67 | read_lock(&udp_hash_lock); |
70 | sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { | 68 | sk_for_each(sk, node, &udptable[udp_hashfn(net, hnum)]) { |
71 | struct inet_sock *inet = inet_sk(sk); | 69 | struct inet_sock *inet = inet_sk(sk); |
72 | 70 | ||
73 | if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum && | 71 | if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum && |
@@ -299,8 +297,10 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) | |||
299 | 297 | ||
300 | if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { | 298 | if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { |
301 | /* Note that an ENOMEM error is charged twice */ | 299 | /* Note that an ENOMEM error is charged twice */ |
302 | if (rc == -ENOMEM) | 300 | if (rc == -ENOMEM) { |
303 | UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite); | 301 | UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, is_udplite); |
302 | atomic_inc(&sk->sk_drops); | ||
303 | } | ||
304 | goto drop; | 304 | goto drop; |
305 | } | 305 | } |
306 | 306 | ||
@@ -355,15 +355,16 @@ static struct sock *udp_v6_mcast_next(struct sock *sk, | |||
355 | * Note: called only from the BH handler context, | 355 | * Note: called only from the BH handler context, |
356 | * so we don't need to lock the hashes. | 356 | * so we don't need to lock the hashes. |
357 | */ | 357 | */ |
358 | static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr, | 358 | static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb, |
359 | struct in6_addr *daddr, struct hlist_head udptable[]) | 359 | struct in6_addr *saddr, struct in6_addr *daddr, |
360 | struct hlist_head udptable[]) | ||
360 | { | 361 | { |
361 | struct sock *sk, *sk2; | 362 | struct sock *sk, *sk2; |
362 | const struct udphdr *uh = udp_hdr(skb); | 363 | const struct udphdr *uh = udp_hdr(skb); |
363 | int dif; | 364 | int dif; |
364 | 365 | ||
365 | read_lock(&udp_hash_lock); | 366 | read_lock(&udp_hash_lock); |
366 | sk = sk_head(&udptable[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]); | 367 | sk = sk_head(&udptable[udp_hashfn(net, ntohs(uh->dest))]); |
367 | dif = inet6_iif(skb); | 368 | dif = inet6_iif(skb); |
368 | sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); | 369 | sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); |
369 | if (!sk) { | 370 | if (!sk) { |
@@ -437,6 +438,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
437 | struct net_device *dev = skb->dev; | 438 | struct net_device *dev = skb->dev; |
438 | struct in6_addr *saddr, *daddr; | 439 | struct in6_addr *saddr, *daddr; |
439 | u32 ulen = 0; | 440 | u32 ulen = 0; |
441 | struct net *net; | ||
440 | 442 | ||
441 | if (!pskb_may_pull(skb, sizeof(struct udphdr))) | 443 | if (!pskb_may_pull(skb, sizeof(struct udphdr))) |
442 | goto short_packet; | 444 | goto short_packet; |
@@ -471,11 +473,13 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
471 | if (udp6_csum_init(skb, uh, proto)) | 473 | if (udp6_csum_init(skb, uh, proto)) |
472 | goto discard; | 474 | goto discard; |
473 | 475 | ||
476 | net = dev_net(skb->dev); | ||
474 | /* | 477 | /* |
475 | * Multicast receive code | 478 | * Multicast receive code |
476 | */ | 479 | */ |
477 | if (ipv6_addr_is_multicast(daddr)) | 480 | if (ipv6_addr_is_multicast(daddr)) |
478 | return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable); | 481 | return __udp6_lib_mcast_deliver(net, skb, |
482 | saddr, daddr, udptable); | ||
479 | 483 | ||
480 | /* Unicast */ | 484 | /* Unicast */ |
481 | 485 | ||
@@ -483,7 +487,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
483 | * check socket cache ... must talk to Alan about his plans | 487 | * check socket cache ... must talk to Alan about his plans |
484 | * for sock caches... i'll skip this for now. | 488 | * for sock caches... i'll skip this for now. |
485 | */ | 489 | */ |
486 | sk = __udp6_lib_lookup(dev_net(skb->dev), saddr, uh->source, | 490 | sk = __udp6_lib_lookup(net, saddr, uh->source, |
487 | daddr, uh->dest, inet6_iif(skb), udptable); | 491 | daddr, uh->dest, inet6_iif(skb), udptable); |
488 | 492 | ||
489 | if (sk == NULL) { | 493 | if (sk == NULL) { |
@@ -881,15 +885,13 @@ do_confirm: | |||
881 | goto out; | 885 | goto out; |
882 | } | 886 | } |
883 | 887 | ||
884 | int udpv6_destroy_sock(struct sock *sk) | 888 | void udpv6_destroy_sock(struct sock *sk) |
885 | { | 889 | { |
886 | lock_sock(sk); | 890 | lock_sock(sk); |
887 | udp_v6_flush_pending_frames(sk); | 891 | udp_v6_flush_pending_frames(sk); |
888 | release_sock(sk); | 892 | release_sock(sk); |
889 | 893 | ||
890 | inet6_destroy_sock(sk); | 894 | inet6_destroy_sock(sk); |
891 | |||
892 | return 0; | ||
893 | } | 895 | } |
894 | 896 | ||
895 | /* | 897 | /* |
@@ -955,7 +957,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket | |||
955 | srcp = ntohs(inet->sport); | 957 | srcp = ntohs(inet->sport); |
956 | seq_printf(seq, | 958 | seq_printf(seq, |
957 | "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " | 959 | "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " |
958 | "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p\n", | 960 | "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n", |
959 | bucket, | 961 | bucket, |
960 | src->s6_addr32[0], src->s6_addr32[1], | 962 | src->s6_addr32[0], src->s6_addr32[1], |
961 | src->s6_addr32[2], src->s6_addr32[3], srcp, | 963 | src->s6_addr32[2], src->s6_addr32[3], srcp, |
@@ -967,7 +969,8 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket | |||
967 | 0, 0L, 0, | 969 | 0, 0L, 0, |
968 | sock_i_uid(sp), 0, | 970 | sock_i_uid(sp), 0, |
969 | sock_i_ino(sp), | 971 | sock_i_ino(sp), |
970 | atomic_read(&sp->sk_refcnt), sp); | 972 | atomic_read(&sp->sk_refcnt), sp, |
973 | atomic_read(&sp->sk_drops)); | ||
971 | } | 974 | } |
972 | 975 | ||
973 | int udp6_seq_show(struct seq_file *seq, void *v) | 976 | int udp6_seq_show(struct seq_file *seq, void *v) |
@@ -978,7 +981,7 @@ int udp6_seq_show(struct seq_file *seq, void *v) | |||
978 | "local_address " | 981 | "local_address " |
979 | "remote_address " | 982 | "remote_address " |
980 | "st tx_queue rx_queue tr tm->when retrnsmt" | 983 | "st tx_queue rx_queue tr tm->when retrnsmt" |
981 | " uid timeout inode\n"); | 984 | " uid timeout inode ref pointer drops\n"); |
982 | else | 985 | else |
983 | udp6_sock_seq_show(seq, v, ((struct udp_iter_state *)seq->private)->bucket); | 986 | udp6_sock_seq_show(seq, v, ((struct udp_iter_state *)seq->private)->bucket); |
984 | return 0; | 987 | return 0; |
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h index 321b81a4d418..92dd7da766d8 100644 --- a/net/ipv6/udp_impl.h +++ b/net/ipv6/udp_impl.h | |||
@@ -29,7 +29,7 @@ extern int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
29 | struct msghdr *msg, size_t len, | 29 | struct msghdr *msg, size_t len, |
30 | int noblock, int flags, int *addr_len); | 30 | int noblock, int flags, int *addr_len); |
31 | extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb); | 31 | extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb); |
32 | extern int udpv6_destroy_sock(struct sock *sk); | 32 | extern void udpv6_destroy_sock(struct sock *sk); |
33 | 33 | ||
34 | #ifdef CONFIG_PROC_FS | 34 | #ifdef CONFIG_PROC_FS |
35 | extern int udp6_seq_show(struct seq_file *seq, void *v); | 35 | extern int udp6_seq_show(struct seq_file *seq, void *v); |
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 491efd00a866..f6cdcb348e05 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c | |||
@@ -2,8 +2,6 @@ | |||
2 | * UDPLITEv6 An implementation of the UDP-Lite protocol over IPv6. | 2 | * UDPLITEv6 An implementation of the UDP-Lite protocol over IPv6. |
3 | * See also net/ipv4/udplite.c | 3 | * See also net/ipv4/udplite.c |
4 | * | 4 | * |
5 | * Version: $Id: udplite.c,v 1.9 2006/10/19 08:28:10 gerrit Exp $ | ||
6 | * | ||
7 | * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk> | 5 | * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk> |
8 | * | 6 | * |
9 | * Changes: | 7 | * Changes: |