1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-27 18:04:05 +03:00

network: introduce link_request_to_set_bridge_vlan()

This will be used in later commits.
This commit is contained in:
Yu Watanabe 2021-05-25 17:32:28 +09:00
parent bfd7fb09cf
commit 8252fb4439
2 changed files with 45 additions and 0 deletions

View File

@ -15,6 +15,7 @@ static const char *const set_link_operation_table[_SET_LINK_OPERATION_MAX] = {
[SET_LINK_ADDRESS_GENERATION_MODE] = "IPv6LL address generation mode",
[SET_LINK_BOND] = "bond configurations",
[SET_LINK_BRIDGE] = "bridge configurations",
[SET_LINK_BRIDGE_VLAN] = "bridge VLAN configurations",
[SET_LINK_FLAGS] = "link flags",
[SET_LINK_GROUP] = "interface group",
[SET_LINK_MAC] = "MAC address",
@ -77,6 +78,10 @@ static int link_set_bridge_handler(sd_netlink *rtnl, sd_netlink_message *m, Link
return set_link_handler_internal(rtnl, m, link, SET_LINK_BRIDGE, true);
}
static int link_set_bridge_vlan_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
return set_link_handler_internal(rtnl, m, link, SET_LINK_BRIDGE_VLAN, true);
}
static int link_set_flags_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
return set_link_handler_internal(rtnl, m, link, SET_LINK_FLAGS, true);
}
@ -296,6 +301,31 @@ static int link_configure(
if (r < 0)
return log_link_debug_errno(link, r, "Could not close IFLA_PROTINFO container: %m");
break;
case SET_LINK_BRIDGE_VLAN:
r = sd_rtnl_message_link_set_family(req, AF_BRIDGE);
if (r < 0)
return log_link_debug_errno(link, r, "Could not set message family: %m");
r = sd_netlink_message_open_container(req, IFLA_AF_SPEC);
if (r < 0)
return log_link_debug_errno(link, r, "Could not open IFLA_AF_SPEC container: %m");
if (!link->network->bridge) {
/* master needs BRIDGE_FLAGS_SELF flag*/
r = sd_netlink_message_append_u16(req, IFLA_BRIDGE_FLAGS, BRIDGE_FLAGS_SELF);
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_BRIDGE_FLAGS attribute: %m");
}
r = bridge_vlan_append_info(link, req, link->network->pvid, link->network->br_vid_bitmap, link->network->br_untagged_bitmap);
if (r < 0)
return log_link_debug_errno(link, r, "Could not append VLANs: %m");
r = sd_netlink_message_close_container(req);
if (r < 0)
return log_link_debug_errno(link, r, "Could not close IFLA_AF_SPEC container: %m");
break;
case SET_LINK_FLAGS: {
unsigned ifi_change = 0, ifi_flags = 0;
@ -527,6 +557,19 @@ int link_request_to_set_bridge(Link *link) {
return link_request_set_link(link, SET_LINK_BRIDGE, link_set_bridge_handler, NULL);
}
int link_request_to_set_bridge_vlan(Link *link) {
assert(link);
assert(link->network);
if (!link->network->use_br_vlan)
return 0;
if (!link->network->bridge && !streq_ptr(link->kind, "bridge"))
return 0;
return link_request_set_link(link, SET_LINK_BRIDGE_VLAN, link_set_bridge_vlan_handler, NULL);
}
int link_request_to_set_flags(Link *link) {
assert(link);
assert(link->network);

View File

@ -10,6 +10,7 @@ typedef enum SetLinkOperation {
SET_LINK_ADDRESS_GENERATION_MODE, /* Setting IPv6LL address generation mode. */
SET_LINK_BOND, /* Setting bond configs. */
SET_LINK_BRIDGE, /* Setting bridge configs. */
SET_LINK_BRIDGE_VLAN, /* Setting bridge vlan configs. */
SET_LINK_FLAGS, /* Setting IFF_NOARP or friends. */
SET_LINK_GROUP, /* Setting interface group. */
SET_LINK_MAC, /* Setting MAC address. */
@ -22,6 +23,7 @@ typedef enum SetLinkOperation {
int link_request_to_set_addrgen_mode(Link *link);
int link_request_to_set_bond(Link *link);
int link_request_to_set_bridge(Link *link);
int link_request_to_set_bridge_vlan(Link *link);
int link_request_to_set_flags(Link *link);
int link_request_to_set_group(Link *link);
int link_request_to_set_mac(Link *link);