Commit Graph

1828 Commits

Author SHA1 Message Date
Philippe Guibert
c5d7815ccc bgpd: fix version attribute is an int, not a string
The json display of the version attribute is originally an
integer. It has changed, most probably mistakenly.

> {
>   "vrfId": 7,
>   "vrfName": "vrf1",
>   "tableVersion": 3,
>   "routerId": "192.0.2.1",
>   "defaultLocPrf": 100,
>   "localAS": 65500,
>   "routes": {
>     "172.31.0.1/32": {
>       "prefix": "172.31.0.1/32",
>       "version": "1",		<--- int or string ??

Let us fix it, by using the integer display instead.

Fixes: f9f2d188e3 ("bgpd: fix 'json detail' output structure")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-11-26 11:01:57 +01:00
Donatas Abraitis
2dc7db9251 bgpd: Optimize the outbound path if RFC8212 is applied
If we have (default enabled) enabled `bgp ebgp-require-policy`, then first check
it before applying the route-maps.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-17 14:41:05 +02:00
Jafar Al-Gharaibeh
66b0a33e0c
Merge pull request #17427 from opensourcerouting/fix/more_details_for_ebgp_no_policy
bgpd: Add more details to ebgp requires policy warning
2024-11-16 19:32:54 -06:00
Donatas Abraitis
a0d2734e87 bgpd: Validate both nexthop information (NEXTHOP and NLRI)
If we receive an IPv6 prefix e.g.: 2001:db8:100::/64 with nextop: 0.0.0.0, and
mp_nexthop: fc00::2, we should not treat this with an invalid nexthop because
of 0.0.0.0. We MUST check for MP_REACH attribute also and decide later if we
have at least one a valid nexthop.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-15 16:40:56 +02:00
Donatas Abraitis
53c858e70e bgpd: Add more details to ebgp requires policy warning
This will tell explicitly which peer does not have a filter applied.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-15 08:09:08 +02:00
Donatas Abraitis
5cf9f6a79f bgpd: Reduce the nesting level for show_adj_route()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-13 13:36:01 +02:00
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
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
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
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
Donald Sharp
d14dbdb897 bgpd: Move RFC 8212 check for inbound before filter in bgp_update
Currently the code to check to see if any input filters are
applicable is *before* the RFC 8212 check to see if we have
any filters at all.  As such we have already tested for this,
so let's move this check for RFC 8212 to immediately before
the input filter test.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:35:01 -04:00
Donald Sharp
5592aecefd bgpd: Convert rcvd_attr_printed to a bool
No need for a integer to store this, use a bool

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:35:01 -04:00
Donald Sharp
c6400ca256 bgpd: Refactor bgp_update some for nexthop reachability
The nexthop reachability code was cut-n-pasted 2 times
with just a tiny bit of difference.  If we ever change
that it becomes `fun` to keep them in sync.  Since this
is more important than full on speed of code let's abstract
and get bgp_update() to be a bit easier to maintain.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:35:01 -04:00
Donald Sharp
e3519b3400 bgpd: In bgp_update() for mac addrs ensure we are dealing with evpn
The code is just arbitrarily checking to see if there are any
mac addresses associated with a prefix.  This makes no
sense from the perspective that it can only happen as
an evpn route.  Let's not make non-evpn people pay
the price to check this data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:35:01 -04:00
Donald Sharp
fb78a9b66b bgpd: In bgp_update try to optimize is_loop_check variable
The variable is_loop_check is being set and then later
we test against it multiple times.  Move the setting
of whether or not to check for as loops to where it
is tested against and stop testing it multiple times.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:35:00 -04:00
Donald Sharp
d9fd4901f0 bgpd: Only set bgp_labels in bgp_update if we have num_labels
In the interest of speeding up code, there is no point in
attempting to see if a label is usable if the number of labels
passed in is 0.  Since that is a much much quicker test than
the bgp_is_valid_label() call, let's test that first.

Additionally, there is no point in walking the label[] array
passed in unless we are in the if statement, so move it inside.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:35:00 -04:00
Donald Sharp
852e6c327d bgpd: allowas_in and aspath_loop_count only used in one if statement
In bgp_update(), the two variables allowas_in and aspath_loop_count
are only used when peer->change_local_as is true.  Move the retrieval
of the allowas_in data to inside the if statement to save some
(very) small amount of time in bgp_update not gathering this
data unless the particular peer has this set.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:35:00 -04:00
Donald Sharp
1115feedc3 bgpd: add some counters not displayed yet
Add some counters to keep track how often stuff is done.
This is mainly for us developers.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-29 14:11:06 -04:00
Russ White
56495a88df
Merge pull request #17251 from donaldsharp/bgp_best_path_evpn_issue
bgpd: bestpath failure when you have a singlepath not in holddown
2024-10-29 10:16:37 -04:00
Donald Sharp
c3eebccdc6 bgpd: bestpath failure when you have a singlepath not in holddown
When you have multiple paths to a particular route and a single
path changes.  In addition of the other paths are either in
hold down or not established or really just not selected you
could end up with a situation where the bestpath choosen
was a path that was in hold down.

Modify the code such that when there is nothing worse
in bestpath selection for the choosen path, but were
unable to do any sorting, just put the path on the top
of the list and declare it the winner.  Else just
do the original and put it at the end.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-25 17:22:13 -04:00
Louis Scalbert
e7b3276ace bgpd: fix display of local label in show bgp
Fix the display of the local label in show bgp.

> r1# show bgp ipv4 labeled-unicast 172.16.2.2/32
> BGP routing table entry for 172.16.2.2/32, version 2
> Local label: 16 <---- MISSING
> Paths: (1 available, best #1, table default, vrf (null))
>   Advertised to non peer-group peers:
>  192.168.1.2
>  65501
>    192.168.1.2 from 192.168.1.2 (172.16.2.2)
>      Origin IGP, metric 0, valid, external, best (First path received)
>      Remote label: 3
>      Last update: Fri Oct 25 17:55:45 2024

Fixes: 67f67ba481 ("bgpd: Drop label_ntop/label_pton functions")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-25 17:56:57 +02:00
Donatas Abraitis
3f446ecb6b
Merge pull request #17199 from enkechen-panw/aigp-fix5
bgpd: compare aigp after local route check in bgp_path_info_cmp()
2024-10-25 09:59:29 +03:00
Donald Sharp
e68550b8d8 bgpd: Only grab the confed path count if we are comparing it
This is just a small optimization but when calling path_info_cmp
hundreds of millions of times this adds up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-24 21:01:26 -04:00
Donald Sharp
4954d9d17c bgpd: Do not call evpn_overlay_free no matter what
bgp_update is a very expensive call.  Calling evpn_overlay_free
even when we have no evpn data to free is not trivial.  Let's
limit the call into this function until we actually have data to
free.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-24 18:05:01 -04:00
Enke Chen
6a7049aaac bgpd: compare aigp after local route check in bgp_path_info_cmp()
For consistency between RIB and BGP, the aigp comparison should
be made after the local route check in bgp bestpath selection.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-24 10:50:37 -07:00
Russ White
df0dd1b39e
Merge pull request #17165 from opensourcerouting/fix/bgp_community_no_export_oad
bgpd: Do not filter no-export community for BGP OAD
2024-10-22 11:05:38 -04:00
Donatas Abraitis
b4e72bc198 bgpd: Rework extended community transitiviness
Extended communities can be transitive or non-transitive.

Like other attributes (e.g., MED) non-transitive extended communities SHOULD
be sent to the direct peer, but not forward them to eBGP peers next.

Before this patch, we never send non-transitive extended attributes to the
direct peers at all.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-22 09:02:49 +03:00
Enke Chen
fc82d7750f bgpd: fix AIGP calculation in route advertisement
Currently the AIGP is always incremented when a route with the
attribute is advertised. That is incorrect when the nexthop is
unchanged, as is commonly the case in route reflection.

Adjust the AIGP for propagation only when the nexthop is set
to ourselves.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-21 18:03:08 -07:00
Donatas Abraitis
e63b1520f1 bgpd: Do not filter no-export community for BGP OAD (one administration domain)
OAD is treated as an _internal_ BGP peer, and some of the rules (including BGP
attributes) can be relaxed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-18 22:35:28 +03:00
sri-mohan1
97f3dd3c26 bgpd: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-10-18 22:21:01 +05:30
Enke Chen
f65356d8bb bgpd: fix several issues in sourcing AIGP attribute
Fix several issues in sourcing AIGP attribute:

1) AIGP should not be set as default for a redistributed route or a
   static network. It should be set by config instead.

2) AIGP sourced by "set aigp-metric igp-metric" in a route-map does
   not set the correct value for a redistributed route.

3) When redistribute a connected route like loopback, the AGIP (with
   value 0) is sourced by "set aigp-metric igp-metric", but the
   attribute is not propagated as the attribute flag is not set.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-16 11:15:28 -07:00
Russ White
80dc863d92
Merge pull request #16946 from opensourcerouting/fix/match_src-peer
bgpd: Implement match src-peer ... command
2024-10-16 07:51:20 -04:00
Russ White
de02471a8d
Merge pull request #17038 from opensourcerouting/feature/bgp_set_metric_internal
bgpd: Derive and set MED from IGP or AIGP
2024-10-15 17:58:05 -04:00
Russ White
5b5756911c
Merge pull request #17073 from louis-6wind/fix-ipv6-ll-nexthop-reflector
bgpd, tests: don't send local nexthop from rr client
2024-10-15 14:18:49 -04:00
Donatas Abraitis
b924f03387 bgpd: Re-announce the routes if the underlay IGP metric changes
If the underlay IGP metric changes, we SHOULD re-announce the routes with the
correct bpi->extra->igpmetric set.

Without this patch if the IGP link cost (metric) changes, we never notice this
and the peers do not have the updated metrics, which in turn causes incorrect
best path selections on remote peers.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-15 17:42:53 +03:00
Donatas Abraitis
5a05dbeb13 bgpd: Set MED using a helper bgp_attr_set_med()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-15 17:36:50 +03:00
Enke Chen
081422e8e7 bgpd: fix route selection with AIGP
The nexthop metric should be added to AIGP when calculating the
bestpath in bgp_path_info_cmp().

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-14 18:45:06 -07:00
Louis Scalbert
c4a8263628 bgpd, tests: don't send local nexthop from rr client
AS 65000  | AS 65001
          |
      RR  |
       |  |
R1 --- | --- R2
          |

When r1 peer is an iBGP route reflector client of rr and r2 peer is a
eBGP neighbor of rr, and all three routers shares the same network, r2
receives announcements coming from r1 with a IPv6 link-local nexthop
from rr. This is incorrect as r2 should send traffic to r1 without
involving rr.

Do not send an IPv6 link-local nexthop if the originating peer is a
route-reflector client.

Link: https://github.com/FRRouting/frr/pull/16219#issuecomment-2397425505
Link: https://github.com/FRRouting/frr/pull/17037#discussion_r1792529683
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-14 10:06:35 +02:00
Louis Scalbert
4ae65cc21e bgpd: rename reflect in subgroup_announce_check
In subgroup_announce_check(), the variable reflect is misleading, as it
suggests a relation to route reflection. However, it actually refers to
the scenario where an iBGP peer announces a route to another iBGP peer.

Rename reflect to ibgp_to_ibgp.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-14 10:06:35 +02:00
Louis Scalbert
5bb99ccad2 bgpd: reset ipv6 invalid link-local nexthop
If the "nexthop-local unchanged" setting is enabled, it preserves the
IPv6 link-local nexthop from the originating peer. However, if the
originating and destination peers are not on the same network segment,
the originating peer's IPv6 link-local address will be unreachable from
the destination peer.

In such cases, reset the IPv6 link-local nexthop, even if "nexthop-local
unchanged" is set on the destination peer.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-10 11:39:04 +02:00
Louis Scalbert
34c1dd076e bgpd: do not insert link-local with local unchanged
Do not add an IPv6 link-local nexthop if the originating peer does not
provide one and the nexthop-local unchanged setting is enabled.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-10 11:38:58 +02:00
Louis Scalbert
38ad215feb Revert "bgpd: Exclude case for remote prefix w/o link-local"
This reverts commit 5f6a61f91f.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-09 16:36:27 +02:00
Russ White
374fda66df
Merge pull request #16945 from opensourcerouting/fix/bgp_received-routes_with_soft_inbound
bgpd: Show unmodified version of received-routes per neighbor
2024-10-08 10:16:24 -04:00
Donald Sharp
5b8bca89b8 bgpd: Remove bgp_path_info_mpath_dequeue
This function is no doing any work.  Let's remove.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-01 12:25:57 -04:00
Donald Sharp
421cf856ef bgpd: Cleanup multipath figuring out in bgp
Currently bgp multipath has these properties:

a) mp_info may or may not be on a single path, based
upon path perturbations in the past.
b) mp_info->count started counting at 0( meaning 1 ).  As that the
bestpath path_info was never included in the count
c) The first mp_info in the list held the multipath data associated
with the multipath.  As such if you were at any other node that data
was not filled in.
d) As such the mp_info's that are not first on the list basically
were just pointers to the corresponding bgp_path_info that was in
the multipath.
e) On bestpath calculation, a linklist(struct linklist *) of bgp_path_info's was
created.
f) This linklist was passed in to a comparison function that took the
old mpinfo list and compared it item by item to the linklist and
doing magic to figure out how to create a new mp_info list.
g) the old mp_info and the link list had to be memory managed and
freed up.
h) BGP_PATH_MULTIPATH is only set on non bestpath nodes in the
multipath.

