Commit graph

302 commits

Author SHA1 Message Date
Stephane Poignant 2cee5567bc
bgpd: flowspec: remove sizelimit check applied to the wrong length field (issue 18557)
Section 4.1 of RFC8955 defines how the length field of flowspec NLRIs is encoded.
The method use implies a maximum length of 4095 for a single flowspec NLRI.
However, in bgp_flowspec.c, we check the length attribute of the bgp_nlri structure against this maximum value, which actually is the *total* length of all NLRI included in the considered MP_REACH_NLRI path attribute.
Due to this confusion, frr would reject valid announces that contain many flowspec NLRIs, when their cummulative length exceeds 4095, and close the session.
The proposed change removes that check entirely. Indeed, there is no need to check the length field of each invidual NLRI because the method employed make it impossible to encode a length greater than 4095.

Signed-off-by: Stephane Poignant <stephane.poignant@proton.ch>
2025-04-04 13:29:02 +02:00
Mark Stapp 58f924d287 bgpd: batch peer connection error clearing
When peer connections encounter errors, attempt to batch some
of the clearing processing that occurs. Add a new batch object,
add multiple peers to it, if possible. Do one rib walk for the
batch, rather than one walk per peer. Use a handler callback
per batch to check and remove peers' path-infos, rather than
a work-queue and callback per peer. The original clearing code
remains; it's used for single peers.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-03-12 12:42:06 -04:00
Mark Stapp 020245befd bgpd: remove apis from bgp_route.h
Remove a couple of apis that don't exist.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-03-12 12:40:07 -04:00
Russ White b040b83c35
Merge pull request #17870 from opensourcerouting/fix/bgp_show_ip_bgp_cmd_internal
bgpd: Show internal data for BGP routes
2025-02-11 08:44:43 -05:00
Chirag Shah c358b92c9f bgpd: fix evpn path info get api
EVPN imported routes AF is not AF_EVPN, in that case
the path info extra with EVPN is nver created.
In order to create evpn info under path extra, define
new api which does not specifically check for AF_EVPN
afi type.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2025-01-21 15:17:20 -08:00
Donatas Abraitis 1d6925e02f bgpd: Show internal data for BGP routes
Sometimes it's very useful to compare pointers from the gdb (and/or from the
logs) or just do some quick adhoc analysis.

```
donatas# sh ip bgp 1.1.1.0/24 internal
BGP routing table entry for 1.1.1.0/24, version 0
Paths: (1 available, no best path)
  Not advertised to any peer
  65002
    127.0.0.1 (inaccessible, import-check enabled) from 127.0.0.1 (127.0.0.2)
      Origin IGP, invalid, external
      Last update: Thu Jan 16 16:49:53 2025
      net: 0x63f3e6fc2ea0, path: 0x63f3e6fc2f50, pathext: 0x63f3e6faed00, attr: 0x63f3e6e8c550
      flags net: 0x0, path: 0x1024, attr: 0x7
donatas#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-17 22:24:35 +02:00
Enke Chen d015e1d7d3 bgpd: remove unused safi in bgp_aggregate structure
Remove the unused safi field in bgp_aggregate structure.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2025-01-11 14:14:10 -08:00
Enke Chen b0f96fc247 Revert "bgpd: Reinstall aggregated routes if using route-maps and it was changed"
This reverts commit ee1986f1b5.

The fix is incomplete, and is no longer needed with the fix that applies
the route-map for an aggregate and then compares the attribute.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2025-01-08 09:13:11 -08:00
Russ White 6060d8b347
Merge pull request #17723 from opensourcerouting/fix/bgpd_metric_worse
bgpd: Respect `bgp bestpath missing-as-worst` for `table-map` as well
2025-01-07 09:41:08 -05:00
Yaroslav Kholod 663281ca6a BGP: Clean address-family config on daemon restart
When stopping and restarting BGP daemon part of the configuration
remains. It should be cleared.
Particulary those are address-family parametes, like: distance,
ead-es-frag, disable-ead-evi-rx, disable-ead-evi-tx.

Signed-off-by: Yaroslav Kholod <y.kholod@vyos.io>
2024-12-30 14:37:54 +02:00
Donatas Abraitis fa8663141e bgpd: Respect bgp bestpath missing-as-worst for table-map as well
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-26 17:26:42 +02:00
Jafar Al-Gharaibeh f7fcc44292
Merge pull request #17674 from opensourcerouting/fix/bgp_show_advertised_routes_detail
bgpd: Fix show neighbor X advertised-routes detail
2024-12-20 14:01:34 -06:00
Donatas Abraitis 708f08cb18 bgpd: Show applied route-map attributes for neighbor X advertised-routes detail
If we have a route-map that sets some attributes e.g. community or large-community,
and the route-map is applied for outgoing direction, everything is fine, but
we missed the point that `advertised-routes detail` was not using the applied
attributes to display and instead it uses what is received from the peer (original).

Let's fix this, and use what's already applied (advertise attributes), and
we can now see:

```
route-map r3 permit 10
 match ip address prefix-list p1
 set community 65001:65002
 set extcommunity bandwidth 100
 set large-community 65001:65002:65003
exit
!
...
 address-family ipv4 unicast
  neighbor 192.168.2.3 route-map r3 out
 exit-address-family
...
```

The output:

```
r2# show bgp ipv4 neighbors 192.168.2.3 advertised-routes detail
BGP table version is 1, local router ID is 192.168.2.2, vrf id 0
Default local pref 100, local AS 65002
BGP routing table entry for 10.10.10.1/32, version 1
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.1.1 192.168.2.3
  65001
    0.0.0.0 from 192.168.1.1 (192.168.1.1)
      Origin IGP, valid, external, best (First path received)
      Community: 65001:65002
      Extended Community: LB:65002:12500000 (100.000 Mbps)
      Large Community: 65001:65002:65003
      Last update: Thu Dec 19 17:00:40 2024
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-19 17:10:06 +02:00
Karthikeya Venkat Muppalla 16ca97d2d9 bgpd: add meta queue in bgp
This commit introduces meta queue to the BGP process_queue which is
helpful in having a priority of lists where some routes can be processed
earlier than 'other' routes. This is similar to how meta queue is
present in zebra.

After Fix:
---------

For testing, note that all 100.x routes are marked as Early routes which
got enqueued and dequeued first before Other routes in every batch of
updates. Also, the items are dequeued in FIFO order.

switch# cat /var/log/frr/bgpd.log | grep sub-queue
2024/12/06 19:19:42.788014 BGP: [V64FH-G6883] 88.0.0.9/32 queued into sub-queue Other Route
2024/12/06 19:19:42.856127 BGP: [V64FH-G6883] 100.90.9.186/32 queued into sub-queue Early Route
2024/12/06 19:19:42.856138 BGP: [V64FH-G6883] 100.90.9.187/32 queued into sub-queue Early Route
2024/12/06 19:19:42.886715 BGP: [V64FH-G6883] 66.0.0.9/32 queued into sub-queue Other Route
2024/12/06 19:19:43.022835 BGP: [V64FH-G6883] 33.0.0.9/32 queued into sub-queue Other Route
2024/12/06 19:19:43.058842 BGP: [V64FH-G6883] 44.0.0.9/32 queued into sub-queue Other Route
2024/12/06 19:19:43.092365 BGP: [V64FH-G6883] 55.0.0.9/32 queued into sub-queue Other Route
2024/12/06 19:19:43.540770 BGP: [ZAPXS-9754G] 100.90.9.186/32 dequeued from sub-queue Early Route
2024/12/06 19:19:43.541233 BGP: [ZAPXS-9754G] 100.90.9.187/32 dequeued from sub-queue Early Route
2024/12/06 19:19:43.541523 BGP: [ZAPXS-9754G] 88.0.0.9/32 dequeued from sub-queue Other Route
2024/12/06 19:19:43.602094 BGP: [V64FH-G6883] 88.0.0.9/32 queued into sub-queue Other Route
2024/12/06 19:19:43.649083 BGP: [V64FH-G6883] 100.90.9.186/32 queued into sub-queue Early Route
2024/12/06 19:19:43.649092 BGP: [V64FH-G6883] 100.90.9.187/32 queued into sub-queue Early Route
2024/12/06 19:19:43.649148 BGP: [V64FH-G6883] 77.0.0.9/32 queued into sub-queue Other Route
2024/12/06 19:19:43.712282 BGP: [V64FH-G6883] 100.90.9.138/32 queued into sub-queue Early Route
2024/12/06 19:19:43.712314 BGP: [V64FH-G6883] 100.90.9.139/32 queued into sub-queue Early Route
2024/12/06 19:19:43.817194 BGP: [V64FH-G6883] 100.90.8.58/32 queued into sub-queue Early Route
2024/12/06 19:19:43.817205 BGP: [V64FH-G6883] 100.90.8.59/32 queued into sub-queue Early Route
2024/12/06 19:19:43.942464 BGP: [ZAPXS-9754G] 100.90.9.186/32 dequeued from sub-queue Early Route
2024/12/06 19:19:43.942530 BGP: [ZAPXS-9754G] 100.90.9.187/32 dequeued from sub-queue Early Route
2024/12/06 19:19:43.942550 BGP: [ZAPXS-9754G] 100.90.9.138/32 dequeued from sub-queue Early Route
2024/12/06 19:19:43.942738 BGP: [ZAPXS-9754G] 100.90.9.139/32 dequeued from sub-queue Early Route
2024/12/06 19:19:43.942763 BGP: [ZAPXS-9754G] 100.90.8.58/32 dequeued from sub-queue Early Route
2024/12/06 19:19:43.942788 BGP: [ZAPXS-9754G] 100.90.8.59/32 dequeued from sub-queue Early Route
2024/12/06 19:19:44.558611 BGP: [ZAPXS-9754G] 66.0.0.9/32 dequeued from sub-queue Other Route
2024/12/06 19:19:44.893541 BGP: [ZAPXS-9754G] 33.0.0.9/32 dequeued from sub-queue Other Route
2024/12/06 19:19:45.171794 BGP: [ZAPXS-9754G] 44.0.0.9/32 dequeued from sub-queue Other Route
2024/12/06 19:19:45.453137 BGP: [ZAPXS-9754G] 55.0.0.9/32 dequeued from sub-queue Other Route
2024/12/06 19:19:45.685269 BGP: [ZAPXS-9754G] 88.0.0.9/32 dequeued from sub-queue Other Route
2024/12/06 19:19:45.764752 BGP: [ZAPXS-9754G] 77.0.0.9/32 dequeued from sub-queue Other Route

