Skip to content

Commit

Permalink
[minigraph.py]: Force /128 prefix for server IPv6 loopbacks (#6524)
Browse files Browse the repository at this point in the history
Meet the requirement for the MUX_CABLE table that IPv6 loopbacks have a /128 prefix

Note that this change only affects the MUX_CABLE table, all other tables continue to use the loopback address provided in minigraph.

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
  • Loading branch information
theasianpianist authored and daall committed Jan 22, 2021
1 parent 4220f1c commit 1923920
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,10 @@ def get_mux_cable_entries(mux_cable_ports, neighbors, devices):
server_ipv4_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv4_lo_addr))
entry['server_ipv4'] = str(server_ipv4_lo_prefix)

if 'lo_addr_v6' in devices[neighbor]:
entry['server_ipv6'] = devices[neighbor]['lo_addr_v6']
if 'lo_addr_v6' in devices[neighbor] and devices[neighbor]['lo_addr_v6'] is not None:
server_ipv6_lo_addr = devices[neighbor]['lo_addr_v6'].split('/')[0]
server_ipv6_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv6_lo_addr))
entry['server_ipv6'] = str(server_ipv6_lo_prefix)
mux_cable_table[intf] = entry
else:
print("Warning: no server IPv4 loopback found for {}, skipping mux cable table entry".format(neighbor))
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/simple-sample-graph-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
<d5p1:IPPrefix>10.10.10.1/32</d5p1:IPPrefix>
</Address>
<AddressV6 xmlns:d5p1="Microsoft.Search.Autopilot.NetMux">
<d5p1:IPPrefix>fe80::0001/128</d5p1:IPPrefix>
<d5p1:IPPrefix>fe80::0001/80</d5p1:IPPrefix>
</AddressV6>
<ManagementAddress xmlns:d5p1="Microsoft.Search.Autopilot.NetMux">
<d5p1:IPPrefix>10.0.0.1/32</d5p1:IPPrefix>
Expand Down
6 changes: 3 additions & 3 deletions src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_minigraph_neighbor_metadata(self):
'server1': {
'hwsku': 'server-sku',
'lo_addr': '10.10.10.1/32',
'lo_addr_v6': 'fe80::0001/128',
'lo_addr_v6': 'fe80::0001/80',
'mgmt_addr': '10.0.0.1/32',
'type': 'Server'
},
Expand Down Expand Up @@ -275,12 +275,12 @@ def test_minigraph_mux_cable_table(self):
'Ethernet4': {
'state': 'auto',
'server_ipv4': '10.10.10.1/32',
'server_ipv6': 'fe80::0001/128'
'server_ipv6': 'fe80::1/128'
},
'Ethernet8': {
'state': 'auto',
'server_ipv4': '10.10.10.2/32',
'server_ipv6': 'fe80::0002/128'
'server_ipv6': 'fe80::2/128'
}
}

Expand Down

0 comments on commit 1923920

Please sign in to comment.