This is really complicated.  Let's change the algorithm to this:

a) When running bestpath, mark a bgp_path_info node that could be in the ecmp path as
BGP_PATH_MULTIPATH_NEW.
b) When running multipath, just walk the list of bgp_path_info's and if
it has BGP_PATH_MULTIPATH_NEW on it, decide if it is in BGP_MULTIPATH.
If we run out of space to put in the ecmp, clear the flag on the rest.
c) Clean up the counting of sometimes adding 1 to the mpath count.
d) Only allocate a mpath_info node for the bestpath.  Clean it up
when done with it.
e) remove the unneeded list management associated with the linklist and
the mp_list.

This greatly simplifies multipath computation for bgp and reduces memory
load for large scale deployments.

2 full feeds in work_queue_run prior:

    0      56367.471      1123    50193    493695    50362    493791         0         0          0    TE   work_queue_run

BGP multipath info            :  1941844     48   110780992  1941844 110780992

2 full feeds in work_queue_run after change:

    1      52924.931      1296    40837    465968    41025    487390         0         0          1    TE   work_queue_run

BGP multipath info            :   970860     32    38836880   970866  38837120

Aproximately 4 seconds of saved cpu time for convergence and ~75 mb
smaller run time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-01 12:25:57 -04:00
Donatas Abraitis
419e024b3f bgpd: Add back pointer to source (from) peer in bgp_path_info struct
This is handy when you need to do source matching e.g. `match src-peer ...`
on outgoing direction with a route-map.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-27 22:53:46 +03:00