Commit graph

1465 commits

Author SHA1 Message Date
Donatas Abraitis dc37bff8c0
Merge pull request #18376 from pguibert6WIND/show_bgp_neighbor_counter_tx
bgpd: fix add prefix sent in 'show bgp neighbor'
2025-04-10 19:38:59 +03:00
Philippe Guibert a47a53b003 bgpd: fix add prefix sent in 'show bgp neighbor'
The 'acceptedPrefixCounter' is available in 'show bgp neighbor json', but
there is no equivalent when using the non json output. Add it.

> # show bgp neighbor
> [..]
>  Community attribute sent to this neighbor(all)
>  0 accepted prefixes, 1 sent prefixes

Fixes: 856ca177c4 ("Added json formating support to show-...-neighbors-... bgp commands.")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-04-10 10:12:36 +02:00
Louis Scalbert a0a0749568 bgpd: remove useless calls to afi2family
Remove useless calls to afi2family(). str2prefix() always sets the
prefix family.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-04-09 13:07:56 +02:00
Mark Stapp 660cbf5651 bgpd: clean up variable-shadowing compiler warnings
Clean up -Wshadow warnings in bgp.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Donald Sharp 863f4b0992 bgpd: Tie in more clear events to clear code
The `clear bgp *` and the interface down events
cause a global clearing of data from the bgp rib.
Let's tie those into the clear peer code such
that we can take advantage of the reduced load
in these cases too.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-20 09:38:51 -04:00
Donatas Abraitis e4b14dae7c bgpd: Do not show neighbor X capability link-local for unnumbered peering
This capability is enabled by default.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-02-10 23:24:55 +02:00
Donatas Abraitis 87da3ec038 bgpd: Enable Link-Local Next Hop capability for unnumbered peers implicitly
Fixes: db853cc97e ("bgpd: Implement Link-Local Next Hop capability")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-02-10 22:59:16 +02:00
Russ White 2ef76a3350
Merge pull request #17871 from opensourcerouting/feature/bgp_link_local_capability
bgpd: Implement Link-Local Next Hop capability
2025-02-07 14:00:59 -05:00
Russ White f74fa9543b
Merge pull request #17992 from chiragshah6/fdev5
bgpd: fix route-distinguisher in vrf leak json cmd
2025-02-04 07:40:36 -05:00
Chirag Shah 892704d07f bgpd: fix route-distinguisher in vrf leak json cmd
For auto configured value RD value comes as NULL,
switching back to original change will ensure to cover
for both auto and user configured RD value in JSON.

tor-11# show bgp vrf blue ipv4 unicast route-leak json
{
  "vrf":"blue",
  "afiSafi":"ipv4Unicast",
  "importFromVrfs":[
    "purple"
  ],
  "importRts":"10.10.3.11:6",
  "exportToVrfs":[
    "purple"
  ],
  "routeDistinguisher":"(null)", <<<<<
  "exportRts":"10.10.3.11:10"
}

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2025-02-03 20:58:45 -08:00
Enke Chen 6204db214e bgpd: add config default for "bgp bestpath aigp"
Just to make it simpler for compiling with a different default value.
No change to its default value.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2025-02-02 20:35:44 -08:00
Enke Chen a2018b3ee9 bgpd: add config default for "route-reflector allow-outbound-policy"
Just to make it simpler for compiling with a different default value.
No change to its default value.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2025-02-01 10:24:19 -08:00
Russ White 7b6f686a9f
Merge pull request #17736 from opensourcerouting/table-direct
bgpd,lib,zebra: permit table-direct on VRFs
2025-01-28 10:24:00 -05:00
Donatas Abraitis 4338e21aa2 Revert "bgpd: Handle Addpath capability using dynamic capabilities"
This reverts commit 05cf9d03b3.

TL;DR; Handling BGP AddPath capability is not trivial (possible) dynamically.

When the sender is AddPath-capable and sends NLRIs encoded with AddPath ID,
and at the same time the receiver sends AddPath capability "disable-addpath-rx"
(flag update) via dynamic capabilities, both peers are out of sync about the
AddPath state. The receiver thinks already he's not AddPath-capable anymore,
hence it tries to parse NLRIs as non-AddPath, while they are actually encoded
as AddPath.

