mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
network: Add support to select an IPv4 link-local start address
This commit is contained in:
parent
db835e5d0e
commit
34b63c9e45
@ -398,6 +398,18 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>IPv4LLStartAddress=</varname></term>
|
||||
<listitem>
|
||||
<para>Specifies the first IPv4 link-local address to try. Takes an IPv4 address
|
||||
for example 169.254.1.2, from the link-local address range 169.254.0.0/16.
|
||||
This setting may be useful if the device should always have the same address
|
||||
as long as there is no address conflict. When unset, a random address will be automatically selected.
|
||||
Defaults to unset.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>IPv4LLRoute=</varname></term>
|
||||
<listitem>
|
||||
|
@ -263,3 +263,44 @@ int config_parse_ipv4ll(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_ipv4ll_address(
|
||||
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) {
|
||||
|
||||
union in_addr_union a;
|
||||
struct in_addr *ipv4ll_address = ASSERT_PTR(data);
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
*ipv4ll_address = (struct in_addr) {};
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = in_addr_from_string(AF_INET, rvalue, &a);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse %s=, ignoring assignment: %s", lvalue, rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (!in4_addr_is_link_local(&a.in)) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Not a IPv4 link local address, ignoring assignment: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*ipv4ll_address = a.in;
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,3 +11,4 @@ int ipv4ll_configure(Link *link);
|
||||
int ipv4ll_update_mac(Link *link);
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4ll);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4ll_address);
|
||||
|
@ -106,6 +106,7 @@ Network.DHCPServer, config_parse_bool,
|
||||
Network.LinkLocalAddressing, config_parse_link_local_address_family, 0, offsetof(Network, link_local)
|
||||
Network.IPv6LinkLocalAddressGenerationMode, config_parse_ipv6_link_local_address_gen_mode, 0, offsetof(Network, ipv6ll_address_gen_mode)
|
||||
Network.IPv6StableSecretAddress, config_parse_in_addr_non_null, AF_INET6, offsetof(Network, ipv6ll_stable_secret)
|
||||
Network.IPv4LLStartAddress, config_parse_ipv4ll_address, 0, offsetof(Network, ipv4ll_start_address)
|
||||
Network.IPv4LLRoute, config_parse_bool, 0, offsetof(Network, ipv4ll_route)
|
||||
Network.DefaultRouteOnDevice, config_parse_bool, 0, offsetof(Network, default_route_on_device)
|
||||
Network.LLDP, config_parse_lldp_mode, 0, offsetof(Network, lldp_mode)
|
||||
|
@ -208,6 +208,7 @@ struct Network {
|
||||
AddressFamily link_local;
|
||||
IPv6LinkLocalAddressGenMode ipv6ll_address_gen_mode;
|
||||
struct in6_addr ipv6ll_stable_secret;
|
||||
struct in_addr ipv4ll_start_address;
|
||||
bool ipv4ll_route;
|
||||
|
||||
/* IPv6 RA support */
|
||||
|
@ -235,6 +235,7 @@ VXLAN=
|
||||
L2TP=
|
||||
MACsec=
|
||||
LinkLocalAddressing=
|
||||
IPv4LLStartAddress=
|
||||
IPv6LinkLocalAddressGenerationMode=
|
||||
IPv6StableSecretAddress=
|
||||
ConfigureWithoutCarrier=
|
||||
|
Loading…
Reference in New Issue
Block a user