Skip to content
New issue

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

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

Already on GitHub? # to your account

Multi-ASIC support for show ip route #1060

Closed
wants to merge 2 commits into from
Closed

Multi-ASIC support for show ip route #1060

wants to merge 2 commits into from

Conversation

gechiang
Copy link
Contributor

Add Multi-ASIC support to handle "show ip route" on multi-ASIC devices

Depends on the following PRs

Signed-off-by: Gen-Hwa Chiang gechiang@microsoft.com

- What I did

Add support for multi ASIC CLI options for "show ip route"
2 new options have added

[-n, --namespace] to allow user to display the information for given namespaces (ASIC)
If this option is not present the information from all the namespaces will be displayed

[-d, --display] to allow user to display ip routes related with nexthop that are going through both internal and external interfaces
If this option is not present only ip routes with external interfaces as its nexthop will be display

On single ASIC platform, this options are not valid, so the behavior remains unchanged

- How I did it

  • Request the back-end handler (FRR/Zebra) via the specified BGP docker(s) to dump out the "show ip route" in "json" format
  • Depends on the -d option optionally filter out those route nexthops that are via internal (back-end) interfaces.
  • If after filtering there are no next hops any more, then skip that particular route from being displayed as well.
  • At the end of the filtering if user also specified "json" option, then just dump out in json format.
  • If user did not specify "json" option, then interpret the route output similar to how FRR/Zebra does and print out each route.

- How to verify it

Help menu

admin@sonic:~$ show ip route -h
Usage: show ip route [OPTIONS] [IPADDRESS] [vrf <vrf_name>] [...]

  Show IP (IPv4) routing table

Options:
  -d, --display [all|frontend]    Show internal interfaces  [default:
                                  frontend]
  -n, --namespace [asic0|asic1|asic2|asic3|asic4|asic5]
                                  Namespace name or all
  --verbose                       Enable verbose output
  -?, -h, --help                  Show this message and exit.
admin@sonic:~$

show ip route for all routes (include routes that uses internal interface as nexthop) from ASIC0 in multi ASIC device

admin@sonic:~$ show ip route -n asic0 -d all
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 route, r - rejected route

C>*10.106.0.4/31 is directly connected, PortChannel1005, 1d00h03m
B>*10.10.192.48/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
C>*10.0.107.16/32 is directly connected, Loopback4096, 1d00h03m
B>*10.0.107.18/32 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                       via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.46/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.106.0.12/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                       via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.52/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.62/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.38/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h03m
B>*10.10.192.36/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.54/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.21/32 [200/0] via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.8/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                      via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.106.0.8/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                      via 10.0.107.2, PortChannel4002, 1d00h03m
C>*10.0.107.0/31 is directly connected, PortChannel4001, 1d00h03m
B>*10.10.192.44/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.68/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.10/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                       via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.64/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h03m
B>*10.10.192.60/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.50/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.34/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.12/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                       via 10.0.107.2, PortChannel4002, 1d00h03m
C>*10.0.107.2/31 is directly connected, PortChannel4002, 1d00h03m
B>*10.0.107.17/32 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                       via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.4/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                      via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.42/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.19/32 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                       via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.14/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                       via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.66/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.70/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.32/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
C>*10.106.0.0/31 is directly connected, PortChannel1002, 1d00h03m
B>*10.0.107.6/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                      via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.56/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.40/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.10.192.58/31 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
  *                        via 10.0.107.2, PortChannel4002, 1d00h03m
B>*10.0.107.20/32 [200/0] via 10.0.107.0, PortChannel4001, 1d00h03m
admin@sonic:~$

show ip route (exclude routes that uses internal interface as nexthop) from ASIC0 in multi ASIC device

admin@sonic:~$ show ip route -n asic0
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 route, r - rejected route

C>*10.106.0.4/31 is directly connected, PortChannel1005, 1d00h03m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h04m
C>*10.106.0.0/31 is directly connected, PortChannel1002, 1d00h03m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h04m
C>*10.0.107.16/32 is directly connected, Loopback4096, 1d00h04m
admin@sonic:~$

show ip route (exclude routes that uses internal interface as nexthop) from ASIC5 in multi ASIC device in json format

