Commit Graph

7574 Commits

Author SHA1 Message Date
Donatas Abraitis
0a0ec0e165
Merge pull request #15624 from raja-rajasekar/rajasekarr/backpressure_bgp_zebra_client_EVPN
bgpd : backpressure - Handle BGP-Zebra(EPVN) Install evt Creation
2024-04-10 08:22:25 +03:00
Rajasekar Raja
a07df6f754 bgpd : backpressure - Handle BGP-Zebra(EPVN) Install evt Creation
Current changes deals with EVPN routes installation to zebra.

In evpn_route_select_install() we invoke evpn_zebra_install/uninstall
which sends zclient_send_message().

This is a continuation of code changes (similar to
ccfe452763) but to handle evpn part
of the code.

Ticket: #3390099

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-04-08 10:51:43 -07:00
Donald Sharp
959439f459
Merge pull request #15640 from opensourcerouting/fix/handling_dynamic_capability_mp_gr
bgpd: Fix errors handling for MP/GR capabilities as dynamic capability
2024-04-05 13:42:03 -04:00
Donald Sharp
3d66dd3e86
Merge pull request #15618 from opensourcerouting/fix/bgp_optimize_suppress_path
bgpd: Optimize the path for suppressed announcements
2024-04-03 08:36:31 -04:00
Donatas Abraitis
27cc9ae508
Merge pull request #15634 from donaldsharp/suppress_fib_funny_business
Suppress fib funny business
2024-04-03 09:51:29 +03:00
Russ White
6bea75f18c
Merge pull request #15628 from opensourcerouting/fix/bgp_prefix_sid_crash
bgpd: Fix error handling when receiving BGP Prefix SID attribute
2024-04-02 11:17:52 -04:00
Donatas Abraitis
c7fde7a32e
Merge pull request #15636 from pguibert6WIND/resolved_prefix_bgp
bgpd: add resolved_prefix visibility on nht
2024-04-02 00:01:34 +03:00
Donatas Abraitis
30a332dad8 bgpd: Fix errors handling for MP/GR capabilities as dynamic capability
When receiving a MP/GR capability as dynamic capability, but malformed, do not
forget to advance the pointer to avoid hitting infinity loop.

After:
```
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [GS0AQ-HKY0X] 127.0.0.1 rcv CAPABILITY
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 5, length 0
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 0, length 0
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [HFHDS-QT71N][EC 33554494] 127.0.0.1(donatas-pc): unrecognized capability code: 0 - ignored
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 0, code: 0, length 0
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [HFHDS-QT71N][EC 33554494] 127.0.0.1(donatas-pc): unrecognized capability code: 0 - ignored
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 0, code: 0, length 0
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [HFHDS-QT71N][EC 33554494] 127.0.0.1(donatas-pc): unrecognized capability code: 0 - ignored
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 0, code: 0, length 1
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [HFHDS-QT71N][EC 33554494] 127.0.0.1(donatas-pc): unrecognized capability code: 0 - ignored
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:15:28 donatas-laptop bgpd[353550]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
```

Before:
```
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [Z1DRQ-N6Z5F] 127.0.0.1(donatas-pc): Dynamic Capability MultiProtocol Extensions afi/safi invalid (bad-value/unicast)
Mar 29 11:14:54 donatas-laptop bgpd[347675]: [JTVED-VGTQQ] 127.0.0.1(donatas-pc): CAPABILITY has action: 1, code: 1, length 10
```

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-30 16:15:08 +02:00
Philippe Guibert
e20faa9fe0 bgpd: add resolved_prefix visibility on nht
The nexthop tracking never displays the prefix that
has been used in ZEBRA to resolve its nexthop. This
information will be useful if some decision has to be
taken regarding any loops, that is to say if for instance
a BGP prefix is resolved over a prefix in ZEBRA that is
exactly the same.

Store the value in bgp nexthop context, and display it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-03-29 17:20:31 +01:00
Philippe Guibert
eea8a8ae24 bgpd: fix srv6 memory leak detection
The asan memory leak has been detected:
> Direct leak of 16 byte(s) in 1 object(s) allocated from:
>     #0 0x7f9066dadd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
>     #1 0x7f9066779b5d in qcalloc lib/memory.c:105
>     #2 0x556d6ca527c2 in vpn_leak_zebra_vrf_sid_update_per_af bgpd/bgp_mplsvpn.c:389
>     #3 0x556d6ca530e1 in vpn_leak_zebra_vrf_sid_update bgpd/bgp_mplsvpn.c:451
>     #4 0x556d6ca64b3b in vpn_leak_postchange bgpd/bgp_mplsvpn.h:311
>     #5 0x556d6ca64b3b in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3751
>     #6 0x556d6cb9f116 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3337
>     #7 0x7f906685a6b6 in zclient_read lib/zclient.c:4490
>     #8 0x7f9066826a32 in event_call lib/event.c:2011
>     #9 0x7f906675c444 in frr_run lib/libfrr.c:1217
>     #10 0x556d6c980d52 in main bgpd/bgp_main.c:545
>     #11 0x7f9065784c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Fix this by freeing the previous memory chunk.

Fixes: b72c9e1475 ("bgpd: cli for SRv6 SID alloc to redirect to vrf (step4)")
Fixes: 527588aa78 ("bgpd: add support for per-VRF SRv6 SID")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-03-29 10:28:45 +01:00
Donatas Abraitis
babb23b748 bgpd: Prevent from one more CVE triggering this place
If we receive an attribute that is handled by bgp_attr_malformed(), use
treat-as-withdraw behavior for unknown (or missing to add - if new) attributes.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-29 09:13:11 +02:00
Donald Sharp
329d5a5cbb bgpd: Arrange peer notification to after zebra announce
Currently BGP attempts to send route change information
to it's peers *before* the route is installed into zebra.
This creates a bug in suppress-fib-pending in the following
scenario:

a) bgp suppress-fib-pending and bgp has a route with
2 way ecmp.
b) bgp receives a route withdraw from peer 1.  BGP
will send the route to zebra and mark the route as
FIB_INSTALL_PENDING.
c) bgp receives a route withdraw from peer 2.  BGP
will see the route has the FIB_INSTALL_PENDING and
not send the withdrawal of the route to the peer.
bgp will then send the route deletion to zebra and
clean up the bgp_path_info's.

At this point BGP is stuck where it has not sent
a route withdrawal to downstream peers.

Let's modify the code in bgp_process_main_one to
send the route notification to zebra first before
attempting to announce the route.  The route withdrawal
will remove the FIB_INSTALL_PENDING flag from the dest
and this will allow group_announce_route to believe
it can send the route withdrawal.

For the master branch this is ok because the recent
backpressure commits are in place and nothing is going
to change from an ordering perspective in that regards.
Ostensibly this fix is also for operators of Sonic and
will be backported to the 8.5 branch as well.  This will
change the order of the send to peers to be after the
zebra installation but sonic users are using suppress-fib-pending
anyways so updates won't go out until rib ack has been
received anyways.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-28 12:27:38 -04:00
Donald Sharp
7c60314652 bgpd: Note when receiving but not understanding a route notification
When BGP has been asked to wait for FIB installation, on route
removal a return call is likely to not have the dest since BGP
will have cleaned up the node, entirely.  Let's just note that
the prefix cannot be found if debugs are turned on and move on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-28 12:25:05 -04:00
Donatas Abraitis
ba6a8f1a31 bgpd: Fix error handling when receiving BGP Prefix SID attribute
Without this patch, we always set the BGP Prefix SID attribute flag without
checking if it's malformed or not. RFC8669 says that this attribute MUST be discarded.

Also, this fixes the bgpd crash when a malformed Prefix SID attribute is received,
with malformed transitive flags and/or TLVs.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-28 17:26:00 +02:00
Russ White
73e0b7a198
Merge pull request #15585 from opensourcerouting/feature/enable_dynamic_capability_for_datacenter_profile
bgpd: Enable BGP dynamic capability by default for datacenter profile
2024-03-26 10:09:50 -04:00
Russ White
67aaa4b076
Merge pull request #15525 from venko-networks/ccs/bugfix/show-ip-bgp
bgpd: add missing white-space between route short status and network …
2024-03-26 10:04:43 -04:00
Russ White
94e6a0f0c1
Merge pull request #15524 from raja-rajasekar/rajasekarr/backpressure_bgp_zebra_client
backpressure bgp zebra client
2024-03-26 10:03:35 -04:00
Donatas Abraitis
59571fd14b bgpd: Optimize the path for suppressed announcements
If supress-duplicates is turned of (which is turned on by default), do not
calculate attribute hash key, that consumes CPU quite a lot.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-26 13:26:17 +02:00
Donald Sharp
ccfe452763 bgpd : backpressure - Handle BGP-Zebra Install evt Creation
BGP is now keeping a list of dests with the dest having a pointer
to the bgp_path_info that it will be working on.

1) When bgp receives a prefix, process it, add the bgp_dest of the
prefix into the new Fifo list if not present, update the flags (Ex:
earlier if the prefix was advertised and now it is a withdrawn),
increment the ref_count and DO NOT advertise the install/withdraw
to zebra yet.

2) Schedule an event to wake up to invoke the new function which will
walk the list one by one and installs/withdraws the routes into zebra.
  a) if BUFFER_EMPTY, process the next item on the list
  b) if BUFFER_PENDING, bail out and the callback in
  zclient_flush_data() will invoke the same function when BUFFER_EMPTY

Changes
 - rename old bgp_zebra_announce to bgp_zebra_announce_actual
 - rename old bgp_zebra_withdrw to bgp_zebra_withdraw_actual
 - Handle new fifo list cleanup in bgp_exit()
 - New funcs: bgp_handle_route_announcements_to_zebra() and
   bgp_zebra_route_install()
 - Define a callback function to invoke
   bgp_handle_route_announcements_to_zebra() when BUFFER_EMPTY in
   zclient_flush_data()

The current change deals with bgp installing routes via
bgp_process_main_one()

Ticket: #3390099

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-03-25 17:49:35 -07:00
Donald Sharp
5f379bebe8 bgpd: backpressure - cleanup bgp_zebra_XX func args
Since installing/withdrawing routes into zebra is going to be changed
around to be dest based in a list,
 - Retrieve the afi/safi to use based upon the dest's afi/safi
   instead of passing it in.
 - Prefix is known by the dest. Remove this arg as well

Ticket: #3390099

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-03-25 14:30:18 -07:00
Donald Sharp
705fed7ca8 bgpd: backpressure - Add a typesafe list for Zebra Announcement
Modify the bgp master to hold a type safe list for bgp_dests that need
to be passed to zebra.

Future commits will use this.

Ticket: #3390099

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-03-25 14:23:53 -07:00
Donatas Abraitis
874242f129 *: Add missing SPDX-License-Identifier for some .c/.h files
Adding them as others: GPL-2.0-or-later

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-21 16:46:58 +02:00
Donatas Abraitis
08c56b40b6
Merge pull request #15574 from chiragshah6/fdev2
bgpd: do not del peer upon pg remote as change
2024-03-20 23:07:22 +02:00
Donatas Abraitis
e2ac728c82 bgpd: Enable BGP dynamic capability by default for datacenter profile
Dynamic capability provides more value without resetting the sessions for some
important other capabilities to exchange, like: graceful-restart, addpath, orf,
fqdn, etc.

Since we support it already, enable it by default.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-20 17:11:14 +02:00
Donatas Abraitis
551656709e bgpd: Drop periodic merge check functions
Not used anymore. There is triggered merge check, not periodic.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-20 16:44:13 +02:00
Cassiano Campes
f3dd00510f bgpd: add missing white-space between route short status and network columns
When running `show ip bgp` command, the 'route short status' and
    'network' columns do not have white-space between them.

    Old show:
        Network          Next Hop            Metric LocPrf Weight Path
     *>i1.1.1.1/32       10.1.12.111              0    100      0 i

    New show:
         Network          Next Hop            Metric LocPrf Weight Path
     *>i 1.1.1.1/32       10.1.12.111              0    100      0 i

    Added white-space to enhance readability between them.

Signed-off-by: Cassiano Campes   <cassiano.campes@venkonetworks.com>
2024-03-19 16:36:14 -03:00
Russ White
8341f6464c
Merge pull request #15558 from opensourcerouting/fix/bgp_dynamic_neighbors_default_advertise
bgpd: Update default-originate route-map actual map structure
2024-03-19 10:25:29 -04:00
Russ White
80c8e10f5d
Merge pull request #15533 from opensourcerouting/fix/add_paths_limit_capability_test
bgpd: Add tests for Paths-Limit capability
2024-03-19 10:18:44 -04:00
Chirag Shah
6b96dcf80e bgpd: do not del peer upon pg remote as change
Currently, when peer-group remote-as is removed, it
deletes all associated neighbors.
Upon re configuring peer-group remote-as, all neighbors
needs to be reconfigured.

