mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
network: introduce link_up_now()
This is currently not used. Preparation for later commit.
This commit is contained in:
parent
77064620d7
commit
2bb7fe554f
@ -1211,7 +1211,7 @@ int link_request_to_bring_up_or_down(Link *link, bool up) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int link_down_now_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
static int link_up_or_down_now_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *msg) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
@ -1225,7 +1225,7 @@ static int link_down_now_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *
|
||||
|
||||
r = sd_netlink_message_get_errno(m);
|
||||
if (r < 0)
|
||||
log_link_message_warning_errno(link, m, r, "Could not bring down interface, ignoring");
|
||||
log_link_message_warning_errno(link, m, r, msg);
|
||||
|
||||
r = link_call_getlink(link, get_link_update_flag_handler);
|
||||
if (r < 0) {
|
||||
@ -1237,7 +1237,15 @@ static int link_down_now_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *
|
||||
return 0;
|
||||
}
|
||||
|
||||
int link_down_now(Link *link) {
|
||||
static int link_up_now_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
return link_up_or_down_now_handler(rtnl, m, link, "Could not bring up interface, ignoring");
|
||||
}
|
||||
|
||||
static int link_down_now_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
return link_up_or_down_now_handler(rtnl, m, link, "Could not bring down interface, ignoring");
|
||||
}
|
||||
|
||||
int link_up_or_down_now(Link *link, bool up) {
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
int r;
|
||||
|
||||
@ -1245,17 +1253,18 @@ int link_down_now(Link *link) {
|
||||
assert(link->manager);
|
||||
assert(link->manager->rtnl);
|
||||
|
||||
log_link_debug(link, "Bringing link down");
|
||||
log_link_debug(link, "Bringing link %s", up ? "up" : "down");
|
||||
|
||||
r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
|
||||
|
||||
r = sd_rtnl_message_link_set_flags(req, 0, IFF_UP);
|
||||
r = sd_rtnl_message_link_set_flags(req, up ? IFF_UP : 0, IFF_UP);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not set link flags: %m");
|
||||
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, link_down_now_handler,
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req,
|
||||
up ? link_up_now_handler : link_down_now_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_warning_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
@ -24,6 +24,13 @@ int link_request_to_activate(Link *link);
|
||||
|
||||
int link_request_to_bring_up_or_down(Link *link, bool up);
|
||||
|
||||
int link_down_now(Link *link);
|
||||
int link_up_or_down_now(Link *link, bool up);
|
||||
static inline int link_up_now(Link *link) {
|
||||
return link_up_or_down_now(link, true);
|
||||
}
|
||||
static inline int link_down_now(Link *link) {
|
||||
return link_up_or_down_now(link, false);
|
||||
}
|
||||
|
||||
int link_down_slave_links(Link *link);
|
||||
int link_remove(Link *link);
|
||||
|
Loading…
Reference in New Issue
Block a user