All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface
@ 2007-03-21  0:05 Thomas Graf
  2007-03-21  0:05 ` [PATCH 01/12] [RTNL]: Message " Thomas Graf
                   ` (11 more replies)
  0 siblings, 12 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:05 UTC (permalink / raw)
  To: davem; +Cc: netdev

Introduces an interface to register rtnetlink message handlers
and converts all users of rtnl_links[].


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/12] [RTNL]: Message handler registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
@ 2007-03-21  0:05 ` Thomas Graf
  2007-03-21  0:05 ` [PATCH 02/12] [NET] link: Use rtnl " Thomas Graf
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_api --]
[-- Type: text/plain, Size: 9564 bytes --]

This patch adds a new interface to register rtnetlink message
handlers replacing the exported rtnl_links[] array which
required many message handlers to be exported unnecessarly.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/include/net/rtnetlink.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ net-2.6.22/include/net/rtnetlink.h	2007-03-21 00:52:26.000000000 +0100
@@ -0,0 +1,18 @@
+#ifndef __NET_RTNETLINK_H
+#define __NET_RTNETLINK_H
+
+#include <linux/rtnetlink.h>
+#include <net/netlink.h>
+
+typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *);
+typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *);
+
+extern int	__rtnl_register(int protocol, int msgtype,
+				rtnl_doit_func, rtnl_dumpit_func);
+extern void	rtnl_register(int protocol, int msgtype,
+			      rtnl_doit_func, rtnl_dumpit_func);
+extern int	rtnl_unregister(int protocol, int msgtype);
+extern void	rtnl_unregister_all(int protocol);
+extern int	rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb);
+
+#endif
Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-21 00:52:26.000000000 +0100
@@ -50,12 +50,18 @@
 #include <net/sock.h>
 #include <net/pkt_sched.h>
 #include <net/fib_rules.h>
-#include <net/netlink.h>
+#include <net/rtnetlink.h>
 #ifdef CONFIG_NET_WIRELESS_RTNETLINK
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
 #endif	/* CONFIG_NET_WIRELESS_RTNETLINK */
 
+struct rtnl_link
+{
+	rtnl_doit_func		doit;
+	rtnl_dumpit_func	dumpit;
+};
+
 static DEFINE_MUTEX(rtnl_mutex);
 static struct sock *rtnl;
 
@@ -95,7 +101,151 @@ int rtattr_parse(struct rtattr *tb[], in
 	return 0;
 }
 
-struct rtnetlink_link * rtnetlink_links[NPROTO];
+struct rtnl_link *rtnl_msg_handlers[NPROTO];
+
+static inline int rtm_msgindex(int msgtype)
+{
+	int msgindex = msgtype - RTM_BASE;
+
+	/*
+	 * msgindex < 0 implies someone tried to register a netlink
+	 * control code. msgindex >= RTM_NR_MSGTYPES may indicate that
+	 * the message type has not been added to linux/rtnetlink.h
+	 */
+	BUG_ON(msgindex < 0 || msgindex >= RTM_NR_MSGTYPES);
+
+	return msgindex;
+}
+
+static rtnl_doit_func rtnl_get_doit(int protocol, int msgindex)
+{
+	struct rtnl_link *tab;
+
+	tab = rtnl_msg_handlers[protocol];
+	if (tab == NULL || tab->doit == NULL)
+		tab = rtnl_msg_handlers[PF_UNSPEC];
+
+	return tab ? tab->doit : NULL;
+}
+
+static rtnl_dumpit_func rtnl_get_dumpit(int protocol, int msgindex)
+{
+	struct rtnl_link *tab;
+
+	tab = rtnl_msg_handlers[protocol];
+	if (tab == NULL || tab->dumpit == NULL)
+		tab = rtnl_msg_handlers[PF_UNSPEC];
+
+	return tab ? tab->dumpit : NULL;
+}
+
+/**
+ * __rtnl_register - Register a rtnetlink message type
+ * @protocol: Protocol family or PF_UNSPEC
+ * @msgtype: rtnetlink message type
+ * @doit: Function pointer called for each request message
+ * @dumpit: Function pointer called for each dump request (NLM_F_DUMP) message
+ *
+ * Registers the specified function pointers (at least one of them has
+ * to be non-NULL) to be called whenever a request message for the
+ * specified protocol family and message type is received.
+ *
+ * The special protocol family PF_UNSPEC may be used to define fallback
+ * function pointers for the case when no entry for the specific protocol
+ * family exists.
+ *
+ * Returns 0 on success or a negative error code.
+ */
+int __rtnl_register(int protocol, int msgtype,
+		    rtnl_doit_func doit, rtnl_dumpit_func dumpit)
+{
+	struct rtnl_link *tab;
+	int msgindex;
+
+	BUG_ON(protocol < 0 || protocol >= NPROTO);
+	msgindex = rtm_msgindex(msgtype);
+
+	tab = rtnl_msg_handlers[protocol];
+	if (tab == NULL) {
+		tab = kcalloc(RTM_NR_MSGTYPES, sizeof(*tab), GFP_KERNEL);
+		if (tab == NULL)
+			return -ENOBUFS;
+
+		rtnl_msg_handlers[protocol] = tab;
+	}
+
+	if (doit)
+		tab[msgindex].doit = doit;
+
+	if (dumpit)
+		tab[msgindex].dumpit = dumpit;
+
+	return 0;
+}
+
+EXPORT_SYMBOL_GPL(__rtnl_register);
+
+/**
+ * rtnl_register - Register a rtnetlink message type
+ *
+ * Identical to __rtnl_register() but panics on failure. This is useful
+ * as failure of this function is very unlikely, it can only happen due
+ * to lack of memory when allocating the chain to store all message
+ * handlers for a protocol. Meant for use in init functions where lack
+ * of memory implies no sense in continueing.
+ */
+void rtnl_register(int protocol, int msgtype,
+		   rtnl_doit_func doit, rtnl_dumpit_func dumpit)
+{
+	if (__rtnl_register(protocol, msgtype, doit, dumpit) < 0)
+		panic("Unable to register rtnetlink message handler, "
+		      "protocol = %d, message type = %d\n",
+		      protocol, msgtype);
+}
+
+EXPORT_SYMBOL_GPL(rtnl_register);
+
+/**
+ * rtnl_unregister - Unregister a rtnetlink message type
+ * @protocol: Protocol family or PF_UNSPEC
+ * @msgtype: rtnetlink message type
+ *
+ * Returns 0 on success or a negative error code.
+ */
+int rtnl_unregister(int protocol, int msgtype)
+{
+	int msgindex;
+
+	BUG_ON(protocol < 0 || protocol >= NPROTO);
+	msgindex = rtm_msgindex(msgtype);
+
+	if (rtnl_msg_handlers[protocol] == NULL)
+		return -ENOENT;
+
+	rtnl_msg_handlers[protocol][msgindex].doit = NULL;
+	rtnl_msg_handlers[protocol][msgindex].dumpit = NULL;
+
+	return 0;
+}
+
+EXPORT_SYMBOL_GPL(rtnl_unregister);
+
+/**
+ * rtnl_unregister_all - Unregister all rtnetlink message type of a protocol
+ * @protocol : Protocol family or PF_UNSPEC
+ *
+ * Identical to calling rtnl_unregster() for all registered message types
+ * of a certain protocol family.
+ */
+void rtnl_unregister_all(int protocol)
+{
+	BUG_ON(protocol < 0 || protocol >= NPROTO);
+
+	kfree(rtnl_msg_handlers[protocol]);
+	rtnl_msg_handlers[protocol] = NULL;
+}
+
+EXPORT_SYMBOL_GPL(rtnl_unregister_all);
 
 static const int rtm_min[RTM_NR_FAMILIES] =
 {
@@ -647,7 +797,7 @@ errout:
 	return err;
 }
 
-static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
+int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int idx;
 	int s_idx = cb->family;
@@ -658,12 +808,12 @@ static int rtnl_dump_all(struct sk_buff 
 		int type = cb->nlh->nlmsg_type-RTM_BASE;
 		if (idx < s_idx || idx == PF_PACKET)
 			continue;
-		if (rtnetlink_links[idx] == NULL ||
-		    rtnetlink_links[idx][type].dumpit == NULL)
+		if (rtnl_msg_handlers[idx] == NULL ||
+		    rtnl_msg_handlers[idx][type].dumpit == NULL)
 			continue;
 		if (idx > s_idx)
 			memset(&cb->args[0], 0, sizeof(cb->args));
-		if (rtnetlink_links[idx][type].dumpit(skb, cb))
+		if (rtnl_msg_handlers[idx][type].dumpit(skb, cb))
 			break;
 	}
 	cb->family = idx;
@@ -671,6 +821,8 @@ static int rtnl_dump_all(struct sk_buff 
 	return skb->len;
 }
 