Instead, when peer-group remote-as is remove,
cease associated peer's connection and keep in Idle state.
When the peer-group remote-as is (re)configured, trigger
BGP Peer FSM to form neighbor.
Note the connection will be initiated after start timer
expiry.

Ticket: #3828243
Testing:

----- Peers start config ----

router bgp 65566
 bgp router-id 27.0.0.5
 bgp bestpath as-path multipath-relax
 neighbor fabric peer-group
 neighbor fabric remote-as external >>>>
 neighbor swp1 interface peer-group fabric
 neighbor swp1 advertisement-interval 0
 neighbor swp1 timers 3 9
 neighbor swp1 timers connect 10
 neighbor swp2 interface peer-group fabric
 neighbor swp2 advertisement-interval 0
 neighbor swp2 timers 3 9

tor(config)# router bgp 65566
tor(config-router)# no neighbor fabric remote-as external

----- Peers are retained in config ----
router bgp 65566
 bgp router-id 27.0.0.5
 bgp bestpath as-path multipath-relax
 neighbor fabric peer-group
 neighbor swp1 interface peer-group fabric
 neighbor swp1 advertisement-interval 0
 neighbor swp1 timers 3 9
 neighbor swp1 timers connect 10
 neighbor swp2 interface peer-group fabric
 neighbor swp2 advertisement-interval 0
 neighbor swp2 timers 3 9

----- Peers are in idle state ----
Neighbor        V  AS  MsgRcvd MsgSent TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
spine-1(swp1)   4   0       52      34      0    0    0 00:00:04         Idle        0 N/A
spine-3(swp2)   4   0       52      34      0    0    0 00:00:04         Idle        0 N/A

tor(config)# router bgp 65566
tor(config-router)# neighbor fabric remote-as external

---- after connect timer expiry forms the neighbor ----

Neighbor       V    AS MsgRcvd MsgSent TblVer InQ OutQ  Up/Down State/PfxRcd  PfxSnt Desc
spine-1(swp1)  4 64435     784     749      0   0    0 00:35:10           11       2 N/A
spine-3(swp2)  4 64435     784     749      0   0    0 00:35:10           11       2 N/A

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-03-18 15:36:41 -07:00
Donatas Abraitis
5e420114e1
Merge pull request #15520 from donaldsharp/bgp_dest_dev_build
bgpd: When using dev build add pointer information to %pBD
2024-03-18 22:49:27 +02:00
Donatas Abraitis
0ecea59c13
Merge pull request #15553 from fdumontet6WIND/as_path_loop
bgpd: make as-path-loop-detection conform to the framework
2024-03-18 10:54:21 +02:00
Donatas Abraitis
4f1e2dcd7a bgpd: Update default-originate route-map actual map structure
If using with `bgp listen range ... peer-group x`, default_rmap[afi][safi] is not
updated, and after the hard-reset in other side, this is flushed and never updated
again without restarting the sender BGP daemon.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-15 13:49:06 +02:00
Francois Dumontet
11d6560104 bgpd: make as-path-loop-detection conform to the framework
currently:
when as-path-loop-detection is set on a peer-group.
members of the peer-group are not using that functionnality.

analysis:
the as-path-loop-detection, is not using the peer's flags
related framework.

fix:
use the peer's flag framework for as-path-loop-detection.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2024-03-14 14:30:51 +01:00
Donald Sharp
bc265804ca bgpd: Add some missing data to show bgp attribute-info
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-14 06:51:45 -04:00
Donald Sharp
894cb4f689 bgpd: When using dev build add pointer information to %pBD
When building FRR with `--enable-dev-build`.  Add a bit of
code to include the pointer value as part of the output.
Helps with tracking down issues and let's us see more data
when using the dev build option.

New output:

