diff options
author | Tom Gundersen <teg@jklm.no> | 2014-05-08 20:40:56 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-05-09 14:41:27 +0200 |
commit | 59cb64e6253e445c78b9e78be5e27bae0015ea38 (patch) | |
tree | 686817765233aa43dc85ee4cdad75435f1295e98 /src/network | |
parent | b226d99b044222739dccfa9cf9f7a9d79576c407 (diff) |
networkd: netdev - cancel all callbacks when freeing
This notifies the link that the netdev no longer exists.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-netdev.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 5ee257f984..ed4bc191f3 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -48,16 +48,35 @@ static const char* const macvlan_mode_table[_NETDEV_MACVLAN_MODE_MAX] = { DEFINE_STRING_TABLE_LOOKUP(macvlan_mode, MacVlanMode); DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode"); -static void netdev_free(NetDev *netdev) { +static void netdev_cancel_callbacks(NetDev *netdev) { + _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL; netdev_enslave_callback *callback; if (!netdev) return; + rtnl_message_new_synthetic_error(-ENODEV, 0, &m); + while ((callback = netdev->callbacks)) { + if (m) { + assert(callback->link); + assert(callback->callback); + assert(netdev->manager); + assert(netdev->manager->rtnl); + + callback->callback(netdev->manager->rtnl, m, link); + } + LIST_REMOVE(callbacks, netdev->callbacks, callback); free(callback); } +} + +static void netdev_free(NetDev *netdev) { + if (!netdev) + return; + + netdev_cancel_callbacks(netdev); if (netdev->name) hashmap_remove(netdev->manager->netdevs, netdev->name); |