Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IPv6]: Use rtnl registration interface

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Thomas Graf and committed by
David S. Miller
c127ea2c fa34ddd7

+31 -31
-2
include/net/ip6_fib.h
··· 219 219 220 220 extern void fib6_rules_init(void); 221 221 extern void fib6_rules_cleanup(void); 222 - extern int fib6_rules_dump(struct sk_buff *, 223 - struct netlink_callback *); 224 222 225 223 #endif 226 224 #endif
-5
include/net/ip6_route.h
··· 116 116 struct net_device *dev, 117 117 u32 pmtu); 118 118 119 - struct nlmsghdr; 120 119 struct netlink_callback; 121 - extern int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb); 122 - extern int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg); 123 - extern int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg); 124 - extern int inet6_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg); 125 120 126 121 struct rt6_rtnl_dump_arg 127 122 {
+16 -19
net/ipv6/addrconf.c
··· 3613 3613 rtnl_set_sk_err(RTNLGRP_IPV6_PREFIX, err); 3614 3614 } 3615 3615 3616 - static struct rtnetlink_link inet6_rtnetlink_table[RTM_NR_MSGTYPES] = { 3617 - [RTM_GETLINK - RTM_BASE] = { .dumpit = inet6_dump_ifinfo, }, 3618 - [RTM_NEWADDR - RTM_BASE] = { .doit = inet6_rtm_newaddr, }, 3619 - [RTM_DELADDR - RTM_BASE] = { .doit = inet6_rtm_deladdr, }, 3620 - [RTM_GETADDR - RTM_BASE] = { .doit = inet6_rtm_getaddr, 3621 - .dumpit = inet6_dump_ifaddr, }, 3622 - [RTM_GETMULTICAST - RTM_BASE] = { .dumpit = inet6_dump_ifmcaddr, }, 3623 - [RTM_GETANYCAST - RTM_BASE] = { .dumpit = inet6_dump_ifacaddr, }, 3624 - [RTM_NEWROUTE - RTM_BASE] = { .doit = inet6_rtm_newroute, }, 3625 - [RTM_DELROUTE - RTM_BASE] = { .doit = inet6_rtm_delroute, }, 3626 - [RTM_GETROUTE - RTM_BASE] = { .doit = inet6_rtm_getroute, 3627 - .dumpit = inet6_dump_fib, }, 3628 - #ifdef CONFIG_IPV6_MULTIPLE_TABLES 3629 - [RTM_GETRULE - RTM_BASE] = { .dumpit = fib6_rules_dump, }, 3630 - #endif 3631 - }; 3632 - 3633 3616 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) 3634 3617 { 3635 3618 inet6_ifa_notify(event ? : RTM_NEWADDR, ifp); ··· 4132 4149 register_netdevice_notifier(&ipv6_dev_notf); 4133 4150 4134 4151 addrconf_verify(0); 4135 - rtnetlink_links[PF_INET6] = inet6_rtnetlink_table; 4152 + 4153 + err = __rtnl_register(PF_INET6, RTM_GETLINK, NULL, inet6_dump_ifinfo); 4154 + if (err < 0) 4155 + goto errout; 4156 + 4157 + /* Only the first call to __rtnl_register can fail */ 4158 + __rtnl_register(PF_INET6, RTM_NEWADDR, inet6_rtm_newaddr, NULL); 4159 + __rtnl_register(PF_INET6, RTM_DELADDR, inet6_rtm_deladdr, NULL); 4160 + __rtnl_register(PF_INET6, RTM_GETADDR, inet6_rtm_getaddr, inet6_dump_ifaddr); 4161 + __rtnl_register(PF_INET6, RTM_GETMULTICAST, NULL, inet6_dump_ifmcaddr); 4162 + __rtnl_register(PF_INET6, RTM_GETANYCAST, NULL, inet6_dump_ifacaddr); 4163 + 4136 4164 #ifdef CONFIG_SYSCTL 4137 4165 addrconf_sysctl.sysctl_header = 4138 4166 register_sysctl_table(addrconf_sysctl.addrconf_root_dir); ··· 4151 4157 #endif 4152 4158 4153 4159 return 0; 4160 + errout: 4161 + unregister_netdevice_notifier(&ipv6_dev_notf); 4162 + 4163 + return err; 4154 4164 } 4155 4165 4156 4166 void __exit addrconf_cleanup(void) ··· 4166 4168 4167 4169 unregister_netdevice_notifier(&ipv6_dev_notf); 4168 4170 4169 - rtnetlink_links[PF_INET6] = NULL; 4170 4171 #ifdef CONFIG_SYSCTL 4171 4172 addrconf_sysctl_unregister(&ipv6_devconf_dflt); 4172 4173 addrconf_sysctl_unregister(&ipv6_devconf);
+2
net/ipv6/af_inet6.c
··· 945 945 { 946 946 /* First of all disallow new sockets creation. */ 947 947 sock_unregister(PF_INET6); 948 + /* Disallow any further netlink messages */ 949 + rtnl_unregister_all(PF_INET6); 948 950 949 951 /* Cleanup code parts. */ 950 952 ipv6_packet_cleanup();
+3 -1
net/ipv6/fib6_rules.c
··· 216 216 return -ENOBUFS; 217 217 } 218 218 219 - int fib6_rules_dump(struct sk_buff *skb, struct netlink_callback *cb) 219 + static int fib6_rules_dump(struct sk_buff *skb, struct netlink_callback *cb) 220 220 { 221 221 return fib_rules_dump(skb, cb, AF_INET6); 222 222 } ··· 255 255 list_add_tail(&main_rule.common.list, &fib6_rules); 256 256 257 257 fib_rules_register(&fib6_rules_ops); 258 + __rtnl_register(PF_INET6, RTM_GETRULE, NULL, fib6_rules_dump); 258 259 } 259 260 260 261 void fib6_rules_cleanup(void) 261 262 { 263 + rtnl_unregister(PF_INET6, RTM_GETRULE); 262 264 fib_rules_unregister(&fib6_rules_ops); 263 265 }
+3 -1
net/ipv6/ip6_fib.c
··· 359 359 return res; 360 360 } 361 361 362 - int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) 362 + static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) 363 363 { 364 364 unsigned int h, s_h; 365 365 unsigned int e = 0, s_e; ··· 1486 1486 NULL, NULL); 1487 1487 1488 1488 fib6_tables_init(); 1489 + 1490 + __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib); 1489 1491 } 1490 1492 1491 1493 void fib6_gc_cleanup(void)
+7 -3
net/ipv6/route.c
··· 2015 2015 return err; 2016 2016 } 2017 2017 2018 - int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 2018 + static int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 2019 2019 { 2020 2020 struct fib6_config cfg; 2021 2021 int err; ··· 2027 2027 return ip6_route_del(&cfg); 2028 2028 } 2029 2029 2030 - int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 2030 + static int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 2031 2031 { 2032 2032 struct fib6_config cfg; 2033 2033 int err; ··· 2164 2164 prefix, NLM_F_MULTI); 2165 2165 } 2166 2166 2167 - int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg) 2167 + static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg) 2168 2168 { 2169 2169 struct nlattr *tb[RTA_MAX+1]; 2170 2170 struct rt6_info *rt; ··· 2508 2508 #ifdef CONFIG_IPV6_MULTIPLE_TABLES 2509 2509 fib6_rules_init(); 2510 2510 #endif 2511 + 2512 + __rtnl_register(PF_INET6, RTM_NEWROUTE, inet6_rtm_newroute, NULL); 2513 + __rtnl_register(PF_INET6, RTM_DELROUTE, inet6_rtm_delroute, NULL); 2514 + __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL); 2511 2515 } 2512 2516 2513 2517 void ip6_route_cleanup(void)