+EXPORT_SYMBOL_GPL(rtnl_dump_all);
+
 void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
 {
 	struct sk_buff *skb;
@@ -702,8 +854,7 @@ static int rtattr_max;
 static __inline__ int
 rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
 {
-	struct rtnetlink_link *link;
-	struct rtnetlink_link *link_tab;
+	rtnl_doit_func doit;
 	int sz_idx, kind;
 	int min_len;
 	int family;
@@ -736,11 +887,6 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 		return -1;
 	}
 
-	link_tab = rtnetlink_links[family];
-	if (link_tab == NULL)
-		link_tab = rtnetlink_links[PF_UNSPEC];
-	link = &link_tab[type];
-
 	sz_idx = type>>2;
 	kind = type&3;
 
@@ -750,14 +896,14 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 	}
 
 	if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
-		if (link->dumpit == NULL)
-			link = &(rtnetlink_links[PF_UNSPEC][type]);
+		rtnl_dumpit_func dumpit;
 
-		if (link->dumpit == NULL)
+		dumpit = rtnl_get_dumpit(family, type);
+		if (dumpit == NULL)
 			goto err_inval;
 
 		if ((*errp = netlink_dump_start(rtnl, skb, nlh,
-						link->dumpit, NULL)) != 0) {
+						dumpit, NULL)) != 0) {
 			return -1;
 		}
 
@@ -786,11 +932,10 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 		}
 	}
 
-	if (link->doit == NULL)
-		link = &(rtnetlink_links[PF_UNSPEC][type]);
-	if (link->doit == NULL)
+	doit = rtnl_get_doit(family, type);
+	if (doit == NULL)
 		goto err_inval;
-	err = link->doit(skb, nlh, (void *)&rta_buf[0]);
+	err = doit(skb, nlh, (void *)&rta_buf[0]);
 
 	*errp = err;
 	return err;
@@ -885,7 +1030,6 @@ void __init rtnetlink_init(void)
 EXPORT_SYMBOL(__rta_fill);
 EXPORT_SYMBOL(rtattr_strlcpy);
 EXPORT_SYMBOL(rtattr_parse);
-EXPORT_SYMBOL(rtnetlink_links);
 EXPORT_SYMBOL(rtnetlink_put_metrics);
 EXPORT_SYMBOL(rtnl_lock);
 EXPORT_SYMBOL(rtnl_trylock);
Index: net-2.6.22/include/linux/rtnetlink.h
===================================================================
--- net-2.6.22.orig/include/linux/rtnetlink.h	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/include/linux/rtnetlink.h	2007-03-21 00:52:26.000000000 +0100
@@ -574,13 +574,6 @@ extern int rtattr_parse(struct rtattr *t
 #define rtattr_parse_nested(tb, max, rta) \
 	rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
 
-struct rtnetlink_link
-{
-	int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
-	int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
-};
-
-extern struct rtnetlink_link * rtnetlink_links[NPROTO];
 extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
 extern int rtnl_unicast(struct sk_buff *skb, u32 pid);
 extern int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 02/12] [NET] link: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
  2007-03-21  0:05 ` [PATCH 01/12] [RTNL]: Message " Thomas Graf
@ 2007-03-21  0:05 ` Thomas Graf
  2007-03-21  0:05 ` [PATCH 03/12] [NEIGH]: " Thomas Graf
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_core_convert --]
[-- Type: text/plain, Size: 2122 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-21 00:52:26.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-21 00:52:28.000000000 +0100
@@ -537,7 +537,7 @@ nla_put_failure:
 	return -EMSGSIZE;
 }
 
-static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int idx;
 	int s_idx = cb->args[0];
@@ -568,7 +568,7 @@ static struct nla_policy ifla_policy[IFL
 	[IFLA_LINKMODE]		= { .type = NLA_U8 },
 };
 
-static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_link_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct ifinfomsg *ifm;
 	struct net_device *dev;
@@ -738,7 +738,7 @@ errout:
 	return err;
 }
 
-static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int nl_link_get(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct ifinfomsg *ifm;
 	struct nlattr *tb[IFLA_MAX+1];
@@ -960,9 +960,6 @@ static void rtnetlink_rcv(struct sock *s
 
 static struct rtnetlink_link link_rtnetlink_table[RTM_NR_MSGTYPES] =
 {
-	[RTM_GETLINK     - RTM_BASE] = { .doit   = rtnl_getlink,
-					 .dumpit = rtnl_dump_ifinfo	 },
-	[RTM_SETLINK     - RTM_BASE] = { .doit   = rtnl_setlink		 },
 	[RTM_GETADDR     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
 	[RTM_GETROUTE    - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
 	[RTM_NEWNEIGH    - RTM_BASE] = { .doit   = neigh_add		 },
@@ -1023,8 +1020,9 @@ void __init rtnetlink_init(void)
 		panic("rtnetlink_init: cannot initialize rtnetlink\n");
 	netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
 	register_netdevice_notifier(&rtnetlink_dev_notifier);
-	rtnetlink_links[PF_UNSPEC] = link_rtnetlink_table;
-	rtnetlink_links[PF_PACKET] = link_rtnetlink_table;
+
+	rtnl_register(PF_UNSPEC, RTM_GETLINK, nl_link_get, nl_link_dump);
+	rtnl_register(PF_UNSPEC, RTM_SETLINK, nl_link_set, NULL);
 }
 
 EXPORT_SYMBOL(__rta_fill);

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 03/12] [NEIGH]: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
  2007-03-21  0:05 ` [PATCH 01/12] [RTNL]: Message " Thomas Graf
  2007-03-21  0:05 ` [PATCH 02/12] [NET] link: Use rtnl " Thomas Graf
@ 2007-03-21  0:05 ` Thomas Graf
  2007-03-21  0:05 ` [PATCH 04/12] [NET] rules: " Thomas Graf
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_neigh_convert --]
[-- Type: text/plain, Size: 5224 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/include/net/neighbour.h
===================================================================
--- net-2.6.22.orig/include/net/neighbour.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/include/net/neighbour.h	2007-03-21 00:52:29.000000000 +0100
@@ -24,6 +24,7 @@
 
 #include <linux/err.h>
 #include <linux/sysctl.h>
+#include <net/rtnetlink.h>
 
 #define NUD_IN_TIMER	(NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE)
 #define NUD_VALID	(NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY)
@@ -213,16 +214,7 @@ extern void			pneigh_enqueue(struct neig
 extern struct pneigh_entry	*pneigh_lookup(struct neigh_table *tbl, const void *key, struct net_device *dev, int creat);
 extern int			pneigh_delete(struct neigh_table *tbl, const void *key, struct net_device *dev);
 
-struct netlink_callback;
-struct nlmsghdr;
-extern int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb);
-extern int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
-extern int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
 extern void neigh_app_ns(struct neighbour *n);
-
-extern int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb);
-extern int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
-
 extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie);
 extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *));
 extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *));
Index: net-2.6.22/net/core/neighbour.c
===================================================================
--- net-2.6.22.orig/net/core/neighbour.c	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/net/core/neighbour.c	2007-03-21 00:52:29.000000000 +0100
@@ -1435,7 +1435,7 @@ int neigh_table_clear(struct neigh_table
 	return 0;
 }
 
-int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_neigh_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct ndmsg *ndm;
 	struct nlattr *dst_attr;
@@ -1500,7 +1500,7 @@ out:
 	return err;
 }
 
-int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct ndmsg *ndm;
 	struct nlattr *tb[NDA_MAX+1];
@@ -1780,7 +1780,7 @@ static struct nla_policy nl_ntbl_parm_po
 	[NDTPA_LOCKTIME]		= { .type = NLA_U64 },
 };
 
-int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct neigh_table *tbl;
 	struct ndtmsg *ndtmsg;
@@ -1904,7 +1904,7 @@ errout:
 	return err;
 }
 
-int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_neightbl_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int family, tidx, nidx = 0;
 	int tbl_skip = cb->args[0];
@@ -2028,7 +2028,7 @@ out:
 	return rc;
 }
 
-int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_neigh_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	struct neigh_table *tbl;
 	int t, family, s_t;
@@ -2737,14 +2737,26 @@ void neigh_sysctl_unregister(struct neig
 
 #endif	/* CONFIG_SYSCTL */
 
+static int __init neigh_init(void)
+{
+	rtnl_register(PF_UNSPEC, RTM_NEWNEIGH, nl_neigh_add, NULL);
+	rtnl_register(PF_UNSPEC, RTM_DELNEIGH, nl_neigh_del, NULL);
+	rtnl_register(PF_UNSPEC, RTM_GETNEIGH, NULL, nl_neigh_dump);
+
+	rtnl_register(PF_UNSPEC, RTM_GETNEIGHTBL, NULL, nl_neightbl_dump);
+	rtnl_register(PF_UNSPEC, RTM_SETNEIGHTBL, nl_neightbl_set, NULL);
+
+	return 0;
+}
+
+subsys_initcall(neigh_init);
+
 EXPORT_SYMBOL(__neigh_event_send);
 EXPORT_SYMBOL(neigh_changeaddr);
 EXPORT_SYMBOL(neigh_compat_output);
 EXPORT_SYMBOL(neigh_connected_output);
 EXPORT_SYMBOL(neigh_create);
-EXPORT_SYMBOL(neigh_delete);
 EXPORT_SYMBOL(neigh_destroy);
-EXPORT_SYMBOL(neigh_dump_info);
 EXPORT_SYMBOL(neigh_event_ns);
 EXPORT_SYMBOL(neigh_ifdown);
 EXPORT_SYMBOL(neigh_lookup);
Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-21 00:52:28.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-21 00:52:29.000000000 +0100
@@ -962,16 +962,11 @@ static struct rtnetlink_link link_rtnetl
 {
 	[RTM_GETADDR     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
 	[RTM_GETROUTE    - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
-	[RTM_NEWNEIGH    - RTM_BASE] = { .doit   = neigh_add		 },
-	[RTM_DELNEIGH    - RTM_BASE] = { .doit   = neigh_delete		 },
-	[RTM_GETNEIGH    - RTM_BASE] = { .dumpit = neigh_dump_info	 },
 #ifdef CONFIG_FIB_RULES
 	[RTM_NEWRULE     - RTM_BASE] = { .doit   = fib_nl_newrule	 },
 	[RTM_DELRULE     - RTM_BASE] = { .doit   = fib_nl_delrule	 },
 #endif
 	[RTM_GETRULE     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
-	[RTM_GETNEIGHTBL - RTM_BASE] = { .dumpit = neightbl_dump_info	 },
-	[RTM_SETNEIGHTBL - RTM_BASE] = { .doit   = neightbl_set		 },
 };
 
 static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 04/12] [NET] rules: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (2 preceding siblings ...)
  2007-03-21  0:05 ` [PATCH 03/12] [NEIGH]: " Thomas Graf
