Skip to content

Conversation

rastislavs
Copy link
Contributor

@rastislavs rastislavs commented Aug 1, 2023

Adds a new bgp/routes API endpoint and the cilium bgp routes CLI command implementation that can be used for retrieval of available/advertised routes from BGP Control Plane's RIBs.

Example usage:

Available ipv4 unicast routes:

$ cilium bgp routes available ipv4 unicast
VRouter   Prefix              NextHop   Age   Attrs
65001     10.0.0.0/24         0.0.0.0   21s   [{Origin: i} {Nexthop: 0.0.0.0}]   
65001     192.168.10.176/32   0.0.0.0   21s   [{Origin: i} {Nexthop: 0.0.0.0}]   

ipv4 unicast routes advertised to the peer 172.0.0.1:

$ cilium bgp routes advertised ipv4 unicast peer 172.0.0.1
VRouter   Prefix              NextHop     Age      Attrs
65001     10.0.0.0/24         172.0.0.2   20m33s   [{Origin: i} {AsPath: 65001} {Nexthop: 172.0.0.2}]   
65001     192.168.10.176/32   172.0.0.2   20m33s   [{Origin: i} {AsPath: 65001} {Nexthop: 172.0.0.2}]

Available ipv4 unicast routes in virtual router with ASN 65001:

$ cilium bgp routes available ipv4 unicast vrouter 65001
VRouter   Prefix              NextHop   Age     Attrs
65001     10.0.0.0/24         0.0.0.0   24m7s   [{Origin: i} {Nexthop: 0.0.0.0}]   
65001     192.168.10.176/32   0.0.0.0   24m7s   [{Origin: i} {Nexthop: 0.0.0.0}]   

Help:

$ cilium bgp routes -h
List routes in the BGP Control Plane's Routing Information Bases (RIBs)

Usage:
  cilium bgp routes <available | advertised> <afi> <safi> [vrouter <asn>] [peer|neighbor <address>] [flags]

Examples:
  Get all IPv4 unicast routes available:
    cilium bgp routes available ipv4 unicast

  Get all IPv6 unicast routes available for a specific vrouter:
    cilium bgp routes available ipv6 unicast vrouter 65001

  Get IPv4 unicast routes advertised to specific peer:
    cilium bgp routes advertised ipv4 unicast peer 10.0.0.1

Flags:
  -h, --help            help for routes
  -o, --output string   json| yaml| jsonpath='{}'

Global Flags:
      --config string   Config file (default is $HOME/.cilium.yaml)
  -D, --debug           Enable debug messages
  -H, --host string     URI to server-side API

@rastislavs rastislavs added kind/feature This introduces new functionality. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. area/bgp Impacts the Border Gateway Protocol feature. labels Aug 1, 2023
@rastislavs rastislavs force-pushed the bgp-get-routes-api-cli branch 2 times, most recently from 3120b5c to 66b0dd2 Compare August 1, 2023 12:26
@rastislavs rastislavs self-assigned this Aug 1, 2023
@rastislavs rastislavs changed the title bgpv1: Add bgp/routes API endpoint and cilium bgp routes CLI bgpv1: Add bgp/routes API endpoint and cilium bgp routes CLI command Aug 1, 2023
@rastislavs
Copy link
Contributor Author

/test

@rastislavs rastislavs marked this pull request as ready for review August 1, 2023 13:54
@rastislavs rastislavs requested review from a team as code owners August 1, 2023 13:54
Copy link
Contributor

@zacharysarah zacharysarah left a comment

Choose a reason for hiding this comment

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

@rastislavs One small wording nit, otherwise LGTM for docs

Copy link
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

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

Changes look good to me. It might be useful to add this command to the bugtool output so the info is available in sysdumps.

@rastislavs rastislavs force-pushed the bgp-get-routes-api-cli branch from 66b0dd2 to 1ffd29b Compare August 2, 2023 21:51
@rastislavs rastislavs requested a review from a team as a code owner August 2, 2023 21:51
@rastislavs rastislavs force-pushed the bgp-get-routes-api-cli branch 4 times, most recently from a5b8191 to 428daf9 Compare August 2, 2023 22:17
@rastislavs
Copy link
Contributor Author

rastislavs commented Aug 2, 2023

@dylandreimerink

It might be useful to add this command to the bugtool output so the info is available in sysdumps.

