Patchwork bridge: Assign rtnl_link_ops to bridge devices created via ioctl()

login
register
mail settings
Submitter stephen hemminger
Date June 26, 2012, 2:59 p.m.
Message ID <20120626075940.099521a7@nehalam.linuxnetplumber.net>
Download mbox | patch
Permalink /patch/167417/
State Superseded
Delegated to: David Miller
Headers show

Comments

stephen hemminger - June 26, 2012, 2:59 p.m.
On Tue, 26 Jun 2012 10:56:15 +0200
Thomas Graf <tgraf@suug.ch> wrote:

> +void br_assign_rtnl_link_ops(struct net_device *dev)
> +{
> +	dev->rtnl_link_ops = &br_link_ops;
> +}

I am fine with the concept, but maybe it would just be simpler to
make br_link_ops public?

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thomas Graf - June 26, 2012, 3:13 p.m.
On Tue, Jun 26, 2012 at 07:59:40AM -0700, Stephen Hemminger wrote:
> On Tue, 26 Jun 2012 10:56:15 +0200
> Thomas Graf <tgraf@suug.ch> wrote:
> 
> > +void br_assign_rtnl_link_ops(struct net_device *dev)
> > +{
> > +	dev->rtnl_link_ops = &br_link_ops;
> > +}
> 
> I am fine with the concept, but maybe it would just be simpler to
> make br_link_ops public?

Either is fine with me. I chose the assignment function to keep the
struct read-only outside of br_netlink.c.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/net/bridge/br_netlink.c	2012-06-22 08:27:50.837126940 -0700
+++ b/net/bridge/br_netlink.c	2012-06-26 07:56:33.510237340 -0700
@@ -208,7 +208,7 @@  static int br_validate(struct nlattr *tb
 	return 0;
 }
 
-static struct rtnl_link_ops br_link_ops __read_mostly = {
+struct rtnl_link_ops br_link_ops __read_mostly = {
 	.kind		= "bridge",
 	.priv_size	= sizeof(struct net_bridge),
 	.setup		= br_dev_setup,
--- a/net/bridge/br_private.h	2012-06-22 08:27:50.837126940 -0700
+++ b/net/bridge/br_private.h	2012-06-26 07:57:25.873711454 -0700
@@ -549,6 +549,7 @@  extern int (*br_fdb_test_addr_hook)(stru
 #endif
 
 /* br_netlink.c */
+extern struct rtnl_link_ops br_link_ops;
 extern int br_netlink_init(void);
 extern void br_netlink_fini(void);
 extern void br_ifinfo_notify(int event, struct net_bridge_port *port);
--- a/net/bridge/br_if.c	2012-06-26 07:59:01.996746090 -0700
+++ b/net/bridge/br_if.c	2012-06-26 07:58:55.904807272 -0700
@@ -240,6 +240,7 @@  int br_add_bridge(struct net *net, const
 		return -ENOMEM;
 
 	dev_net_set(dev, net);
+	br->rtnl_link_ops = &br_link_ops;
 
 	res = register_netdev(dev);
 	if (res)