Skip to content

Commit

Permalink
Fix can't access IPV6 address via management interface because 'defau…
Browse files Browse the repository at this point in the history
…lt' route table does not add to route lookup issue. (sonic-net#17281) (sonic-net#17676)
  • Loading branch information
mssonicbld authored Jan 4, 2024
1 parent 76d8ff0 commit 38c5e68
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
16 changes: 12 additions & 4 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,29 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
{% set vrf_table = '5000' %}
vrf mgmt
{% endif %}
{% set force_mgmt_route_priority = 32764 %}
########## management network policy routing rules
# management port up rules
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev {{ name }} table {{ vrf_table }} metric 201
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add {{ prefix | network }}/{{ prefix | prefixlen }} dev {{ name }} table {{ vrf_table }}
up ip {{ '-4' if prefix | ipv4 else '-6' }} rule add pref 32765 from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
up ip {{ '-4' if prefix | ipv4 else '-6' }} rule add pref {{ force_mgmt_route_priority + 1 }} from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
up ip rule add pref 32764 to {{ route }} table {{ vrf_table }}
up ip rule add pref {{ force_mgmt_route_priority }} to {{ route }} table {{ vrf_table }}
{% endfor %}
{% if prefix | ipv6 and vrf_table == 'default'%}
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref {{ force_mgmt_route_priority + 3 }} lookup {{ vrf_table }}
{% endif %}
# management port down rules
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev {{ name }} table {{ vrf_table }}
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} dev {{ name }} table {{ vrf_table }}
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete pref 32765 from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete pref {{ force_mgmt_route_priority + 1 }} from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
pre-down ip rule delete pref 32764 to {{ route }} table {{ vrf_table }}
pre-down ip rule delete pref {{ force_mgmt_route_priority }} to {{ route }} table {{ vrf_table }}
{% endfor %}
{% if prefix | ipv6 and vrf_table == 'default'%}
pre-down ip -6 rule delete pref {{ force_mgmt_route_priority + 3 }} lookup {{ vrf_table }}
{% endif %}
{# TODO: COPP policy type rules #}
{% endfor %}
{% else %}
Expand Down
3 changes: 3 additions & 0 deletions src/sonic-config-engine/tests/sample_output/py2/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ iface eth0 inet6 static
up ip -6 route add default via 2603:10e2:0:2902::1 dev eth0 table default metric 201
up ip -6 route add 2603:10e2:0:2902::/64 dev eth0 table default
up ip -6 rule add pref 32765 from 2603:10e2:0:2902::8/128 table default
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref 32767 lookup default
# management port down rules
pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default
pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:2902::8/128 table default
pre-down ip -6 rule delete pref 32767 lookup default
#
source /etc/network/interfaces.d/*
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ iface eth1 inet6 static
up ip -6 route add default via 2603:10e2:0:abcd::1 dev eth1 table default metric 201
up ip -6 route add 2603:10e2:0:abcd::/64 dev eth1 table default
up ip -6 rule add pref 32765 from 2603:10e2:0:abcd::8/128 table default
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref 32767 lookup default
# management port down rules
pre-down ip -6 route delete default via 2603:10e2:0:abcd::1 dev eth1 table default
pre-down ip -6 route delete 2603:10e2:0:abcd::/64 dev eth1 table default
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:abcd::8/128 table default
pre-down ip -6 rule delete pref 32767 lookup default
iface eth0 inet6 static
address 2603:10e2:0:2902::8
netmask 64
Expand All @@ -67,10 +70,13 @@ iface eth0 inet6 static
up ip -6 route add default via 2603:10e2:0:2902::1 dev eth0 table default metric 201
up ip -6 route add 2603:10e2:0:2902::/64 dev eth0 table default
up ip -6 rule add pref 32765 from 2603:10e2:0:2902::8/128 table default
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref 32767 lookup default
# management port down rules
pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default
pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:2902::8/128 table default
pre-down ip -6 rule delete pref 32767 lookup default
#
source /etc/network/interfaces.d/*
#
Expand Down
3 changes: 3 additions & 0 deletions src/sonic-config-engine/tests/sample_output/py3/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ iface eth0 inet6 static
up ip -6 route add default via 2603:10e2:0:2902::1 dev eth0 table default metric 201
up ip -6 route add 2603:10e2:0:2902::/64 dev eth0 table default
up ip -6 rule add pref 32765 from 2603:10e2:0:2902::8/128 table default
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref 32767 lookup default
# management port down rules
pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default
pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:2902::8/128 table default
pre-down ip -6 rule delete pref 32767 lookup default
#
source /etc/network/interfaces.d/*
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ iface eth0 inet6 static
up ip -6 route add default via 2603:10e2:0:2902::1 dev eth0 table default metric 201
up ip -6 route add 2603:10e2:0:2902::/64 dev eth0 table default
up ip -6 rule add pref 32765 from 2603:10e2:0:2902::8/128 table default
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref 32767 lookup default
# management port down rules
pre-down ip -6 route delete default via 2603:10e2:0:2902::1 dev eth0 table default
pre-down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:2902::8/128 table default
pre-down ip -6 rule delete pref 32767 lookup default
iface eth1 inet static
address 10.0.10.100
netmask 255.255.255.0
Expand All @@ -67,10 +70,13 @@ iface eth1 inet6 static
up ip -6 route add default via 2603:10e2:0:abcd::1 dev eth1 table default metric 201
up ip -6 route add 2603:10e2:0:abcd::/64 dev eth1 table default
up ip -6 rule add pref 32765 from 2603:10e2:0:abcd::8/128 table default
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref 32767 lookup default
# management port down rules
pre-down ip -6 route delete default via 2603:10e2:0:abcd::1 dev eth1 table default
pre-down ip -6 route delete 2603:10e2:0:abcd::/64 dev eth1 table default
pre-down ip -6 rule delete pref 32765 from 2603:10e2:0:abcd::8/128 table default
pre-down ip -6 rule delete pref 32767 lookup default
#
source /etc/network/interfaces.d/*
#
Expand Down

0 comments on commit 38c5e68

Please sign in to comment.