Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix can't access IPV6 address via management interface because 'default' route table does not add to route lookup issue. #17281

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
pre-down ip rule delete pref 32764 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 32767 lookup {{ vrf_table }}
Copy link
Collaborator

@qiluo-msft qiluo-msft Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32767

How do you get the magic number? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number is based on IPV4 default route table priority:

admin@vlab-01:~$ ip -4 rule list
1001: from all lookup local
32764: from all to 172.17.0.1/24 lookup default
32765: from 10.250.0.101 lookup default
32766: from all lookup main
32767: from all lookup default

The default route table need have lowest priority so when can' find route from 'local' and 'main' table the rules from 'default' table will be use.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we need to define a named constant for 32764, and +3 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

pre-down ip -6 rule delete pref 32767 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 @@ -42,6 +42,9 @@ iface eth0 inet6 static
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
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please move this to 'up' section - line 40

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

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 @@ -57,6 +57,9 @@ iface eth1 inet6 static
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
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. please keep 'up' and 'pre-down' separate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

pre-down ip -6 rule delete pref 32767 lookup default
iface eth0 inet6 static
address 2603:10e2:0:2902::8
netmask 64
Expand All @@ -71,6 +74,9 @@ iface eth0 inet6 static
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
# 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
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 @@ -42,6 +42,9 @@ iface eth0 inet6 static
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
# 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
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 @@ -43,6 +43,9 @@ iface eth0 inet6 static
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
# 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
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 Down Expand Up @@ -71,6 +74,9 @@ iface eth1 inet6 static
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
# 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
pre-down ip -6 rule delete pref 32767 lookup default
#
source /etc/network/interfaces.d/*
#
Expand Down