mirror of
https://github.com/systemd/systemd
synced 2024-10-15 20:45:09 +00:00
networkd: VXLAN support keyword 'inherit' for TTL
This commit is contained in:
parent
cd43199671
commit
f4a8ca329a
|
@ -559,10 +559,10 @@
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>TTL=</varname></term>
|
<term><varname>TTL=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>A fixed Time To Live N on Virtual eXtensible Local
|
<para>A fixed Time To Live N on Virtual eXtensible Local Area Network packets.
|
||||||
Area Network packets. N is a number in the range 1–255. 0
|
Takes <literal>inherit</literal> or a number in the range 0–255. 0 is a special
|
||||||
is a special value meaning that packets inherit the TTL
|
value meaning inherit the inner protocol's TTL value. <literal>inherit</literal>
|
||||||
value.</para>
|
means that it will inherit the outer protocol's TTL value.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -102,7 +102,7 @@ VXLAN.Group, config_parse_vxlan_address,
|
||||||
VXLAN.Local, config_parse_vxlan_address, 0, offsetof(VxLan, local)
|
VXLAN.Local, config_parse_vxlan_address, 0, offsetof(VxLan, local)
|
||||||
VXLAN.Remote, config_parse_vxlan_address, 0, offsetof(VxLan, remote)
|
VXLAN.Remote, config_parse_vxlan_address, 0, offsetof(VxLan, remote)
|
||||||
VXLAN.TOS, config_parse_unsigned, 0, offsetof(VxLan, tos)
|
VXLAN.TOS, config_parse_unsigned, 0, offsetof(VxLan, tos)
|
||||||
VXLAN.TTL, config_parse_unsigned, 0, offsetof(VxLan, ttl)
|
VXLAN.TTL, config_parse_vxlan_ttl, 0, offsetof(VxLan, ttl)
|
||||||
VXLAN.MacLearning, config_parse_bool, 0, offsetof(VxLan, learning)
|
VXLAN.MacLearning, config_parse_bool, 0, offsetof(VxLan, learning)
|
||||||
VXLAN.ARPProxy, config_parse_bool, 0, offsetof(VxLan, arp_proxy)
|
VXLAN.ARPProxy, config_parse_bool, 0, offsetof(VxLan, arp_proxy)
|
||||||
VXLAN.ReduceARPProxy, config_parse_bool, 0, offsetof(VxLan, arp_proxy)
|
VXLAN.ReduceARPProxy, config_parse_bool, 0, offsetof(VxLan, arp_proxy)
|
||||||
|
|
|
@ -65,7 +65,11 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LINK attribute: %m");
|
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LINK attribute: %m");
|
||||||
|
|
||||||
if (v->ttl != 0) {
|
if (v->inherit) {
|
||||||
|
r = sd_netlink_message_append_flag(m, IFLA_VXLAN_TTL_INHERIT);
|
||||||
|
if (r < 0)
|
||||||
|
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_TTL_INHERIT attribute: %m");
|
||||||
|
} else {
|
||||||
r = sd_netlink_message_append_u8(m, IFLA_VXLAN_TTL, v->ttl);
|
r = sd_netlink_message_append_u8(m, IFLA_VXLAN_TTL, v->ttl);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_TTL attribute: %m");
|
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_TTL attribute: %m");
|
||||||
|
@ -288,6 +292,47 @@ int config_parse_flow_label(const char *unit,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int config_parse_vxlan_ttl(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) {
|
||||||
|
VxLan *v = userdata;
|
||||||
|
unsigned f;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(filename);
|
||||||
|
assert(lvalue);
|
||||||
|
assert(rvalue);
|
||||||
|
assert(data);
|
||||||
|
|
||||||
|
if (streq(rvalue, "inherit"))
|
||||||
|
v->inherit = true;
|
||||||
|
else {
|
||||||
|
r = safe_atou(rvalue, &f);
|
||||||
|
if (r < 0) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||||
|
"Failed to parse VXLAN TTL '%s', ignoring assignment: %m", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f > 255) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||||
|
"Invalid VXLAN TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
v->ttl = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
|
static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
|
||||||
VxLan *v = VXLAN(netdev);
|
VxLan *v = VXLAN(netdev);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ struct VxLan {
|
||||||
bool remote_csum_rx;
|
bool remote_csum_rx;
|
||||||
bool group_policy;
|
bool group_policy;
|
||||||
bool generic_protocol_extension;
|
bool generic_protocol_extension;
|
||||||
|
bool inherit;
|
||||||
|
|
||||||
struct ifla_vxlan_port_range port_range;
|
struct ifla_vxlan_port_range port_range;
|
||||||
};
|
};
|
||||||
|
@ -69,3 +70,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_vxlan_address);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_port_range);
|
CONFIG_PARSER_PROTOTYPE(config_parse_port_range);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_flow_label);
|
CONFIG_PARSER_PROTOTYPE(config_parse_flow_label);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_df);
|
CONFIG_PARSER_PROTOTYPE(config_parse_df);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_vxlan_ttl);
|
||||||
|
|
Loading…
Reference in a new issue