diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-07-19 22:46:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-19 22:46:31 +0200 |
commit | 4573b1707a5d7a60711b9348a7267ab9a068bbfb (patch) | |
tree | deb60025a24af537a00388885de094a5d8b79c89 /python | |
parent | 061c7ac507dd2af5e62b90c558fecac823f2d9ae (diff) | |
parent | fabd8b4bbb150b237121cd3eeffa8026903a159e (diff) | |
download | vyos-1x-4573b1707a5d7a60711b9348a7267ab9a068bbfb.tar.gz vyos-1x-4573b1707a5d7a60711b9348a7267ab9a068bbfb.zip |
Merge pull request #506 from jjakob/broadcast-fix-T2519
interface: T2519: add broadcast address when adding IPv4 addresses
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/ifconfig/interface.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index c73a3bbf8..8d7b247fc 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -667,10 +667,12 @@ class Interface(Control): if addr in self._addr: return False + addr_is_v4 = is_ipv4(addr) + # we can't have both DHCP and static IPv4 addresses assigned for a in self._addr: if ( ( addr == 'dhcp' and a != 'dhcpv6' and is_ipv4(a) ) or - ( a == 'dhcp' and addr != 'dhcpv6' and is_ipv4(addr) ) ): + ( a == 'dhcp' and addr != 'dhcpv6' and addr_is_v4 ) ): raise ConfigError(( "Can't configure both static IPv4 and DHCP address " "on the same interface")) @@ -681,7 +683,8 @@ class Interface(Control): elif addr == 'dhcpv6': self.dhcp.v6.set() elif not is_intf_addr_assigned(self.ifname, addr): - self._cmd(f'ip addr add "{addr}" dev "{self.ifname}"') + self._cmd(f'ip addr add "{addr}" ' + f'{"brd + " if addr_is_v4 else ""}dev "{self.ifname}"') else: return False |