Skip to content

Fix remove ip rif#1535

Merged
prsunny merged 2 commits intosonic-net:masterfrom
d-dashkov:fix_remove_ip_rif
Apr 26, 2021
Merged

Fix remove ip rif#1535
prsunny merged 2 commits intosonic-net:masterfrom
d-dashkov:fix_remove_ip_rif

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 30, 2021

What I did

Resolves sonic-net/sonic-buildimage#7028
Added checking of static routes, related to the interface, before deleting of the last IP entry to prevent deleting the RIF if a static route is present in the system.
The related unit tests has added.

How I did it

By checking IPv4 and IPv6 routes, received from Zebra.

How to verify it

  1. sudo config int ip add Ethernet2 10.0.0.18/31
  2. sudo config route add prefix 20.0.0.1/32 nexthop Ethernet2
  3. sudo config int ip rem Ethernet2 10.0.0.18/31
    If 10.0.0.18/31 is the last IP entry, you will receive the next error: Error: Cannot remove the last IP entry of interface Ethernet2. A static ip route is still bound to the RIF.
    The similar situation is for IPv6: Error: Cannot remove the last IP entry of interface Ethernet2. A static ipv6 route is still bound to the RIF.

@ghost ghost force-pushed the fix_remove_ip_rif branch from d1798b3 to 20b760d Compare March 30, 2021 16:11
@ghost ghost marked this pull request as ready for review March 30, 2021 16:21
@ghost
Copy link
Copy Markdown
Author

ghost commented Mar 30, 2021

@prsunny, I have added PR according to your comments in #1513. Could you check the PR?

@ghost ghost force-pushed the fix_remove_ip_rif branch 2 times, most recently from 27e4149 to 3b445c9 Compare April 13, 2021 09:58
@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 13, 2021

@prsunny, I have fixed the unit tests. Could you review the PR?

config/main.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why all? why not just show ip route static. Lets optimize this as best as possible since this could potentially introduce further delays in this command.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

vrf all is required to check scopes of all the VRFs present in the system, because command show ip route shows routes only in scope of default VRF.
Good point regarding static prefix, I have updated and retested the changes. Thank you.
Please, take a look on the difference between outputs of commands show ip route static and show ip route vrf all static. That's why I have added vrf all:

admin@sonic:~$ show ip route vrf all static
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup

VRF Vrf11:
S   20.0.0.144/32 [1/0] is directly connected, Ethernet68 inactive, weight 1, 00:00:18

VRF default:
S>* 0.0.0.0/0 [200/0] via 192.168.111.3, eth0, weight 1, 23:09:50
S   20.0.0.1/32 [1/0] is directly connected, Ethernet64 inactive, weight 1, 00:01:14
                      is directly connected, Ethernet68 (vrf Vrf11) inactive, weight 1, 00:01:14

admin@sonic:~$ show ip route static
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup

S>* 0.0.0.0/0 [200/0] via 192.168.111.3, eth0, weight 1, 23:10:01
S   20.0.0.1/32 [1/0] is directly connected, Ethernet64 inactive, weight 1, 00:01:25
                      is directly connected, Ethernet68 (vrf Vrf11) inactive, weight 1, 00:01:25

Maksym Belei added 2 commits April 15, 2021 12:47
* Check whether a static route present, which is related
  to the RIF of the interface for which we want to
  delete the last IP entry. This is required to prevent
  deleting of RIFs, if there are static routes in the
  system.

Signed-off-by: Maksym Belei <[email protected]>
* Update unit tests according to the changes.

Signed-off-by: Maksym Belei <[email protected]>
@ghost ghost force-pushed the fix_remove_ip_rif branch from 3b445c9 to 37a2e87 Compare April 15, 2021 09:48
@ghost ghost requested a review from prsunny April 15, 2021 10:00
@prsunny prsunny requested a review from arlakshm April 23, 2021 00:08
@arlakshm
Copy link
Copy Markdown
Contributor

@maksymbelei95, @prsunny. Should we add a check to disallow configuring of static route with nexthop as ifname if the interface has no ip address?

@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Apr 23, 2021

@maksymbelei95, @prsunny. Should we add a check to disallow configuring of static route with nexthop as ifname if the interface has no ip address?

Its a good suggestion. Added the comment in #1534

@ghost
Copy link
Copy Markdown
Author

ghost commented Apr 26, 2021

@prsunny, if there is no active questions regarding this PR, could you merge it?

Copy link
Copy Markdown
Contributor

@arlakshm arlakshm left a comment

Choose a reason for hiding this comment

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

lgtm

@prsunny prsunny merged commit c3963c5 into sonic-net:master Apr 26, 2021
gitsabari pushed a commit to gitsabari/sonic-utilities that referenced this pull request Jun 15, 2021
*Added checking of static routes, related to the interface, before deleting of the last IP entry to prevent deleting the RIF if a static route is present in the system.

Signed-off-by: Maksym Belei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to set port to be member of VLAN(specific scenario with static route)

2 participants