diff options
author | Tom Gundersen <teg@jklm.no> | 2014-08-19 17:51:50 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-08-19 17:55:34 +0200 |
commit | 6c3e68e7c1adc6176526e69769bf2eba86cdd257 (patch) | |
tree | 72df306e3cc8b9ca4a0e2473260e574a1885c5a5 | |
parent | 2a5948f715b1b4a5510b723755a263602349a8af (diff) |
networkd: netdev - add missing callback when adding stacked devices
As the comment says, the passed in callback must always be invoked, or the underlying link
will hang. This was missed when reworking the code, so add it back in.
-rw-r--r-- | src/network/networkd-netdev.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 825b86d2a7..1a436f75df 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -445,13 +445,17 @@ int netdev_get_mac(const char *ifname, struct ether_addr **ret) { return 0; } -static int netdev_create(NetDev *netdev, Link *link) { +static int netdev_create(NetDev *netdev, Link *link, + sd_rtnl_message_handler_t callback) { int r; assert(netdev); + assert(!link || callback); /* create netdev */ if (NETDEV_VTABLE(netdev)->create) { + assert(!link); + r = NETDEV_VTABLE(netdev)->create(netdev); if (r < 0) return r; @@ -546,14 +550,30 @@ static int netdev_create(NetDev *netdev, Link *link) { } - r = sd_rtnl_call_async(netdev->manager->rtnl, m, netdev_create_handler, netdev, 0, NULL); - if (r < 0) { - log_error_netdev(netdev, - "Could not send rtnetlink message: %s", strerror(-r)); - return r; - } + if (link) { + r = sd_rtnl_call_async(netdev->manager->rtnl, m, + callback, link, 0, NULL); + if (r < 0) { + log_error_netdev(netdev, + "Could not send rtnetlink message: %s", + strerror(-r)); + return r; + } - netdev_ref(netdev); + link_ref(link); + } else { + r = sd_rtnl_call_async(netdev->manager->rtnl, m, + netdev_create_handler, netdev, 0, + NULL); + if (r < 0) { + log_error_netdev(netdev, + "Could not send rtnetlink message: %s", + strerror(-r)); + return r; + } + + netdev_ref(netdev); + } netdev->state = NETDEV_STATE_CREATING; @@ -580,7 +600,7 @@ int netdev_join(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback) break; case NETDEV_CREATE_STACKED: - r = netdev_create(netdev, link); + r = netdev_create(netdev, link, callback); if (r < 0) return r; @@ -699,7 +719,7 @@ static int netdev_load_one(Manager *manager, const char *filename) { switch (NETDEV_VTABLE(netdev)->create_type) { case NETDEV_CREATE_MASTER: case NETDEV_CREATE_INDEPENDENT: - r = netdev_create(netdev, NULL); + r = netdev_create(netdev, NULL, NULL); if (r < 0) return r; |