Commit graph

149 commits

Author SHA1 Message Date
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
Donatas Abraitis c91c5e8463 bgpd: Make sure Link-Local Next Hop capability has its own update-group
We should involve checking received (not only advertised) capability, because
otherwise we put both peers (one with LL capability, another without) into a
single update-group and send 16-bytes NH instead of 16-bytes and 32-bytes
separately.

Fixes: db853cc97e ("bgpd: Implement Link-Local Next Hop capability")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-02-10 23:50:26 +02:00
Alexander Skorichenko 7bda2b36a9 bgpd: Fix bgp peer solo option
Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
2025-01-23 14:48:16 +01:00
Donatas Abraitis 3784736b09 bgpd: Drop timestamp_string()
Replace with time_to_string().

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-20 17:58:49 +02:00
Donatas Abraitis b37f5f53b3 bgpd: Replace ctime_r() to time_to_string[_json]() to handle JSON/non-JSON
For JSON output we don't need newline to be printed.

Before:

```
"lastUpdate":{"epoch":1734490463,"string":"Wed Dec 18 04:54:23 2024\n"
```

After:

```
"lastUpdate":{"epoch":1734678560,"string":"Fri Dec 20 09:09:20 2024"
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-20 17:58:49 +02:00
Louis Scalbert 91512c3048 bgpd: split nexthop-local unchanged peer subgroup
5bb99ccad2 ("bgpd: reset ipv6 invalid link-local nexthop") now resets
the link-local when originating and destination peers are not on the
same network segment. However, it does not work all the time.

The fix compares the 'from' and 'peer' global IPv6 address. However,
'peer' refers to one of the peers of subgroup. The subgroup may contain
peers located on different network segment.

Split nexthop-local unchanged peer subgroup by network segment.

Fixes: 5bb99ccad2 ("bgpd: reset ipv6 invalid link-local nexthop")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-11 14:07:46 +02:00
Donatas Abraitis cadfa693d6 bgpd: Implement BGP dual-as feature
This is helpful for migrations, etc.

The neighbor is configured with:

```
router bgp 65000
 neighbor X local-as 65001 no-prepend replace-as dual-as