Added into bugtool (as well as the previously existing "cilium bgp peers" command). Realized that we need to properly handle cases when BGP Control Plane is not enabled, so fixed that in 04acf9f.

@rastislavs rastislavs force-pushed the bgp-get-routes-api-cli branch from 428daf9 to 3443810 Compare August 2, 2023 22:26
@rastislavs
Copy link
Contributor Author

/test

@learnitall learnitall removed their request for review August 4, 2023 18:16
Copy link
Contributor

@zacharysarah zacharysarah left a comment

Choose a reason for hiding this comment

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

LGTM for docs

Copy link
Contributor

@harsimran-pabla harsimran-pabla left a comment

Choose a reason for hiding this comment

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

Few comments, overall looks good. There are few follow ups, maybe tasks can be created for them

  • Extend this to cilium-cli
  • Paging of the result, as it can be very large (order of 10k).
  • Some optimization for later ( getting result concurrently from various vrouters - gobgp instances )

Add a new API endpoint bgp/routes to retrieve BGP CPlane's RIB from API.
The actual implementation will be in subsequent commits.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
Co-authored-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
@rastislavs rastislavs force-pushed the bgp-get-routes-api-cli branch from 3443810 to 46bc64f Compare August 10, 2023 09:45
YutaroHayakawa and others added 4 commits August 10, 2023 11:53
Implement bgp/routes API by wiring-up API call with BGPRouterManager.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
Co-authored-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
Implement `cilium bgp routes` command that retrieves routes from
bgp/routes API and displays response.
Also allow using "peer" and "neighbor" keyword interchangeably in bgp CLI
(e.g. "cilium bgp peers" == "cilium bgp neighbors",
"cilium bgp routes ... peer 172.0.0.1" == "cilium bgp routes ... neighbor 172.0.0.1").

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
Co-authored-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
Fixes an issue with bgp/peers & bgp/routes API endpoint and cilium
"bgp peers" & "bgp routes" CLI command when BGP Control Plane is disabled.
Instead of returning an internal server error returns an specific error
that can be properly handled in the CLI command code.

Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
Includes "cilium bgp peers" & "cilium bgp routes" command outputs
in the bugtool so that BGP info is available in sysdumps.

Signed-off-by: Rastislav Szabo <rastislav.szabo@isovalent.com>
@rastislavs
Copy link
Contributor Author

@harsimran-pabla

There are few follow ups, maybe tasks can be created for them

I have created an overarching follow-up task with potential enhancements: #27420

@rastislavs
Copy link
Contributor Author

/test

Copy link
Contributor

@harsimran-pabla harsimran-pabla left a comment

Choose a reason for hiding this comment

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

Thank you!! LGTM

Copy link
Member

@nathanjsweet nathanjsweet left a comment

Choose a reason for hiding this comment

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

A couple of nits for API and CLI.

Copy link
Member

@nathanjsweet nathanjsweet left a comment

Choose a reason for hiding this comment

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

Approve for API and CLI

@nathanjsweet nathanjsweet merged commit 964bbb5 into cilium:main Aug 10, 2023
ldelossa added a commit to ldelossa/cilium that referenced this pull request Aug 16, 2023
Due to the merge of cilium#27182 before cilium#27285 a bug was introduced in
pkg/bgpv1/manager/manager_test.go.

This commit fixes the issue.

Signed-off-by: Louis DeLosSantos <louis.delos@isovalent.com>
ldelossa added a commit that referenced this pull request Aug 16, 2023
Due to the merge of #27182 before #27285 a bug was introduced in
pkg/bgpv1/manager/manager_test.go.

This commit fixes the issue.

Signed-off-by: Louis DeLosSantos <louis.delos@isovalent.com>
@joestringer
Copy link
Member

We may want to mark this release-note/major as an improvement to the visibility and day 2 operations for BGP support in Cilium.

@rastislavs rastislavs added release-note/major This PR introduces major new functionality to Cilium. and removed release-note/minor This PR changes functionality that users may find relevant to operating Cilium. labels Sep 4, 2023
@rastislavs
Copy link
Contributor Author

@joestringer

We may want to mark this release-note/major as an improvement to the visibility and day 2 operations for BGP support in Cilium.

makes sense, marked as release-note/major

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bgp Impacts the Border Gateway Protocol feature. kind/feature This introduces new functionality. release-note/major This PR introduces major new functionality to Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants