1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

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.
This commit is contained in:
Tom Gundersen 2014-08-19 17:51:50 +02:00
parent 2a5948f715
commit 6c3e68e7c1

View File

@ -445,13 +445,17 @@ int netdev_get_mac(const char *ifname, struct ether_addr **ret) {
return 0; 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; int r;
assert(netdev); assert(netdev);
assert(!link || callback);
/* create netdev */ /* create netdev */
if (NETDEV_VTABLE(netdev)->create) { if (NETDEV_VTABLE(netdev)->create) {
assert(!link);
r = NETDEV_VTABLE(netdev)->create(netdev); r = NETDEV_VTABLE(netdev)->create(netdev);
if (r < 0) if (r < 0)
return r; 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 (link) {
if (r < 0) { r = sd_rtnl_call_async(netdev->manager->rtnl, m,
log_error_netdev(netdev, callback, link, 0, NULL);
"Could not send rtnetlink message: %s", strerror(-r)); if (r < 0) {
return r; 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; netdev->state = NETDEV_STATE_CREATING;
@ -580,7 +600,7 @@ int netdev_join(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback)
break; break;
case NETDEV_CREATE_STACKED: case NETDEV_CREATE_STACKED:
r = netdev_create(netdev, link); r = netdev_create(netdev, link, callback);
if (r < 0) if (r < 0)
return r; return r;
@ -699,7 +719,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
switch (NETDEV_VTABLE(netdev)->create_type) { switch (NETDEV_VTABLE(netdev)->create_type) {
case NETDEV_CREATE_MASTER: case NETDEV_CREATE_MASTER:
case NETDEV_CREATE_INDEPENDENT: case NETDEV_CREATE_INDEPENDENT:
r = netdev_create(netdev, NULL); r = netdev_create(netdev, NULL, NULL);
if (r < 0) if (r < 0)
return r; return r;