diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-netdev.c | 4 | ||||
-rw-r--r-- | src/network/networkd-tunnel.c | 14 | ||||
-rw-r--r-- | src/network/networkd.h | 2 |
3 files changed, 9 insertions, 11 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 13338aec51..a53f046540 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -222,6 +222,7 @@ static int netdev_enter_ready(NetDev *netdev) { return 0; } +/* callback for netdev's created without a backing Link */ static int netdev_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { NetDev *netdev = userdata; int r; @@ -402,6 +403,7 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c return 0; } +/* the callback must be called, possibly after a timeout, as otherwise the Link will hang */ int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback) { int r; @@ -415,7 +417,7 @@ int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callbac case NETDEV_KIND_GRE: case NETDEV_KIND_SIT: case NETDEV_KIND_VTI: - return netdev_create_tunnel(link, netdev_create_handler); + return netdev_create_tunnel(netdev, link, callback); default: break; } diff --git a/src/network/networkd-tunnel.c b/src/network/networkd-tunnel.c index 88146fe628..cffa5644ca 100644 --- a/src/network/networkd-tunnel.c +++ b/src/network/networkd-tunnel.c @@ -468,21 +468,17 @@ static int netdev_fill_vti_rtnl_message(Link *link, sd_rtnl_message *m) { return r; } -int netdev_create_tunnel(Link *link, sd_rtnl_message_handler_t callback) { +int netdev_create_tunnel(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback) { _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL; - NetDev *netdev; int r; - assert(link); - assert(link->network); - assert(link->network->tunnel); - - netdev = link->network->tunnel; - assert(netdev); assert(netdev->ifname); assert(netdev->manager); assert(netdev->manager->rtnl); + assert(link); + assert(link->network); + assert(link->network->tunnel == netdev); r = sd_rtnl_message_new_link(netdev->manager->rtnl, &m, RTM_NEWLINK, 0); if (r < 0) { @@ -517,7 +513,7 @@ int netdev_create_tunnel(Link *link, sd_rtnl_message_handler_t callback) { return -ENOTSUP; } - r = sd_rtnl_call_async(netdev->manager->rtnl, m, callback, netdev, 0, NULL); + 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)); diff --git a/src/network/networkd.h b/src/network/networkd.h index 11268de70d..d1b0bb72ae 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -349,7 +349,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref); int netdev_get(Manager *manager, const char *name, NetDev **ret); int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *newlink); int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t cb); -int netdev_create_tunnel(Link *link, sd_rtnl_message_handler_t callback); +int netdev_create_tunnel(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback); int netdev_create_veth(NetDev *netdev, sd_rtnl_message_handler_t callback); int netdev_create_vxlan(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback); |