1 From: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
2 Subject: [PATCH] bridge: remove IPv6 depependency of bridge in 2.6.38+
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).
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.
14 --- a/include/net/addrconf.h
15 +++ b/include/net/addrconf.h
16 @@ -122,6 +122,12 @@ static inline int addrconf_ifid_eui48(u8
20 +extern int (*ipv6_dev_get_saddr_hook)(struct net *net,
21 + const struct net_device *dev,
22 + const struct in6_addr *daddr,
24 + struct in6_addr *saddr);
26 static inline unsigned long addrconf_timeout_fixup(u32 timeout,
29 --- a/net/bridge/Kconfig
30 +++ b/net/bridge/Kconfig
31 @@ -6,7 +6,6 @@ config BRIDGE
32 tristate "802.1d Ethernet Bridging"
35 - depends on IPV6 || IPV6=n
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)
44 obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
45 +obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_stubs.o
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 @@ -1511,7 +1511,7 @@ out:
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)
60 @@ -1581,7 +1581,6 @@ int ipv6_dev_get_saddr(struct net *net,
61 in6_ifa_put(hiscore->ifa);
64 -EXPORT_SYMBOL(ipv6_dev_get_saddr);
66 int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
68 @@ -5962,6 +5961,9 @@ int __init addrconf_init(void)
70 ipv6_addr_label_rtnl_register();
72 + BUG_ON(ipv6_dev_get_saddr_hook != NULL);
73 + rcu_assign_pointer(ipv6_dev_get_saddr_hook, ___ipv6_dev_get_saddr);
77 rtnl_af_unregister(&inet6_ops);
78 @@ -5981,6 +5983,9 @@ void addrconf_cleanup(void)
79 struct net_device *dev;
82 + rcu_assign_pointer(ipv6_dev_get_saddr_hook, NULL);
85 unregister_netdevice_notifier(&ipv6_dev_notf);
86 unregister_pernet_subsys(&addrconf_ops);
87 ipv6_addr_label_cleanup();
89 +++ b/net/ipv6/inet6_stubs.c
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.
97 +#include <linux/export.h>
98 +#include <net/ipv6.h>
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);
104 +EXPORT_SYMBOL(ipv6_dev_get_saddr_hook);
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)
110 + int ret = -EADDRNOTAVAIL;
111 + typeof(ipv6_dev_get_saddr_hook) dev_get_saddr;
114 + dev_get_saddr = rcu_dereference(ipv6_dev_get_saddr_hook);
117 + ret = dev_get_saddr(net, dst_dev, daddr, prefs, saddr);
122 +EXPORT_SYMBOL(ipv6_dev_get_saddr);