2024/03/08 19:48:56 BGP: [V0J1J-W5RHA] 11.0.20.1/32(0x5759ddf8d7c0) for 11.0.20.1/32

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-14 09:45:09 +00:00
Donatas Abraitis
081f6520ff bgpd: Avoid padding for bgp_paths_limit_capability struct
When sending the packets over the network (dynamic capability) it reports 6 bytes
instead of 5 bytes, and causes some issues between little/big endian machines.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-14 09:50:49 +02:00
Donald Sharp
addff17a55 bgpd: Ensure community data is freed in some cases.
Customer has this valgrind trace:

Direct leak of 2829120 byte(s) in 70728 object(s) allocated from:
  0 in community_new ../bgpd/bgp_community.c:39
  1 in community_uniq_sort ../bgpd/bgp_community.c:170
  2 in route_set_community ../bgpd/bgp_routemap.c:2342
  3 in route_map_apply_ext ../lib/routemap.c:2673
  4 in subgroup_announce_check ../bgpd/bgp_route.c:2367
  5 in subgroup_process_announce_selected ../bgpd/bgp_route.c:2914
  6 in group_announce_route_walkcb ../bgpd/bgp_updgrp_adv.c:199
  7 in hash_walk ../lib/hash.c:285
  8 in update_group_af_walk ../bgpd/bgp_updgrp.c:2061
  9 in group_announce_route ../bgpd/bgp_updgrp_adv.c:1059
 10 in bgp_process_main_one ../bgpd/bgp_route.c:3221
 11 in bgp_process_wq ../bgpd/bgp_route.c:3221
 12 in work_queue_run ../lib/workqueue.c:282

The above leak detected by valgrind was from a screenshot so I copied it
by hand.  Any mistakes in line numbers are purely from my transcription.
Additionally this is against a slightly modified 8.5.1 version of FRR.
Code inspection of 8.5.1 -vs- latest master shows the same problem
exists.  Code should be able to be followed from there to here.

What is happening:

There is a route-map being applied that modifes the outgoing community
to a peer.  This is saved in the attr copy created in
subgroup_process_announce_selected.  This community pointer is not
interned.  So the community->refcount is still 0.  Normally when
a prefix is announced, the attr and the prefix are placed on a
adjency out structure where the attribute is interned.  This will
cause the community to be saved in the community hash list as well.
In a non-normal operation when the decision to send is aborted after
the route-map application, the attribute is just dropped and the
pointer to the community is just dropped too, leading to situations
where the memory is leaked.  The usage of bgp suppress-fib would
would be a case where the community is caused to be leaked.
Additionally the previous commit where an unsuppress-map is used
to modify the outgoing attribute but since unsuppress-map was
not considered part of outgoing policy the attribute would be dropped as
well.  This pointer drop also extends to any dynamically allocated
memory saved by the attribute pointer that was not interned yet as well.

So let's modify the return case where the decision is made to
not send the prefix to the peer to always just flush the attribute
to ensure memory is not leaked.

Fixes: #15459
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-13 19:28:11 -04:00
Donald Sharp
6814401c47 bgpd: Include unsuppress-map as a valid outgoing policy
If unsuppress-map is setup for outgoing peers, consider that
policy is being applied as for RFC 8212.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-13 19:28:11 -04:00
Donald Sharp
e613e12f12 bgpd: Ensure that the correct aspath is free'd
Currently in subgroup_default_originate the attr.aspath
is set in bgp_attr_default_set, which hashs the aspath
and creates a refcount for it.  If this is a withdraw
the subgroup_announce_check and bgp_adj_out_set_subgroup
is called which will intern the attribute.  This will
cause the the attr.aspath to be set to a new value
finally at the bottom of the function it intentionally
uninterns the aspath which is not the one that was
created for this function.  This reduces the other
aspath's refcount by 1 and if a clear bgp * is issued
fast enough the aspath for that will be removed
and the system will crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-13 19:28:11 -04:00
Donatas Abraitis
56a23f056c bgpd: Set Paths Limit to 0 instead of unsetting the capability
The capability should be untouched, and send 0 (unlimited) instead.

Otherwise, we miss the capability and things are broken later until the
session reset.

Fixes: 72f0e06824 ("bgpd: Implement Paths-Limit capability")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-13 16:48:54 +02:00
Donatas Abraitis
5f50359c8a bgpd: Show Addpath capability TX/RX flags unconditionally
It's very annoying when testing and instead of looking for true/false, you
have to check if the field exists.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-13 16:48:54 +02:00
Donatas Abraitis
778357e9ef bgpd: Check the route and the nexthop appropriately when validating NH
A route and its nexthop might belong to different VRFs. Therefore, we need
both the bgp and bgp_nexthop pointers.

Fixes: 8d51fafdcb ("bgpd: Drop bgp_static_update_safi() function")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-13 09:39:22 +02:00
Donald Sharp
0042ea49b5
Merge pull request #15513 from opensourcerouting/fix/bgp_default_software_version
bgpd: Fix `no` form for `neighbor X capability software-version`
2024-03-11 07:17:09 -04:00
Donatas Abraitis
78757362f2 bgpd: Allow dynamically disable graceful-restart/long-lived graceful-restart
If we enter `bgp graceful-restart-disable`, make sure we disable the capabilities.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-10 18:25:30 +02:00
Donatas Abraitis
77102e853e bgpd: Unset advertised capabilities if capability is disabled
When using dynamic capabilities, do not forget to unset advertised capabilities.

Otherwise, it's kept as advertised.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-09 22:23:37 +02:00
Donatas Abraitis
2038fad33e bgpd: Fix no form for neighbor X capability software-version
If `bgp default software-version-capability` is enabled, allow unsetting this
for a single neighbor also.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-09 21:52:17 +02:00
Donatas Abraitis
864844a2e8
Merge pull request #15486 from donaldsharp/make_prefix
bgpd: pi->attr is deref'ed in all paths leading up to test
2024-03-06 08:43:40 +02:00
Donald Sharp
a9c16a0a89 bgpd: pi->attr is deref'ed in all paths leading up to test
In make_prefix, the code checks to see if the pi->attr
is non-NULL.  Since (A) we cannot have a path_info without
an attribute and (B) all paths leading up to the test
in make_prefix already have pi->attr deref'ed and the
code is not crashing we know this is safe to remove.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-05 10:37:48 -05:00
Chirag Shah
5cb7712b3e bgpd:aggr summary-only remove suppressed from evpn
Ticket: #3534718 #3720960
Testing Done:

Config:
router bgp 65564 vrf sym_2
 bgp router-id 27.0.0.9
 !
 address-family ipv4 unicast
  redistribute static
 exit-address-family

vrf sym_2
 vni 8889
 ip route 63.2.1.0/24 blackhole
 ip route 63.2.1.2/32 blackhole
 ip route 63.2.1.3/32 blackhole
exit-vrf

tor-1:# vtysh -c "show bgp l2vpn evpn route" | grep -A3 63.2
*> [5]:[0]:[24]:[63.2.1.0] RD 27.0.0.9:19
                    27.0.0.9 (tor-1)
                                             0         32768 ?
                    ET:8 RT:28:8889 Rmac:44:38:39:ff:ff:29
--
*> [5]:[0]:[32]:[63.2.1.2] RD 27.0.0.9:19
                    27.0.0.9 (tor-1)
                                             0         32768 ?
                    ET:8 RT:28:8889 Rmac:44:38:39:ff:ff:29
*> [5]:[0]:[32]:[63.2.1.3] RD 27.0.0.9:19
                    27.0.0.9 (tor-1)
                                             0         32768 ?
                    ET:8 RT:28:8889 Rmac:44:38:39:ff:ff:29

tor-1(config)# router bgp 65564 vrf sym_2
tor-1(config-router)# address-family ipv4 unicast
tor-1(config-router-af)# aggregate-address 63.2.0.0/16 summary-only
tor-1(config-rou-f)# end

tor-1:# vtysh -c "show bgp l2vpn evpn route" | grep -A3 63.2.1
tor-1:# vtysh -c "show bgp l2vpn evpn route" | grep -A3 63.2
*> [5]:[0]:[16]:[63.2.0.0] RD 27.0.0.9:19
                    27.0.0.9 (tor-1)
                                             0         32768 ?
                    ET:8 RT:28:8889 Rmac:44:38:39:ff:ff:29

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-03-05 07:03:39 -08:00
Russ White
018fad7806
Merge pull request #15450 from opensourcerouting/fix/coverity
bgpd: Check if attributes exists for the path before checking mp_nexthop_len
2024-03-05 08:43:28 -05:00