AddPath capability itself does not provide (in RFC) any mechanism on backward
compatible way to handle NLRIs if they come mixed (AddPath + non-AddPath).

This explains why we have failures in our CI periodically.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-25 20:51:16 +02:00
Rafael Zalamena 7bcb2f5193 bgpd: allow table-direct on different VRFs
Allow table-direct to be configured in different VRFs.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2025-01-23 14:37:09 -03:00
Philippe Guibert 25b6751d14 bgpd: fix static analyzer issues around bgp pointer
Some static analyzer issues can be observed in BGP code:

> In file included from ./lib/zebra.h:13,
>                  from lib/event.c:8:
> ./lib/compiler.h:222:26: note: '#pragma message: Remove `clear thread cpu` command'
>   222 | #define CPP_NOTICE(text) _Pragma(CPP_STR(message text))
>       |                          ^~~~~~~
> lib/event.c:433:1: note: in expansion of macro 'CPP_NOTICE'
>   433 | CPP_NOTICE("Remove `clear thread cpu` command")
>       | ^~~~~~~~~~
> bgpd/bgp_vty.c:1592:5: warning: Access to field 'as_pretty' results in a dereference of a null pointer (loaded from variable 'bgp') [core.NullDereference]
> 1592 |                                 bgp->as_pretty);
>       |                                 ^~~~~~~~~~~~~~
> bgpd/bgp_vty.c:1599:5: warning: Access to field 'as_pretty' results in a dereference of a null pointer (loaded from variable 'bgp') [core.NullDereference]
> 1599 |                                 bgp->as_pretty);
>       |                                 ^~~~~~~~~~~~~~
> bgpd/bgp_vty.c:1612:7: warning: Access to field 'flags' results in a dereference of a null pointer (loaded from variable 'bgp') [core.NullDereference]
> 1612 |                     IS_BGP_INSTANCE_HIDDEN(bgp)) {
>       |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./bgpd/bgpd.h:2906:3: note: expanded from macro 'IS_BGP_INSTANCE_HIDDEN'
> 2906 |         (CHECK_FLAG(_bgp->flags, BGP_FLAG_INSTANCE_HIDDEN) &&                  \
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./lib/zebra.h:274:31: note: expanded from macro 'CHECK_FLAG'
>   274 | #define CHECK_FLAG(V,F)      ((V) & (F))
>       |                               ^~~
> bgpd/bgp_vty.c:1614:4: warning: Access to field 'flags' results in a dereference of a null pointer (loaded from variable 'bgp') [core.NullDereference]
> 1614 |                         UNSET_FLAG(bgp->flags, BGP_FLAG_INSTANCE_HIDDEN);
>       |                         ^          ~~~
> ./lib/zebra.h:276:34: note: expanded from macro 'UNSET_FLAG'
>   276 | #define UNSET_FLAG(V,F)      (V) &= ~(F)
>       |                               ~  ^
> 4 warnings generated.
> Static Analysis warning summary compared to base:

Fix those issues by protecting the bgp pointer.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-01-21 13:48:36 +01:00
Philippe Guibert 3a921c6a1d bgpd: fix import vrf creates multiple bgp instances
The more the vrf green is referenced in the import bgp command, the more
there are instances created. The below configuration shows that the vrf
green is referenced twice, and two BGP instances of vrf green are
created.

The below configuration:
> router bgp 99
> [..]
>  import vrf green
> exit
> router bgp 99 vrf blue
> [..]
>  import vrf green
> exit
> router bgp 99 vrf green
> [..]
> exit
>
> r4# show bgp vrfs
> Type  Id     routerId          #PeersCfg  #PeersEstb  Name
>              L3-VNI            RouterMAC              Interface
> DFLT  0      10.0.3.4          0          0           default
>              0                 00:00:00:00:00:00      unknown
>  VRF  5      10.0.40.4         0          0           blue
>              0                 00:00:00:00:00:00      unknown
>  VRF  6      0.0.0.0           0          0           green
>              0                 00:00:00:00:00:00      unknown
>  VRF  6      10.0.94.4         0          0           green
>              0                 00:00:00:00:00:00      unknown

Fix this at import command, by looking at an already present bgp
instance.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-01-21 13:48:36 +01:00
Philippe Guibert 9f7177af13 bgpd: fix duplicate BGP instance created with unified config
When running the bgp_evpn_rt5 setup with unified config, memory leak
about a non deleted BGP instance happens.

> root@ubuntu2204hwe:~/frr/tests/topotests/bgp_evpn_rt5# cat /tmp/topotests/bgp_evpn_rt5.test_bgp_evpn/r1.asan.bgpd.1164105
>
> =================================================================
> ==1164105==ERROR: LeakSanitizer: detected memory leaks
>
> Indirect leak of 12496 byte(s) in 1 object(s) allocated from:
>     #0 0x7f358eeb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
>     #1 0x7f358e877233 in qcalloc lib/memory.c:106
>     #2 0x55d06c95680a in bgp_create bgpd/bgpd.c:3405
>     #3 0x55d06c95a7b3 in bgp_get bgpd/bgpd.c:3805
>     #4 0x55d06c87a9b5 in bgp_get_vty bgpd/bgp_vty.c:603
>     #5 0x55d06c68dc71 in bgp_evpn_local_l3vni_add bgpd/bgp_evpn.c:7032
>     #6 0x55d06c92989b in bgp_zebra_process_local_l3vni bgpd/bgp_zebra.c:3204
>     #7 0x7f358e9e3feb in zclient_read lib/zclient.c:4626
>     #8 0x7f358e98082d in event_call lib/event.c:1996
>     #9 0x7f358e848931 in frr_run lib/libfrr.c:1232
>     #10 0x55d06c60eae1 in main bgpd/bgp_main.c:557
>     #11 0x7f358e229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Actually, a BGP VRF Instance is created in auto mode when creating the
global BGP instance for the L3 VNI. And again, an other BGP VRF instance
is created. Fix this by ensuring that a non existing BGP instance is not
present. If it is present, and with auto mode or in hidden mode, then
override the AS value.

Fixes: f153b9a9b6 ("bgpd: Ignore auto created VRF BGP instances")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-01-21 13:48:36 +01:00
Donatas Abraitis db853cc97e bgpd: Implement Link-Local Next Hop capability
Related: https://datatracker.ietf.org/doc/html/draft-white-linklocal-capability

TL;DR; use 16 bytes long next-hops for point-to-point (unnumbered) links instead
of sending 32 bytes (::/LL, GUA/LL, LL/LL combinations).

For backward compatiblity we should handle even 32 bytes existing next hops.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-17 16:48:32 +02:00
Russ White 66a5d76920
Merge pull request #17810 from donaldsharp/bgp_connect_refactor
Bgp connect refactor
2025-01-15 11:11:41 -05:00
Donatas Abraitis d60320c6d2 bgpd: Handle ENHE capability via dynamic capability
FRR supports dynamic capability which is useful to exchange the capabilities
without tearing down the session. ENHE capability was missed to be included
handling via dynamic capability. Let's add it too.

This was missed and asked in Slack that it would be useful.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-14 22:46:53 +02:00
Donald Sharp 78fa9b6feb bgpd: su_remote and su_local are properties of the connection
su_local and su_remote in the peer can change based upon
if we are initiating the remote connection or receiving it.
As such we need to treat it as a property of the connection.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-10 10:07:11 -05:00
Donatas Abraitis 76fc75de9e bgpd: Fix showing default timers bgp x y
Fixes: ef4a9215b9 ("bgpd: Reuse defined constants for BGP timers")
Fixes: ab3535fbcf ("bgpd: Implement connect retry backoff")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-09 23:56:31 +02:00
Russ White 2a90c80f49
Merge pull request #17733 from pguibert6WIND/bmp_event_changes
BMP handling of BGP configuration changes
2025-01-07 09:06:43 -05:00
Russ White c9c9608c70
Merge pull request #17431 from krishna-samy/bgpd_json_commits
bgpd: show json output changes to optimize various show commands
2025-01-07 08:43:55 -05:00
Philippe Guibert 4052c18a42 bgpd: bmp, define hook for route distinguisher updates
At startup, if bmp loc-rib is enabled, the peer_id of the
loc-rib per peer header message has the route distinguisher set to 0:0.
Actually, the route distinguisher has been updated after the peer up
message is sent, and the information is not refreshed.

Create a hook API to handle route distinguisher config events: pre and
post configuration. Use that hook in BMP module to send peer down, and
peer up events when necessary.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-12-30 15:13:38 +01:00
Donatas Abraitis 28e62b46ba bgpd: Show prefix-related stats per neighbor
E.g.:

```
  Prefix statistics:
    Inbound filtered: 0
    AS-PATH loop: 0
    Originator loop: 0
    Cluster loop: 0
    Invalid next-hop: 0
    Withdrawn: 0
    Attributes discarded: 3
```

JSON:

```
    "prefixStats":{
      "inboundFiltered":0,
      "aspathLoop":0,
      "originatorLoop":0,
      "clusterLoop":0,
      "invalidNextHop":0,
      "withdrawn":0,
      "attributesDiscarded":3
    },
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-30 12:26:19 +02:00
Donatas Abraitis 9ce3b144c9
Merge pull request #17580 from varuntumbe/dev/label_pool_release_fix
BGP Labelpool : Releasing the label in labelpool when VPN session gets removed
2024-12-23 14:48:21 +02:00
Donatas Abraitis b6dcf61877 bgpd: Fix enforce-first-as per peer-group removal
If we do `no neighbor PG enforce-first-as`, it wasn't working because the flag
was inherited incorrectly for the members of the peer-group.

Fixes: 322462920e ("bgpd: Enable enforce-first-as by default")

Closes: https://github.com/FRRouting/frr/issues/17702

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-21 17:04:30 +02:00
Donatas Abraitis 7f4374fefc
Merge pull request #17669 from pguibert6WIND/rdvpn_mem_leak
bgpd: fix memory leak when reconfiguring a route distinguisher
2024-12-20 16:15:15 +02:00
Jafar Al-Gharaibeh f78b1786a6
Merge pull request #17599 from opensourcerouting/fix/reduce_default_connect_timer
bgpd: Connect retry timer backoff
2024-12-18 16:26:37 -06:00
Philippe Guibert 0dd96287dd bgpd: fix memory leak when reconfiguring a route distinguisher
A memory leak happens when reconfiguring an already configured route
distinguisher on an L3VPN BGP instance. Fix this by freeing the previous
route distinguisher.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-12-18 16:56:15 +01:00
varuntumbe d5c2f2df19 bgpd: Releasing the label in bgp_delete flow
Releasing the vpn label from label pool chunk using bgp_lp_release routine whenever vpn session is removed.
bgp_lp_release will clear corresponding bit in the allocated map of the label pool chunk and increases nfree by 1

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-12-16 21:27:46 +05:30
Donatas Abraitis ef4a9215b9 bgpd: Reuse defined constants for BGP timers
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-11 15:56:12 +02:00
Rajasekar Raja 0f2cb27310 bgpd: backpressure - Optimize EVPN L3VNI remote routes processing
Anytime BGP gets a L3 VNI ADD/DEL from zebra,
 - Walking the entire global routing table per L3VNI is very expensive.
 - The next read (say of another VNI ADD/DEL) from the socket does
   not proceed unless this walk is complete.

So for triggers where a bulk of L3VNI's are flapped, this results in
huge output buffer FIFO growth spiking up the memory in zebra since bgp
is slow/busy processing the first message.

To avoid this, idea is to hookup the BGP-VRF off the struct bgp_master
and maintain a struct bgp FIFO list which is processed later on, where
we walk a chunk of BGP-VRFs and do the remote route install/uninstall.

Ticket :#3864372

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-12-09 08:46:16 -08:00
Philippe Guibert 12a9ca4de6 bgpd: fix unconfigure asdot neighbor
The below command is not successfull on an existing as dot peer

> no neighbor 10.0.0.2 remote-as 1.1
> % Create the peer-group or interface first

Handle the case where the remote-as argument can be an ASNUM.

Fixes: 8079a4138d ("lib, bgp: add initial support for asdot format")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-12-04 21:29:34 +01:00
Donald Sharp eacf923b00 bgpd: Fix pattern of usage in bgp_notify_config_change
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
        peer_notify_config_change(peer->connection);
else
        bgp_session_reset_safe(peer, &nnode);

Let's add a bool return to peer_notify_config_change of whether or
not it should call the peer session reset.  This simplifies
the code a bunch.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:59:18 -05:00
Donald Sharp ba0edb9545 bgpd: Add peer_notify_config_change() function
We have about a bajillion tests of if we can
notify the peer and then we send a config change
notification.  Let's just make a function that
does this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:58:23 -05:00
Donald Sharp 2e5b4e32c4 bgpd: peer_notify_unconfig should be connection based
Convert this function to being connection based.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:49:34 -05:00
Donatas Abraitis ee5893ff59 bgpd: Use gracefulRestart JSON field
Deprecate gracefulRestartCapability which is inconsistent with an existing
format if advertised and received are printed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-25 10:44:52 +02:00
Donatas Abraitis 0a85b1ba04 bgpd: Fix graceful-restart for peer-groups
Slipped somehow that peer-groups with GR is just completely broken, but it was
working before.

Strikes again, that we MUST have more and more topotests.

Fixes: 15403f521a ("bgpd: Streamline GR config, act on change immediately")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-24 21:57:19 +02:00
Donatas Abraitis 8cc6359fdc bgpd: Disable sending ROV extended community by default
https://datatracker.ietf.org/doc/html/rfc8097 defines ROV extended community,
but https://datatracker.ietf.org/doc/draft-ietf-sidrops-avoid-rpki-state-in-bgp
is against sending it by default even for iBGP peers.

Let's do this practice and reverse it.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-19 16:25:12 +02:00
Pooja Jagadeesh Doijode 7decdc572c bgpd: [EVPN GR] Added JSON support for "show bgp router"
Introduced JSON support of "show bgp router" command

VTY:
mlx-3700-19# show bgp router
BGP started gracefully at Tue Nov 14 21:18:34 2023
Graceful restart completed at Tue Nov 14 21:18:37 2023
Number of BGP instances (including default): 1

JSON:
mlx-3700-19# show bgp router json
{
  "bgpStartedAt":"Tue Nov 14 21:18:34 2023\n",
  "bgpStartedGracefully":"Yes",
  "grComplete":"Yes",
  "grCompletedAt":"Tue Nov 14 21:18:37 2023\n",
  "bgpInMaintenanceMode":"No",
  "bgpInstanceCount":1
}

Issue:3624937
Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2024-11-15 22:48:58 -08:00
Donatas Abraitis afb6f66f2b bgpd: Depracate no_synchronization_cmd, no_auto_summary_cmd commands
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-14 16:15:23 +02:00
hanyu.zly 9fa56a03c7 bgpd:support tcp-mss for neighbor group
Signed-off-by: hanyu.zly <hanyu.zly@alibaba-inc.com>
2024-11-07 14:50:21 +08:00
David Lamparter e4df480831
Merge pull request #16354 from Sokolmish/zebra-no-ra 2024-10-28 13:28:29 +01:00
Russ White a481d93941
Merge pull request #17053 from opensourcerouting/fix/drop_bgp_network_import_check_exact_cmd
bgpd: Drop deprecated `bgp network import-check exact` command
2024-10-15 11:14:35 -04:00
Donald Sharp 0f8842ed18 bgpd: Allow specification of vrf in show bgp neighbor graceful-restart
This command did not allow the operator to display neighbor information
related to graceful-restart when used inside of a vrf.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-10 09:13:39 -04:00
Donatas Abraitis 5913d49d5b bgpd: Drop deprecated bgp network import-check exact command
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-10 12:53:51 +03:00
Donald Sharp 40c94ca369 bgpd: Remove dead code from recent commit
Recent commit 4d0e7a49cf
brought in changes that moved a check for ret up
in the code, caused some code to be left around
and be effectively dead since it would never be called.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-25 09:30:37 -04:00