summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/networkd-link.c49
-rw-r--r--src/network/networkd-setlink.c20
-rw-r--r--src/network/networkd-setlink.h2
3 files changed, 23 insertions, 48 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 44d62fe857..dfd1806786 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1207,53 +1207,6 @@ int link_down(Link *link, link_netlink_message_handler_t callback) {
return 0;
}
-static int link_group_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_message_warning_errno(link, m, r, "Could not set group for the interface");
-
- return 1;
-}
-
-static int link_set_group(Link *link) {
- _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
- int r;
-
- assert(link);
- assert(link->network);
- assert(link->manager);
- assert(link->manager->rtnl);
-
- if (!link->network->group_set)
- return 0;
-
- log_link_debug(link, "Setting group");
-
- 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_netlink_message_append_u32(req, IFLA_GROUP, link->network->group);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not set link group: %m");
-
- r = netlink_call_async(link->manager->rtnl, NULL, req, link_group_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_handle_bound_to_list(Link *link) {
Link *l;
int r;
@@ -1890,7 +1843,7 @@ static int link_configure(Link *link) {
if (r < 0)
return r;
- r = link_set_group(link);
+ r = link_request_to_set_group(link);
if (r < 0)
return r;
diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c
index a030eebd0d..1120c5b922 100644
--- a/src/network/networkd-setlink.c
+++ b/src/network/networkd-setlink.c
@@ -12,6 +12,7 @@
static const char *const set_link_operation_table[_SET_LINK_OPERATION_MAX] = {
[SET_LINK_FLAGS] = "link flags",
+ [SET_LINK_GROUP] = "interface group",
[SET_LINK_MAC] = "MAC address",
[SET_LINK_MTU] = "MTU",
};
@@ -51,6 +52,10 @@ static int link_set_flags_handler(sd_netlink *rtnl, sd_netlink_message *m, Link
return set_link_handler_internal(rtnl, m, link, SET_LINK_FLAGS, true);
}
+static int link_set_group_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
+ return set_link_handler_internal(rtnl, m, link, SET_LINK_GROUP, true);
+}
+
static int link_set_mac_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
return set_link_handler_internal(rtnl, m, link, SET_LINK_MAC, true);
}
@@ -129,6 +134,11 @@ static int link_configure(
break;
}
+ case SET_LINK_GROUP:
+ r = sd_netlink_message_append_u32(req, IFLA_GROUP, link->network->group);
+ if (r < 0)
+ return log_link_debug_errno(link, r, "Could not append IFLA_GROUP attribute: %m");
+ break;
case SET_LINK_MAC:
r = sd_netlink_message_append_ether_addr(req, IFLA_ADDRESS, link->network->mac);
if (r < 0)
@@ -224,6 +234,16 @@ int link_request_to_set_flags(Link *link) {
return link_request_set_link(link, SET_LINK_FLAGS, link_set_flags_handler, NULL);
}
+int link_request_to_set_group(Link *link) {
+ assert(link);
+ assert(link->network);
+
+ if (!link->network->group_set)
+ return 0;
+
+ return link_request_set_link(link, SET_LINK_GROUP, link_set_group_handler, NULL);
+}
+
int link_request_to_set_mac(Link *link) {
assert(link);
assert(link->network);
diff --git a/src/network/networkd-setlink.h b/src/network/networkd-setlink.h
index 0d6315a76f..42934c3590 100644
--- a/src/network/networkd-setlink.h
+++ b/src/network/networkd-setlink.h
@@ -8,6 +8,7 @@ typedef struct Request Request;
typedef enum SetLinkOperation {
SET_LINK_FLAGS, /* Setting IFF_NOARP or friends. */
+ SET_LINK_GROUP, /* Setting interface group. */
SET_LINK_MAC, /* Setting MAC address. */
SET_LINK_MTU, /* Setting MTU. */
_SET_LINK_OPERATION_MAX,
@@ -15,6 +16,7 @@ typedef enum SetLinkOperation {
} SetLinkOperation;
int link_request_to_set_flags(Link *link);
+int link_request_to_set_group(Link *link);
int link_request_to_set_mac(Link *link);
int link_request_to_set_mtu(Link *link, uint32_t mtu);