kernel: update kernel 4.3 to version 4.3-rc7
[openwrt/openwrt.git] / target / linux / generic / patches-4.3 / 643-bridge_remove_ipv6_dependency.patch
1 From: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
2 Subject: [PATCH] bridge: remove IPv6 depependency of bridge in 2.6.38+
3
4 Since 2.6.38 the bridge module has a dependency to IPv6 if IPv6 is
5 enabled. Since the IPv6 module isn't exactly lightweight and bridge also
6 only needs a single function from IPv6, it's rather easy to create a
7 common "lib" module with a RCU pointer to the actual implementation, if
8 the IPv6 module is loaded (although slightly hackish).
9
10 The codepath seems to be only taken when using IPv6, so there should be
11 no negative side effects when IPv6 isn't loaded. I did not measure how
12 big the performance impact is.
13 ---
14 --- a/include/net/addrconf.h
15 +++ b/include/net/addrconf.h
16 @@ -122,6 +122,12 @@ static inline int addrconf_ifid_eui48(u8
17 return 0;
18 }
19
20 +extern int (*ipv6_dev_get_saddr_hook)(struct net *net,
21 + const struct net_device *dev,
22 + const struct in6_addr *daddr,
23 + unsigned int prefs,
24 + struct in6_addr *saddr);
25 +
26 static inline unsigned long addrconf_timeout_fixup(u32 timeout,
27 unsigned int unit)
28 {
29 --- a/net/bridge/Kconfig
30 +++ b/net/bridge/Kconfig
31 @@ -6,7 +6,6 @@ config BRIDGE
32 tristate "802.1d Ethernet Bridging"
33 select LLC
34 select STP
35 - depends on IPV6 || IPV6=n
36 ---help---
37 If you say Y here, then your Linux box will be able to act as an
38 Ethernet bridge, which means that the different Ethernet segments it
39 --- a/net/ipv6/Makefile
40 +++ b/net/ipv6/Makefile
41 @@ -46,6 +46,7 @@ obj-y += addrconf_core.o exthdrs_core.o
42 obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
43
44 obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
45 +obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_stubs.o
46
47 ifneq ($(CONFIG_IPV6),)
48 obj-$(CONFIG_NET_UDP_TUNNEL) += ip6_udp_tunnel.o
49 --- a/net/ipv6/addrconf.c
50 +++ b/net/ipv6/addrconf.c
51 @@ -1509,7 +1509,7 @@ out:
52 return hiscore_idx;
53 }
54
55 -int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
56 +static int ___ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
57 const struct in6_addr *daddr, unsigned int prefs,
58 struct in6_addr *saddr)
59 {
60 @@ -1579,7 +1579,6 @@ int ipv6_dev_get_saddr(struct net *net,
61 in6_ifa_put(hiscore->ifa);
62 return 0;
63 }
64 -EXPORT_SYMBOL(ipv6_dev_get_saddr);
65
66 int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
67 u32 banned_flags)
68 @@ -5941,6 +5940,9 @@ int __init addrconf_init(void)
69
70 ipv6_addr_label_rtnl_register();
71
72 + BUG_ON(ipv6_dev_get_saddr_hook != NULL);
73 + rcu_assign_pointer(ipv6_dev_get_saddr_hook, ___ipv6_dev_get_saddr);
74 +
75 return 0;
76 errout:
77 rtnl_af_unregister(&inet6_ops);
78 @@ -5960,6 +5962,9 @@ void addrconf_cleanup(void)
79 struct net_device *dev;
80 int i;
81
82 + rcu_assign_pointer(ipv6_dev_get_saddr_hook, NULL);
83 + synchronize_rcu();
84 +
85 unregister_netdevice_notifier(&ipv6_dev_notf);
86 unregister_pernet_subsys(&addrconf_ops);
87 ipv6_addr_label_cleanup();
88 --- /dev/null
89 +++ b/net/ipv6/inet6_stubs.c
90 @@ -0,0 +1,33 @@
91 +/*
92 + * This program is free software; you can redistribute it and/or
93 + * modify it under the terms of the GNU General Public License
94 + * as published by the Free Software Foundation; either version
95 + * 2 of the License, or (at your option) any later version.
96 + */
97 +#include <linux/export.h>
98 +#include <net/ipv6.h>
99 +
100 +int (*ipv6_dev_get_saddr_hook)(struct net *net, const struct net_device *dev,
101 + const struct in6_addr *daddr, unsigned int prefs,
102 + struct in6_addr *saddr);
103 +
104 +EXPORT_SYMBOL(ipv6_dev_get_saddr_hook);
105 +
106 +int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
107 + const struct in6_addr *daddr, unsigned int prefs,
108 + struct in6_addr *saddr)
109 +{
110 + int ret = -EADDRNOTAVAIL;
111 + typeof(ipv6_dev_get_saddr_hook) dev_get_saddr;
112 +
113 + rcu_read_lock();
114 + dev_get_saddr = rcu_dereference(ipv6_dev_get_saddr_hook);
115 +
116 + if (dev_get_saddr)
117 + ret = dev_get_saddr(net, dst_dev, daddr, prefs, saddr);
118 +
119 + rcu_read_unlock();
120 + return ret;
121 +}
122 +EXPORT_SYMBOL(ipv6_dev_get_saddr);
123 +