With 'update-delay' feature (EOIU marker):
------------------------------------------

switch# vtysh -c "show run bgp" | grep update-delay
 update-delay 40

switch# cat /var/log/frr/bgpd.log | grep sub-queue
2024/12/06 23:27:46.124461 BGP: [V64FH-G6883] 22.0.0.9/32 queued into sub-queue Other Route
2024/12/06 23:27:46.160224 BGP: [V64FH-G6883] 100.90.8.11/32 queued into sub-queue Early Route
2024/12/06 23:27:46.219663 BGP: [W9QTR-P4REP] EOIU Marker queued into sub-queue EOIU Marker
2024/12/06 23:27:46.269711 BGP: [ZAPXS-9754G] 100.90.8.11/32 dequeued from sub-queue Early Route
2024/12/06 23:27:46.270980 BGP: [ZAPXS-9754G] 22.0.0.9/32 dequeued from sub-queue Other Route
2024/12/06 23:27:46.404868 BGP: [RBX2V-K33CZ] EOIU Marker dequeued from sub-queue EOIU Markera

Ticket: #4200787
Signed-off-by: Karthikeya Venkat Muppalla <kmuppalla@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-17 12:41:29 -05: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
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
Donald Sharp 69b8857ab9 bgpd: Allow BGP to process certain routes early
There is a need to be able to process certain bgp
routes earlier than others.  Especially when there
is major trauma going on in the network.  Start
the ability for this to happen.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-11 17:46:33 -04:00
Donald Sharp 4dd9d1176f bgpd: Ensure evpn local table display shows route send status
evpn has a concept of `local` tables where the evpn routes
are actually converted into underlying routes/neighbor
table entries( or vice versa ).  Then this local route
is propagated to the global evpn l2vpn table and sent
to the peers.  Certain show commands in evpn look
operate on the local table but make the output look
like the data has not been sent to the peer.  This
is confusing for the operator.  Modify the code
such that local tables get a `Local BGP table not advertised`
in the place where the code talks about whom has received
the data or not.

