1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-04 21:47:31 +03:00

Merge pull request #19715 from yuwata/network-link-group

network: allow to set Group=0 in [Link] section
This commit is contained in:
Yu Watanabe 2021-05-25 13:29:50 +09:00 committed by GitHub
commit 5de0d10bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 15 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)
@ -110,7 +110,7 @@ Network.LLMNR, config_parse_resolve_support,
Network.MulticastDNS, config_parse_resolve_support, 0, offsetof(Network, mdns)
Network.DNSOverTLS, config_parse_dns_over_tls_mode, 0, offsetof(Network, dns_over_tls_mode)
Network.DNSSEC, config_parse_dnssec_mode, 0, offsetof(Network, dnssec_mode)
Network.DNSSECNegativeTrustAnchors, config_parse_dnssec_negative_trust_anchors, 0, 0
Network.DNSSECNegativeTrustAnchors, config_parse_dnssec_negative_trust_anchors, 0, offsetof(Network, dnssec_negative_trust_anchors)
Network.NTP, config_parse_ntp, 0, offsetof(Network, ntp)
Network.IPForward, config_parse_address_family_with_kernel, 0, offsetof(Network, ip_forward)
Network.IPMasquerade, config_parse_ip_masquerade, 0, offsetof(Network, ip_masquerade)

View File

@ -753,12 +753,13 @@ int config_parse_domains(
void *data,
void *userdata) {
Network *n = data;
Network *n = userdata;
int r;
assert(n);
assert(filename);
assert(lvalue);
assert(rvalue);
assert(n);
if (isempty(rvalue)) {
n->search_domains = ordered_set_free(n->search_domains);
@ -837,6 +838,7 @@ int config_parse_hostname(
assert(filename);
assert(lvalue);
assert(rvalue);
assert(hostname);
r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &hn, userdata);
if (r < 0)
@ -882,6 +884,7 @@ int config_parse_timezone(
assert(filename);
assert(lvalue);
assert(rvalue);
assert(datap);
r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &tz, userdata);
if (r < 0)
@ -914,6 +917,7 @@ int config_parse_dns(
assert(filename);
assert(lvalue);
assert(rvalue);
assert(n);
if (isempty(rvalue)) {
for (unsigned i = 0; i < n->n_dns; i++)
@ -970,15 +974,16 @@ int config_parse_dnssec_negative_trust_anchors(
void *data,
void *userdata) {
Network *n = data;
Set **nta = data;
int r;
assert(n);
assert(filename);
assert(lvalue);
assert(rvalue);
assert(nta);
if (isempty(rvalue)) {
n->dnssec_negative_trust_anchors = set_free_free(n->dnssec_negative_trust_anchors);
*nta = set_free_free(*nta);
return 0;
}
@ -1003,7 +1008,7 @@ int config_parse_dnssec_negative_trust_anchors(
continue;
}
r = set_ensure_consume(&n->dnssec_negative_trust_anchors, &dns_name_hash_ops, TAKE_PTR(w));
r = set_ensure_consume(nta, &dns_name_hash_ops, TAKE_PTR(w));
if (r < 0)
return log_oom();
}
@ -1024,9 +1029,10 @@ int config_parse_ntp(
char ***l = data;
int r;
assert(l);
assert(filename);
assert(lvalue);
assert(rvalue);
assert(l);
if (isempty(rvalue)) {
*l = strv_free(*l);
@ -1079,11 +1085,16 @@ int config_parse_required_for_online(
void *data,
void *userdata) {
Network *network = data;
Network *network = userdata;
LinkOperationalStateRange range;
bool required = true;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(network);
if (isempty(rvalue)) {
network->required_for_online = true;
network->required_operstate_for_online = LINK_OPERSTATE_RANGE_DEFAULT;
@ -1110,6 +1121,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);