Commit graph

37295 commits

Author SHA1 Message Date
Donatas Abraitis 98ca49e0ee bgpd: Show neighbor advertised paths including addpath
Without the patch only the best path is displayed.

With the patch, display all paths including addpaths, but only for non-JSON
output to avoid breaking existing output.

E.g.:

```
munet> r2 shi vtysh -c 'sh ip bgp nei 192.168.2.3 advertised-routes'
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.16.254/32 192.168.2.3              0             0 65003 ?
 *   172.16.16.254/32 192.168.2.4              0             0 65004 ?
 *>  192.168.2.0/24   192.168.2.3              0             0 65003 ?
 *   192.168.2.0/24   192.168.2.4              0             0 65004 ?
```

Before it was:

```
munet> r2 shi vtysh -c 'sh ip bgp nei 192.168.2.3 advertised-routes'
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.16.254/32 192.168.2.3              0             0 65003 ?
 *>  192.168.2.0/24   192.168.2.3              0             0 65003 ?
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-13 13:32:28 +02:00
Donatas Abraitis 8e771bda84 bgpd: Fix color extended community parsing
CID: 1601739

Fixes: 937cf4db17 ("bgpd:support of color extended community color-only types")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-13 10:03:17 +02:00
Russ White 5456bc5d93
Merge pull request #17331 from Jafaral/ospf-instance
tests: add support for ospf instances  with unified configs
2024-11-12 18:00:46 -05:00
Jafar Al-Gharaibeh dfd85da52f
Merge pull request #17205 from piotrjurkiewicz/patch-1
debian: Add missing libprotobuf-dev to grpc profile
2024-11-12 16:13:27 -06:00
Donald Sharp ac6314d380
Merge pull request #17297 from mjstapp/mjs_ifp_table
zebra, lib: use internal rbtree for per-NS tree of ifps
2024-11-12 15:12:07 -05:00
Jafar Al-Gharaibeh 92ecd0a5d4 tests: add support for ospf instances with unified configs
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-11-12 10:51:33 -06:00
Russ White d1d8aeec86
Merge pull request #17368 from louis-6wind/bgp_vpnv4_asbr-clarify
tests: clarify bgp_vpnv4_asbr
2024-11-12 11:40:01 -05:00
Russ White fe56a659b6
Merge pull request #17410 from opensourcerouting/fix/bgpd_ebgp_multihop_set_unset
BGP BFD session things
2024-11-12 11:02:22 -05:00
Russ White 9ce07a1313
Merge pull request #17374 from opensourcerouting/fix/rfc_9687
Add two RFCs for BGP to the list
2024-11-12 09:59:06 -05:00
Russ White e895c8e09d
Merge pull request #17366 from baozhen-H3C/202411061447
isisd: fix crash when switching P2P after shutdowning LAN circuit
2024-11-12 09:55:47 -05:00
Russ White d18337f4bd
Merge pull request #17344 from opensourcerouting/fix/reset_bgp_session_only_if_bfd_is_properly_working
bgpd: Reset BGP session only if it was a real BFD DOWN event
2024-11-12 09:53:40 -05:00
Dmytro Shytyi be4eb370db
isisd: properly display srv6 algorithm
When the segment-routing ipv6 is configured, the SPF
algoritm shows S-SPF is used:

> rt1# show isis segment-routing srv6 node
> Area 1:
> IS-IS L1 SRv6-Nodes:
>
> System ID Algorithm SRH Max SL SRH Max End Pop SRH Max H.encaps SRH Max End D
> -----------------------------------------------------------------------------------------
> 0000.0000.0001 S-SPF 3 3 2 5

Actually, the segment-routing ipv6 algo capabilities (SPF) are rewritten.
Don't rewrite the algo[0].

> rt1# show isis segment-routing srv6 node
> Area 1:
> IS-IS L1 SRv6-Nodes:
>
> System ID Algorithm SRH Max SL SRH Max End Pop SRH Max H.encaps SRH Max End D
> -----------------------------------------------------------------------------------------
> 0000.0000.0001 SPF 3 3 2 5

Fixes: ("78774bbcd51b") isisd: add isis flex-algo lsp advertisement

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-11-12 15:24:57 +01:00
Donatas Abraitis 2c08d9f824 tests: Check if BFD session is created with update-source (interface)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-12 13:12:56 +02:00
Donatas Abraitis fcabeeaf79 bgpd: Update source address for BFD session
If BFD is down, we should try to detect the source automatically from the given
interface.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-12 13:09:09 +02:00
Donatas Abraitis 1abe911c5b
Merge pull request #17409 from krishna-samy/show_nexthop_json_fix
bgpd: fix resolvedPrefix in show nexthop json output
2024-11-11 17:10:16 +02:00
Donatas Abraitis 55dcbd3292 tests: Check if BGP BFD session is created correctly with multihop/update-source
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-11 17:07:45 +02:00
Donatas Abraitis 29eafd32c5 bgpd: Do not try to uninstall BFD session if the peer is not established
Having something like:

```
 neighbor 192.168.1.222 ebgp-multihop 32
 neighbor 192.168.1.222 update-source 192.168.1.5
 neighbor 192.168.1.222 bfd
