From 72d1a565df33402114cc0e0833dd427824b1377d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Nov 2021 11:29:13 +0100 Subject: [PATCH 1/4] Disable temporary address generation when renderer is NetworkManager and ipv6-privacy is false --- src/nm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nm.c b/src/nm.c index ddea8c44e..0b02c853a 100644 --- a/src/nm.c +++ b/src/nm.c @@ -819,6 +819,8 @@ write_nm_conf_access_point(const NetplanNetDefinition* def, const char* rootdir, g_key_file_set_string(kf, "ipv6", "addr-gen-mode", addr_gen_mode_str(def->ip6_addr_gen_mode)); if (def->ip6_privacy) g_key_file_set_integer(kf, "ipv6", "ip6-privacy", 2); + else + g_key_file_set_integer(kf, "ipv6", "ip6-privacy", 0); if (def->gateway6) g_key_file_set_string(kf, "ipv6", "gateway", def->gateway6); if (def->ip6_nameservers) { From 62eec894a3dd0632f310f4a3c3058cc31c7bb222 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 15 Nov 2021 14:22:53 +0100 Subject: [PATCH 2/4] Fix unit tests when ip6-privacy=0 --- tests/generator/test_common.py | 10 ++++++++++ tests/generator/test_dhcp_overrides.py | 1 + tests/generator/test_routing.py | 7 +++++++ tests/generator/test_tunnels.py | 3 +++ tests/generator/test_vlans.py | 1 + tests/parser/test_keyfile.py | 4 ++++ 6 files changed, 26 insertions(+) diff --git a/tests/generator/test_common.py b/tests/generator/test_common.py index 47c1fdc11..f4bd7f4c3 100644 --- a/tests/generator/test_common.py +++ b/tests/generator/test_common.py @@ -1048,6 +1048,7 @@ def test_eth_dhcp6(self): [ipv6] method=auto +ip6-privacy=0 '''}) def test_eth_dhcp4_and_6(self): @@ -1069,6 +1070,7 @@ def test_eth_dhcp4_and_6(self): [ipv6] method=auto +ip6-privacy=0 '''}) def test_ip6_addr_gen_mode(self): @@ -1096,6 +1098,7 @@ def test_ip6_addr_gen_mode(self): [ipv6] method=auto addr-gen-mode=1 +ip6-privacy=0 ''', 'enblue': '''[connection] id=netplan-enblue @@ -1111,6 +1114,7 @@ def test_ip6_addr_gen_mode(self): [ipv6] method=auto addr-gen-mode=0 +ip6-privacy=0 '''}) def test_ip6_addr_gen_token(self): @@ -1139,6 +1143,7 @@ def test_ip6_addr_gen_token(self): method=auto addr-gen-mode=0 token=::2 +ip6-privacy=0 ''', 'enblue': '''[connection] id=netplan-enblue @@ -1155,6 +1160,7 @@ def test_ip6_addr_gen_token(self): method=auto addr-gen-mode=0 token=::2 +ip6-privacy=0 '''}) def test_eth_manual_addresses(self): @@ -1184,6 +1190,7 @@ def test_eth_manual_addresses(self): [ipv6] method=manual address1=2001:FFfe::1/64 +ip6-privacy=0 '''}) self.assert_networkd({}) self.assert_nm_udev(None) @@ -1214,6 +1221,7 @@ def test_eth_manual_addresses_dhcp(self): [ipv6] method=manual address1=2001:FFfe::1/64 +ip6-privacy=0 '''}) def test_eth_ipv6_privacy(self): @@ -1264,6 +1272,7 @@ def test_gateway(self): [ipv6] method=manual address1=2001:FFfe::1/64 +ip6-privacy=0 gateway=2001:FFfe::2 '''}) @@ -1298,6 +1307,7 @@ def test_nameserver(self): [ipv6] method=manual +ip6-privacy=0 dns=1234::FFFF; dns-search=lab;kitchen; ''', diff --git a/tests/generator/test_dhcp_overrides.py b/tests/generator/test_dhcp_overrides.py index 7d5bb613a..bfaf428a5 100644 --- a/tests/generator/test_dhcp_overrides.py +++ b/tests/generator/test_dhcp_overrides.py @@ -422,5 +422,6 @@ def test_override_default_metric_v6(self): [ipv6] method=auto +ip6-privacy=0 route-metric=6666 '''}) diff --git a/tests/generator/test_routing.py b/tests/generator/test_routing.py index 89ec7cecc..c20e02db4 100644 --- a/tests/generator/test_routing.py +++ b/tests/generator/test_routing.py @@ -844,6 +844,7 @@ def test_route_v6_single(self): [ipv6] method=manual address1=2001:f00f:f00f::2/64 +ip6-privacy=0 route1=2001:dead:beef::2/64,2001:beef:beef::1 '''}) @@ -875,6 +876,7 @@ def test_route_v6_multiple(self): [ipv6] method=manual address1=2001:f00f:f00f::2/64 +ip6-privacy=0 route1=2001:dead:beef::2/64,2001:beef:beef::1 route2=2001:dead:feed::2/64,2001:beef:beef::2,1000 '''}) @@ -904,6 +906,7 @@ def test_route_v6_default(self): [ipv6] method=manual address1=2001:dead:beef::2/64 +ip6-privacy=0 route1=::/0,2001:beef:beef::1 '''}) @@ -948,6 +951,7 @@ def test_routes_mixed(self): [ipv6] method=manual address1=2001:f00f::2/128 +ip6-privacy=0 route1=2001:dead:beef::2/64,2001:beef:beef::1,997 route2=2001:f00f:f00f::fe/64,2001:beef:feed::1 '''}) @@ -1272,6 +1276,7 @@ def test_use_routes_v6(self): [ipv6] method=auto +ip6-privacy=0 ignore-auto-routes=true never-default=true '''}) @@ -1302,6 +1307,7 @@ def test_default_metric_v4(self): [ipv6] method=auto +ip6-privacy=0 '''}) def test_default_metric_v6(self): @@ -1329,5 +1335,6 @@ def test_default_metric_v6(self): [ipv6] method=auto +ip6-privacy=0 route-metric=5050 '''}) diff --git a/tests/generator/test_tunnels.py b/tests/generator/test_tunnels.py index 534c2babe..e772e9c31 100644 --- a/tests/generator/test_tunnels.py +++ b/tests/generator/test_tunnels.py @@ -408,6 +408,7 @@ def test_simple_multi_pass(self): [ipv6] method=manual address1=2001:de:ad:be:ef:ca:fe:1/128 +ip6-privacy=0 ''', 'br0.nmconnection': '''[connection] id=netplan-br0 @@ -977,6 +978,7 @@ def test_sit_he(self): [ipv6] method=manual address1=2001:cafe:face::1/64 +ip6-privacy=0 ''', 'he-ipv6': '''[connection] id=netplan-he-ipv6 @@ -994,6 +996,7 @@ def test_sit_he(self): [ipv6] method=manual address1=2001:dead:beef::2/64 +ip6-privacy=0 gateway=2001:dead:beef::1 '''}) diff --git a/tests/generator/test_vlans.py b/tests/generator/test_vlans.py index 63827fdfc..dd047f7d8 100644 --- a/tests/generator/test_vlans.py +++ b/tests/generator/test_vlans.py @@ -302,5 +302,6 @@ def test_vlan_sriov(self): [ipv6] method=auto +ip6-privacy=0 '''}) self.assert_nm_udev(None) diff --git a/tests/parser/test_keyfile.py b/tests/parser/test_keyfile.py index ba1300356..43bb77e80 100644 --- a/tests/parser/test_keyfile.py +++ b/tests/parser/test_keyfile.py @@ -68,6 +68,7 @@ def test_keyfile_gsm(self): [ipv6] dns-search= +ip6-privacy=0 method=auto '''.format(UUID)) self.assert_netplan({UUID: '''network: @@ -265,6 +266,7 @@ def test_keyfile_method_manual(self): method=manual address1=1:2:3::9/128 gateway=6:6::6 +ip6-privacy=0 route1=dead:beef::1/128,2001:1234::2 route1_options=unknown=invalid, @@ -997,6 +999,7 @@ def test_keyfile_customer_A2(self): [ipv6] method=auto +ip6-privacy=0 addr-gen-mode=1 '''.format(UUID)) self.assert_netplan({UUID: '''network: @@ -1059,6 +1062,7 @@ def test_keyfile_netplan0103_compat(self): address2=dcba::beef/56 dns=1::cafe;2::cafe; dns-search=wallaceandgromit.com; +ip6-privacy=0 method=manual route1=1:2:3:4:5:6:7:8/64,8:7:6:5:4:3:2:1,3 route2=2001::1000/56,2001::1111,1 From 22a9752ac3993d843c86ef91b5b52a16cad70dae Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Le Roux Date: Wed, 1 Dec 2021 14:36:57 +0100 Subject: [PATCH 3/4] Fix unit tests when ip6-privacy=0 (part 2) --- tests/generator/base.py | 2 +- tests/generator/test_vlans.py | 1 + tests/parser/test_keyfile.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/generator/base.py b/tests/generator/base.py index a45b5e569..eb3a99a5e 100644 --- a/tests/generator/base.py +++ b/tests/generator/base.py @@ -76,7 +76,7 @@ ConfigureWithoutCarrier=yes\n' NM_WG = '[connection]\nid=netplan-wg0\ntype=wireguard\ninterface-name=wg0\n\n[wireguard]\nprivate-key=%s\nlisten-port=%s\n%s\ \n\n[ipv4]\nmethod=manual\naddress1=15.15.15.15/24\ngateway=20.20.20.21\n\n[ipv6]\nmethod=manual\naddress1=\ -2001:de:ad:be:ef:ca:fe:1/128\n' +2001:de:ad:be:ef:ca:fe:1/128\nip6-privacy=0\n' ND_WG = '[NetDev]\nName=wg0\nKind=wireguard\n\n[WireGuard]\nPrivateKey%s\nListenPort=%s\n%s\n' ND_VLAN = '[NetDev]\nName=%s\nKind=vlan\n\n[VLAN]\nId=%d\n' SD_WPA = '''[Unit] diff --git a/tests/generator/test_vlans.py b/tests/generator/test_vlans.py index dd047f7d8..f728d351f 100644 --- a/tests/generator/test_vlans.py +++ b/tests/generator/test_vlans.py @@ -203,6 +203,7 @@ def test_vlan(self): [ipv6] method=auto +ip6-privacy=0 '''}) self.assert_nm_udev(None) diff --git a/tests/parser/test_keyfile.py b/tests/parser/test_keyfile.py index 43bb77e80..35cbe734b 100644 --- a/tests/parser/test_keyfile.py +++ b/tests/parser/test_keyfile.py @@ -95,6 +95,7 @@ def test_keyfile_gsm(self): gsm.home-only: "true" ipv4.dns-search: "" ipv6.dns-search: "" + ipv6.ip6-privacy: "0" '''.format(UUID, UUID)}) def test_keyfile_cdma(self): @@ -318,6 +319,7 @@ def test_keyfile_method_manual(self): ipv4.method: "manual" ipv4.address1: "1.2.3.4/24,8.8.8.8" ipv6.dns-search: "bar.local" + ipv6.ip6-privacy: "0" ipv6.route1: "dead:beef::1/128,2001:1234::2" ipv6.route1_options: "unknown=invalid," proxy._: "" @@ -1027,6 +1029,7 @@ def test_keyfile_customer_A2(self): ipv4.address1: "10.10.28.159/24" ipv4.address2: "10.10.164.254/24" ipv4.address3: "10.10.246.132/24" + ipv6.ip6-privacy: "0" ipv6.addr-gen-mode: "1" '''.format(UUID, UUID)}) @@ -1135,5 +1138,6 @@ def test_keyfile_netplan0103_compat(self): ipv4.route4: "3.3.3.3/6,0.0.0.0,4" ipv4.route4_options: "cwnd=10,mtu=1492,src=1.2.3.4" ipv6.dns-search: "wallaceandgromit.com;" + ipv6.ip6-privacy: "0" proxy._: "" '''.format(UUID, UUID)}) From 7ca04c20202dc7d3113f3e35f8d43962b1748959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20M=C3=A4rdian?= Date: Fri, 10 Dec 2021 14:50:18 +0100 Subject: [PATCH 4/4] test-keyfile: mark ip6-privacy=0 as a default setting --- tests/parser/base.py | 2 ++ tests/parser/test_keyfile.py | 8 -------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/parser/base.py b/tests/parser/base.py index 0cfc00596..b1e34f010 100644 --- a/tests/parser/base.py +++ b/tests/parser/base.py @@ -132,6 +132,8 @@ def normalize_keyfile(self, file_contents): # Normalize lines if k == 'addr-gen-mode': v = v.replace('1', 'stable-privacy').replace('0', 'eui64') + elif k == 'ip6-privacy' and v == '0': + continue elif k == 'wake-on-lan' and v == '1': continue elif k == 'stp' and v == 'true': diff --git a/tests/parser/test_keyfile.py b/tests/parser/test_keyfile.py index 35cbe734b..ba1300356 100644 --- a/tests/parser/test_keyfile.py +++ b/tests/parser/test_keyfile.py @@ -68,7 +68,6 @@ def test_keyfile_gsm(self): [ipv6] dns-search= -ip6-privacy=0 method=auto '''.format(UUID)) self.assert_netplan({UUID: '''network: @@ -95,7 +94,6 @@ def test_keyfile_gsm(self): gsm.home-only: "true" ipv4.dns-search: "" ipv6.dns-search: "" - ipv6.ip6-privacy: "0" '''.format(UUID, UUID)}) def test_keyfile_cdma(self): @@ -267,7 +265,6 @@ def test_keyfile_method_manual(self): method=manual address1=1:2:3::9/128 gateway=6:6::6 -ip6-privacy=0 route1=dead:beef::1/128,2001:1234::2 route1_options=unknown=invalid, @@ -319,7 +316,6 @@ def test_keyfile_method_manual(self): ipv4.method: "manual" ipv4.address1: "1.2.3.4/24,8.8.8.8" ipv6.dns-search: "bar.local" - ipv6.ip6-privacy: "0" ipv6.route1: "dead:beef::1/128,2001:1234::2" ipv6.route1_options: "unknown=invalid," proxy._: "" @@ -1001,7 +997,6 @@ def test_keyfile_customer_A2(self): [ipv6] method=auto -ip6-privacy=0 addr-gen-mode=1 '''.format(UUID)) self.assert_netplan({UUID: '''network: @@ -1029,7 +1024,6 @@ def test_keyfile_customer_A2(self): ipv4.address1: "10.10.28.159/24" ipv4.address2: "10.10.164.254/24" ipv4.address3: "10.10.246.132/24" - ipv6.ip6-privacy: "0" ipv6.addr-gen-mode: "1" '''.format(UUID, UUID)}) @@ -1065,7 +1059,6 @@ def test_keyfile_netplan0103_compat(self): address2=dcba::beef/56 dns=1::cafe;2::cafe; dns-search=wallaceandgromit.com; -ip6-privacy=0 method=manual route1=1:2:3:4:5:6:7:8/64,8:7:6:5:4:3:2:1,3 route2=2001::1000/56,2001::1111,1 @@ -1138,6 +1131,5 @@ def test_keyfile_netplan0103_compat(self): ipv4.route4: "3.3.3.3/6,0.0.0.0,4" ipv4.route4_options: "cwnd=10,mtu=1492,src=1.2.3.4" ipv6.dns-search: "wallaceandgromit.com;" - ipv6.ip6-privacy: "0" proxy._: "" '''.format(UUID, UUID)})