-
Notifications
You must be signed in to change notification settings - Fork 543
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
prevent default fallback route lookup from user-defined VRF table to local table(default vrf). #1557
base: master
Are you sure you want to change the base?
Conversation
…to local table(default vrf).
Adding few details for adding l3mdev unreachable rule: If l3mdev unreachable rule is not present, route lookup by default falls back to local table(default vrf routing table which has connected prefixes). If connected prefix is present in local table for which lookup is performed in non-default vrf, result will lead to nexthop in local table causing packet leak from non-default vrf to default vrf. Before Fix: root@sonic:/home/admin# show vrf Vrf-red Ethernet56 root@sonic:/home/admin# ip -4 ru ls root@sonic:/home/admin# ip -4 route get 24.0.0.100 vrf Vrf-red root@sonic:/home/admin# config interface ip remove Ethernet56 24.0.0.2/24 root@sonic:/home/admin# ip -4 route get 24.0.0.100 vrf Vrf-red root@sonic:/home/admin# ip -4 route get 24.0.0.100 root@sonic:/home/admin# ip -s addr show Ethernet24 root@sonic:/home/admin# ip -s addr show Ethernet56 After fix: root@sonic:~# ip -4 ru ls root@sonic:~# show vrf Vrf-red Ethernet48 root@sonic:~# ip -s addr show Ethernet48 root@sonic:~# ip -s addr show Ethernet24 root@sonic:~# ip -4 route get 24.0.0.100 vrf Vrf-red root@sonic:~# config interface ip remove Ethernet48 24.0.0.1/24 root@sonic:~# ip -s addr show Ethernet48 root@sonic:~# ip -4 route get 24.0.0.100 vrf Vrf-red root@sonic:~# |
@lguohan - can we get some review on this please? |
<< IP_CMD << " -6 rule add pref " << TABLE_LOCAL_PREF << " table local && " << IP_CMD << " -6 rule del pref 0"; | ||
<< IP_CMD << " -6 rule add pref " << TABLE_LOCAL_PREF << " table local && " << IP_CMD << " -6 rule del pref 0 && " | ||
<< IP_CMD << " rule add pref " << VRF_FALLBACK_DISABLE_PREF << " l3mdev unreachable && " | ||
<< IP_CMD << " -6 rule add pref " << VRF_FALLBACK_DISABLE_PREF << " l3mdev unreachable"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have vstest for this feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lguohan for the review . I will soon update the test run results .
What I did
By default fallback to local table if l3mdev table lookup fails is
enabled in kernel.
This enables packet to move to default-vrf if route lookup in
non-default-vrf fails.
To disable this fallback feature below IPv4 & IPv6 rules are added to
FIB Routing Policy Data Base.
ip ru add pref 1001 l3mdev unreachable
ip -6 ru add pref 1001 l3mdev unreachable
Why I did it
This fix is needed as it prevents default fallback route lookup from user-defined VRF table to local table(default vrf).
How I verified it
Please refer to below output after fix :
admin@sonic: ip -4 rule ls
1000: from all lookup [l3mdev-table]
1003: from 10.59.133.11 lookup mgmt
1004: from all to 10.0.0.0/8 lookup mgmt
32765: from all lookup local
32766: from all lookup main
32767: from all lookup default
admin@sonic:
admin@sonic: ip -6 rule ls
1000: from all lookup [l3mdev-table]
1003: from 2100::2 lookup mgmt
32765: from all lookup local
32766: from all lookup main
admin@sonic: