mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
networkd: address add support to configure flags (#4201)
This patch enables to configure IFA_F_HOMEADDRESS IFA_F_NODAD IFA_F_MANAGETEMPADDR IFA_F_NOPREFIXROUTE IFA_F_MCAUTOJOIN
This commit is contained in:
parent
3157b2d9d2
commit
e63be0847c
@ -695,6 +695,57 @@
|
||||
which is then configured to use them explicitly.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>HomeAddress=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean argument. Designates this address the "home address" as defined in
|
||||
<ulink url="https://tools.ietf.org/html/rfc6275">RFC 6275</ulink>.
|
||||
Supported only on IPv6. Defaults to false.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>DuplicateAddressDetection=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean argument. Do not perform Duplicate Address Detection
|
||||
<ulink url="https://tools.ietf.org/html/rfc4862">RFC 4862</ulink> when adding this address.
|
||||
Supported only on IPv6. Defaults to false.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ManageTemporaryAddress=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean argument. If true the kernel manage temporary addresses created
|
||||
from this one as template on behalf of Privacy Extensions
|
||||
<ulink url="https://tools.ietf.org/html/rfc3041">RFC 3041</ulink>. For this to become
|
||||
active, the use_tempaddr sysctl setting has to be set to a value greater than zero.
|
||||
The given address needs to have a prefix length of 64. This flag allows to use privacy
|
||||
extensions in a manually configured network, just like if stateless auto-configuration
|
||||
was active. Defaults to false. </para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>PrefixRoute=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean argument. When adding or modifying an IPv6 address, the userspace
|
||||
application needs a way to suppress adding a prefix route. This is for example relevant
|
||||
together with IFA_F_MANAGERTEMPADDR, where userspace creates autoconf generated addresses,
|
||||
but depending on on-link, no route for the prefix should be added. Defaults to false.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>AutoJoin=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean argument. Joining multicast group on ethernet level via
|
||||
<command>ip maddr</command> command would not work if we have an Ethernet switch that does
|
||||
IGMP snooping since the switch would not replicate multicast packets on ports that did not
|
||||
have IGMP reports for the multicast addresses. Linux vxlan interfaces created via
|
||||
<command>ip link add vxlan</command> or networkd's netdev kind vxlan have the group option
|
||||
that enables then to do the required join. By extending ip address command with option
|
||||
<literal>autojoin</literal> we can get similar functionality for openvswitch (OVS) vxlan
|
||||
interfaces as well as other tunneling mechanisms that need to receive multicast traffic.
|
||||
Defaults to <literal>no</literal>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -1052,6 +1052,10 @@ typedef int32_t key_serial_t;
|
||||
#define ETHERTYPE_LLDP 0x88cc
|
||||
#endif
|
||||
|
||||
#ifndef IFA_F_MCAUTOJOIN
|
||||
#define IFA_F_MCAUTOJOIN 0x400
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "missing_syscall.h"
|
||||
|
@ -571,6 +571,21 @@ int address_configure(
|
||||
|
||||
address->flags |= IFA_F_PERMANENT;
|
||||
|
||||
if (address->home_address)
|
||||
address->flags |= IFA_F_HOMEADDRESS;
|
||||
|
||||
if (address->duplicate_address_detection)
|
||||
address->flags |= IFA_F_NODAD;
|
||||
|
||||
if (address->manage_temporary_address)
|
||||
address->flags |= IFA_F_MANAGETEMPADDR;
|
||||
|
||||
if (address->prefix_route)
|
||||
address->flags |= IFA_F_NOPREFIXROUTE;
|
||||
|
||||
if (address->autojoin)
|
||||
address->flags |= IFA_F_MCAUTOJOIN;
|
||||
|
||||
r = sd_rtnl_message_addr_set_flags(req, (address->flags & 0xff));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not set flags: %m");
|
||||
@ -856,6 +871,50 @@ int config_parse_lifetime(const char *unit,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_address_flags(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;
|
||||
_cleanup_address_free_ Address *n = NULL;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(section);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = address_new_static(network, section_line, &n);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = parse_boolean(rvalue);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse address flag, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (streq(lvalue, "HomeAddress"))
|
||||
n->home_address = r;
|
||||
else if (streq(lvalue, "DuplicateAddressDetection"))
|
||||
n->duplicate_address_detection = r;
|
||||
else if (streq(lvalue, "ManageTemporaryAddress"))
|
||||
n->manage_temporary_address = r;
|
||||
else if (streq(lvalue, "PrefixRoute"))
|
||||
n->prefix_route = r;
|
||||
else if (streq(lvalue, "AutoJoin"))
|
||||
n->autojoin = r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool address_is_ready(const Address *a) {
|
||||
assert(a);
|
||||
|
||||
|
@ -53,6 +53,11 @@ struct Address {
|
||||
union in_addr_union in_addr_peer;
|
||||
|
||||
bool ip_masquerade_done:1;
|
||||
bool duplicate_address_detection;
|
||||
bool manage_temporary_address;
|
||||
bool home_address;
|
||||
bool prefix_route;
|
||||
bool autojoin;
|
||||
|
||||
LIST_FIELDS(Address, addresses);
|
||||
};
|
||||
@ -77,3 +82,4 @@ int config_parse_address(const char *unit, const char *filename, unsigned line,
|
||||
int config_parse_broadcast(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);
|
||||
int config_parse_label(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);
|
||||
int config_parse_lifetime(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);
|
||||
int config_parse_address_flags(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);
|
||||
|
@ -70,6 +70,11 @@ Address.Peer, config_parse_address,
|
||||
Address.Broadcast, config_parse_broadcast, 0, 0
|
||||
Address.Label, config_parse_label, 0, 0
|
||||
Address.PreferredLifetime, config_parse_lifetime, 0, 0
|
||||
Address.HomeAddress, config_parse_address_flags, 0, 0
|
||||
Address.DuplicateAddressDetection, config_parse_address_flags, 0, 0
|
||||
Address.ManageTemporaryAddress, config_parse_address_flags, 0, 0
|
||||
Address.PrefixRoute, config_parse_address_flags, 0, 0
|
||||
Address.AutoJoin, config_parse_address_flags, 0, 0
|
||||
Route.Gateway, config_parse_gateway, 0, 0
|
||||
Route.Destination, config_parse_destination, 0, 0
|
||||
Route.Source, config_parse_destination, 0, 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user