Skip to content

Commit

Permalink
[show] Add 'ip/ipv6 bgp network' commands (sonic-net#888)
Browse files Browse the repository at this point in the history
Co-authored-by: Travis Van Duyn <[email protected]>
  • Loading branch information
tsvanduyn and Travis Van Duyn authored Apr 24, 2020
1 parent a7b310e commit fc719ad
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
67 changes: 67 additions & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,38 @@ Optionally, you can specify an IP address in order to display only that particul
Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp neighbors" for Quagga.
**show ip bgp network [[<ipv4-address>|<ipv4-prefix>] [(bestpath | multipath | longer-prefixes | json)]]
This command displays all the details of IPv4 Border Gateway Protocol (BGP) prefixes.
- Usage:
```
show ip bgp network [[<ipv4-address>|<ipv4-prefix>] [(bestpath | multipath | longer-prefixes | json)]]
```
- Example:
NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used.
```
admin@sonic:~$ show ip bgp network

admin@sonic:~$ show ip bgp network 10.1.0.32 bestpath

admin@sonic:~$ show ip bgp network 10.1.0.32 multipath

admin@sonic:~$ show ip bgp network 10.1.0.32 json

admin@sonic:~$ show ip bgp network 10.1.0.32/32 bestpath

admin@sonic:~$ show ip bgp network 10.1.0.32/32 multipath

admin@sonic:~$ show ip bgp network 10.1.0.32/32 json

admin@sonic:~$ show ip bgp network 10.1.0.32/32 longer-prefixes
```
**show bgp ipv6 summary (Versions >= 201904 using default FRR routing stack)**
Expand Down Expand Up @@ -1671,6 +1703,41 @@ This command displays all the details of one particular IPv6 Border Gateway Prot
Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga.
**show ipv6 bgp network [[<ipv6-address>|<ipv6-prefix>] [(bestpath | multipath | longer-prefixes | json)]]
This command displays all the details of IPv6 Border Gateway Protocol (BGP) prefixes.
- Usage:
```
show ipv6 bgp network [[<ipv6-address>|<ipv6-prefix>] [(bestpath | multipath | longer-prefixes | json)]]
```
- Example:
NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used.
```
admin@sonic:~$ show ipv6 bgp network

admin@sonic:~$ show ipv6 bgp network fc00::72 bestpath

admin@sonic:~$ show ipv6 bgp network fc00::72 multipath

admin@sonic:~$ show ipv6 bgp network fc00::72 json

admin@sonic:~$ show ipv6 bgp network fc00::72/64 bestpath

admin@sonic:~$ show ipv6 bgp network fc00::72/64 multipath

admin@sonic:~$ show ipv6 bgp network fc00::72/64 json

admin@sonic:~$ show ipv6 bgp network fc00::72/64 longer-prefixes
```
**show route-map**
Expand Down
31 changes: 31 additions & 0 deletions show/bgp_frr_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,34 @@ def neighbors(ipaddress, info_type):
command += '"'

run_command(command)

# 'network' subcommand ("show ip bgp network")
@bgp.command()
@click.argument('ipaddress', metavar='[<ipv4-address>|<ipv4-prefix>]', required=False)
@click.argument('info_type', metavar='[bestpath|json|longer-prefixes|multipath]',
type=click.Choice(['bestpath', 'json', 'longer-prefixes', 'multipath']), required=False)
def network(ipaddress, info_type):
"""Show IP (IPv4) BGP network"""

command = 'sudo vtysh -c "show ip bgp'

if ipaddress is not None:
if '/' in ipaddress:
# For network prefixes then this all info_type(s) are available
pass
else:
# For an ipaddress then check info_type, exit if specified option doesn't work.
if info_type in ['longer-prefixes']:
click.echo('The parameter option: "{}" only available if passing a network prefix'.format(info_type))
click.echo("EX: 'show ip bgp network 10.0.0.0/24 longer-prefixes'")
raise click.Abort()

command += ' {}'.format(ipaddress)

# info_type is only valid if prefix/ipaddress is specified
if info_type is not None:
command += ' {}'.format(info_type)

command += '"'

run_command(command)
31 changes: 31 additions & 0 deletions show/bgp_frr_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,34 @@ def neighbors(ipaddress, info_type):
info_type = "" if info_type is None else info_type
command = 'sudo vtysh -c "show bgp ipv6 neighbor {} {}"'.format(ipaddress, info_type)
run_command(command)

# 'network' subcommand ("show ipv6 bgp network")
@bgp.command()
@click.argument('ipaddress', metavar='[<ipv6-address>|<ipv6-prefix>]', required=False)
@click.argument('info_type', metavar='[bestpath|json|longer-prefixes|multipath]',
type=click.Choice(['bestpath', 'json', 'longer-prefixes', 'multipath']), required=False)
def network(ipaddress, info_type):
"""Show BGP ipv6 network"""

command = 'sudo vtysh -c "show bgp ipv6'

if ipaddress is not None:
if '/' in ipaddress:
# For network prefixes then this all info_type(s) are available
pass
else:
# For an ipaddress then check info_type, exit if specified option doesn't work.
if info_type in ['longer-prefixes']:
click.echo('The parameter option: "{}" only available if passing a network prefix'.format(info_type))
click.echo("EX: 'show ipv6 bgp network fc00:1::/64 longer-prefixes'")
raise click.Abort()

command += ' {}'.format(ipaddress)

# info_type is only valid if prefix/ipaddress is specified
if info_type is not None:
command += ' {}'.format(info_type)

command += '"'

run_command(command)

0 comments on commit fc719ad

Please sign in to comment.