@ 2007-03-21  0:05 ` Thomas Graf
  2007-03-21  0:05 ` [PATCH 05/12] [IPv4]: " Thomas Graf
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_rules_convert --]
[-- Type: text/plain, Size: 2862 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/core/fib_rules.c
===================================================================
--- net-2.6.22.orig/net/core/fib_rules.c	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/net/core/fib_rules.c	2007-03-21 00:52:30.000000000 +0100
@@ -152,7 +152,7 @@ out:
 
 EXPORT_SYMBOL_GPL(fib_rules_lookup);
 
-int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int nl_rule_new(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib_rule_hdr *frh = nlmsg_data(nlh);
 	struct fib_rules_ops *ops = NULL;
@@ -239,7 +239,7 @@ errout:
 	return err;
 }
 
-int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int nl_rule_del(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib_rule_hdr *frh = nlmsg_data(nlh);
 	struct fib_rules_ops *ops = NULL;
@@ -471,6 +471,10 @@ static struct notifier_block fib_rules_n
 
 static int __init fib_rules_init(void)
 {
+	rtnl_register(PF_UNSPEC, RTM_NEWRULE, nl_rule_new, NULL);
+	rtnl_register(PF_UNSPEC, RTM_DELRULE, nl_rule_del, NULL);
+	rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, rtnl_dump_all);
+
 	return register_netdevice_notifier(&fib_rules_notifier);
 }
 
Index: net-2.6.22/include/net/fib_rules.h
===================================================================
--- net-2.6.22.orig/include/net/fib_rules.h	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/include/net/fib_rules.h	2007-03-21 00:52:30.000000000 +0100
@@ -5,7 +5,7 @@
 #include <linux/netdevice.h>
 #include <linux/fib_rules.h>
 #include <net/flow.h>
-#include <net/netlink.h>
+#include <net/rtnetlink.h>
 
 struct fib_rule
 {
@@ -98,10 +98,6 @@ extern int			fib_rules_lookup(struct fib
 						 struct flowi *, int flags,
 						 struct fib_lookup_arg *);
 
-extern int			fib_nl_newrule(struct sk_buff *,
-					       struct nlmsghdr *, void *);
-extern int			fib_nl_delrule(struct sk_buff *,
-					       struct nlmsghdr *, void *);
 extern int			fib_rules_dump(struct sk_buff *,
 					       struct netlink_callback *, int);
 #endif
Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-21 00:52:29.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-21 00:52:30.000000000 +0100
@@ -962,11 +962,6 @@ static struct rtnetlink_link link_rtnetl
 {
 	[RTM_GETADDR     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
 	[RTM_GETROUTE    - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
-#ifdef CONFIG_FIB_RULES
-	[RTM_NEWRULE     - RTM_BASE] = { .doit   = fib_nl_newrule	 },
-	[RTM_DELRULE     - RTM_BASE] = { .doit   = fib_nl_delrule	 },
-#endif
-	[RTM_GETRULE     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
 };
 
 static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 05/12] [IPv4]: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (3 preceding siblings ...)
  2007-03-21  0:05 ` [PATCH 04/12] [NET] rules: " Thomas Graf
@ 2007-03-21  0:05 ` Thomas Graf
  2007-03-21  0:05 ` [PATCH 06/12] [PKT_SCHED] qdisc: " Thomas Graf
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_ip4_convert --]
[-- Type: text/plain, Size: 7648 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/include/net/ip_fib.h
===================================================================
--- net-2.6.22.orig/include/net/ip_fib.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/include/net/ip_fib.h	2007-03-21 00:52:33.000000000 +0100
@@ -215,10 +215,6 @@ extern void fib_select_default(const str
 /* Exported by fib_frontend.c */
 extern struct nla_policy rtm_ipv4_policy[];
 extern void		ip_fib_init(void);
-extern int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
-extern int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
-extern int inet_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
-extern int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb);
 extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
 			       struct net_device *dev, __be32 *spec_dst, u32 *itag);
 extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res);
@@ -235,8 +231,6 @@ extern __be32  __fib_res_prefsrc(struct 
 extern struct fib_table *fib_hash_init(u32 id);
 
 #ifdef CONFIG_IP_MULTIPLE_TABLES
-extern int fib4_rules_dump(struct sk_buff *skb, struct netlink_callback *cb);
-
 extern void __init fib4_rules_init(void);
 
 #ifdef CONFIG_NET_CLS_ROUTE
Index: net-2.6.22/net/ipv4/devinet.c
===================================================================
--- net-2.6.22.orig/net/ipv4/devinet.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/ipv4/devinet.c	2007-03-21 00:52:33.000000000 +0100
@@ -48,7 +48,6 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/notifier.h>
 #include <linux/inetdevice.h>
@@ -62,7 +61,7 @@
 #include <net/ip.h>
 #include <net/route.h>
 #include <net/ip_fib.h>
-#include <net/netlink.h>
+#include <net/rtnetlink.h>
 
 struct ipv4_devconf ipv4_devconf = {
 	.accept_redirects = 1,
@@ -442,7 +441,7 @@ struct in_ifaddr *inet_ifa_byprefix(stru
 	return NULL;
 }
 
-static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_addr_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct nlattr *tb[IFA_MAX+1];
 	struct in_device *in_dev;
@@ -563,7 +562,7 @@ errout:
 	return ERR_PTR(err);
 }
 
-static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_addr_new(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct in_ifaddr *ifa;
 
@@ -1174,7 +1173,7 @@ nla_put_failure:
 	return -EMSGSIZE;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_addr_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int idx, ip_idx;
 	struct net_device *dev;
@@ -1241,19 +1240,6 @@ errout:
 		rtnl_set_sk_err(RTNLGRP_IPV4_IFADDR, err);
 }
 
-static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = {
-	[RTM_NEWADDR  - RTM_BASE] = { .doit	= inet_rtm_newaddr,	},
-	[RTM_DELADDR  - RTM_BASE] = { .doit	= inet_rtm_deladdr,	},
-	[RTM_GETADDR  - RTM_BASE] = { .dumpit	= inet_dump_ifaddr,	},
-	[RTM_NEWROUTE - RTM_BASE] = { .doit	= inet_rtm_newroute,	},
-	[RTM_DELROUTE - RTM_BASE] = { .doit	= inet_rtm_delroute,	},
-	[RTM_GETROUTE - RTM_BASE] = { .doit	= inet_rtm_getroute,
-				      .dumpit	= inet_dump_fib,	},
-#ifdef CONFIG_IP_MULTIPLE_TABLES
-	[RTM_GETRULE  - RTM_BASE] = { .dumpit	= fib4_rules_dump,	},
-#endif
-};
-
 #ifdef CONFIG_SYSCTL
 
 void inet_forward_change(void)
@@ -1636,7 +1622,10 @@ void __init devinet_init(void)
 {
 	register_gifconf(PF_INET, inet_gifconf);
 	register_netdevice_notifier(&ip_netdev_notifier);
-	rtnetlink_links[PF_INET] = inet_rtnetlink_table;
+
+	rtnl_register(PF_INET, RTM_NEWADDR, nl_addr_new, NULL);
+	rtnl_register(PF_INET, RTM_DELADDR, nl_addr_del, NULL);
+	rtnl_register(PF_INET, RTM_GETADDR, NULL, nl_addr_dump);
 #ifdef CONFIG_SYSCTL
 	devinet_sysctl.sysctl_header =
 		register_sysctl_table(devinet_sysctl.devinet_root_dir);
Index: net-2.6.22/net/ipv4/fib_rules.c
===================================================================
--- net-2.6.22.orig/net/ipv4/fib_rules.c	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/net/ipv4/fib_rules.c	2007-03-21 00:52:33.000000000 +0100
@@ -277,7 +277,7 @@ nla_put_failure:
 	return -ENOBUFS;
 }
 
-int fib4_rules_dump(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_fib4_rule_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	return fib_rules_dump(skb, cb, AF_INET);
 }
@@ -329,4 +329,6 @@ void __init fib4_rules_init(void)
 	list_add_tail(&default_rule.common.list, &fib4_rules);
 
 	fib_rules_register(&fib4_rules_ops);
+
+	rtnl_register(PF_INET, RTM_GETRULE, NULL, nl_fib4_rule_dump);
 }
Index: net-2.6.22/net/ipv4/fib_frontend.c
===================================================================
--- net-2.6.22.orig/net/ipv4/fib_frontend.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/ipv4/fib_frontend.c	2007-03-21 00:52:33.000000000 +0100
@@ -34,7 +34,6 @@
 #include <linux/if_addr.h>
 #include <linux/if_arp.h>
 #include <linux/skbuff.h>
-#include <linux/netlink.h>
 #include <linux/init.h>
 #include <linux/list.h>
 
@@ -46,6 +45,7 @@
 #include <net/icmp.h>
 #include <net/arp.h>
 #include <net/ip_fib.h>
+#include <net/rtnetlink.h>
 
 #define FFprint(a...) printk(KERN_DEBUG a)
 
@@ -535,7 +535,7 @@ errout:
 	return err;
 }
 
-int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int nl_route_del(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib_config cfg;
 	struct fib_table *tb;
@@ -556,7 +556,7 @@ errout:
 	return err;
 }
 
-int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int nl_route_new(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib_config cfg;
 	struct fib_table *tb;
@@ -577,7 +577,7 @@ errout:
 	return err;
 }
 
-int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_route_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	unsigned int h, s_h;
 	unsigned int e = 0, s_e;
@@ -914,6 +914,10 @@ void __init ip_fib_init(void)
 	register_netdevice_notifier(&fib_netdev_notifier);
 	register_inetaddr_notifier(&fib_inetaddr_notifier);
 	nl_fib_lookup_init();
+
+	rtnl_register(PF_INET, RTM_NEWROUTE, nl_route_new, NULL);
+	rtnl_register(PF_INET, RTM_DELROUTE, nl_route_del, NULL);
+	rtnl_register(PF_INET, RTM_GETROUTE, NULL, nl_route_dump);
 }
 
 EXPORT_SYMBOL(inet_addr_type);
Index: net-2.6.22/net/ipv4/route.c
===================================================================
--- net-2.6.22.orig/net/ipv4/route.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/ipv4/route.c	2007-03-21 00:52:33.000000000 +0100
@@ -82,7 +82,6 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
 #include <linux/inetdevice.h>
 #include <linux/igmp.h>
 #include <linux/pkt_sched.h>
@@ -104,6 +103,7 @@
 #include <net/xfrm.h>
 #include <net/ip_mp_alg.h>
 #include <net/netevent.h>
+#include <net/rtnetlink.h>
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
 #endif
@@ -2721,7 +2721,7 @@ nla_put_failure:
 	return -EMSGSIZE;
 }
 
-int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
+static int nl_route_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct rtmsg *rtm;
 	struct nlattr *tb[RTA_MAX+1];
@@ -3194,6 +3194,8 @@ int __init ip_rt_init(void)
 	xfrm_init();
 	xfrm4_init();
 #endif
+	rtnl_register(PF_INET, RTM_GETROUTE, nl_route_get, NULL);
+
 	return rc;
 }
 

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 06/12] [PKT_SCHED] qdisc: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (4 preceding siblings ...)
  2007-03-21  0:05 ` [PATCH 05/12] [IPv4]: " Thomas Graf
@ 2007-03-21  0:05 ` Thomas Graf
  2007-03-21  0:06 ` [PATCH 07/12] [PKT_SCHED] cls: " Thomas Graf
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_qdisc_convert --]
[-- Type: text/plain, Size: 3809 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/include/net/sch_generic.h
===================================================================
--- net-2.6.22.orig/include/net/sch_generic.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/include/net/sch_generic.h	2007-03-21 00:52:35.000000000 +0100
@@ -5,10 +5,10 @@
 #include <linux/types.h>
 #include <linux/rcupdate.h>
 #include <linux/module.h>
-#include <linux/rtnetlink.h>
 #include <linux/pkt_sched.h>
 #include <linux/pkt_cls.h>
 #include <net/gen_stats.h>
+#include <net/rtnetlink.h>
 
 struct Qdisc_ops;
 struct qdisc_walker;
Index: net-2.6.22/net/sched/sch_api.c
===================================================================
--- net-2.6.22.orig/net/sched/sch_api.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/sched/sch_api.c	2007-03-21 00:52:35.000000000 +0100
@@ -27,7 +27,6 @@
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -611,7 +610,7 @@ check_loop_fn(struct Qdisc *q, unsigned 
  * Delete/get qdisc.
  */
 
-static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
+static int nl_qdisc_get(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
 	struct tcmsg *tcm = NLMSG_DATA(n);
 	struct rtattr **tca = arg;
@@ -672,7 +671,7 @@ static int tc_get_qdisc(struct sk_buff *
    Create/change qdisc.
  */
 
-static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
+static int nl_qdisc_new(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
 	struct tcmsg *tcm;
 	struct rtattr **tca;
@@ -884,7 +883,7 @@ err_out:
 	return -EINVAL;
 }
 
-static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_qdisc_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int idx, q_idx;
 	int s_idx, s_q_idx;
@@ -933,7 +932,7 @@ done:
 
 
 
-static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
+static int nl_class_modify(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
 	struct tcmsg *tcm = NLMSG_DATA(n);
 	struct rtattr **tca = arg;
@@ -1119,7 +1118,7 @@ static int qdisc_class_dump(struct Qdisc
 			      a->cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWTCLASS);
 }
 
-static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_class_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int t;
 	int s_t;
@@ -1239,29 +1238,17 @@ static const struct file_operations psch
 
 static int __init pktsched_init(void)
 {
-	struct rtnetlink_link *link_p;
-
-	link_p = rtnetlink_links[PF_UNSPEC];
-
-	/* Setup rtnetlink links. It is made here to avoid
-	   exporting large number of public symbols.
-	 */
-
-	if (link_p) {
-		link_p[RTM_NEWQDISC-RTM_BASE].doit = tc_modify_qdisc;
-		link_p[RTM_DELQDISC-RTM_BASE].doit = tc_get_qdisc;
-		link_p[RTM_GETQDISC-RTM_BASE].doit = tc_get_qdisc;
-		link_p[RTM_GETQDISC-RTM_BASE].dumpit = tc_dump_qdisc;
-		link_p[RTM_NEWTCLASS-RTM_BASE].doit = tc_ctl_tclass;
-		link_p[RTM_DELTCLASS-RTM_BASE].doit = tc_ctl_tclass;
-		link_p[RTM_GETTCLASS-RTM_BASE].doit = tc_ctl_tclass;
-		link_p[RTM_GETTCLASS-RTM_BASE].dumpit = tc_dump_tclass;
-	}
-
 	register_qdisc(&pfifo_qdisc_ops);
 	register_qdisc(&bfifo_qdisc_ops);
 	proc_net_fops_create("psched", 0, &psched_fops);
 
+	rtnl_register(PF_UNSPEC, RTM_NEWQDISC, nl_qdisc_new, NULL);
+	rtnl_register(PF_UNSPEC, RTM_DELQDISC, nl_qdisc_get, NULL);
+	rtnl_register(PF_UNSPEC, RTM_GETQDISC, nl_qdisc_get, nl_qdisc_dump);
+	rtnl_register(PF_UNSPEC, RTM_NEWTCLASS, nl_class_modify, NULL);
+	rtnl_register(PF_UNSPEC, RTM_DELTCLASS, nl_class_modify, NULL);
+	rtnl_register(PF_UNSPEC, RTM_GETTCLASS, nl_class_modify, nl_class_dump);
+
 	return 0;
 }
 

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 07/12] [PKT_SCHED] cls: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (5 preceding siblings ...)
  2007-03-21  0:05 ` [PATCH 06/12] [PKT_SCHED] qdisc: " Thomas Graf
@ 2007-03-21  0:06 ` Thomas Graf
  2007-03-21  0:06 ` [PATCH 08/12] [PKT_SCHED] act: " Thomas Graf
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:06 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_cls_convert --]
[-- Type: text/plain, Size: 1882 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/sched/cls_api.c
===================================================================
--- net-2.6.22.orig/net/sched/cls_api.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/sched/cls_api.c	2007-03-21 00:52:36.000000000 +0100
@@ -29,7 +29,6 @@
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/netlink.h>
@@ -128,7 +127,7 @@ static __inline__ u32 tcf_auto_prio(stru
 
 /* Add/change/delete/get a filter node */
 
-static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
+static int nl_cls_modify(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
 	struct rtattr **tca;
 	struct tcmsg *t;
@@ -384,7 +383,7 @@ static int tcf_node_dump(struct tcf_prot
 			     a->cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWTFILTER);
 }
 
-static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_cls_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int t;
 	int s_t;
@@ -616,18 +615,10 @@ rtattr_failure: __attribute__ ((unused))
 
 static int __init tc_filter_init(void)
 {
-	struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC];
+	rtnl_register(PF_UNSPEC, RTM_NEWTFILTER, nl_cls_modify, NULL);
+	rtnl_register(PF_UNSPEC, RTM_DELTFILTER, nl_cls_modify, NULL);
+	rtnl_register(PF_UNSPEC, RTM_GETTFILTER, nl_cls_modify, nl_cls_dump);
 
-	/* Setup rtnetlink links. It is made here to avoid
-	   exporting large number of public symbols.
-	 */
-
-	if (link_p) {
-		link_p[RTM_NEWTFILTER-RTM_BASE].doit = tc_ctl_tfilter;
-		link_p[RTM_DELTFILTER-RTM_BASE].doit = tc_ctl_tfilter;
-		link_p[RTM_GETTFILTER-RTM_BASE].doit = tc_ctl_tfilter;
-		link_p[RTM_GETTFILTER-RTM_BASE].dumpit = tc_dump_tfilter;
-	}
 	return 0;
 }
 

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 08/12] [PKT_SCHED] act: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (6 preceding siblings ...)
  2007-03-21  0:06 ` [PATCH 07/12] [PKT_SCHED] cls: " Thomas Graf
@ 2007-03-21  0:06 ` Thomas Graf
  2007-03-21  0:06 ` [PATCH 09/12] [DECNet]: " Thomas Graf
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:06 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_act_convert --]
[-- Type: text/plain, Size: 1696 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/sched/act_api.c
===================================================================
--- net-2.6.22.orig/net/sched/act_api.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/sched/act_api.c	2007-03-21 00:52:37.000000000 +0100
@@ -25,7 +25,6 @@
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <net/sock.h>
@@ -940,7 +939,7 @@ done:
 	return ret;
 }
 
-static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
+static int nl_act_modify(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
 {
 	struct rtattr **tca = arg;
 	u32 pid = skb ? NETLINK_CB(skb).pid : 0;
@@ -1012,8 +1011,7 @@ find_dump_kind(struct nlmsghdr *n)
 	return kind;
 }
 
-static int
-tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_act_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	struct nlmsghdr *nlh;
 	unsigned char *b = skb_tail_pointer(skb);
@@ -1077,14 +1075,9 @@ nlmsg_failure:
 
 static int __init tc_action_init(void)
 {
-	struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC];
-
-	if (link_p) {
-		link_p[RTM_NEWACTION-RTM_BASE].doit = tc_ctl_action;
-		link_p[RTM_DELACTION-RTM_BASE].doit = tc_ctl_action;
-		link_p[RTM_GETACTION-RTM_BASE].doit = tc_ctl_action;
-		link_p[RTM_GETACTION-RTM_BASE].dumpit = tc_dump_action;
-	}
+	rtnl_register(PF_UNSPEC, RTM_NEWACTION, nl_act_modify, NULL);
+	rtnl_register(PF_UNSPEC, RTM_DELACTION, nl_act_modify, NULL);
+	rtnl_register(PF_UNSPEC, RTM_GETACTION, nl_act_modify, nl_act_dump);
 
 	return 0;
 }

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 09/12] [DECNet]: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (7 preceding siblings ...)
  2007-03-21  0:06 ` [PATCH 08/12] [PKT_SCHED] act: " Thomas Graf
@ 2007-03-21  0:06 ` Thomas Graf
  2007-03-21  0:06 ` [PATCH 10/12] [IPv6]: " Thomas Graf
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:06 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_dn_convert --]
[-- Type: text/plain, Size: 8044 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/include/net/dn_fib.h
===================================================================
--- net-2.6.22.orig/include/net/dn_fib.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/include/net/dn_fib.h	2007-03-21 00:52:38.000000000 +0100
@@ -148,17 +148,8 @@ extern void dn_fib_rules_cleanup(void);
 extern unsigned dnet_addr_type(__le16 addr);
 extern int dn_fib_lookup(struct flowi *fl, struct dn_fib_res *res);
 
-/*
- * rtnetlink interface
- */
-extern int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
-extern int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
 extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
 
-extern int dn_fib_rtm_delrule(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
-extern int dn_fib_rtm_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
-extern int dn_fib_dump_rules(struct sk_buff *skb, struct netlink_callback *cb);
-
 extern void dn_fib_free_info(struct dn_fib_info *fi);
 
 static inline void dn_fib_info_put(struct dn_fib_info *fi)
Index: net-2.6.22/net/decnet/dn_rules.c
===================================================================
--- net-2.6.22.orig/net/decnet/dn_rules.c	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/net/decnet/dn_rules.c	2007-03-21 00:52:38.000000000 +0100
@@ -241,7 +241,7 @@ static u32 dn_fib_rule_default_pref(void
 	return 0;
 }
 
-int dn_fib_dump_rules(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_dn_rules_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	return fib_rules_dump(skb, cb, AF_DECnet);
 }
@@ -265,10 +265,12 @@ void __init dn_fib_rules_init(void)
 {
 	list_add_tail(&default_rule.common.list, &dn_fib_rules);
 	fib_rules_register(&dn_fib_rules_ops);
+	rtnl_register(PF_DECnet, RTM_GETRULE, NULL, nl_dn_rules_dump);
 }
 
 void __exit dn_fib_rules_cleanup(void)
 {
+	rtnl_unregister(PF_DECnet, RTM_GETRULE);
 	fib_rules_unregister(&dn_fib_rules_ops);
 }
 
Index: net-2.6.22/net/decnet/dn_fib.c
===================================================================
--- net-2.6.22.orig/net/decnet/dn_fib.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/decnet/dn_fib.c	2007-03-21 00:52:38.000000000 +0100
@@ -501,7 +501,7 @@ static int dn_fib_check_attr(struct rtms
 	return 0;
 }
 
-int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+int nl_route_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct dn_fib_table *tb;
 	struct rtattr **rta = arg;
@@ -517,7 +517,7 @@ int dn_fib_rtm_delroute(struct sk_buff *
 	return -ESRCH;
 }
 
-int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_route_new(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct dn_fib_table *tb;
 	struct rtattr **rta = arg;
@@ -745,11 +745,13 @@ void __exit dn_fib_cleanup(void)
 
 void __init dn_fib_init(void)
 {
-
 	dn_fib_table_init();
 	dn_fib_rules_init();
 
 	register_dnaddr_notifier(&dn_fib_dnaddr_notifier);
+
+	rtnl_register(PF_DECnet, RTM_NEWROUTE, nl_route_new, NULL);
+	rtnl_register(PF_DECnet, RTM_DELROUTE, nl_route_del, NULL);
 }
 
 
Index: net-2.6.22/net/decnet/af_decnet.c
===================================================================
--- net-2.6.22.orig/net/decnet/af_decnet.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/decnet/af_decnet.c	2007-03-21 00:52:38.000000000 +0100
@@ -2413,6 +2413,7 @@ module_init(decnet_init);
 static void __exit decnet_exit(void)
 {
 	sock_unregister(AF_DECnet);
+	rtnl_unregister_all(PF_DECnet);
 	dev_remove_pack(&dn_dix_packet_type);
 
 	dn_unregister_sysctl();
Index: net-2.6.22/net/decnet/dn_dev.c
===================================================================
--- net-2.6.22.orig/net/decnet/dn_dev.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/decnet/dn_dev.c	2007-03-21 00:52:38.000000000 +0100
@@ -645,7 +645,7 @@ static struct nla_policy dn_ifa_policy[I
 				    .len = IFNAMSIZ - 1 },
 };
 
-static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_addr_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct nlattr *tb[IFA_MAX+1];
 	struct dn_dev *dn_db;
@@ -677,7 +677,7 @@ errout:
 	return err;
 }
 
-static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_addr_new(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct nlattr *tb[IFA_MAX+1];
 	struct net_device *dev;
@@ -789,7 +789,7 @@ errout:
 		rtnl_set_sk_err(RTNLGRP_DECnet_IFADDR, err);
 }
 
-static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_addr_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int idx, dn_idx = 0, skip_ndevs, skip_naddr;
 	struct net_device *dev;
@@ -1447,24 +1447,6 @@ static const struct file_operations dn_d
 
 #endif /* CONFIG_PROC_FS */
 
-static struct rtnetlink_link dnet_rtnetlink_table[RTM_NR_MSGTYPES] =
-{
-	[RTM_NEWADDR  - RTM_BASE] = { .doit	= dn_nl_newaddr,	},
-	[RTM_DELADDR  - RTM_BASE] = { .doit	= dn_nl_deladdr,	},
-	[RTM_GETADDR  - RTM_BASE] = { .dumpit	= dn_nl_dump_ifaddr,	},
-#ifdef CONFIG_DECNET_ROUTER
-	[RTM_NEWROUTE - RTM_BASE] = { .doit	= dn_fib_rtm_newroute,	},
-	[RTM_DELROUTE - RTM_BASE] = { .doit	= dn_fib_rtm_delroute,	},
-	[RTM_GETROUTE - RTM_BASE] = { .doit	= dn_cache_getroute,
-				      .dumpit	= dn_fib_dump,		},
-	[RTM_GETRULE  - RTM_BASE] = { .dumpit	= dn_fib_dump_rules,	},
-#else
-	[RTM_GETROUTE - RTM_BASE] = { .doit	= dn_cache_getroute,
-				      .dumpit	= dn_cache_dump,	},
-#endif
-
-};
-
 static int __initdata addr[2];
 module_param_array(addr, int, NULL, 0444);
 MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node");
@@ -1485,7 +1467,9 @@ void __init dn_dev_init(void)
 
 	dn_dev_devices_on();
 
-	rtnetlink_links[PF_DECnet] = dnet_rtnetlink_table;
+	rtnl_register(PF_DECnet, RTM_NEWADDR, nl_addr_new, NULL);
+	rtnl_register(PF_DECnet, RTM_DELADDR, nl_addr_del, NULL);
+	rtnl_register(PF_DECnet, RTM_GETADDR, NULL, nl_addr_dump);
 
 	proc_net_fops_create("decnet_dev", S_IRUGO, &dn_dev_seq_fops);
 
@@ -1500,8 +1484,6 @@ void __init dn_dev_init(void)
 
 void __exit dn_dev_cleanup(void)
 {
-	rtnetlink_links[PF_DECnet] = NULL;
-
 #ifdef CONFIG_SYSCTL
 	{
 		int i;
Index: net-2.6.22/include/net/dn_route.h
===================================================================
--- net-2.6.22.orig/include/net/dn_route.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/include/net/dn_route.h	2007-03-21 00:52:38.000000000 +0100
@@ -18,7 +18,6 @@
 extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
 extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags);
 extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb);
-extern int dn_cache_getroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
 extern void dn_rt_cache_flush(int delay);
 
 /* Masks for flags field */
Index: net-2.6.22/net/decnet/dn_route.c
===================================================================
--- net-2.6.22.orig/net/decnet/dn_route.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/decnet/dn_route.c	2007-03-21 00:52:38.000000000 +0100
@@ -1522,7 +1522,7 @@ rtattr_failure:
 /*
  * This is called by both endnodes and routers now.
  */
-int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void *arg)
+static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct rtattr **rta = arg;
 	struct rtmsg *rtm = NLMSG_DATA(nlh);
@@ -1813,6 +1813,13 @@ void __init dn_route_init(void)
 	dn_dst_ops.gc_thresh = (dn_rt_hash_mask + 1);
 
 	proc_net_fops_create("decnet_cache", S_IRUGO, &dn_rt_cache_seq_fops);
+
+#ifdef CONFIG_DECNET_ROUTER
+	rtnl_register(PF_DECnet, RTM_GETROUTE, dn_cache_getroute, dn_fib_dump);
+#else
+	rtnl_register(PF_DECnet, RTM_GETROUTE, dn_cache_getroute,
+		      dn_cache_dump);
+#endif
 }
 
 void __exit dn_route_cleanup(void)

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 10/12] [IPv6]: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (8 preceding siblings ...)
  2007-03-21  0:06 ` [PATCH 09/12] [DECNet]: " Thomas Graf
@ 2007-03-21  0:06 ` Thomas Graf
  2007-03-21  1:01   ` YOSHIFUJI Hideaki / 吉藤英明
  2007-03-21  0:06 ` [PATCH 11/12] [BRIDGE]: " Thomas Graf
  2007-03-21  0:06 ` [PATCH 12/12] [RTNL]: Use rtnl registration interface for dump-all aliases Thomas Graf
  11 siblings, 1 reply; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:06 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_ip6_convert --]
[-- Type: text/plain, Size: 9353 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/include/net/ip6_fib.h
===================================================================
--- net-2.6.22.orig/include/net/ip6_fib.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/include/net/ip6_fib.h	2007-03-21 00:52:40.000000000 +0100
@@ -218,8 +218,6 @@ extern void			fib6_init(void);
 
 extern void			fib6_rules_init(void);
 extern void			fib6_rules_cleanup(void);
-extern int			fib6_rules_dump(struct sk_buff *,
-						struct netlink_callback *);
 
 #endif
 #endif
Index: net-2.6.22/net/ipv6/addrconf.c
===================================================================
--- net-2.6.22.orig/net/ipv6/addrconf.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/ipv6/addrconf.c	2007-03-21 00:52:40.000000000 +0100
@@ -2948,8 +2948,7 @@ static struct nla_policy ifa_ipv6_policy
 	[IFA_CACHEINFO]		= { .len = sizeof(struct ifa_cacheinfo) },
 };
 
-static int
-inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_addr_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct ifaddrmsg *ifm;
 	struct nlattr *tb[IFA_MAX+1];
@@ -3005,8 +3004,7 @@ static int inet6_addr_modify(struct inet
 	return 0;
 }
 
-static int
-inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+static int nl_addr_new(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct ifaddrmsg *ifm;
 	struct nlattr *tb[IFA_MAX+1];
@@ -3287,27 +3285,26 @@ done:
 	return skb->len;
 }
 
-static int inet6_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_addr_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	enum addr_type_t type = UNICAST_ADDR;
 	return inet6_dump_addr(skb, cb, type);
 }
 
-static int inet6_dump_ifmcaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_mcaddr_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	enum addr_type_t type = MULTICAST_ADDR;
 	return inet6_dump_addr(skb, cb, type);
 }
 
 
-static int inet6_dump_ifacaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_acaddr_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	enum addr_type_t type = ANYCAST_ADDR;
 	return inet6_dump_addr(skb, cb, type);
 }
 
