diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-05-09 15:53:01 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-05-11 06:15:35 +0900 |
commit | 8e54db83e2837247bec2fc9f27a62877921c9f18 (patch) | |
tree | 21c0d09e1b1214247a8e1c0f073403246ccbcb09 /src | |
parent | 7f8539504cf4da1259845cee2b5136bf29c5cad2 (diff) | |
download | systemd-8e54db83e2837247bec2fc9f27a62877921c9f18.tar.gz |
network: make link_drop() can take custom handler
It will be used in the later commit.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/netdev/netdev.c | 2 | ||||
-rw-r--r-- | src/network/networkd-link.c | 9 | ||||
-rw-r--r-- | src/network/networkd-link.h | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index d8b8bca7e8..b6aa860ba5 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -254,7 +254,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, link_netlink_message if (link->flags & IFF_UP && netdev->kind == NETDEV_KIND_BOND) { log_netdev_debug(netdev, "Link '%s' was up when attempting to enslave it. Bringing link down.", link->ifname); - r = link_down(link); + r = link_down(link, NULL); if (r < 0) return log_netdev_error_errno(netdev, r, "Could not bring link down: %m"); } diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 9f354b519f..c5857da8fc 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -2128,7 +2128,7 @@ static int link_down_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link return 1; } -int link_down(Link *link) { +int link_down(Link *link, link_netlink_message_handler_t callback) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL; int r; @@ -2147,7 +2147,8 @@ int link_down(Link *link) { if (r < 0) return log_link_error_errno(link, r, "Could not set link flags: %m"); - r = netlink_call_async(link->manager->rtnl, NULL, req, link_down_handler, + r = netlink_call_async(link->manager->rtnl, NULL, req, + callback ?: link_down_handler, link_netlink_destroy_callback, link); if (r < 0) return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); @@ -2179,7 +2180,7 @@ static int link_handle_bound_to_list(Link *link) { } if (!required_up && link_is_up) { - r = link_down(link); + r = link_down(link, NULL); if (r < 0) return r; } else if (required_up && !link_is_up) { @@ -2912,7 +2913,7 @@ static int link_configure_can(Link *link) { if (streq_ptr(link->kind, "can")) { /* The CAN interface must be down to configure bitrate, etc... */ if ((link->flags & IFF_UP)) { - r = link_down(link); + r = link_down(link, NULL); if (r < 0) { link_enter_failed(link); return r; diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index 930dd25f92..e1f4b23a5a 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -139,7 +139,7 @@ int link_get(Manager *m, int ifindex, Link **ret); int link_add(Manager *manager, sd_netlink_message *message, Link **ret); void link_drop(Link *link); -int link_down(Link *link); +int link_down(Link *link, link_netlink_message_handler_t callback); void link_enter_failed(Link *link); int link_initialized(Link *link, sd_device *device); |