diff options
author | Jiri Pirko <jpirko@redhat.com> | 2011-02-13 04:33:42 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-13 19:58:40 -0500 |
commit | afc6151a78a43bdca5f64a8bd3e3c13837580c54 (patch) | |
tree | ec95ce72f88991aeb28df160b4a0215b137b2844 /net/bridge | |
parent | 9232ecca3ecd2e32140118c8fdabd7f8fb9ef4d5 (diff) |
bridge: implement [add/del]_slave ops
add possibility to addif/delif via rtnetlink
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge')
-rw-r--r-- | net/bridge/br_device.c | 17 | ||||
-rw-r--r-- | net/bridge/br_if.c | 11 |
2 files changed, 27 insertions, 1 deletions
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 556443566e9c..1461b19efd38 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
@@ -297,6 +297,21 @@ void br_netpoll_disable(struct net_bridge_port *p) | |||
297 | 297 | ||
298 | #endif | 298 | #endif |
299 | 299 | ||
300 | static int br_add_slave(struct net_device *dev, struct net_device *slave_dev) | ||
301 | |||
302 | { | ||
303 | struct net_bridge *br = netdev_priv(dev); | ||
304 | |||
305 | return br_add_if(br, slave_dev); | ||
306 | } | ||
307 | |||
308 | static int br_del_slave(struct net_device *dev, struct net_device *slave_dev) | ||
309 | { | ||
310 | struct net_bridge *br = netdev_priv(dev); | ||
311 | |||
312 | return br_del_if(br, slave_dev); | ||
313 | } | ||
314 | |||
300 | static const struct ethtool_ops br_ethtool_ops = { | 315 | static const struct ethtool_ops br_ethtool_ops = { |
301 | .get_drvinfo = br_getinfo, | 316 | .get_drvinfo = br_getinfo, |
302 | .get_link = ethtool_op_get_link, | 317 | .get_link = ethtool_op_get_link, |
@@ -326,6 +341,8 @@ static const struct net_device_ops br_netdev_ops = { | |||
326 | .ndo_netpoll_cleanup = br_netpoll_cleanup, | 341 | .ndo_netpoll_cleanup = br_netpoll_cleanup, |
327 | .ndo_poll_controller = br_poll_controller, | 342 | .ndo_poll_controller = br_poll_controller, |
328 | #endif | 343 | #endif |
344 | .ndo_add_slave = br_add_slave, | ||
345 | .ndo_del_slave = br_del_slave, | ||
329 | }; | 346 | }; |
330 | 347 | ||
331 | static void br_dev_free(struct net_device *dev) | 348 | static void br_dev_free(struct net_device *dev) |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 2a6801d8b728..dce8f0009a12 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -148,6 +148,8 @@ static void del_nbp(struct net_bridge_port *p) | |||
148 | 148 | ||
149 | netdev_rx_handler_unregister(dev); | 149 | netdev_rx_handler_unregister(dev); |
150 | 150 | ||
151 | netdev_set_master(dev, NULL); | ||
152 | |||
151 | br_multicast_del_port(p); | 153 | br_multicast_del_port(p); |
152 | 154 | ||
153 | kobject_uevent(&p->kobj, KOBJ_REMOVE); | 155 | kobject_uevent(&p->kobj, KOBJ_REMOVE); |
@@ -429,10 +431,14 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) | |||
429 | if (br_netpoll_info(br) && ((err = br_netpoll_enable(p)))) | 431 | if (br_netpoll_info(br) && ((err = br_netpoll_enable(p)))) |
430 | goto err3; | 432 | goto err3; |
431 | 433 | ||
432 | err = netdev_rx_handler_register(dev, br_handle_frame, p); | 434 | err = netdev_set_master(dev, br->dev); |
433 | if (err) | 435 | if (err) |
434 | goto err3; | 436 | goto err3; |
435 | 437 | ||
438 | err = netdev_rx_handler_register(dev, br_handle_frame, p); | ||
439 | if (err) | ||
440 | goto err4; | ||
441 | |||
436 | dev->priv_flags |= IFF_BRIDGE_PORT; | 442 | dev->priv_flags |= IFF_BRIDGE_PORT; |
437 | 443 | ||
438 | dev_disable_lro(dev); | 444 | dev_disable_lro(dev); |
@@ -455,6 +461,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) | |||
455 | kobject_uevent(&p->kobj, KOBJ_ADD); | 461 | kobject_uevent(&p->kobj, KOBJ_ADD); |
456 | 462 | ||
457 | return 0; | 463 | return 0; |
464 | |||
465 | err4: | ||
466 | netdev_set_master(dev, NULL); | ||
458 | err3: | 467 | err3: |
459 | sysfs_remove_link(br->ifobj, p->dev->name); | 468 | sysfs_remove_link(br->ifobj, p->dev->name); |
460 | err2: | 469 | err2: |