1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

network: allow to set Group=0 in [Link] section

Previously, when a link has already in a numbered group, we cannot
remove the link from the group.

This also fixes the range mentioned in the man page.
This commit is contained in:
Yu Watanabe 2021-05-21 14:11:36 +09:00
parent 07c0e5eeaf
commit f0c09831bd
5 changed files with 45 additions and 6 deletions

View File

@ -204,10 +204,10 @@
<varlistentry>
<term><varname>Group=</varname></term>
<listitem>
<para>Link groups are similar to port ranges found in managed switches.
When network interfaces are added to a numbered group, operations on
all the interfaces from that group can be performed at once. An unsigned
integer in the range 0…4294967294. Defaults to unset.</para>
<para>Link groups are similar to port ranges found in managed switches. When network interfaces
are added to a numbered group, operations on all the interfaces from that group can be
performed at once. Takes an unsigned integer in the range 0…4294967295. Defaults to unset.
</para>
</listitem>
</varlistentry>
<varlistentry>

View File

@ -1454,7 +1454,7 @@ static int link_set_group(Link *link) {
assert(link->manager);
assert(link->manager->rtnl);
if (link->network->group <= 0)
if (!link->network->group_set)
return 0;
log_link_debug(link, "Setting group");

View File

@ -59,7 +59,7 @@ Match.Architecture, config_parse_net_condition,
Match.Firmware, config_parse_net_condition, CONDITION_FIRMWARE, offsetof(Network, conditions)
Link.MACAddress, config_parse_hwaddr, 0, offsetof(Network, mac)
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(Network, mtu)
Link.Group, config_parse_uint32, 0, offsetof(Network, group)
Link.Group, config_parse_link_group, 0, 0
Link.ARP, config_parse_tristate, 0, offsetof(Network, arp)
Link.Multicast, config_parse_tristate, 0, offsetof(Network, multicast)
Link.AllMulticast, config_parse_tristate, 0, offsetof(Network, allmulticast)

View File

@ -1110,6 +1110,43 @@ int config_parse_required_for_online(
return 0;
}
int config_parse_link_group(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Network *network = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(network);
if (isempty(rvalue)) {
network->group = 0;
network->group_set = false;
return 0;
}
r = safe_atou32(rvalue, &network->group);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse Group=, ignoring assignment: %s", rvalue);
return 0;
}
network->group_set = true;
return 0;
}
DEFINE_CONFIG_PARSE_ENUM(config_parse_required_family_for_online, link_required_address_family, AddressFamily,
"Failed to parse RequiredFamilyForOnline= setting");

View File

@ -97,6 +97,7 @@ struct Network {
struct ether_addr *mac;
uint32_t mtu;
uint32_t group;
bool group_set;
int arp;
int multicast;
int allmulticast;
@ -359,6 +360,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_required_family_for_online);
CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_activation_policy);
CONFIG_PARSER_PROTOTYPE(config_parse_link_group);
const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);