Skip to content

bgp: Make the BGP peer name retrievable from GoBGP#44024

Merged
YutaroHayakawa merged 1 commit intomainfrom
yutaro/encode-name-to-gobgp
Jan 29, 2026
Merged

bgp: Make the BGP peer name retrievable from GoBGP#44024
YutaroHayakawa merged 1 commit intomainfrom
yutaro/encode-name-to-gobgp

Conversation

@YutaroHayakawa
Copy link
Copy Markdown
Member

@YutaroHayakawa YutaroHayakawa commented Jan 26, 2026

This is a preparation for the upcoming new BGPv2-native CLI and metrics.

In BGPv2, the peer is identified by the explicit name instead of IP address. The reason for this spec is that makes it easier for users to identify dynamically discovered peers on CLI or metrics.

However, the CLI and metrics output are based on the information retrieved from the RouterManager which doesn't have a peer name => peer IP address correspondence. Having this mapping in the RouterManager is tricky because the peer discovery is done by the reconcilers.

The solution here is keeping the peer name in the GoBGP's Peer object. While GoBGP still identifies peer with IP address, we have a Description field that accepts arbitrary string. We can keep the peer name there.

For the sake of the future extensibility, the name is encoded as a JSON string. Whenever we want to encode additional metadata, we can introduce a new JSON field.

The agent API field is extended with name:

$ cilium-dbg bgp peer -o json
[
  {
    "configured-hold-time-seconds": 90,
    "configured-keep-alive-time-seconds": 30,
    "connect-retry-time-seconds": 120,
    "ebgp-multihop-ttl": 1,
    "families": [
      {
        "afi": "ipv6",
        "safi": "unicast"
      },
      {
        "afi": "ipv4",
        "safi": "unicast"
      }
    ],
    ...
    "name": "peer0",
    "peer-address": "10.0.0.1",
    "peer-port": 179,
    "remote-capabilities": [],
    "session-state": "active"
  }
]

Note that cilium-cli is not yet updated with this change because we will introduce a completely new CLI output shortly, so it doesn't make sense to augment the current output with name.

The TestGetPeerStatus test case used to identify peer with IP + ASN. Change it to leverage this API.

bgp: Make the BGP instance name retrievable from GoBGP

@YutaroHayakawa YutaroHayakawa requested review from a team as code owners January 26, 2026 23:31
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jan 26, 2026
@YutaroHayakawa YutaroHayakawa requested a review from squeed January 26, 2026 23:31
@YutaroHayakawa YutaroHayakawa force-pushed the yutaro/encode-name-to-gobgp branch from ee01c53 to b511773 Compare January 26, 2026 23:32
This is a preparation for the upcoming new BGPv2-native CLI and metrics.

In BGPv2, the peer is identified by the explicit name instead of IP
address. The reason for this spec is that makes it easier for users to
identify dynamically discovered peers on CLI or metrics.

However, the CLI and metrics output are based on the information
retrieved from the RouterManager which doesn't have a peer name => peer
IP address correspondence. Having this mapping in the RouterManager is
tricky because the peer discovery is done by the reconcilers.

The solution here is keeping the peer name in the GoBGP's Peer object.
While GoBGP still identifies peer with IP address, we have a Description
field that accepts arbitrary string. We can keep the peer name there.

For the sake of the future extensibility, the name is encoded as a JSON
string. Whenever we want to encode additional metadata, we can introduce
a new JSON field.

The agent API field is extended with name:

```
$ cilium-dbg bgp peer -o json
[
  {
    "configured-hold-time-seconds": 90,
    "configured-keep-alive-time-seconds": 30,
    "connect-retry-time-seconds": 120,
    "ebgp-multihop-ttl": 1,
    "families": [
      {
        "afi": "ipv6",
        "safi": "unicast"
      },
      {
        "afi": "ipv4",
        "safi": "unicast"
      }
    ],
    ...
    "name": "peer0",
    "peer-address": "10.0.0.1",
    "peer-port": 179,
    "remote-capabilities": [],
    "session-state": "active"
  }
]
```

Note that cilium-cli is not yet updated with this change because we will
introduce a completely new CLI output shortly, so it doesn't make sense
to augment the current output with name.

The TestGetPeerStatus test case used to identify peer with IP + ASN.
Change it to leverage this API.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
@YutaroHayakawa YutaroHayakawa force-pushed the yutaro/encode-name-to-gobgp branch from b511773 to 4afed2e Compare January 27, 2026 00:22
@YutaroHayakawa YutaroHayakawa changed the title bgp: Make the BGP instance name retrievable from GoBGP bgp: Make the BGP peer name retrievable from GoBGP Jan 27, 2026
Copy link
Copy Markdown
Contributor

@rastislavs rastislavs left a comment

Choose a reason for hiding this comment

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

Neat trick :) Thanks!

@bimmlerd bimmlerd removed request for a team and bimmlerd January 27, 2026 10:13
@bimmlerd
Copy link
Copy Markdown
Member

(removing contributing review, I think it was accidentially requested and the need disappeared in the force push)

@YutaroHayakawa
Copy link
Copy Markdown
Member Author

/test

@YutaroHayakawa YutaroHayakawa added the release-note/misc This PR makes changes that have no direct user impact. label Jan 27, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jan 27, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jan 29, 2026
@YutaroHayakawa YutaroHayakawa added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit 3221c72 Jan 29, 2026
507 of 513 checks passed
@YutaroHayakawa YutaroHayakawa deleted the yutaro/encode-name-to-gobgp branch January 29, 2026 23:12
@YutaroHayakawa YutaroHayakawa added the needs-backport/1.19 This PR / issue needs backporting to the v1.19 branch label Feb 24, 2026
@YutaroHayakawa YutaroHayakawa mentioned this pull request Feb 24, 2026
21 tasks
@YutaroHayakawa YutaroHayakawa added backport-pending/1.19 The backport for Cilium 1.19.x for this PR is in progress. and removed needs-backport/1.19 This PR / issue needs backporting to the v1.19 branch labels Feb 24, 2026
@github-actions github-actions bot added backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. and removed backport-pending/1.19 The backport for Cilium 1.19.x for this PR is in progress. labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants