From: Yu Watanabe Date: Fri, 10 May 2019 21:21:40 +0000 (+0900) Subject: network: make BindCarrier= work with CAN devices X-Git-Tag: v243-rc1~452^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06d7cee5890840227d621cceb71c3d7a9af1e2fc;p=thirdparty%2Fsystemd.git network: make BindCarrier= work with CAN devices If CAN device is set `BindCarrier=` then the interface could not be down. This fixes the issue. --- diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index c5857da8fc4..84a0bf3c727 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -2122,9 +2122,6 @@ static int link_down_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link if (r < 0) log_link_warning_errno(link, r, "Could not bring down interface: %m"); - if (streq_ptr(link->kind, "can")) - link_set_can(link); - return 1; } @@ -2907,13 +2904,35 @@ static int link_drop_config(Link *link) { return 0; } +static int can_down_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) { + int r; + + assert(link); + + if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) + return 1; + + r = sd_netlink_message_get_errno(m); + if (r < 0) { + log_link_warning_errno(link, r, "Could not bring down interface: %m"); + link_enter_failed(link); + return 1; + } + + r = link_set_can(link); + if (r < 0) + link_enter_failed(link); + + return 1; +} + static int link_configure_can(Link *link) { int r; 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, NULL); + r = link_down(link, can_down_handler); if (r < 0) { link_enter_failed(link); return r;