```

Neighbor X can use either 65000, or 65001 to peer with.

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

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-13 10:51:41 +03:00
Donatas Abraitis b9d4191a51 bgpd: Allow using solo for peer-groups
Inherit solo flag for peer-group members also.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-05 15:16:05 +03:00
Donatas Abraitis 0dfe25697f bgpd: Implement neighbor X remote-as auto
In some cases (large scale) it's desired to avoid changing configurations, but
let the BGP to automatically handle ASN changes.

`auto` means the peering can be iBGP or eBGP. It will be automatically detected
and adjusted from the OPEN message.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-04 14:42:19 +03: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
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
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
Donatas Abraitis 72f0e06824 bgpd: Implement Paths-Limit capability
https://datatracker.ietf.org/doc/html/draft-abraitis-idr-addpath-paths-limit

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-13 17:07:15 +02:00
Donatas Abraitis 5298c05bd7 bgpd: Increase peer's struct cap from uint32 to uint64
Approaching the limits of uint32.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-24 23:09:52 +02:00
Russ White 315262cab3
Merge pull request #14992 from opensourcerouting/fix/oad_missing_parts
bgpd: Recent OAD fixes
2023-12-12 11:04:34 -05:00
Donatas Abraitis bc53667dc7 bgpd: Use sub_sort also when creating a hash key for update-groups
If OAD is not set or set at least for one peer in peer-group, then split, and
create a separate update-group for those peers.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-12 11:38:23 +02:00
Donatas Abraitis 29d33bd57d bgpd: Add sub_sort for update group debug logging
When added OAD support, it's handy to know peer->sub_sort also when printing
update-group debug messages.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-12 11:34:29 +02:00
Donatas Abraitis 087d64a7d9 bgpd: Convert variable withdraw integer to bool
It holds only 0/1.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-08 11:58:59 +02:00
Donatas Abraitis 5e81120961 bgpd: Implement EBGP-OAD peering type
At each EBGP boundary, BGP path attributes are modified as per [RFC4271], which includes stripping any IBGP-only attributes.

Some networks span more than one autonomous system and require more flexibility in the propagation of path attributes. It is worth noting that these multi-AS networks have a common or single administrative entity. These networks are said to belong to One Administrative Domain (OAD). It is desirable to carry IBGP-only attributes across EBGP peerings when the peers belong to an OAD.

This document defines a new EBGP peering type known as EBGP-OAD, which is used between two EBGP peers that belong to an OAD. This document also defines rules for route announcement and processing for EBGP-OAD peers.

https://datatracker.ietf.org/doc/html/draft-uttaro-idr-bgp-oad

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-10-06 21:53:43 +03:00
Mark Stapp 8f338b16ed bgpd: fix return of local from ctime_r
Don't return a local - caller needs to pass in a buffer.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-09-21 08:20:49 -04:00
Mark Stapp 8527084488 bgpd: replace ctime with ctime_r
No ctime, use ctime_r.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-09-19 16:25:01 -04:00
Donald Sharp 0c3a70c644 bgpd: Move the peer->su to connection->su
The sockunion is per connection.  So let's move it over.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10 08:31:25 -04:00
Donald Sharp d2ba78929f bgpd: bgp_fsm_change_status/BGP_TIMER_ON and BGP_EVENT_ADD
Modify bgp_fsm_change_status to be connection oriented and
also make the BGP_TIMER_ON and BGP_EVENT_ADD macros connection
oriented as well.  Attempt to make peer_xfer_conn a bit more
understandable because, frankly it was/is confusing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10 08:31:25 -04:00
Donald Sharp 7b1158b169 bgpd: peer_established should be connection oriented
The peer_established function should be connection oriented.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10 08:31:25 -04:00
Donald Sharp 981dd86920 bgpd: move t_generate_updgrp_packets into peer_connection
The t_generate_updgrp_packets event pointer belongs in the
peer_connection pointer.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-09 16:28:05 -04:00
Donald Sharp 4215e8011b bgpd: Remove withdraw_low from system, it is never used
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-21 12:46:31 -04:00
Donatas Abraitis c76f6146ab bgpd: Deprecate Prestandard Outbound Route Filtering capability
https://www.rfc-editor.org/rfc/rfc8810.html

Not relevant anymore. Use RFC'd version of ORF.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-07-07 23:41:43 +03:00
Russ White 4d9fb376c8
Merge pull request #13728 from opensourcerouting/fix/addpath_drop_non_best_addpaths
bgpd: Implement neighbor X addpath-tx-best-selected command
2023-06-20 09:20:36 -04:00
Donatas Abraitis 78981a80c7 bgpd: Implement neighbor X addpath-tx-best-selected command
When using `addpath-tx-all` BGP announces all known paths instead of announcing
only an arbitrary number of best paths.

With this new command we can send N best paths to the neighbor. That means, we
send the best path, then send the second best path excluding the previous one,
and so on. In other words, we run best path selection algorithm N times before
we finish.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-07 22:27:29 +03:00
Donatas Abraitis 610af81ae4 bgpd: Remove bgp_lock() when spawning a timer for default-originate
Not sure why it's here, but looks like it was since the beginning, let's see
if we can drop it.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-31 22:49:32 +03:00
anlan_cs 06af0667ad bgpd: Remove unnecessary check for groups
The `NULL` check for newly created groups (`updgroup` and `subgroup`)
are unnecessary,  just remove them.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-04-16 13:52:35 +08:00
Donald Sharp 24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp cb37cb336a *: Rename thread.[ch] to event.[ch]
This is a first in a series of commits, whose goal is to rename
the thread system in FRR to an event system.  There is a continual
problem where people are confusing `struct thread` with a true
pthread.  In reality, our entire thread.c is an event system.

In this commit rename the thread.[ch] files to event.[ch].

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:16 -04:00
Donald Sharp d8bc11a592 *: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it.  This function also takes a double
pointer to the hash to set it NULL.  Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21 08:54:21 -04:00
Donald Sharp b0d2fa3857 bgpd: Add missing items to debug for update group hash key creation
There are some missing values in the debug lines.  Let's add them
in and help us understand.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-07 07:58:27 -05:00
Donatas Abraitis d782e3ffa2 bgpd: Convert missing uint32_t to uint64_t for for af_flags/flags
It was hard to catch those unless using higher values than uint32_t, but
already hit, it's time to fix completely.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-02-23 23:02:35 +02:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donatas Abraitis 25851bf0a1 bgpd: Do not send routes back received from a peer
Before this patch, we needed to explicitly define a neighbor to be SOLO
(= separate update-group). Let's ease this functionality for an operator to
avoid confusions.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-14 21:30:07 +02:00
Donald Sharp 5691f760d2 bgpd: Don't always allocate json memory in non-json path
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-08 18:22:17 -05:00
Donatas Abraitis 8ccee4b8cc bgpd: Adopt addpath functionality for labeled-unicast
The same as for RIB, labeled-unicast allocations should live in
unicast space.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-12-06 21:39:15 +02:00
Ashwini Reddy fa5a9276d1 bgpd: JSON support for show ip bgp vrf all update-group
Ticket:#3229030
Testing Done: UT

Changes:

 - JSON support for the update group command.

Testing:

torc-11# show ip bgp vrf all ipv6 update-groups json

torc-12# show bgp vrf all update-groups json
{
  "default":{
    "2":{
      "groupCreateTime":{
        "epoch":1669225617,
        "epochString":"Wed Nov 23 17:46:57 2022\n"
      },
      "afi":"IPv6",
      "safi":"unicast",
      "outRouteMap":"MY_ORIGIN_ASPATH_ONLY",
      "minRouteAdvInt":0,
      "subGroup":[
        {
          "subGroupId":2,
          "groupCreateTime":{
            "epoch":1669225617,
            "epochString":"Wed Nov 23 17:46:57 2022\n"
          },
          "statistics":{
            "joinEvents":2,
            "pruneEvents":0,
            "mergeEvents":0,
            "splitEvents":0,
            "switchEvents":0,
            "peerRefreshEvents":0,
            "mergeCheckEvents":2
          },
          "coalesceTime":1100,
          "version":12,
          "packetQueueInfo":{
            "qeueueLen":0,
            "queuedTotal":1,
            "queueHwmLen":1,
            "totalEnqueued":1
          },
          "adjListCount":1,
          "needsRefresh":false,
          "peers":[
            "uplink_1",
            "uplink_2"
          ]
        }
      ]
    }
  }
}
{
  "sym_3":{
  }
}
{
  "sym_5":{
  }
}
{
  "sym_2":{
  }
}
{
  "sym_4":{
  }
}
{
  "sym_1":{
  }
}

Co-authored-by: Chirag Shah <chirag@nvidia.com>
Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
2022-11-23 19:04:00 -08:00
Donatas Abraitis 97a52c82a5 bgpd: Implement Accumulated IGP Metric Attribute for BGP
https://www.rfc-editor.org/rfc/rfc7311.html

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-10-26 11:26:57 +03:00
Donatas Abraitis 61adcf71be bgpd: Fix memory leak for conf_copy() - SoO ecommunity
==1179738== 48 (40 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 29
==1179738==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==1179738==    by 0x493C8D5: qcalloc (memory.c:116)
==1179738==    by 0x208F0C: ecommunity_dup (bgp_ecommunity.c:267)
==1179738==    by 0x2B300C: conf_copy (bgp_updgrp.c:170)
==1179738==    by 0x2B35BF: peer2_updgrp_copy (bgp_updgrp.c:277)
==1179738==    by 0x2B5189: update_group_find (bgp_updgrp.c:826)
==1179738==    by 0x2B70D0: update_group_adjust_peer (bgp_updgrp.c:1769)
==1179738==    by 0x23DB7D: update_group_adjust_peer_afs (bgp_updgrp.h:519)
==1179738==    by 0x243B21: bgp_establish (bgp_fsm.c:2129)
==1179738==    by 0x244B94: bgp_event_update (bgp_fsm.c:2597)
==1179738==    by 0x26B0E6: bgp_process_packet (bgp_packet.c:2895)
==1179738==    by 0x498F5FD: thread_call (thread.c:2008)
==1179738==    by 0x49253DA: frr_run (libfrr.c:1198)
==1179738==    by 0x1EEC38: main (bgp_main.c:520)

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-10 18:13:45 +03:00
Donatas Abraitis da5e1a58e9 bgpd: Increase peer af_flags to uint64_t
Increasing in advance, as we already hitting the current limit.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-31 14:35:55 +03:00
Russ White d72c279d08
Merge pull request #11833 from opensourcerouting/feature/bgp_neighbor_soo
bgpd: Add `neighbor soo` command
2022-08-30 11:17:53 -04:00
Donald Sharp 083ec940ab bgpd: Convert from bgp_clock() to monotime()
Let's convert to our actual library call instead
of using yet another abstraction that makes it fun
for people to switch daemons.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 08:23:40 -04:00