bridge: Assign rtnl_link_ops to bridge devices created via ioctl()
Subsystems (3)
PATCH 1/1 bridge: Assign rtnl_link_ops to bridge devices created via ioctl()
This ensures that bridges created with brctl(8) or ioctl(2) directly also carry IFLA_LINKINFO when dumped over netlink. This also allows to create a bridge with ioctl(2) and delete it with RTM_DELLINK.
--- net/bridge/br_if.c | 1 + net/bridge/br_netlink.c | 5 +++++ net/bridge/br_private.h | 1 + 3 files changed, 7 insertions(+), 0 deletions(-)
net/bridge/br_if.c +1 -0
@@ -240,6 +240,7 @@ int br_add_bridge(struct net *net, const char *name)return -ENOMEM ;dev_net_set (dev, net); +br_assign_rtnl_link_ops (dev); res =register_netdev (dev);if (res)
net/bridge/br_netlink.c +5 -0
@@ -216,6 +216,11 @@ static struct rtnl_link_ops br_link_ops __read_mostly = { .dellink = br_dev_delete, }; +void br_assign_rtnl_link_ops (struct net_device *dev) +{ + dev->rtnl_link_ops = &br_link_ops; +} +int __init br_netlink_init (void ) {int err;
net/bridge/br_private.h +1 -0
@@ -552,6 +552,7 @@ extern int (*br_fdb_test_addr_hook)(struct net_device *dev, unsigned char *addr)extern int br_netlink_init (void );extern void br_netlink_fini (void );extern void br_ifinfo_notify (int event,struct net_bridge_port *port); +extern void br_assign_rtnl_link_ops (struct net_device *dev);#ifdef CONFIG_SYSFS /* br_sysfs_if.c */
Signature · 1 line
1.7.7.6
Review
Quoted 4 lines · On Tue, 26 Jun 2012 10:56:15 +0200 Thomas Graf <[email protected]> wrote:
(quoted diff) +4
-0+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?
net/bridge/br_netlink.c +1 -1
@@ -208,7 +208,7 @@ static int br_validate(struct nlattr *tbreturn 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,
net/bridge/br_private.h +1 -0
@@ -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);
net/bridge/br_if.c +1 -0
@@ -240,6 +240,7 @@ int br_add_bridge(struct net *net, constreturn -ENOMEM ;dev_net_set (dev, net); + br->rtnl_link_ops = &br_link_ops; res =register_netdev (dev);if (res)
Quoted 10 lines · Stephen Hemminger
Review
Quoted 4 lines · On Tue, 26 Jun 2012 10:56:15 +0200 Thomas Graf <[email protected]> wrote:
(quoted diff) +4
-0+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_opspublic?
Either is fine with me. I chose the assignment function to keep the struct read-only outside of br_netlink.c.
PATCH 1/1 bridge: Assign rtnl_link_ops to bridge devices created via ioctl (v2)
This ensures that bridges created with brctl(8) or ioctl(2) directly also carry IFLA_LINKINFO when dumped over netlink. This also allows to create a bridge with ioctl(2) and delete it with RTM_DELLINK.
---
v2 - Minor change to Thomas's original patch.
This is a bug fix, should go to stable as well.
net/bridge/br_if.c | 1 + net/bridge/br_netlink.c | 2 +- net/bridge/br_private.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
net/bridge/br_netlink.c +1 -1
@@ -208,7 +208,7 @@ static int br_validate(struct nlattr *tbreturn 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,
net/bridge/br_private.h +1 -0
@@ -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);
net/bridge/br_if.c +1 -0
@@ -240,6 +240,7 @@ int br_add_bridge(struct net *net, constreturn -ENOMEM ;dev_net_set (dev, net); + dev->rtnl_link_ops = &br_link_ops; res =register_netdev (dev);if (res)
David Miller
maintainerRe: [PATCH] bridge: Assign rtnl_link_ops to bridge devices created via ioctl (v2)
From: Stephen Hemminger <[email protected]>
Date: Tue, 26 Jun 2012 08:48:45 -0700
Quoted 10 lines
This ensures that bridges created with brctl(8) or ioctl(2) directly also carry
IFLA_LINKINFOwhen dumped over netlink. This also allows to create a bridge with ioctl(2) and delete it withRTM_DELLINK.Signed-off-by Thomas Graf <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>---
v2 - Minor change to Thomas's original patch.
This is a bug fix, should go to stable as well.
Applied and queued up for -stable, thanks.