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

[NEIGH]: 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
c8822a4e 340d17fc

+20 -21
+1 -9
include/net/neighbour.h
··· 24 24 25 25 #include <linux/err.h> 26 26 #include <linux/sysctl.h> 27 + #include <net/rtnetlink.h> 27 28 28 29 #define NUD_IN_TIMER (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE) 29 30 #define NUD_VALID (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY) ··· 214 213 extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, const void *key, struct net_device *dev, int creat); 215 214 extern int pneigh_delete(struct neigh_table *tbl, const void *key, struct net_device *dev); 216 215 217 - struct netlink_callback; 218 - struct nlmsghdr; 219 - extern int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb); 220 - extern int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); 221 - extern int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); 222 216 extern void neigh_app_ns(struct neighbour *n); 223 - 224 - extern int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb); 225 - extern int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); 226 - 227 217 extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); 228 218 extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *)); 229 219 extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *));
+19 -7
net/core/neighbour.c
··· 1441 1441 return 0; 1442 1442 } 1443 1443 1444 - int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1444 + static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1445 1445 { 1446 1446 struct ndmsg *ndm; 1447 1447 struct nlattr *dst_attr; ··· 1506 1506 return err; 1507 1507 } 1508 1508 1509 - int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1509 + static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1510 1510 { 1511 1511 struct ndmsg *ndm; 1512 1512 struct nlattr *tb[NDA_MAX+1]; ··· 1786 1786 [NDTPA_LOCKTIME] = { .type = NLA_U64 }, 1787 1787 }; 1788 1788 1789 - int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1789 + static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1790 1790 { 1791 1791 struct neigh_table *tbl; 1792 1792 struct ndtmsg *ndtmsg; ··· 1910 1910 return err; 1911 1911 } 1912 1912 1913 - int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) 1913 + static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) 1914 1914 { 1915 1915 int family, tidx, nidx = 0; 1916 1916 int tbl_skip = cb->args[0]; ··· 2034 2034 return rc; 2035 2035 } 2036 2036 2037 - int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) 2037 + static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) 2038 2038 { 2039 2039 struct neigh_table *tbl; 2040 2040 int t, family, s_t; ··· 2746 2746 2747 2747 #endif /* CONFIG_SYSCTL */ 2748 2748 2749 + static int __init neigh_init(void) 2750 + { 2751 + rtnl_register(PF_UNSPEC, RTM_NEWNEIGH, neigh_add, NULL); 2752 + rtnl_register(PF_UNSPEC, RTM_DELNEIGH, neigh_delete, NULL); 2753 + rtnl_register(PF_UNSPEC, RTM_GETNEIGH, NULL, neigh_dump_info); 2754 + 2755 + rtnl_register(PF_UNSPEC, RTM_GETNEIGHTBL, NULL, neightbl_dump_info); 2756 + rtnl_register(PF_UNSPEC, RTM_SETNEIGHTBL, neightbl_set, NULL); 2757 + 2758 + return 0; 2759 + } 2760 + 2761 + subsys_initcall(neigh_init); 2762 + 2749 2763 EXPORT_SYMBOL(__neigh_event_send); 2750 2764 EXPORT_SYMBOL(neigh_changeaddr); 2751 2765 EXPORT_SYMBOL(neigh_compat_output); 2752 2766 EXPORT_SYMBOL(neigh_connected_output); 2753 2767 EXPORT_SYMBOL(neigh_create); 2754 - EXPORT_SYMBOL(neigh_delete); 2755 2768 EXPORT_SYMBOL(neigh_destroy); 2756 - EXPORT_SYMBOL(neigh_dump_info); 2757 2769 EXPORT_SYMBOL(neigh_event_ns); 2758 2770 EXPORT_SYMBOL(neigh_ifdown); 2759 2771 EXPORT_SYMBOL(neigh_lookup);
-5
net/core/rtnetlink.c
··· 963 963 { 964 964 [RTM_GETADDR - RTM_BASE] = { .dumpit = rtnl_dump_all }, 965 965 [RTM_GETROUTE - RTM_BASE] = { .dumpit = rtnl_dump_all }, 966 - [RTM_NEWNEIGH - RTM_BASE] = { .doit = neigh_add }, 967 - [RTM_DELNEIGH - RTM_BASE] = { .doit = neigh_delete }, 968 - [RTM_GETNEIGH - RTM_BASE] = { .dumpit = neigh_dump_info }, 969 966 #ifdef CONFIG_FIB_RULES 970 967 [RTM_NEWRULE - RTM_BASE] = { .doit = fib_nl_newrule }, 971 968 [RTM_DELRULE - RTM_BASE] = { .doit = fib_nl_delrule }, 972 969 #endif 973 970 [RTM_GETRULE - RTM_BASE] = { .dumpit = rtnl_dump_all }, 974 - [RTM_GETNEIGHTBL - RTM_BASE] = { .dumpit = neightbl_dump_info }, 975 - [RTM_SETNEIGHTBL - RTM_BASE] = { .doit = neightbl_set }, 976 971 }; 977 972 978 973 static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)