mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
network: change link group type to int32
Both linux kernel kernel and iproute2 uses int32 type for a link group attribute and -1 has a special meaning, so setting it to 4294967295 would make it -1 in the linux kernel (and ip link cmd).
This commit is contained in:
parent
e44a47d186
commit
10af8bb24b
|
@ -209,7 +209,7 @@
|
|||
<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. Takes an unsigned integer in the range 0…4294967295. Defaults to unset.
|
||||
performed at once. Takes an unsigned integer in the range 0…2147483647. Defaults to unset.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -1256,6 +1256,7 @@ int config_parse_link_group(
|
|||
|
||||
Network *network = userdata;
|
||||
int r;
|
||||
int32_t group;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
|
@ -1263,19 +1264,24 @@ int config_parse_link_group(
|
|||
assert(network);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
network->group = 0;
|
||||
network->group_set = false;
|
||||
network->group = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = safe_atou32(rvalue, &network->group);
|
||||
r = safe_atoi32(rvalue, &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;
|
||||
if (group < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Value of Group= must be in the range 0…2147483647, ignoring assignment: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
network->group = group;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,8 +96,7 @@ struct Network {
|
|||
/* [Link] section */
|
||||
struct ether_addr *mac;
|
||||
uint32_t mtu;
|
||||
uint32_t group;
|
||||
bool group_set;
|
||||
int32_t group;
|
||||
int arp;
|
||||
int multicast;
|
||||
int allmulticast;
|
||||
|
|
|
@ -458,7 +458,7 @@ static int link_configure(
|
|||
break;
|
||||
}
|
||||
case SET_LINK_GROUP:
|
||||
r = sd_netlink_message_append_u32(req, IFLA_GROUP, link->network->group);
|
||||
r = sd_netlink_message_append_u32(req, IFLA_GROUP, (uint32_t) link->network->group);
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "Could not append IFLA_GROUP attribute: %m");
|
||||
break;
|
||||
|
@ -770,7 +770,7 @@ int link_request_to_set_group(Link *link) {
|
|||
assert(link);
|
||||
assert(link->network);
|
||||
|
||||
if (!link->network->group_set)
|
||||
if (link->network->group < 0)
|
||||
return 0;
|
||||
|
||||
return link_request_set_link(link, SET_LINK_GROUP, link_set_group_handler, NULL);
|
||||
|
|
Loading…
Reference in a new issue