```

Won't work and the result is (empty):

```
$ show bfd peers
BFD Peers:
```

bgp_stop() is called in BGP FSM multiple times (even at startup) that
causes intermediate session interruption when update-source/ebgp-multihop
is triggered.

With this fix, the ordering does not matter and the BFD session's parameters
are updated correctly.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-11 16:49:22 +02:00
Donatas Abraitis 6e92e25518 bgpd: Do not use an existing peer pointer for ALL_LIST_ELEMENTS()
Use a separate `member` in this case.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-11 16:49:08 +02:00
Krishnasamy R 95c08e082c bgpd: fix resolvedPrefix in show nexthop json output
While populating  the nexthop info for "show bgp nexthop json", resolvedPrefix
is added in parent json object instead of json_nexthop object.
This results in displaying wrong resolvedPrefix for nexthops.
Fixing the same by adding resolvedPrefix to json_nexthop object, so that
the proper resolvedPrefix would be displayed for the respective nexthop

Signed-off-by: Krishnasamy R <krishnasamyr@nvidia.com>
2024-11-11 01:59:31 -08:00
Donatas Abraitis 1dcb4bb2d3
Merge pull request #17362 from raja-rajasekar/rajasekarr/src_proto_for_redist_cmd
bgpd: Fix for match source-protocol in route-map for redistribute cmd
2024-11-09 22:01:44 +02:00
Rajasekar Raja 68358c0f92 bgpd: Fix for match source-protocol in route-map for redistribute cmd
A redistribute cmd can have a route-map attached to it and adding the
match source-protocol to that route-map means BGP to filter which
protocol routes to accept among the bunch of routes zebra is sending.

Fixing this since this wasnt implemented earlier.

Ticket :#4119692

Signed-off-by: Donald Sharp <sharpd@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-11-09 08:36:42 -08:00
Donald Sharp b365b0ff24
Merge pull request #17386 from opensourcerouting/fix/initialize_mbefore
lib: Initialize mbefore for route_map_apply_ext()
2024-11-08 11:15:04 -05:00
Donatas Abraitis 3a47d1f7cb
Merge pull request #17384 from donaldsharp/bgp_withdraw_and_unlikely
Bgp withdraw and unlikely
2024-11-08 09:20:19 +02:00
Donatas Abraitis a85dce2c66
Merge pull request #17341 from zice312963205/zly_tcpmss
bgpd:support tcp-mss for neighbor group
2024-11-08 09:11:41 +02:00
Donatas Abraitis f47ae0218b lib: Initialize mbefore for route_map_apply_ext()
CID 1601478: Uninitialized variables  (UNINIT)
Using uninitialized value "mbefore.real.tv_usec" when calling "event_consumed_time".

Fixes: 3e3a666331 ("lib: Add ability to track time in individual routemaps")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-08 09:00:34 +02:00
Donatas Abraitis af9a2cb875
Merge pull request #17231 from guoguojia2021/guozhongfeng_alibaba
bgpd:support of color extended community color-only types
2024-11-08 08:56:21 +02:00
Donatas Abraitis 56ae4112cc packaging: Use PCRE2 for .deb/.rpm builds
We have the support of PCRE2 since 061f5d1cb4.

Also we already do this for containers (docker images).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-08 08:50:54 +02:00
Russ White 68ec006481
Merge pull request #12109 from donaldsharp/routemap_time_spent
lib: Add ability to track time in individual routemaps
2024-11-07 13:19:11 -05:00
Donald Sharp bd03373c37 bgpd: Add unlikely for debugs in bgp_update()
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donald Sharp fc818fe6ad bgpd: Mark debugs as unlikely in bgp_withdraw
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donald Sharp ea4823964c bgpd: In bgp_withdraw attempt to avoid a if statement on every pass
We have this:

if ( (safi == SAFI_UNICAST) && ...)
    do stuff
if ( (safi == SAFI_MPLS_VPN) && ... )
    do stuff

this leads to having to test safi multiple times if safi is
SAFI_UNICAST.  Let's make it a else if as that we know that
the safi is going to not change.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donald Sharp 16bb315957 bgpd: Pass in the prefix instead of looking it up again
In an attempt to make the code faster let's just pass
in the prefix instead of having to do a lookup a majillion
times again after we already have it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donald Sharp 36abc43cfc
Merge pull request #17376 from opensourcerouting/fix/stale_routes_with_addpath
bgpd: Clear stale routes with multiple paths
2024-11-07 11:04:56 -05:00
Donatas Abraitis 846af511f4
Merge pull request #17244 from donaldsharp/high_ecmp_test
tests: Add a topology that supports a large number of ecmp
2024-11-07 17:15:24 +02:00
Donatas Abraitis 2e5e3b4bd0 tests: Check if stale routes with addpath are marked with LLGR community
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-07 14:15:18 +02:00
Donatas Abraitis 444bdc4cc0 tests: Check if routes with addpath are cleared if they are stale
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-07 14:05:36 +02:00
Donatas Abraitis 895d586a5f bgpd: Set LLGR stale routes for all the paths including addpath
Without this patch we set only the first path for the route (if multiple exist)
as LLGR stale and stop doing that for the rest of the paths, which is wrong.

Fixes: 1479ed2fb3 ("bgpd: Implement LLGR helper mode")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-07 14:05:36 +02:00
Donatas Abraitis 7de464b00f bgpd: Clear all paths including addpath once GR expires
We iterated over all bgp_path_info's, but once we remove the path, we didn't
check for other paths under the same bgp_dest.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-07 14:05:35 +02:00
guozhongfeng.gzf 812dcc44d3 doc:the doc of extcomumnity color
Signed-off-by: guozhongfeng.gzf <guozhongfeng.gzf@alibaba-inc.com>
2024-11-07 19:02:21 +08:00
guozhongfeng.gzf 5a28b620d3 tests:support of color extended community color-only types
Signed-off-by: guozhongfeng.gzf <guozhongfeng.gzf@alibaba-inc.com>
2024-11-07 19:02:21 +08:00
guozhongfeng.gzf 937cf4db17 bgpd:support of color extended community color-only types
Add support of color extended community color-only types, RFC 9256.
The type only support 00 01 10.

configuration example:
!
frr version 10.3-dev-my-manual-build
frr defaults traditional
hostname router3
!
route-map color permit 1
 set extcommunity color 10:100 01:200 00:300
exit
!
vrf Vrf1
exit-vrf
!
interface lo
 ipv6 address 3::3/128
exit
!
router bgp 3
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 no bgp ebgp-requires-policy
 no bgp default ipv4-unicast
 bgp bestpath as-path multipath-relax
 timers bgp 10 30
 neighbor 100.13.13.1 remote-as 1
 neighbor 100.13.13.1 advertisement-interval 0
 neighbor 100.23.23.2 remote-as 2
 neighbor 100.23.23.2 advertisement-interval 0
 neighbor 1000:3000::1 remote-as 1
 neighbor 1000:3000::1 ebgp-multihop
 neighbor 1000:3000::1 update-source 1000:3000::3
 neighbor 1000:3000::1 capability extended-nexthop
 neighbor 2000:3000::2 remote-as 2
 neighbor 2000:3000::2 ebgp-multihop
 neighbor 2000:3000::2 update-source 2000:3000::3
 neighbor 2000:3000::2 capability extended-nexthop
 !
 address-family ipv4 unicast
  neighbor 100.13.13.1 activate
  neighbor 100.23.23.2 activate
 exit-address-family
 !
 address-family ipv6 unicast
  redistribute connected route-map color
  neighbor 1000:3000::1 activate
  neighbor 2000:3000::2 activate
 exit-address-family
exit
!
end

Signed-off-by: guozhongfeng.gzf <guozhongfeng.gzf@alibaba-inc.com>
2024-11-07 19:02:11 +08:00
Donatas Abraitis 9fd7ec9551 doc: Add missing RFCs for BGP to the list
* RFC 9687
* RFC 7311

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-07 11:27:48 +02:00
Donatas Abraitis a04407cdaa bgpd: Add SendHoldTimer_Expires event to bgp_fsm_rfc_codes
Not really used, but since we have it, let's update it as a pointer.

This event comes from https://datatracker.ietf.org/doc/html/rfc9687

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-07 11:20:06 +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
Louis Scalbert aceae79ae0 tests: clarify bgp_vpnv4_asbr
Clarify bgp_vpnv4_asbr. Cosmetic change.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-11-06 16:46:02 +01:00
baozhen-H3C d145fe197e
isisd: fix crash when switching P2P after shutdowning LAN circuit
When shutdown a LAN-type circuit, and if the current device is not the DIS (assuming it is a level-1 device), the isis_circuit_down() function will not call the isis_dr_resign() function to clear the circuit->u.bc.run_dr_elect[0] bit (this bit is set on interfaces in the isis_run_dr() function). After switching the link to a P2P type, since u.p2p and u.bc form a union, and circuit->u.bc.snpa = "\000\000\000\000\000" and circuit->u.bc.run_dr_elect = "\001", this results in circuit->u.p2p.neighbor = 0x1000000000000. Consequently, the value of adj->sysid accesses a wild pointer, causing the current crash.

The backtrace is as follows:
(gdb) bt
#0  0x00007fbd30e55fe1 in raise () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007fbd30f76b29 in core_handler (signo=11, siginfo=0x7ffc60b7a270, 
    context=0x7ffc60b7a140) at ../lib/sigevent.c:261
#2  <signal handler called>
#3  0x00007fbd30dddba4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x0000562aec46617f in isis_spf_run_lfa (area=0x562aee3a56d0, spftree=0x562aee3a51a0)
    at ../isisd/isis_lfa.c:2403
#5  0x0000562aec483854 in isis_run_spf_with_protection (area=0x562aee3a56d0, 
    spftree=0x562aee3a51a0) at ../isisd/isis_spf.c:1891
#6  0x0000562aec483b05 in isis_run_spf_cb (thread=0x7ffc60b7b000)
    at ../isisd/isis_spf.c:1953
#7  0x00007fbd30f900bb in thread_call (thread=0x7ffc60b7b000) at ../lib/thread.c:1990
#8  0x00007fbd30f2897b in frr_run (master=0x562aee0833c0) at ../lib/libfrr.c:1198
#9  0x0000562aec454d6d in main (argc=5, argv=0x7ffc60b7b228, envp=0x7ffc60b7b258)
    at ../isisd/isis_main.c:273
(gdb) f 4
#4  0x0000562aec46617f in isis_spf_run_lfa (area=0x562aee3a56d0, spftree=0x562aee3a51a0)
    at ../isisd/isis_lfa.c:2403
2403    ../isisd/isis_lfa.c: No such file or directory.
(gdb) p circuit->u.p2p.neighbor
$1 = (struct isis_adjacency *) 0x1000000000000
(gdb) p adj->sysid
Cannot access memory at address 0x1000000000006
(gdb) p circuit->u.bc  
$2 = {snpa = "\000\000\000\000\000", run_dr_elect = "\001", t_run_dr = {0x0, 0x0}, 
  t_send_lan_hello = {0x0, 0x0}, adjdb = {0x0, 0x0}, lan_neighs = {0x0, 0x0}, 
  is_dr = "\000", l1_desig_is = "\000\000\000\000\000\000", 
  l2_desig_is = "\000\000\000\000\000\000", t_refresh_pseudo_lsp = {0x0, 0x0}}
(gdb) 

The backtrace provided above pertains to version 8.5.4, but it seems that the same issue exists in the code of the master branch as well.

Signed-off-by: baozhen-H3C <bao.zhen@h3c.com>
2024-11-06 20:17:03 +08:00
Donatas Abraitis 1df6c57e69
Merge pull request #17363 from acooks-at-bda/fix-redundant-null-ptr-check-CID-1599962
ospf6d: remove redundant null ptr check
2024-11-06 08:10:00 +02:00
Donatas Abraitis 23c4341cfc
Merge pull request #17364 from acooks-at-bda/fix-redundant-null-ptr-check-CID-1599957
ospf6d: remove redundant null ptr check in ospf6_link_lsa_get_prefix_str() - CID 1599957
2024-11-06 08:09:20 +02:00
Andrew Cooks 8c5a0bb456 ospf6d: remove redundant null ptr check
Fix defect flagged by Coverity:

*** CID 1599957:  Null pointer dereferences  (REVERSE_INULL)
/ospf6d/ospf6_intra.c: 581 in ospf6_link_lsa_get_prefix_str()
575                                                int buflen, int pos)
576     {
577             struct ospf6_link_lsa *link_lsa = lsa_after_header(lsa->header);
578             struct ospf6_prefix *prefix = nth_prefix(lsa->header, pos);
579             struct in6_addr in6 = { 0 };
580
>>>     CID 1599957:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "lsa" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
581             if (!lsa || !prefix || !buf || buflen < (1 + INET6_ADDRSTRLEN))
582                     return NULL;
583
584             /* position zero is used for the lladdr in the body of the LSA */
585             if (pos == 0) {
586                     inet_ntop(AF_INET6, &link_lsa->linklocal_addr, buf, buflen);

The check for lsa being not-null happens in ospf6_lsdb_show() and
first dereference happens in ospf6_lsa_show_summary()

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-11-06 11:06:31 +10:00
Andrew Cooks 24d8d95dd1 ospf6d: remove redundant null ptr check
Fix defect flagged by Coverity:

*** CID 1599962:  Null pointer dereferences  (REVERSE_INULL)
/ospf6d/ospf6_intra.c: 775 in ospf6_intra_prefix_lsa_get_prefix_str()
769     {
770             struct ospf6_prefix *prefix = nth_prefix(lsa->header, pos);
771             struct in6_addr in6 = { 0 };
772             char tbuf[16];
773
774             /* ensure buflen >= INET6_ADDRSTRLEN + '/128\0' */
>>>     CID 1599962:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "lsa" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
775             if (!lsa || !prefix || !buf || buflen < (5 + INET6_ADDRSTRLEN))
776                     return NULL;
777
778             memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
779                    OSPF6_PREFIX_SPACE(prefix->prefix_length));
780             inet_ntop(AF_INET6, &in6, buf, buflen);

The check for lsa being not-null happens in ospf6_lsdb_show() and
first dereference happens in ospf6_lsa_show_summary()

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-11-06 11:00:13 +10:00