summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-03-30 19:16:52 +0200
committerChristian Poessinger <christian@poessinger.com>2022-03-30 19:16:52 +0200
commitbafb1973d906707cb571385e994a949d0d90b645 (patch)
tree4fc8d570ffda4d743c14d24e9ed1a4643b7a5bd8
parentc82db71fa2ce0aa0b1768c51b78e790ee291836f (diff)
downloadvyos-1x-bafb1973d906707cb571385e994a949d0d90b645.tar.gz
vyos-1x-bafb1973d906707cb571385e994a949d0d90b645.zip
vyos.ifconfig: make add_addr() method more reader firendly
-rwxr-xr-xpython/vyos/ifconfig/interface.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 8ce851cdb..4fda1c0a9 100755
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -1089,8 +1089,11 @@ class Interface(Control):
elif addr == 'dhcpv6':
self.set_dhcpv6(True)
elif not is_intf_addr_assigned(self.ifname, addr):
- self._cmd(f'ip addr add "{addr}" '
- f'{"brd + " if addr_is_v4 else ""}dev "{self.ifname}"')
+ tmp = f'ip addr add {addr} dev {self.ifname}'
+ # Add broadcast address for IPv4
+ if is_ipv4(addr): tmp += ' brd +'
+
+ self._cmd(tmp)
else:
return False