-static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
-			     void *arg)
+static int nl_addr_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct ifaddrmsg *ifm;
 	struct nlattr *tb[IFA_MAX+1];
@@ -3491,7 +3488,7 @@ nla_put_failure:
 	return -EMSGSIZE;
 }
 
-static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	int idx, err;
 	int s_idx = cb->args[0];
@@ -3607,23 +3604,6 @@ errout:
 		rtnl_set_sk_err(RTNLGRP_IPV6_PREFIX, err);
 }
 
-static struct rtnetlink_link inet6_rtnetlink_table[RTM_NR_MSGTYPES] = {
-	[RTM_GETLINK - RTM_BASE] = { .dumpit	= inet6_dump_ifinfo, },
-	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
-	[RTM_DELADDR - RTM_BASE] = { .doit	= inet6_rtm_deladdr, },
-	[RTM_GETADDR - RTM_BASE] = { .doit	= inet6_rtm_getaddr,
-				     .dumpit	= inet6_dump_ifaddr, },
-	[RTM_GETMULTICAST - RTM_BASE] = { .dumpit = inet6_dump_ifmcaddr, },
-	[RTM_GETANYCAST - RTM_BASE] = { .dumpit	= inet6_dump_ifacaddr, },
-	[RTM_NEWROUTE - RTM_BASE] = { .doit	= inet6_rtm_newroute, },
-	[RTM_DELROUTE - RTM_BASE] = { .doit	= inet6_rtm_delroute, },
-	[RTM_GETROUTE - RTM_BASE] = { .doit	= inet6_rtm_getroute,
-				      .dumpit	= inet6_dump_fib, },
-#ifdef CONFIG_IPV6_MULTIPLE_TABLES
-	[RTM_GETRULE  - RTM_BASE] = { .dumpit   = fib6_rules_dump,   },
-#endif
-};
-
 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
 {
 	inet6_ifa_notify(event ? : RTM_NEWADDR, ifp);
@@ -4135,7 +4115,18 @@ int __init addrconf_init(void)
 	register_netdevice_notifier(&ipv6_dev_notf);
 
 	addrconf_verify(0);
-	rtnetlink_links[PF_INET6] = inet6_rtnetlink_table;
+
+	err = __rtnl_register(PF_INET6, RTM_GETLINK, NULL, nl_link_dump);
+	if (err < 0)
+		goto errout;
+
+	/* Only the first call to __rtnl_register can fail */
+	__rtnl_register(PF_INET6, RTM_NEWADDR, nl_addr_new, NULL);
+	__rtnl_register(PF_INET6, RTM_DELADDR, nl_addr_del, NULL);
+	__rtnl_register(PF_INET6, RTM_GETADDR, nl_addr_get, nl_addr_dump);
+	__rtnl_register(PF_INET6, RTM_GETMULTICAST, NULL, nl_mcaddr_dump);
+	__rtnl_register(PF_INET6, RTM_GETANYCAST, NULL, nl_acaddr_dump);
+
 #ifdef CONFIG_SYSCTL
 	addrconf_sysctl.sysctl_header =
 		register_sysctl_table(addrconf_sysctl.addrconf_root_dir);
@@ -4143,6 +4134,10 @@ int __init addrconf_init(void)
 #endif
 
 	return 0;
+errout:
+	unregister_netdevice_notifier(&ipv6_dev_notf);
+
+	return err;
 }
 
 void __exit addrconf_cleanup(void)
@@ -4154,7 +4149,6 @@ void __exit addrconf_cleanup(void)
 
 	unregister_netdevice_notifier(&ipv6_dev_notf);
 
-	rtnetlink_links[PF_INET6] = NULL;
 #ifdef CONFIG_SYSCTL
 	addrconf_sysctl_unregister(&ipv6_devconf_dflt);
 	addrconf_sysctl_unregister(&ipv6_devconf);
Index: net-2.6.22/net/ipv6/fib6_rules.c
===================================================================
--- net-2.6.22.orig/net/ipv6/fib6_rules.c	2007-03-20 23:53:21.000000000 +0100
+++ net-2.6.22/net/ipv6/fib6_rules.c	2007-03-21 00:52:40.000000000 +0100
@@ -221,7 +221,7 @@ nla_put_failure:
 	return -ENOBUFS;
 }
 
-int fib6_rules_dump(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_fib6_rules_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	return fib_rules_dump(skb, cb, AF_INET6);
 }
@@ -259,9 +259,11 @@ void __init fib6_rules_init(void)
 	list_add_tail(&main_rule.common.list, &fib6_rules);
 
 	fib_rules_register(&fib6_rules_ops);
+	__rtnl_register(PF_INET6, RTM_GETRULE, NULL, nl_fib6_rules_dump);
 }
 
 void fib6_rules_cleanup(void)
 {
+	rtnl_unregister(PF_INET6, RTM_GETRULE);
 	fib_rules_unregister(&fib6_rules_ops);
 }
Index: net-2.6.22/include/net/ip6_route.h
===================================================================
--- net-2.6.22.orig/include/net/ip6_route.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/include/net/ip6_route.h	2007-03-21 00:52:40.000000000 +0100
@@ -116,12 +116,7 @@ extern void			rt6_pmtu_discovery(struct 
 						   struct net_device *dev,
 						   u32 pmtu);
 
-struct nlmsghdr;
 struct netlink_callback;
-extern int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb);
-extern int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
-extern int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
-extern int inet6_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
 
 struct rt6_rtnl_dump_arg
 {
Index: net-2.6.22/net/ipv6/route.c
===================================================================
--- net-2.6.22.orig/net/ipv6/route.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/ipv6/route.c	2007-03-21 00:52:40.000000000 +0100
@@ -1994,7 +1994,7 @@ errout:
 	return err;
 }
 
-int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int nl_route_del(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib6_config cfg;
 	int err;
@@ -2006,7 +2006,7 @@ int inet6_rtm_delroute(struct sk_buff *s
 	return ip6_route_del(&cfg);
 }
 
-int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int nl_route_new(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib6_config cfg;
 	int err;
@@ -2143,7 +2143,7 @@ int rt6_dump_route(struct rt6_info *rt, 
 		     prefix, NLM_F_MULTI);
 }
 
-int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
+static int nl_route_get(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct nlattr *tb[RTA_MAX+1];
 	struct rt6_info *rt;
@@ -2487,6 +2487,10 @@ void __init ip6_route_init(void)
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
 	fib6_rules_init();
 #endif
+
+	__rtnl_register(PF_INET6, RTM_NEWROUTE, nl_route_new, NULL);
+	__rtnl_register(PF_INET6, RTM_DELROUTE, nl_route_del, NULL);
+	__rtnl_register(PF_INET6, RTM_GETROUTE, nl_route_get, NULL);
 }
 
 void ip6_route_cleanup(void)
Index: net-2.6.22/net/ipv6/ip6_fib.c
===================================================================
--- net-2.6.22.orig/net/ipv6/ip6_fib.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/ipv6/ip6_fib.c	2007-03-21 00:52:40.000000000 +0100
@@ -359,7 +359,7 @@ end:
 	return res;
 }
 
