1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Merge pull request #12586 from ssahani/route-properties

Route properties
This commit is contained in:
Yu Watanabe 2019-05-18 10:31:37 +09:00 committed by GitHub
commit e7b621ee1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 14 deletions

View File

@ -1235,6 +1235,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>TTLPropagate=</varname></term>
<listitem>
<para>Takes a boolean. When true enables TTL propagation at Label Switched Path (LSP) egress.
When unset, the kernel's default will be used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>MTUBytes=</varname></term>
<listitem>

View File

@ -622,23 +622,23 @@ static const NLType rtnl_route_types[] = {
[RTA_PRIORITY] = { .type = NETLINK_TYPE_U32 },
[RTA_PREFSRC] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */
[RTA_METRICS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_metrics_type_system},
/* [RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
*/
[RTA_MULTIPATH] = { .size = sizeof(struct rtnexthop) },
[RTA_FLOW] = { .type = NETLINK_TYPE_U32 }, /* 6? */
/*
RTA_CACHEINFO,
RTA_TABLE,
RTA_MARK,
RTA_MFC_STATS,
RTA_VIA,
RTA_NEWDST,
*/
[RTA_CACHEINFO] = { .size = sizeof(struct rta_cacheinfo) },
[RTA_TABLE] = { .type = NETLINK_TYPE_U32 },
[RTA_MARK] = { .type = NETLINK_TYPE_U32 },
[RTA_MFC_STATS] = { .type = NETLINK_TYPE_U64 },
[RTA_VIA] = { .type = NETLINK_TYPE_U32 },
[RTA_NEWDST] = { .type = NETLINK_TYPE_U32 },
[RTA_PREF] = { .type = NETLINK_TYPE_U8 },
/*
RTA_ENCAP_TYPE,
RTA_ENCAP,
*/
[RTA_EXPIRES] = { .type = NETLINK_TYPE_U32 },
[RTA_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 },
[RTA_ENCAP] = { .type = NETLINK_TYPE_NESTED }, /* Multiple type systems i.e. LWTUNNEL_ENCAP_MPLS/LWTUNNEL_ENCAP_IP/LWTUNNEL_ENCAP_ILA etc... */
[RTA_UID] = { .type = NETLINK_TYPE_U32 },
[RTA_TTL_PROPAGATE] = { .type = NETLINK_TYPE_U8 },
[RTA_IP_PROTO] = { .type = NETLINK_TYPE_U8 },
[RTA_SPORT] = { .type = NETLINK_TYPE_U16 },
[RTA_DPORT] = { .type = NETLINK_TYPE_U16 },
};
static const NLTypeSystem rtnl_route_type_system = {

View File

@ -130,6 +130,7 @@ Route.InitialCongestionWindow, config_parse_tcp_window,
Route.InitialAdvertisedReceiveWindow, config_parse_tcp_window, 0, 0
Route.QuickAck, config_parse_quickack, 0, 0
Route.FastOpenNoCookie, config_parse_fast_open_no_cookie, 0, 0
Route.TTLPropagate, config_parse_route_ttl_propagate, 0, 0
DHCP.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier)
DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns)
DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp)

View File

@ -61,6 +61,7 @@ int route_new(Route **ret) {
.quickack = -1,
.fast_open_no_cookie = -1,
.gateway_onlink = -1,
.ttl_propagate = -1,
};
*ret = TAKE_PTR(route);
@ -617,6 +618,12 @@ int route_configure(
return log_link_error_errno(link, r, "Could not append RTA_OIF attribute: %m");
}
if (route->ttl_propagate >= 0) {
r = sd_netlink_message_append_u8(req, RTA_TTL_PROPAGATE, route->ttl_propagate);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_TTL_PROPAGATE attribute: %m");
}
r = sd_netlink_message_open_container(req, RTA_METRICS);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_METRICS attribute: %m");
@ -1300,6 +1307,45 @@ int config_parse_route_mtu(
return 0;
}
int config_parse_route_ttl_propagate(
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_(route_free_or_set_invalidp) Route *n = NULL;
int r, k;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
k = parse_boolean(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k,
"Failed to parse TTLPropagate= value, ignoring: %s", rvalue);
return 0;
}
n->ttl_propagate = k;
TAKE_PTR(n);
return 0;
}
int route_section_verify(Route *route, Network *network) {
if (section_is_invalid(route->section))
return -EINVAL;

View File

@ -18,6 +18,7 @@ struct Route {
int family;
int quickack;
int fast_open_no_cookie;
int ttl_propagate;
unsigned char dst_prefixlen;
unsigned char src_prefixlen;
@ -77,4 +78,5 @@ CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
CONFIG_PARSER_PROTOTYPE(config_parse_quickack);
CONFIG_PARSER_PROTOTYPE(config_parse_fast_open_no_cookie);
CONFIG_PARSER_PROTOTYPE(config_parse_route_ttl_propagate);
CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);

View File

@ -83,6 +83,7 @@ QuickAck=
FastOpenNoCookie=
Source=
Metric=
TTLPropagate=
[Network]
IPv6DuplicateAddressDetection=
IPMasquerade=