From 5dfdb8b1008f7198073a6b2c10e506fa1cf5a816 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 20 Dec 2020 17:05:05 +0100 Subject: Revert "dhcpv6: T3134: add missing duid support" This reverts commit 9541355433e202fade4692851bffa33ba9d48f44. --- interface-definitions/include/dhcpv6-options.xml.i | 12 ------ interface-definitions/include/interface-mac.xml.i | 2 +- python/vyos/ifconfig/interface.py | 44 ++++++++-------------- smoketest/scripts/cli/base_interfaces_test.py | 21 ----------- src/validators/ipv6-duid | 27 ------------- src/validators/mac-address | 2 + 6 files changed, 18 insertions(+), 90 deletions(-) delete mode 100755 src/validators/ipv6-duid diff --git a/interface-definitions/include/dhcpv6-options.xml.i b/interface-definitions/include/dhcpv6-options.xml.i index 997d4f2a4..9a1016956 100644 --- a/interface-definitions/include/dhcpv6-options.xml.i +++ b/interface-definitions/include/dhcpv6-options.xml.i @@ -4,18 +4,6 @@ DHCPv6 client settings/options - - - DHCP unique identifier (DUID) to be sent by dhcpv6 client - - <h:h:h:h:h:h:h:h:h:h:h:h:h:h:h:h> - DHCP unique identifier (DUID) - - - - - - Acquire only config parameters, no address diff --git a/interface-definitions/include/interface-mac.xml.i b/interface-definitions/include/interface-mac.xml.i index 87dc5fb60..e277de85c 100644 --- a/interface-definitions/include/interface-mac.xml.i +++ b/interface-definitions/include/interface-mac.xml.i @@ -3,7 +3,7 @@ Media Access Control (MAC) address - macaddr + h:h:h:h:h:h Hardware (MAC) address diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 18357125b..7026223b1 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -13,15 +13,14 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see . +from netifaces import interfaces import os import re import json import jmespath -from binascii import unhexlify from copy import deepcopy from glob import glob -from netifaces import interfaces from ipaddress import IPv4Network from ipaddress import IPv6Address @@ -734,7 +733,7 @@ class Interface(Control): >>> Interface('eth0').set_proxy_arp_pvlan(1) """ self.set_interface('proxy_arp_pvlan', enable) - + def get_addr(self): """ @@ -890,7 +889,7 @@ class Interface(Control): # drop all interface addresses first self.flush_addrs() - + ifname = self.ifname for bridge, bridge_config in bridge_dict.items(): @@ -904,18 +903,18 @@ class Interface(Control): # set bridge port path priority if 'priority' in bridge_config: self.set_path_cost(bridge_config['priority']) - + vlan_filter = 0 vlan_add = set() - + del_ifname_vlan_ids = get_vlan_ids(ifname) bridge_vlan_filter = Section.klass(bridge)(bridge, create=True).get_vlan_filter() - + if bridge_vlan_filter: if 1 in del_ifname_vlan_ids: del_ifname_vlan_ids.remove(1) vlan_filter = 1 - + for vlan in del_ifname_vlan_ids: cmd = f'bridge vlan del dev {ifname} vid {vlan}' self._cmd(cmd) @@ -938,13 +937,13 @@ class Interface(Control): cmd = f'bridge vlan add dev {self.ifname} vid {vlan} master' self._cmd(cmd) vlan_add.add(vlan) - + if vlan_filter: # Setting VLAN ID for the bridge for vlan in vlan_add: cmd = f'bridge vlan add dev {bridge} vid {vlan} self' self._cmd(cmd) - + # enable/disable Vlan Filter # When the VLAN aware option is not detected, the setting of `bridge` should not be overwritten Section.klass(bridge)(bridge, create=True).set_vlan_filter(vlan_filter) @@ -1000,22 +999,11 @@ class Interface(Control): ifname = self.ifname config_file = f'/run/dhcp6c/dhcp6c.{ifname}.conf' - duid_file = f'/var/lib/dhcpv6/dhcp6c_duid' if enable and 'disable' not in self._config: render(config_file, 'dhcp-client/ipv6.tmpl', self._config) - duid = dict_search('dhcpv6_options.duid', self._config) - if duid != None: - # DUID file path hardcoded and must be written as binary. - # https://github.com/jinmei/wide-dhcpv6/blob/24ee2a4f0009bc/dhcp6c.h#L33 - with open(duid_file, 'wb') as f: - f.write(unhexlify(duid.replace(':', '').encode())) - else: - if os.path.isfile(duid_file): - os.remove(duid_file) - # We must ignore any return codes. This is required to enable DHCPv6-PD # for interfaces which are yet not up and running. return self._popen(f'systemctl restart dhcp6c@{ifname}.service') @@ -1024,8 +1012,6 @@ class Interface(Control): if os.path.isfile(config_file): os.remove(config_file) - if os.path.isfile(duid_file): - os.remove(duid_file) def get_tc_config(self,objectname): # Parse configuration @@ -1055,7 +1041,7 @@ class Interface(Control): # Remove existing mirroring rules self.del_tc_qdisc(ifname,'ingress','ffff:') self.del_tc_qdisc(ifname,'prio','1:') - + # Setting up packet mirroring ingress_mirror = dict_search('mirror.ingress', self._config) # if interface does yet not exist bail out early and @@ -1067,7 +1053,7 @@ class Interface(Control): # Export the mirrored traffic to the interface mirror_cmd = f'tc filter add dev {ifname} parent ffff: protocol all prio 10 u32 match u32 0 0 flowid 1:1 action mirred egress mirror dev {ingress_mirror}' self._cmd(mirror_cmd) - + egress_mirror = dict_search('mirror.egress', self._config) # if interface does yet not exist bail out early and # add it later @@ -1085,14 +1071,14 @@ class Interface(Control): # https://man7.org/linux/man-pages/man8/tc-mirred.8.html ifname = self._config['ifname'] mirror_rules = self._config.get('is_monitor_intf') - + # Remove existing mirroring rules # The rule must be completely deleted first for rule in mirror_rules: for intf, dire in rule.items(): self.del_tc_qdisc(intf,'ingress','ffff:') self.del_tc_qdisc(intf,'prio','1:') - + # Setting mirror rules for rule in mirror_rules: for intf, dire in rule.items(): @@ -1279,11 +1265,11 @@ class Interface(Control): if 'is_bridge_member' in config: bridge_dict = config.get('is_bridge_member') self.add_to_bridge(bridge_dict) - + # Re-set rules for the mirror monitoring interface if 'is_monitor_intf' in config: self.apply_mirror_of_monitor() - + # remove no longer required 802.1ad (Q-in-Q VLANs) ifname = config['ifname'] for vif_s_id in config.get('vif_s_remove', {}): diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py index f8e9835af..fd37cb2a1 100644 --- a/smoketest/scripts/cli/base_interfaces_test.py +++ b/smoketest/scripts/cli/base_interfaces_test.py @@ -399,27 +399,6 @@ class BasicInterfaceTest: tmp = read_file(f'/proc/sys/net/ipv6/conf/{interface}/dad_transmits') self.assertEqual(dad_transmits, tmp) - def test_ipv6_dhcpv6_duid(self): - """ Test interface base IPv6 options """ - if not self._test_ipv6: - return None - - for interface in self._interfaces: - path = self._base_path + [interface] - for option in self._options.get(interface, []): - self.session.set(path + option.split()) - - # Options - duid = '0e:00:00:01:00:01:27:71:db:f0:00:50:56:bf:c5:6d' - self.session.set(path + ['dhcpv6-options', 'duid', duid]) - - self.session.commit() - - for interface in self._interfaces: - with open('/var/lib/dhcpv6/dhcp6c_duid', 'rb') as f: - tmp = hexlify(f.read()).decode() - - self.assertEqual(duid.replace(':',''), tmp) def test_ipv6_dhcpv6_pd(self): """ Test interface base IPv6 options """ diff --git a/src/validators/ipv6-duid b/src/validators/ipv6-duid deleted file mode 100755 index c0233b2f1..000000000 --- a/src/validators/ipv6-duid +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2020 VyOS maintainers and contributors -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 or later as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import re -import sys - -pattern = "^([0-9A-Fa-f]{2}:){15}([0-9A-Fa-f]{2})$" - -if __name__ == '__main__': - if len(sys.argv) != 2: - sys.exit(1) - if not re.match(pattern, sys.argv[1]): - sys.exit(1) - sys.exit(0) diff --git a/src/validators/mac-address b/src/validators/mac-address index 201dcaf12..b2d3496f4 100755 --- a/src/validators/mac-address +++ b/src/validators/mac-address @@ -17,8 +17,10 @@ import re import sys + pattern = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$" + if __name__ == '__main__': if len(sys.argv) != 2: sys.exit(1) -- cgit v1.2.3