-int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_route_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	unsigned int h, s_h;
 	unsigned int e = 0, s_e;
@@ -1478,6 +1478,8 @@ void __init fib6_init(void)
 					   NULL, NULL);
 
 	fib6_tables_init();
+
+	__rtnl_register(PF_INET6, RTM_GETROUTE, NULL, nl_route_dump);
 }
 
 void fib6_gc_cleanup(void)
Index: net-2.6.22/net/ipv6/af_inet6.c
===================================================================
--- net-2.6.22.orig/net/ipv6/af_inet6.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/ipv6/af_inet6.c	2007-03-21 00:52:40.000000000 +0100
@@ -945,6 +945,8 @@ static void __exit inet6_exit(void)
 {
 	/* First of all disallow new sockets creation. */
 	sock_unregister(PF_INET6);
+	/* Disallow any further netlink messages */
+	rtnl_unregister_all(PF_INET6);
 
 	/* Cleanup code parts. */
 	ipv6_packet_cleanup();

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 11/12] [BRIDGE]: Use rtnl registration interface
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (9 preceding siblings ...)
  2007-03-21  0:06 ` [PATCH 10/12] [IPv6]: " Thomas Graf
@ 2007-03-21  0:06 ` Thomas Graf
  2007-03-21  0:06 ` [PATCH 12/12] [RTNL]: Use rtnl registration interface for dump-all aliases Thomas Graf
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:06 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_bridge_convert --]
[-- Type: text/plain, Size: 3125 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/bridge/br.c
===================================================================
--- net-2.6.22.orig/net/bridge/br.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/bridge/br.c	2007-03-21 00:52:42.000000000 +0100
@@ -47,7 +47,10 @@ static int __init br_init(void)
 	if (err)
 		goto err_out2;
 
-	br_netlink_init();
+	err = br_netlink_init();
+	if (err)
+		goto err_out3;
+
 	brioctl_set(br_ioctl_deviceless_stub);
 	br_handle_frame_hook = br_handle_frame;
 
@@ -55,7 +58,8 @@ static int __init br_init(void)
 	br_fdb_put_hook = br_fdb_put;
 
 	return 0;
-
+err_out3:
+	unregister_netdevice_notifier(&br_device_notifier);
 err_out2:
 	br_netfilter_fini();
 err_out1:
Index: net-2.6.22/net/bridge/br_netlink.c
===================================================================
--- net-2.6.22.orig/net/bridge/br_netlink.c	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/bridge/br_netlink.c	2007-03-21 00:52:42.000000000 +0100
@@ -11,8 +11,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/rtnetlink.h>
-#include <net/netlink.h>
+#include <net/rtnetlink.h>
 #include "br_private.h"
 
 static inline size_t br_nlmsg_size(void)
@@ -105,7 +104,7 @@ errout:
 /*
  * Dump information about all ports, in response to GETLINK
  */
-static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
+static int nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	struct net_device *dev;
 	int idx;
@@ -134,7 +133,7 @@ skip:
  * Change state of port (ie from forwarding to blocking etc)
  * Used by spanning tree in user space.
  */
-static int br_rtm_setlink(struct sk_buff *skb,  struct nlmsghdr *nlh, void *arg)
+static int nl_link_set(struct sk_buff *skb,  struct nlmsghdr *nlh, void *arg)
 {
 	struct ifinfomsg *ifm;
 	struct nlattr *protinfo;
@@ -179,18 +178,19 @@ static int br_rtm_setlink(struct sk_buff
 }
 
 
-static struct rtnetlink_link bridge_rtnetlink_table[RTM_NR_MSGTYPES] = {
-	[RTM_GETLINK - RTM_BASE] = { .dumpit	= br_dump_ifinfo, },
-	[RTM_SETLINK - RTM_BASE] = { .doit      = br_rtm_setlink, },
-};
-
-void __init br_netlink_init(void)
+int __init br_netlink_init(void)
 {
-	rtnetlink_links[PF_BRIDGE] = bridge_rtnetlink_table;
+	if (__rtnl_register(PF_BRIDGE, RTM_GETLINK, NULL, nl_link_dump))
+		return -ENOBUFS;
+
+	/* Only the first call to __rtnl_register can fail */
+	__rtnl_register(PF_BRIDGE, RTM_SETLINK, nl_link_set, NULL);
+
+	return 0;
 }
 
 void __exit br_netlink_fini(void)
 {
-	rtnetlink_links[PF_BRIDGE] = NULL;
+	rtnl_unregister_all(PF_BRIDGE);
 }
 
Index: net-2.6.22/net/bridge/br_private.h
===================================================================
--- net-2.6.22.orig/net/bridge/br_private.h	2007-03-20 23:53:20.000000000 +0100
+++ net-2.6.22/net/bridge/br_private.h	2007-03-21 00:52:42.000000000 +0100
@@ -235,7 +235,7 @@ extern void (*br_fdb_put_hook)(struct ne
 
 
 /* br_netlink.c */
-extern void br_netlink_init(void);
+extern int br_netlink_init(void);
 extern void br_netlink_fini(void);
 extern void br_ifinfo_notify(int event, struct net_bridge_port *port);
 

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 12/12] [RTNL]: Use rtnl registration interface for dump-all aliases
  2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
                   ` (10 preceding siblings ...)
  2007-03-21  0:06 ` [PATCH 11/12] [BRIDGE]: " Thomas Graf
@ 2007-03-21  0:06 ` Thomas Graf
  11 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21  0:06 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_dump_all --]
