[202311] Fix IPV6 forced-mgmt-route not work issue #18045
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix IPV6 forced-mgmt-route not work issue
This is cherry-pick PR for #17299
Why I did it
IPV6 forced-mgmt-route not work
When add a IPV6 route, should use 'ip -6 rule add pref 32764 address' command, but currently in the template the '-6' parameter are missing, so the IPV6 route been add to IPV4 route table.
Also this PR depends on #17281 , which will fix the IPV6 'default' route table missing in IPV6 route lookup issue.
Work item tracking
How I did it
Add IPV6 route with 'ip -6' command
How to verify it
Pass all UT
Manually verify:
// setup forced mgmt routes
admin@vlab-01:
$ sonic-db-cli CONFIG_DB HSET "MGMT_INTERFACE|eth0|fec0::ffff:afa:1/64" forced_mgmt_routes@ "1110::ffff:afa:1/64"$ sudo config save -y1
admin@vlab-01:
Running command: /usr/local/bin/sonic-cfggen -d --print-data > /etc/sonic/config_db.json
admin@vlab-01:~$ sudo config reload -y
Disabling container monitoring ...
Stopping SONiC target ...
// check interface config update correctly
admin@vlab-01:~$ cat /etc/network/interfaces
...
iface eth0 inet6 static
address fec0::ffff:afa:1
netmask 64
network fec0::
broadcast fec0::ffff:ffff:ffff:ffff
########## management network policy routing rules
# management port up rules
up ip -6 route add default via fec0::1 dev eth0 table default metric 201
up ip -6 route add fec0::/64 dev eth0 table default
up ip -6 rule add pref 32765 from fec0::ffff:afa:1/128 table default
up ip -6 rule add pref 32764 to 1110::ffff:afa:1/64 table default <== force mgmt route added correctly with 'ip -6'
// check route tables:
admin@vlab-01:
$ ip -6 rule list$1001: from all lookup local
32764: from all to 1110::ffff:afa:1/64 lookup default
32765: from fec0::ffff:afa:1 lookup default <== force mgmt route been add to IPV6 table
32766: from all lookup main
admin@vlab-01:
// traceroute command can find route
admin@vlab-01:~$ traceroute 1110::ffff:afa:1
traceroute to 1110::ffff:afa:1 (1110::ffff:afa:1), 30 hops max, 80 byte packets
1 * * *
2 * * *
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Description for the changelog
Fix IPV6 forced-mgmt-route not work issue
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)