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

network: drop duplicated link_up_can()

This commit is contained in:
Yu Watanabe 2021-04-30 06:57:15 +09:00
parent 88c2c8a0ba
commit f282ce20aa
3 changed files with 4 additions and 45 deletions

View File

@ -52,48 +52,6 @@ int config_parse_can_bitrate(
return 0;
}
static int link_up_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)
/* we warn but don't fail the link, as it may be brought up later */
log_link_message_warning_errno(link, m, r, "Could not bring up interface");
return 1;
}
static int link_up_can(Link *link) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
int r;
assert(link);
log_link_debug(link, "Bringing CAN link up");
r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
r = sd_rtnl_message_link_set_flags(req, IFF_UP, IFF_UP);
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_up_handler,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
link_ref(link);
return 0;
}
static int link_set_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;
@ -256,7 +214,7 @@ static int link_set_can(Link *link) {
link_ref(link);
if (!(link->flags & IFF_UP))
return link_up_can(link);
return link_up(link);
return 0;
}
@ -308,7 +266,7 @@ int link_configure_can(Link *link) {
}
if (!(link->flags & IFF_UP)) {
r = link_up_can(link);
r = link_up(link);
if (r < 0) {
link_enter_failed(link);
return r;

View File

@ -1376,7 +1376,7 @@ static int link_up_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link)
return 1;
}
static int link_up(Link *link) {
int link_up(Link *link) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
int r;

View File

@ -207,6 +207,7 @@ DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
int link_get(Manager *m, int ifindex, Link **ret);
int link_up(Link *link);
int link_down(Link *link, link_netlink_message_handler_t callback);
void link_enter_failed(Link *link);