[-- Type: text/plain, Size: 1064 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-21 00:52:30.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-21 00:52:43.000000000 +0100
@@ -958,12 +958,6 @@ static void rtnetlink_rcv(struct sock *s
 	} while (qlen);
 }
 
-static struct rtnetlink_link link_rtnetlink_table[RTM_NR_MSGTYPES] =
-{
-	[RTM_GETADDR     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
-	[RTM_GETROUTE    - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
-};
-
 static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)
 {
 	struct net_device *dev = ptr;
@@ -1013,6 +1007,9 @@ void __init rtnetlink_init(void)
 
 	rtnl_register(PF_UNSPEC, RTM_GETLINK, nl_link_get, nl_link_dump);
 	rtnl_register(PF_UNSPEC, RTM_SETLINK, nl_link_set, NULL);
+
+	rtnl_register(PF_UNSPEC, RTM_GETADDR, NULL, rtnl_dump_all);
+	rtnl_register(PF_UNSPEC, RTM_GETROUTE, NULL, rtnl_dump_all);
 }
 
 EXPORT_SYMBOL(__rta_fill);

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 10/12] [IPv6]: Use rtnl registration interface
  2007-03-21  0:06 ` [PATCH 10/12] [IPv6]: " Thomas Graf
@ 2007-03-21  1:01   ` YOSHIFUJI Hideaki / 吉藤英明
  2007-03-21 12:43     ` Thomas Graf
  0 siblings, 1 reply; 16+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-03-21  1:01 UTC (permalink / raw)
  To: tgraf; +Cc: davem, netdev, yoshfuji

In article <20070321000710.549330036@lsx.localdomain> (at Wed, 21 Mar 2007 01:06:03 +0100), Thomas Graf <tgraf@suug.ch> says:

> -static int
> -inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
> +static int nl_addr_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
>  {
>  	struct ifaddrmsg *ifm;

I'm rather not favor changing function names here...

--yoshfuji

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 10/12] [IPv6]: Use rtnl registration interface
  2007-03-21  1:01   ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-03-21 12:43     ` Thomas Graf
  0 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-21 12:43 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / ?$B5HF#1QL@; +Cc: davem, netdev

* YOSHIFUJI Hideaki / ?$B5HF#1QL@ <yoshfuji@linux-ipv6.org> 2007-03-21 02:01
> In article <20070321000710.549330036@lsx.localdomain> (at Wed, 21 Mar 2007 01:06:03 +0100), Thomas Graf <tgraf@suug.ch> says:
> 
> > -static int
> > -inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
> > +static int nl_addr_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
> >  {
> >  	struct ifaddrmsg *ifm;
> 
> I'm rather not favor changing function names here...

I was trying to achieve consistent naming among all message handlers.
All these functions are static with a single reference.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 04/12] [NET] rules: Use rtnl registration interface
  2007-03-22 12:59 [PATCH 00/12] [RESEND] rtnetlink message handler registration interface Thomas Graf
@ 2007-03-22 12:59 ` Thomas Graf
  0 siblings, 0 replies; 16+ messages in thread
From: Thomas Graf @ 2007-03-22 12:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: rtnl_reg_rules_convert --]
[-- Type: text/plain, Size: 2874 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/core/fib_rules.c
===================================================================
--- net-2.6.22.orig/net/core/fib_rules.c	2007-03-22 12:48:05.000000000 +0100
+++ net-2.6.22/net/core/fib_rules.c	2007-03-22 12:52:34.000000000 +0100
@@ -152,7 +152,7 @@ out:
 
 EXPORT_SYMBOL_GPL(fib_rules_lookup);
 
-int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib_rule_hdr *frh = nlmsg_data(nlh);
 	struct fib_rules_ops *ops = NULL;
@@ -239,7 +239,7 @@ errout:
 	return err;
 }
 
-int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
 	struct fib_rule_hdr *frh = nlmsg_data(nlh);
 	struct fib_rules_ops *ops = NULL;
@@ -471,6 +471,10 @@ static struct notifier_block fib_rules_n
 
 static int __init fib_rules_init(void)
 {
+	rtnl_register(PF_UNSPEC, RTM_NEWRULE, fib_nl_newrule, NULL);
+	rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL);
+	rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, rtnl_dump_all);
+
 	return register_netdevice_notifier(&fib_rules_notifier);
 }
 
Index: net-2.6.22/include/net/fib_rules.h
===================================================================
--- net-2.6.22.orig/include/net/fib_rules.h	2007-03-22 12:48:05.000000000 +0100
+++ net-2.6.22/include/net/fib_rules.h	2007-03-22 12:51:31.000000000 +0100
@@ -5,7 +5,7 @@
 #include <linux/netdevice.h>
 #include <linux/fib_rules.h>
 #include <net/flow.h>
-#include <net/netlink.h>
+#include <net/rtnetlink.h>
 
 struct fib_rule
 {
@@ -98,10 +98,6 @@ extern int			fib_rules_lookup(struct fib
 						 struct flowi *, int flags,
 						 struct fib_lookup_arg *);
 
-extern int			fib_nl_newrule(struct sk_buff *,
-					       struct nlmsghdr *, void *);
-extern int			fib_nl_delrule(struct sk_buff *,
-					       struct nlmsghdr *, void *);
 extern int			fib_rules_dump(struct sk_buff *,
 					       struct netlink_callback *, int);
 #endif
Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-22 12:49:47.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-22 12:51:31.000000000 +0100
@@ -962,11 +962,6 @@ static struct rtnetlink_link link_rtnetl
 {
 	[RTM_GETADDR     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
 	[RTM_GETROUTE    - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
-#ifdef CONFIG_FIB_RULES
-	[RTM_NEWRULE     - RTM_BASE] = { .doit   = fib_nl_newrule	 },
-	[RTM_DELRULE     - RTM_BASE] = { .doit   = fib_nl_delrule	 },
-#endif
-	[RTM_GETRULE     - RTM_BASE] = { .dumpit = rtnl_dump_all	 },
 };
 
 static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)

--


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-03-22 13:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21  0:05 [PATCH 00/12] [PATCHSET] RTNetlink message handler registration interface Thomas Graf
2007-03-21  0:05 ` [PATCH 01/12] [RTNL]: Message " Thomas Graf
2007-03-21  0:05 ` [PATCH 02/12] [NET] link: Use rtnl " Thomas Graf
2007-03-21  0:05 ` [PATCH 03/12] [NEIGH]: " Thomas Graf
2007-03-21  0:05 ` [PATCH 04/12] [NET] rules: " Thomas Graf
2007-03-21  0:05 ` [PATCH 05/12] [IPv4]: " Thomas Graf
2007-03-21  0:05 ` [PATCH 06/12] [PKT_SCHED] qdisc: " Thomas Graf
2007-03-21  0:06 ` [PATCH 07/12] [PKT_SCHED] cls: " Thomas Graf
2007-03-21  0:06 ` [PATCH 08/12] [PKT_SCHED] act: " Thomas Graf
2007-03-21  0:06 ` [PATCH 09/12] [DECNet]: " Thomas Graf
2007-03-21  0:06 ` [PATCH 10/12] [IPv6]: " Thomas Graf
2007-03-21  1:01   ` YOSHIFUJI Hideaki / 吉藤英明
2007-03-21 12:43     ` Thomas Graf
2007-03-21  0:06 ` [PATCH 11/12] [BRIDGE]: " Thomas Graf
2007-03-21  0:06 ` [PATCH 12/12] [RTNL]: Use rtnl registration interface for dump-all aliases Thomas Graf
2007-03-22 12:59 [PATCH 00/12] [RESEND] rtnetlink message handler registration interface Thomas Graf
2007-03-22 12:59 ` [PATCH 04/12] [NET] rules: Use rtnl " Thomas Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.