Skip to content

Commit

Permalink
Check for duplicate before adding link local IP
Browse files Browse the repository at this point in the history
  • Loading branch information
sumukhatv committed Feb 5, 2021
1 parent edc2196 commit e2ecf4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions scripts/neighbor_advertiser
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,10 @@ def get_vlan_addresses(vlan_interface):
keys = line.split()
if keys[0] == 'inet6':
ip = IPNetwork(keys[1])
if str(ip.ip).startswith("fe80"):
if str(ip.ip).startswith("fe80") and str(ip.ip) not in ipv6_addr:
# Link local ipv6 address
ipv6_addr.append(str(ip.ip))
ipv6_prefix.append(ip.prefixlen)
ipv6_prefix.append('128')
except Exception:
log.log_error('failed to get %s addresses from o.s.' % vlan_interface)
pass
Expand Down
5 changes: 4 additions & 1 deletion tests/neighbor_advertiser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def test_neighbor_advertiser_slice(self, set_up):
subprocess.check_output(cmd.split())
cmd = "sudo ip link add Vlan2000 type dummy"
subprocess.check_output(cmd.split())
cmd = "sudo ip -6 address add dev Vlan2000 scope link fe80::1e43:dfaf:fe2e:1800/64"
subprocess.check_output(cmd.split())
output = neighbor_advertiser.construct_neighbor_advertiser_slice()
expected_output = dict(
{
Expand All @@ -50,7 +52,8 @@ def test_neighbor_advertiser_slice(self, set_up):
{'macAddr': '1d:34:db:16:a6:00', 'ipAddr': '192.168.0.10', 'ipPrefixLen': '21'}
],
'ipv6AddrMappings': [
{'macAddr': '1d:34:db:16:a6:00', 'ipAddr': 'fc02:1011::1', 'ipPrefixLen': '64'}
{'macAddr': '1d:34:db:16:a6:00', 'ipAddr': 'fc02:1011::1', 'ipPrefixLen': '64'},
{'macAddr': '1d:34:db:16:a6:00', 'ipAddr': 'fe80::1e43:dfaf:fe2e:1800', 'ipPrefixLen': '128'}
],
'vxlanId': '2000',
'vlanId': '2000',
Expand Down

0 comments on commit e2ecf4c

Please sign in to comment.