admin@sonic:~$ show ip route -n asic5 json
{
  "10.0.107.21/32": [
    {
      "distance": 0,
      "uptime": "1d00h06m",
      "destSelected": true,
      "protocol": "connected",
      "internalFlags": 8,
      "metric": 0,
      "selected": true,
      "installed": true,
      "internalNextHopNum": 1,
      "prefix": "10.0.107.21/32",
      "internalNextHopActiveNum": 1,
      "table": 254,
      "internalStatus": 16,
      "nexthops": [
        {
          "directlyConnected": true,
          "interfaceName": "Loopback4096",
          "interfaceIndex": 9,
          "fib": true,
          "flags": 3,
          "active": true
        }
      ]
    }
  ],
  "172.16.132.64/32": [
    {
      "distance": 0,
      "uptime": "1d00h06m",
      "destSelected": true,
      "protocol": "connected",
      "internalFlags": 8,
      "metric": 0,
      "selected": true,
      "installed": true,
      "internalNextHopNum": 1,
      "prefix": "172.16.132.64/32",
      "internalNextHopActiveNum": 1,
      "table": 254,
      "internalStatus": 16,
      "nexthops": [
        {
          "directlyConnected": true,
          "interfaceName": "Loopback0",
          "interfaceIndex": 8,
          "fib": true,
          "flags": 3,
          "active": true
        }
      ]
    }
  ],
  "10.0.107.14/31": [
    {
      "distance": 200,
      "uptime": "1d00h05m",
      "protocol": "bgp",
      "internalFlags": 5,
      "metric": 0,
      "internalStatus": 0,
      "internalNextHopNum": 1,
      "prefix": "10.0.107.14/31",
      "internalNextHopActiveNum": 0,
      "table": 254,
      "nexthops": [
        {
          "ip": "10.0.107.15",
          "flags": 0,
          "afi": "ipv4"
        }
      ]
    }
  ],
  "10.0.107.2/31": [
    {
      "distance": 200,
      "uptime": "1d00h06m",
      "protocol": "bgp",
      "internalFlags": 5,
      "metric": 0,
      "internalStatus": 0,
      "internalNextHopNum": 1,
      "prefix": "10.0.107.2/31",
      "internalNextHopActiveNum": 0,
      "table": 254,
      "nexthops": [
        {
          "ip": "10.0.107.3",
          "flags": 0,
          "afi": "ipv4"
        }
      ]
    }
  ],
  "10.0.107.10/31": [
    {
      "distance": 200,
      "uptime": "1d00h05m",
      "protocol": "bgp",
      "internalFlags": 5,
      "metric": 0,
      "internalStatus": 0,
      "internalNextHopNum": 1,
      "prefix": "10.0.107.10/31",
      "internalNextHopActiveNum": 0,
      "table": 254,
      "nexthops": [
        {
          "ip": "10.0.107.11",
          "flags": 0,
          "afi": "ipv4"
        }
      ]
    }
  ],
  "10.0.107.6/31": [
    {
      "distance": 200,
      "uptime": "1d00h06m",
      "protocol": "bgp",
      "internalFlags": 5,
      "metric": 0,
      "internalStatus": 0,
      "internalNextHopNum": 1,
      "prefix": "10.0.107.6/31",
      "internalNextHopActiveNum": 0,
      "table": 254,
      "nexthops": [
        {
          "ip": "10.0.107.7",
          "flags": 0,
          "afi": "ipv4"
        }
      ]
    }
  ],
  "0.0.0.0/0": [
    {
      "distance": 210,
      "uptime": "1d00h06m",
      "destSelected": true,
      "protocol": "kernel",
      "internalFlags": 8,
      "metric": 0,
      "selected": true,
      "installed": true,
      "internalNextHopNum": 1,
      "prefix": "0.0.0.0/0",
      "internalNextHopActiveNum": 1,
      "table": 254,
      "internalStatus": 16,
      "nexthops": [
        {
          "interfaceName": "eth0",
          "ip": "240.127.1.1",
          "interfaceIndex": 13,
          "fib": true,
          "flags": 3,
          "active": true,
          "afi": "ipv4"
        }
      ]
    }
  ]
}
admin@sonic:~$

show ip route (exclude routes that uses internal interface as nexthop) from ASIC5 in multi ASIC device

admin@sonic:~$ show ip route -n asic5
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 route, r - rejected route

C>*10.0.107.21/32 is directly connected, Loopback4096, 1d00h06m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h06m
B 10.0.107.14/31 [200/0] via 10.0.107.15, inactive 1d00h06m
B 10.0.107.2/31 [200/0] via 10.0.107.3, inactive 1d00h06m
B 10.0.107.10/31 [200/0] via 10.0.107.11, inactive 1d00h06m
B 10.0.107.6/31 [200/0] via 10.0.107.7, inactive 1d00h06m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h07m
admin@sonic:~$

show ip route for all routes (exclude routes that uses internal interface as nexthop) from ALL ASICs in multi ASIC device

admin@sonic:~$ show ip route
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 route, r - rejected route

