50e4fe4b10d9ece4ac993ea44dc97016c534c870
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-4.0 / 643-bridge_remove_ipv6_dependency.patch
1 --- a/include/net/addrconf.h
2 +++ b/include/net/addrconf.h
3 @@ -91,6 +91,12 @@ int ipv6_rcv_saddr_equal(const struct so
4 void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr);
5 void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr);
6
7 +extern int (*ipv6_dev_get_saddr_hook)(struct net *net,
8 + const struct net_device *dev,
9 + const struct in6_addr *daddr,
10 + unsigned int prefs,
11 + struct in6_addr *saddr);
12 +
13 static inline unsigned long addrconf_timeout_fixup(u32 timeout,
14 unsigned int unit)
15 {
16 --- a/net/bridge/Kconfig
17 +++ b/net/bridge/Kconfig
18 @@ -6,7 +6,6 @@ config BRIDGE
19 tristate "802.1d Ethernet Bridging"
20 select LLC
21 select STP
22 - depends on IPV6 || IPV6=n
23 ---help---
24 If you say Y here, then your Linux box will be able to act as an
25 Ethernet bridge, which means that the different Ethernet segments it
26 --- a/net/ipv6/Makefile
27 +++ b/net/ipv6/Makefile
28 @@ -45,6 +45,7 @@ obj-y += addrconf_core.o exthdrs_core.o
29 obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
30
31 obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
32 +obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_stubs.o
33
34 ifneq ($(CONFIG_IPV6),)
35 obj-$(CONFIG_NET_UDP_TUNNEL) += ip6_udp_tunnel.o
36 --- a/net/ipv6/addrconf.c
37 +++ b/net/ipv6/addrconf.c
38 @@ -1346,7 +1346,7 @@ out:
39 return ret;
40 }
41
42 -int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
43 +static int __ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
44 const struct in6_addr *daddr, unsigned int prefs,
45 struct in6_addr *saddr)
46 {
47 @@ -1469,7 +1469,6 @@ try_nextdev:
48 in6_ifa_put(hiscore->ifa);
49 return 0;
50 }
51 -EXPORT_SYMBOL(ipv6_dev_get_saddr);
52
53 int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
54 u32 banned_flags)
55 @@ -5539,6 +5538,9 @@ int __init addrconf_init(void)
56
57 ipv6_addr_label_rtnl_register();
58
59 + BUG_ON(ipv6_dev_get_saddr_hook != NULL);
60 + rcu_assign_pointer(ipv6_dev_get_saddr_hook, __ipv6_dev_get_saddr);
61 +
62 return 0;
63 errout:
64 rtnl_af_unregister(&inet6_ops);
65 @@ -5558,6 +5560,9 @@ void addrconf_cleanup(void)
66 struct net_device *dev;
67 int i;
68
69 + rcu_assign_pointer(ipv6_dev_get_saddr_hook, NULL);
70 + synchronize_rcu();
71 +
72 unregister_netdevice_notifier(&ipv6_dev_notf);
73 unregister_pernet_subsys(&addrconf_ops);
74 ipv6_addr_label_cleanup();
75 --- /dev/null
76 +++ b/net/ipv6/inet6_stubs.c
77 @@ -0,0 +1,33 @@
78 +/*
79 + * This program is free software; you can redistribute it and/or
80 + * modify it under the terms of the GNU General Public License
81 + * as published by the Free Software Foundation; either version
82 + * 2 of the License, or (at your option) any later version.
83 + */
84 +#include <linux/export.h>
85 +#include <net/ipv6.h>
86 +
87 +int (*ipv6_dev_get_saddr_hook)(struct net *net, const struct net_device *dev,
88 + const struct in6_addr *daddr, unsigned int prefs,
89 + struct in6_addr *saddr);
90 +
91 +EXPORT_SYMBOL(ipv6_dev_get_saddr_hook);
92 +
93 +int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
94 + const struct in6_addr *daddr, unsigned int prefs,
95 + struct in6_addr *saddr)
96 +{
97 + int ret = -EADDRNOTAVAIL;
98 + typeof(ipv6_dev_get_saddr_hook) dev_get_saddr;
99 +
100 + rcu_read_lock();
101 + dev_get_saddr = rcu_dereference(ipv6_dev_get_saddr_hook);
102 +
103 + if (dev_get_saddr)
104 + ret = dev_get_saddr(net, dst_dev, daddr, prefs, saddr);
105 +
106 + rcu_read_unlock();
107 + return ret;
108 +}
109 +EXPORT_SYMBOL(ipv6_dev_get_saddr);
110 +