Example:
torm11# show bgp l2vpn evpn route vni 1000 mac 8a:a1:cc:73:a3:ac ip 45.0.0.5
BGP routing table entry for [2]:[0]:[48]:[8a:a1:cc:73:a3:ac]:[32]:[45.0.0.5]
Paths: (2 available, best #2)
  Local BGP table not advertised
  Route [2]:[0]:[48]:[8a:a1:cc:73:a3:ac]:[32]:[45.0.0.5] VNI 1000
  Imported from 192.168.100.18:2:[2]:[0]:[48]:[8a:a1:cc:73:a3:ac]:[32]:[45.0.0.5], VNI 1000
  65101 65005
    192.168.100.18(leaf2) from leaf2(192.168.5.1) (192.168.100.14)
      Origin IGP, valid, external
      Extended Community: RT:65005:1000 ET:8
      Last update: Thu Mar 21 14:29:04 2024
  Route [2]:[0]:[48]:[8a:a1:cc:73:a3:ac]:[32]:[45.0.0.5] VNI 1000
  Imported from 192.168.100.18:2:[2]:[0]:[48]:[8a:a1:cc:73:a3:ac]:[32]:[45.0.0.5], VNI 1000
  65101 65005
    192.168.100.18(leaf1) from leaf1(192.168.1.1) (192.168.100.13)
      Origin IGP, valid, external, bestpath-from-AS 65101, best (Router ID)
      Extended Community: RT:65005:1000 ET:8
      Last update: Thu Mar 21 14:29:04 2024

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-30 16:23:20 -04:00
Louis Scalbert a152692f5a bgpd: fix labels static-analyser
Fix static-analyser warnings with BGP labels:

> $ scan-build make -j12
> bgpd/bgp_updgrp_packet.c:819:10: warning: Access to field 'extra' results in a dereference of a null pointer (loaded from variable 'path') [core.NullDereference]
>                                                 ? &path->extra->labels->label[0]
>                                                    ^~~~~~~~~

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-08-26 10:29:12 +02:00
Donatas Abraitis 4ace11d010 bgpd: Move evpn_overlay to a pointer
Before this convertion:

```
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
	struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
	struct bgp_route_evpn      evpn_overlay;         /*   208    36 */
```

After this convertion:

```
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
	struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
	struct bgp_route_evpn *    evpn_overlay;         /*   208     8 */
```

Saving 28 bytes when EVPN is not used.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-11 13:59:13 +03:00
Louis Scalbert ca32945b1f bgpd: move labels from extra to extra->labels
Move labels from extra to extra->labels. Labels are now stored in a hash
list.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 13:11:29 +02:00
Louis Scalbert a6de910448 bgpd: store number of labels with 8 bits
8 bits are sufficient to store the number of labels because the current
maximum is 2.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 13:11:29 +02:00
Louis Scalbert 64fe15fd28 bgpd: add bgp_path_info_num_labels()
Add bgp_path_info_num_labels() to get the number of labels stored in
a path_info structure.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 11:08:46 +02:00
Louis Scalbert 04748e36a5 bgpd: add bgp_path_info_labels_same()
Add bgp_path_info_labels_same() to compare labels with labels from
path_info. Remove labels_same() that was used for mplsvpn only.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 11:08:46 +02:00
Louis Scalbert 7a513e3361 bgpd: add bgp_path_info_has_valid_label()
Add bgp_path_has_valid_label to check that a path_info has a valid
label.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 11:08:46 +02:00
Russ White 057d56ee29
Merge pull request #15726 from donaldsharp/med_value
bgpd: Fix display when using `missing-as-worst`
2024-04-16 10:14:12 -04:00
Donald Sharp bc9885b22e bgpd: Fix display when using missing-as-worst
The usage of the `bgp bestpath med missing-as-worst` command
was being accepted and applied during bestpath, but during output
of the routes affected by this it would not give any indication
that this was happening or what med value was being used.

Fixes: #15718
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-15 12:33:53 -04:00
Donald Sharp f3575f61c7 bgpd: Sort the bgp_path_info's
Currently bgp_path_info's are stored in reverse order
received.  Sort them by the best path ordering.

This will allow for optimizations in the future on
how multipath is done.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-01 14:54:02 -04:00
Donald Sharp ab49fc9c48 bgpd: Add pi to bgp_process
This will allow a consistency of approach to adding/removing
pi's to from the workqueue for processing as well as properly
handling the dest->info pi list more appropriately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-01 10:24:14 -04:00
Donald Sharp 6c8bfaa66e bgpd: Add BGP_PATH_UNSORTED for future commits
Add a new flag BGP_PATH_UNSORTED to keep track
of sorted -vs- unsorted path_info's.  Add some
ability to the system to understand when that
flag is set.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-01 10:24:14 -04: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
Donald Sharp bb1e1265aa bgpd: Save memory when using bgp_path_info_extra and vnc
Structure size of bgp_path_info_extra when compiled
with vnc is 184 bytes.  Reduce this size to 72 bytes
when compiled w/ vnc but not necessarily turned
on vnc.

With 2 full bgp feeds this saves aproximately 100mb
when compiling with vnc and not using vnc.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-01 07:54:35 -05:00
Russ White 61aa468a04
Merge pull request #15257 from opensourcerouting/fix/reinstall_aggregate_route_if_rmap
bgpd: Reinstall aggregated routes if using route-maps and it was changed
2024-01-30 15:08:08 -05:00
Donatas Abraitis ee1986f1b5 bgpd: Reinstall aggregated routes if using route-maps and it was changed
Without this change when we change the route-map, we never reinstall the route
if the route-map has changed.

We checked only some attributes like aspath, communities, large-communities,
extended-communities, but ignoring the rest of attributes.

With this change, let's check if the route-map has changed.

bgp_route_map_process_update() is triggered on route-map change, and we set
`changed` to true, which treats aggregated route as not the same as it was before.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-30 15:47:49 +02:00
Donatas Abraitis a699cc1796 bgpd: Optimize memory usage for bgp_aggregate struct
```
struct bgp_aggregate {
        uint8_t                    summary_only;         /*     0     1 */
        uint8_t                    as_set;               /*     1     1 */
        uint8_t                    origin;               /*     2     1 */
        _Bool                      med_mismatched;       /*     3     1 */
        _Bool                      med_initialized;      /*     4     1 */
        _Bool                      match_med;            /*     5     1 */

        /* XXX 2 bytes hole, try to pack */

        struct {
                char *             name;                 /*     8     8 */
                struct route_map * map;                  /*    16     8 */
        } rmap;                                          /*     8    16 */
        long unsigned int          count;                /*    24     8 */
        long unsigned int          incomplete_origin_count; /*    32     8 */
        long unsigned int          egp_origin_count;     /*    40     8 */
        struct hash *              community_hash;       /*    48     8 */
        struct hash *              ecommunity_hash;      /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        struct hash *              lcommunity_hash;      /*    64     8 */
        struct hash *              aspath_hash;          /*    72     8 */
        struct community *         community;            /*    80     8 */
        struct ecommunity *        ecommunity;           /*    88     8 */
        struct lcommunity *        lcommunity;           /*    96     8 */
        struct aspath *            aspath;               /*   104     8 */
        safi_t                     safi;                 /*   112     4 */
        uint32_t                   med_matched_value;    /*   116     4 */
        char *                     suppress_map_name;    /*   120     8 */
        /* --- cacheline 2 boundary (128 bytes) --- */
        struct route_map *         suppress_map;         /*   128     8 */

        /* size: 136, cachelines: 3, members: 22 */
        /* sum members: 134, holes: 1, sum holes: 2 */
        /* last cacheline: 8 bytes */
};
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-30 08:12:59 +02:00
Donatas Abraitis 0804038916 bgpd: Optimize memory usage for bgp_static struct
```
struct bgp_static {
        int                        backdoor;             /*     0     4 */
        uint32_t                   label_index;          /*     4     4 */
        uint8_t                    valid;                /*     8     1 */

        /* XXX 1 byte hole, try to pack */

        uint16_t                   encap_tunneltype;     /*    10     2 */
        uint32_t                   igpmetric;            /*    12     4 */
        struct in_addr             igpnexthop;           /*    16     4 */
        uint32_t                   atomic;               /*    20     4 */
        struct {
                char *             name;                 /*    24     8 */
                struct route_map * map;                  /*    32     8 */
        } rmap;                                          /*    24    16 */
        struct prefix_rd           prd __attribute__((__aligned__(8))); /*    40    16 */
        char *                     prd_pretty;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        mpls_label_t               label;                /*    64     4 */

        /* XXX 4 bytes hole, try to pack */

        esi_t *                    eth_s_id;             /*    72     8 */
        struct ethaddr *           router_mac;           /*    80     8 */
        struct prefix              gatewayIp __attribute__((__aligned__(8))); /*    88    56 */

        /* size: 144, cachelines: 3, members: 14 */
        /* sum members: 139, holes: 2, sum holes: 5 */
        /* forced alignments: 2 */
        /* last cacheline: 16 bytes */
} __attribute__((__aligned__(8)));   /* saved 8 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-30 08:12:59 +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
Chirag Shah 71d08ecc9d bgpd: aggr summary-only suppressed export to evpn
When exporting bgp vrf instance unicast route into
EVPN as type-5, check for suppressed ones and do not
export them.

Ticket:#3534718
Testing Done:

Config:

router bgp 660000 vrf vrf1
 bgp router-id 144.1.1.2
 no bgp network import-check
 neighbor 144.1.1.1 remote-as external
 !
 address-family ipv4 unicast
  aggregate-address 50.1.0.0/16 summary-only
  redistribute connected
 exit-address-family
 !
 address-family l2vpn evpn
  advertise ipv4 unicast
 exit-address-family
exit

v4 suppressed route: (5 suppressed routes not exported to evpn)

tor1# vtysh -c "show bgp vrf vrf1 ipv4 unicast" | grep "50.1"
*> 50.1.0.0/16      0.0.0.0(bordertor-11)
s> 50.1.1.212/32    6.0.0.30(leaf-11)<
s> 50.1.1.222/32    6.0.0.31(leaf-11)<
s> 50.1.110.0/24    0.0.0.0(bordertor-11)
s> 50.1.210.214/32  6.0.0.30(leaf-11)<
s> 50.1.220.224/32  6.0.0.31(leaf-11)<

tor1# vtysh -c "show bgp l2vpn evpn route" | grep -A3 "*> \[5\].*\[50.1"
*> [5]:[0]:[16]:[50.1.0.0] RD 144.1.1.2:7
                    6.0.0.1 (bordertor-11)
                                             0         32768 ?
                    ET:8 RT:4640:104001 Rmac:00:02:00:00:00:04

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-11-29 21:44:08 -08:00
mxyns 66d564a60b bgpd: loc-rib uptime moved to bgp_path_info_extra and set in header
moved loc-rib uptime field "bgp_rib_uptime" to struct bgp_path_info_extra for memory concerns
moved logic into bgp_route_update's callback bmp_route_update
written timestamp in per peer header

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns 90ffa97e38 bgpd: beginning to add rib_uptime field for loc-rib timestamp
added time_t field to bgp_path_info
set value before bgp dp hook is called
value not set in the msg yet, testing and double checking is needed before

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns 66e0c6f826 bgpd: peer flag set for loc-rib monitoring (left set to 0 in other cases)
set peer type flag to 3 for loc rib monitoring
leave to 0 in other cases like before, even though RFC7854 tells us to set it to 0 1 or 2 depending on the case global/rd/local instance

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:47 +01:00
Maxence Younsi 9d219585e6 bgpd: basic loc rib monitoring (no syncing yet, not rfc compliant encoding)
bmp loc rib monitoring rfc 9069 debuts, loc-rib monitoring draft/poc

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:47 +01:00
Donatas Abraitis e0a8795484 bgpd: Use proper AFI when dumping information for dampening stuff
Before we called IPv4 for IPv6 dampening info.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-22 12:04:17 +03:00
Donald Sharp 250518f8c6 bgpd: Make debug a passed in variable for bgp_evpn_path_info_cmp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-19 15:51:05 -04:00
Donatas Abraitis 75dbd45c55
Merge pull request #14383 from donaldsharp/bgp_coverity_cleanup_early_sept
Bgp coverity cleanup early sept
2023-09-13 21:52:37 +03:00
Donald Sharp b45925ad10 bgpd: evpn_cleanup_local_non_best_route could free dest
But never really does due to locking, but since it can
we need to treat it like it does and ensure that FRR
is not making a mistake, by using memory after it
has been freed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-11 12:45:59 -04:00
Donald Sharp d16d013ca3 bgpd: bgp_path_info_cmp should use a bool for debug
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-07 15:17:39 -04:00
Yuqing Zhao 6e7f305e54 bgpd: Convert from struct bgp_node to struct bgp_dest
This is based on @donaldsharp's work

The current code base is the struct bgp_node data structure.
The problem with this is that it creates a bunch of
extra data per route_node.
The table structure generates ‘holder’ nodes
that are never going to receive bgp routes,
and now the memory of those nodes is allocated
as if they are a full bgp_node.

After splitting up the bgp_node into bgp_dest and route_node,
the memory of ‘holder’ node which does not have any bgp data
will be allocated as the route_node, not the bgp_node,
and the memory usage is reduced.
The memory usage of BGP node will be reduced from 200B to 96B.
The total memory usage optimization of this part is ~16.00%.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Yuqing Zhao <xiaopanghu99@163.com>
2023-08-22 09:35:46 +08:00
Donatas Abraitis ad151f66aa bgpd: Refactor bgp_static_set/bgp_static_set_safi
Those two functions are very similar, let's get a single one.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-14 17:10:07 +03:00