C>*10.106.0.4/31 is directly connected, PortChannel1005, 1d00h04m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h05m
C>*10.106.0.0/31 is directly connected, PortChannel1002, 1d00h04m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h04m
C>*10.0.107.16/32 is directly connected, Loopback4096, 1d00h04m
C>*10.106.0.8/31 is directly connected, PortChannel1008, 1d00h04m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h05m
C>*10.106.0.12/31 is directly connected, PortChannel1011, 1d00h04m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h04m
C>*10.0.107.17/32 is directly connected, Loopback4096, 1d00h04m
C>*10.10.192.34/31 is directly connected, PortChannel1003, 1d00h04m
C>*10.10.192.48/31 is directly connected, PortChannel1013, 1d00h04m
C>*10.10.192.36/31 is directly connected, PortChannel1004, 1d00h04m
C>*10.10.192.32/31 is directly connected, PortChannel1001, 1d00h04m
C>*10.0.107.18/32 is directly connected, Loopback4096, 1d00h04m
C>*10.10.192.46/31 is directly connected, PortChannel1012, 1d00h04m
C>*10.10.192.44/31 is directly connected, PortChannel1010, 1d00h04m
C>*10.10.192.50/31 is directly connected, PortChannel1014, 1d00h04m
C>*10.10.192.38/31 is directly connected, PortChannel1006, 1d00h04m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h04m
C>*10.10.192.40/31 is directly connected, PortChannel1007, 1d00h04m
C>*10.10.192.42/31 is directly connected, PortChannel1009, 1d00h04m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h04m
C>*10.10.192.54/31 is directly connected, PortChannel1016, 1d00h04m
C>*10.0.107.19/32 is directly connected, Loopback4096, 1d00h04m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h04m
C>*10.10.192.62/31 is directly connected, PortChannel1020, 1d00h04m
C>*10.10.192.60/31 is directly connected, PortChannel1019, 1d00h04m
C>*10.10.192.70/31 is directly connected, PortChannel1024, 1d00h04m
C>*10.10.192.68/31 is directly connected, PortChannel1023, 1d00h04m
C>*10.10.192.52/31 is directly connected, PortChannel1015, 1d00h04m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h05m
C>*10.10.192.66/31 is directly connected, PortChannel1022, 1d00h04m
C>*10.10.192.58/31 is directly connected, PortChannel1018, 1d00h04m
C>*10.10.192.64/31 is directly connected, PortChannel1021, 1d00h04m
C>*10.10.192.56/31 is directly connected, PortChannel1017, 1d00h04m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h04m
B 10.0.107.8/31 [200/0] via 10.0.107.9, inactive 1d00h04m
B 10.0.107.0/31 [200/0] via 10.0.107.1, inactive 1d00h04m
B 10.0.107.12/31 [200/0] via 10.0.107.13, inactive 1d00h04m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h05m
B 10.0.107.4/31 [200/0] via 10.0.107.5, inactive 1d00h04m
C>*10.0.107.20/32 is directly connected, Loopback4096, 1d00h04m
C>*10.0.107.21/32 is directly connected, Loopback4096, 1d00h04m
C>*172.16.132.64/32 is directly connected, Loopback0, 1d00h04m
B 10.0.107.14/31 [200/0] via 10.0.107.15, inactive 1d00h04m
B 10.0.107.2/31 [200/0] via 10.0.107.3, inactive 1d00h04m
B 10.0.107.10/31 [200/0] via 10.0.107.11, inactive 1d00h04m
B 10.0.107.6/31 [200/0] via 10.0.107.7, inactive 1d00h04m
K>*0.0.0.0/0 [210/0] via 240.127.1.1, eth0, 1d00h05m
admin@sonic:~$

- Previous command output (if the output of a command-line utility has changed)

- New command output (if the output of a command-line utility has changed)

** Please Note **
The test case changes will be submitted with a separate PR later so that we can take advantage of some other multi-ASIC CLI PR that have already created the test modules that can be reused without too much duplication of work.

@jleveque jleveque requested a review from prsunny August 21, 2020 00:22
@smaheshm
Copy link
Contributor

@gechiang Are you going with separate implementation for multi ASIC and single ASIC or are you going to refactor to use common code.

@gechiang
Copy link
Contributor Author

gechiang commented Sep 2, 2020

@gechiang Are you going with separate implementation for multi ASIC and single ASIC or are you going to refactor to use common code.

Yes. I have changed the code so that even pizzabox case will also use the same code processing. Originally was trying to minimize the potential impact in case this code has some bug that I was not able to shake out. Feel pretty confident about the overall changes so all will go through same code path now.

@gechiang
Copy link
Contributor Author

gechiang commented Sep 2, 2020

Canceling this PR. Will make a new PR with the latest update instead.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants