From 062c2eea3ac6cb57f9caae49aec40c68af2fed2a Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Thu, 14 Feb 2019 21:05:17 +0530 Subject: [PATCH 1/2] networkd: ipv6ra allow to ignore addresses Allows to ignore prefixes. ``` UseAutonomousPrefix= UseOnLinkPrefix= ``` closes #9582 --- man/systemd.network.xml | 17 +++++++++++++++++ src/network/networkd-ndisc.c | 11 +++++++---- src/network/networkd-network-gperf.gperf | 2 ++ src/network/networkd-network.c | 2 ++ src/network/networkd-network.h | 2 ++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index ee464ffff4c..f6826234959 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1504,6 +1504,23 @@ + + + UseAutonomousPrefix= + + When true (the default), the autonomous prefix received in the Router Advertisement will be used and take + precedence over any statically configured ones. + + + + + UseOnLinkPrefix= + + When true (the default), the onlink prefix received in the Router Advertisement will be used and take + precedence over any statically configured ones. + + + diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index e5b8d115551..b8384dfe537 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -527,10 +527,13 @@ static void ndisc_router_process_options(Link *link, sd_ndisc_router *rt) { return; } - if (flags & ND_OPT_PI_FLAG_ONLINK) - (void) ndisc_router_process_onlink_prefix(link, rt); - if (flags & ND_OPT_PI_FLAG_AUTO) - (void) ndisc_router_process_autonomous_prefix(link, rt); + if (link->network->ipv6_accept_ra_use_onlink_prefix) + if (flags & ND_OPT_PI_FLAG_ONLINK) + (void) ndisc_router_process_onlink_prefix(link, rt); + + if (link->network->ipv6_accept_ra_use_autonomous_prefix) + if (flags & ND_OPT_PI_FLAG_AUTO) + (void) ndisc_router_process_autonomous_prefix(link, rt); break; } diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 5d8aede5930..20397dc7d44 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -146,6 +146,8 @@ DHCP.IAID, config_parse_iaid, DHCP.ListenPort, config_parse_uint16, 0, offsetof(Network, dhcp_client_port) DHCP.RapidCommit, config_parse_bool, 0, offsetof(Network, rapid_commit) DHCP.ForceDHCPv6PDOtherInformation, config_parse_bool, 0, offsetof(Network, dhcp6_force_pd_other_information) +IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix) +IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix) IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns) IPv6AcceptRA.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, ipv6_accept_ra_use_domains) IPv6AcceptRA.RouteTable, config_parse_uint32, 0, offsetof(Network, ipv6_accept_ra_route_table) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 12344ec695b..623a00e6680 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -206,6 +206,8 @@ int network_load_one(Manager *manager, const char *filename) { .multicast = -1, .allmulticast = -1, .ipv6_accept_ra_use_dns = true, + .ipv6_accept_ra_use_autonomous_prefix = true, + .ipv6_accept_ra_use_onlink_prefix = true, .ipv6_accept_ra_route_table = RT_TABLE_MAIN, }; diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index f6e62cdd799..8ec6b6b689f 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -209,6 +209,8 @@ struct Network { uint32_t ipv6_mtu; bool ipv6_accept_ra_use_dns; + bool ipv6_accept_ra_use_autonomous_prefix; + bool ipv6_accept_ra_use_onlink_prefix; bool active_slave; bool primary_slave; DHCPUseDomains ipv6_accept_ra_use_domains; From 24433ffa6d2491c22dfc13cfd4827df852ea5318 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Thu, 14 Feb 2019 21:10:59 +0530 Subject: [PATCH 2/2] Add to fuzzer --- test/fuzz/fuzz-network-parser/directives.network | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index 209132f239a..822b2c20038 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -176,6 +176,8 @@ Prefix= UseDomains= RouteTable= UseDNS= +UseAutonomousPrefix= +UseOnLinkPrefix= [DHCPServer] EmitNTP= PoolSize=