Commit Graph

1607 Commits

Author SHA1 Message Date
Ryo Nakano
65d6b56a06 bgpd: Fix show bgp all rpki notfound
The command "show bgp all rpki notfound" includes not only RPKI
notfound routes but also RPKI valid and invalid routes in its results.

Fix the code to display only RPKI notfound routes.

Old output:
```
frr# show bgp all rpki notfound

For address family: IPv4 Unicast
BGP table version is 0, local router ID is 10.0.0.1, vrf id 0
Default local pref 100, local AS 64512
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
N   x.x.x.0/18       a.a.a.a                       100      0 64513 i
V   y.y.y.0/19       a.a.a.a                       200      0 64513 i
I   z.z.z.0/16       a.a.a.a                        10      0 64513 i

Displayed  3 routes and 3 total paths
```

New output:
```
frr# show bgp all rpki notfound

For address family: IPv4 Unicast
BGP table version is 0, local router ID is 10.0.0.1, vrf id 0
Default local pref 100, local AS 64512
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
N   x.x.x.0/18       a.a.a.a                       100      0 64513 i

Displayed  1 routes and 3 total paths
```

Signed-off-by: Ryo Nakano <ryo.z.nakano@gmail.com>
2023-09-01 15:39:05 +09:00
Donald Sharp
2bc08688da bgpd: When using show bgp peerhash don't display (NULL)
Fix up the output to not display a (NULL) output for the bgp name

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-31 11:01:44 -04:00
Donatas Abraitis
e89fd723ee
Merge pull request #14118 from GaladrielZhao/master
bgpd: Convert from struct bgp_node to struct bgp_dest
2023-08-30 17:43:29 +03:00
Valerian_He
77f3d6e520 bgpd: fix bug in a place about label validation
Shouldn't validate the label after 'decode_label'. If we validate
the label after 'decode_label', even the 'MPLS_INVALID_LABEL' will
be valid then.

Signed-off-by: Valerian_He <1826906282@qq.com>
2023-08-24 02:17:06 +00: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
Donald Sharp
e20c23fa5b bgpd: Move status and ostatus to struct peer_connection
The status and ostatus are a function of the `struct peer_connection`
move it into that data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-18 09:29:04 -04:00
Rajesh Varatharaj
d33bd63126 bgpd: fix coverity issue in bgpd
Should address this issue:
** CID 1566843:  Uninitialized variables  (UNINIT)
/bgpd/bgp_route.c: 6754 in bgp_static_set()
6748                            bgp_static->backdoor = backdoor;
6749                            bgp_static->valid = 0;
6750                            bgp_static->igpmetric = 0;
6751                            bgp_static->igpnexthop.s_addr = INADDR_ANY;
6752                            bgp_static->label_index = label_index;
6753                            bgp_static->label = label;
>>>     CID 1566843:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value prd.
6754                            bgp_static->prd = prd;
6755
6756                            if (rmap) {
6757                                    XFREE(MTYPE_ROUTE_MAP_NAME,
6758                                          bgp_static->rmap.name);
6759                                    route_map_counter_decrement(

Testing Done:
 build

Ticket: #NA
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
2023-08-15 11:14:16 -07:00
Donald Sharp
77014daf3a
Merge pull request #14016 from mjstapp/event_exec_ptr
* : include event ptr in event_execute api
2023-08-15 11:52:49 -04: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
Donatas Abraitis
456b63d8c8
Merge pull request #14099 from lkClare/formated_sync_0727
bgpd: bgp_path_info_extra memory optimization
2023-08-09 14:46:48 +03:00
Donatas Abraitis
ffa7233fa1 bgpd: Fix RFC number in a comment
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-08 16:31:12 +03:00
Valerian_He
98efa5bc6b bgpd: bgp_path_info_extra memory optimization
Even if some of the attributes in bgp_path_info_extra are
not used, their memory is still allocated every time. It
cause a waste of memory.
This commit code deletes all unnecessary attributes and
changes the optional attributes to pointer storage. Memory
will only be allocated when they are actually used. After
optimization, extra info related memory is reduced by about
half(~400B -> ~200B).

Signed-off-by: Valerian_He <1826906282@qq.com>
2023-08-08 10:48:07 +00:00
Mark Stapp
adca5c22c5 * : include event ptr in event_execute api
Include an event ptr-to-ptr in the event_execute() api
call, like the various schedule api calls. This allows the
execute() api to cancel an existing scheduled task if that
task is being executed inline.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-07-25 10:17:48 -04:00
Sindhu Parvathi Gopinathan
e784a60b17 bgpd: non pretty json output for neighbor routes
Currently, json output of show BGP commands are no pretty format.

This is an extremely expensive operation for huge scale (lots of
routes with lots of paths).

BGP json non-pretty commands support added:

```
show bgp neighbors <nbr-id> advertised-routes json
show bgp neighbors <nbr-id> received-routes json
show bgp neighbors <nbr-id> advertised-routes detail json
show bgp neighbors <nbr-id> received-routes detail json
```

Ticket:#3513256
Issue:3513256

Testing: UT done

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
2023-07-24 10:50:45 -07:00
Donald Sharp
4a986f20d7
Merge pull request #14041 from opensourcerouting/fix/memory_leak_bgp_redistribute_add
bgpd: Do not try to redistribute routes if we are shutting down
2023-07-18 10:55:22 -04:00
Russ White
3d91ef63c1
Merge pull request #14015 from opensourcerouting/fix/bgpd_refactor_bgp_update_withdraw_safi
bgpd: Refactor a bit bgp_{update,withdraw} functions
2023-07-18 09:42:07 -04:00
Russ White
8593341164
Merge pull request #13868 from zice312963205/zly_mapflag
bgpd:Fixing a conflict issue between rmap_in_change_flag and rmap_out…
2023-07-18 09:14:50 -04:00
Donatas Abraitis
bddf5c13b2 bgpd: Do not try to redistribute routes if we are shutting down
When switching `router bgp`, `no router bgp` and doing redistributions, we should
ignore this action, otherwise memory leak happens:

```
Indirect leak of 400 byte(s) in 2 object(s) allocated from:
    0 0x7f81b36b3a06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
    1 0x7f81b327bd2e in qcalloc lib/memory.c:105
    2 0x55f301d28628 in bgp_node_create bgpd/bgp_table.c:92
    3 0x7f81b3309d0b in route_node_new lib/table.c:52
    4 0x7f81b3309d0b in route_node_set lib/table.c:61
    5 0x7f81b330be0a in route_node_get lib/table.c:319
    6 0x55f301ce89df in bgp_redistribute_add bgpd/bgp_route.c:8907
    7 0x55f301dac182 in zebra_read_route bgpd/bgp_zebra.c:593
    8 0x7f81b334dcd7 in zclient_read lib/zclient.c:4179
    9 0x7f81b331d702 in event_call lib/event.c:1995
    10 0x7f81b325d597 in frr_run lib/libfrr.c:1213
    11 0x55f301b94b12 in main bgpd/bgp_main.c:505
    12 0x7f81b2b57082 in __libc_start_main ../csu/libc-start.c:308
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-07-18 13:28:01 +03:00
Donatas Abraitis
8d51fafdcb bgpd: Drop bgp_static_update_safi() function
Combine bgp_static_update() and bgp_static_update_safi() into a single one.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-07-14 19:12:01 +03:00
Donatas Abraitis
b8ca2d4fb8 bgpd: Drop bgp_static_withdraw_safi() function
Combine bgp_static_withdraw() and bgp_static_withdraw_safi() into a single one.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-07-14 19:12:01 +03:00
Donald Sharp
e445039e47
Merge pull request #13983 from WiMoVE-OSS/bgpd-memory-leak-table-stats-single
bgpd: Fix memory leak by moving allocation of json object
2023-07-12 14:45:09 -04:00
Alexander Sohn
2dfc9167ab
bgpd: Fix memory leak by moving allocation of json object
Signed-off-by: Alexander Sohn <github@asohn.de>
2023-07-11 16:21:57 +02: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
Jack.zhang
a725bf4bbb bgpd:Fixing a conflict issue between rmap_in_change_flag and rmap_out_change_flag.
Imagine the following scenario:
when a neighbor has an inbound policy set to modify the next hop, but no outbound route-map is configured.
In this case, if(!post_attr && (ROUTE_MAP_OUT_NAME(filter) || bgp_path_suppressed(pi))) returns false, causing rmap_in_change_flag to not be correctly cleared, and mistakenly identified as rmap_out_change_flag, leading to the failure of the subsequent neighbor-nexthop-self command.

Signed-off-by: Jack.zhang <hanyu.zly@alibaba-inc.com>
2023-06-28 11:42:19 +08: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
Russ White
554c2e0350
Merge pull request #13750 from louis-6wind/fix-no-retain-memory-usage
bgpd: fix memory usage of vpn no retain
2023-06-20 09:19:50 -04:00
Russ White
68da3eab07
Merge pull request #13524 from pguibert6WIND/mpls_vpn_lsr_redistribute
MPLS vpn LSR redistribute
2023-06-20 09:13:33 -04:00
Russ White
95070f2eef
Merge pull request #13557 from anlancs/fix/bgpd-evpn-rmac-best-path
bgpd: Fix missing deletion of evpn routes
2023-06-20 09:12:51 -04:00
Louis Scalbert
a04d32b366 bgpd: fix incorrect json output in bgp_show_table_rd()
'{}' extra output may present JSON output from bgp_show_table_rd() when
no prefix are seen.

> {
>  "vrfId": 0,
>  "vrfName": "default",
>  "tableVersion": 0,
>  "routerId": "1.1.1.1",
>  "defaultLocPrf": 100,
>  "localAS": 65500,
>  "routes": {  "routeDistinguishers" : { "444:1" : {  }  }  }  }
> {}

Do not output '{}' when bgp_show_table() returns a valid JSON.
Tested without rd in config, bgp_show_table() returns nothing and the
JSON output is only '{}'

Fixes: 0224b3296c ("bgpd: Print empty JSON `{}` if no entries under `show bgp ipv4 vpn json`")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-06-16 14:18:25 +02:00
Louis Scalbert
3cc70b02a9 bgpd: fix memory usage of vpn no retain
By default, bgpd stores all MPLS VPN SAFI prefixes unless the "no bgp
retain route-target all" option is used to store only prefixes that are
imported into local VRFs. The "no retain" option temporarily uses too
much memory, as all prefixes are stored in memory before the deletion of
non-imported prefixes is done.

Filter out non-imported prefixes before they are set into the BGP adj
RIB out.

Fixes: a486300b26 ("bgpd: implement retain route-target all behaviour")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-06-16 14:18:25 +02:00
Louis Scalbert
59bbe85d4b bgpd: revert no retain backend
Partially revert a486300b26 ("bgpd: implement retain route-target all
behaviour") in order to fix a memory consumption issue in the next
commit.

Fixes: a486300b26 ("bgpd: implement retain route-target all behaviour")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-06-16 14:18:25 +02:00
Philippe Guibert
961b898197 bgpd: fix static analysis issue in subgroup_announce_check()
Remove the check about pi->peer value different from null.
Introducing this check introduces a SA warning on the value
of the from value (derived from pi->peer).

Actually, peer is set when bgp_path_info_make() call is
performed; peer is never null.

Fixes: 23bb4a9b5c64 ("bgpd: advertise mpls vpn routes with appropriate label")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:55:17 +02:00
Philippe Guibert
7817cdeadc bgpd: fix accept-own routes received by a route reflector
When using the bgp-accept-own community, with the
'attribute-unchanged next-hop' command, the advertised
mpls vpn updates that are reflected by a route reflector
are received, but are not selected.

Once the accept-own community is detected, a new bgp_path
is created, in addition of the original one; then the
next-hop of the NLRI is checked, but fails for two reasons:
- the next-hop tracking returns the real IP reachability
status for prefixes that have the BGP_ROUTE_IMPORTED subtype.
This is what happens with bgp updates with the accept-own
community.
- as the next-hop was unchanged and was the peer IP in the VRF.
Consequently, the new bgp_path is considered inactive in the
default VRF, and is not selected.

The incoming bgp updates with the accept-own community should
not be checked against the next-hop tracking. As the bgp_path
subtype has been changed to BGP_ROUTE_IMPORTED, let us check
the bgp subtype before calling the 'bgp_find_or_add_nexthop()'
function in the 'bgp_update()' call.

Fixes: 46dbf9d0c0 bgpd: ("Implement ACCEPT_OWN extended community")
Fixes: 376797711f4d - bgpd: track mpls vpn nexthops
Fixes: e6110f755718 bgpd: ("fix use nexthop tracking for exported vpn paths")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:55:17 +02:00
Philippe Guibert
98c615f05a bgpd: advertise mpls vpn routes with appropriate label
The advertised label value from mpls vpn routes is not modified
when the advertised next-hop is modified to next-hop-self.

Actually, the original label value received is redistributed as
is, whereas the new_label value bound in the nexthop label
bind entry should be used.

Only the VPN entries that contain MPLS information, and that
are redistributed between distinct peers, will have a label
value to advertise.
- no SRv6 attribute
- no local prefix
- no exported VPN prefixes from a VRF

If the advertisement to a given peer has the next-hop modified,
then the new label value will be picked up. The considered cases
are peers configured with 'next-hop-self' option, or ebgp peerings
without the 'next-hop-unchanged' option.

Note that the the NLRI format will follow the rfc3107 format, as
multiple label values for MPLS VPN NLRIs are not supported (the
rfc8277 is not supported).
Note also that the case where an outgoing route-map is applied to
the outgoing neighbor is not considered in this commit.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
1069425868 bgpd: allocate label bound to received mpls vpn routes
Current implementation does not offer a new label to bind
to a received VPN route entry to redistribute with that new
label.

This commit allocates a label for VPN entries that have
a valid label, and a reachable next-hop interface that is
configured as follows:

> interface eth0
>  mpls bgp l3vpn-multi-domain-switching
> exit

An mplsvpn next-hop label binding entry is created in an mpls
vpn nexthop label bind hash table of the current BGP instance.
That mpls vpn next-hop label entry is indexed by the (next-hop,
orig_label) values provided by the incoming updates, and shared
with other updates having the same (next-hop, orig_label) values.

A new 'LP_TYPE_BGP_L3VPN_BIND' label value is picked up from the
zebra mpls label pool, and assigned to the new_label attribute.

The 'bgp_path_info' appends a 'bgp_mplsvpn_nh_label_bind' structure
to the 'mplsvpn' union structure. Both structures in the union are not
used at the same, as the paths are either VRF updates to export, or MPLS
VPN updates. Using an union gives a 24 bytes memory gain compared to if
the structures had not been in an union (24 bytes compared to 48 bytes).

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
28d5c6e531 bgpd: move label allocation code to a specific function
The label allocation mechanism is called implicitly for
labeled unicast paths. The check should be explicit, because
the current patch set will extend the mechanism for mpls vpn
paths, and the code should explicitly tell which safi calls
which code.

Fix this implicit call by checking the safi value. Move the
code to a specific function.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
cd0e9bfbc4 bgpd: track mpls vpn nexthops
There is no nexthop reachability information for
received MPLS VPN prefixes.
This information is necessary when BGP also acts
as LSR device, and is needed to create an MPLS entry
between two BGP speakers: the next-hop to pick-up
in the MPLS entry has to be connected.

The nexthop reachability information is available
for other non MPLS VPN prefixes, and is handled
by the bgp nexthop cache (bnc) contexts.
Extend the usage of the BNC contexts for L3VPN
prefixes.

Note that the MPLS VPN routes had to be redistributed
as before, to avoid breaking existing deployments
that use FRR as route reflectors. Because of this, the
nexthop reachability status has been maintained to OK
for MPLS VPN prefixes.

Note also that the label allocation per nexthop tracking
was wrongly using the MPLS VPN safi to get a valid BNC
context, when choosing which label to return in the
'vpn_leak_from_vrf_get_per_nexthop_label()' function.
Fix this by using SAFI_UNICAST instead.

Fixes: 577be36a41 ("bgpd: add support for l3vpn per-nexthop label")
Link: https://github.com/FRRouting/frr/pull/13380
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Donald Sharp
4d616f022f bgpd: some safi's do not mix with bgp suppress-fib
BGP cannot decide to disseminate the safi based upon the
bgp suppress-fib command.  Modify the code to look at
the safi for the decision to communicate to a peer the
particular node.

Ticket: #3402926
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-14 15:15:13 -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
anlan_cs
0c061db4d0 bgpd: Fix missing deletion of evpn routes
Consider the scenario of evpn, the box has some type-5 ECMP routes.

After one of its remote peers is removed ( or down ), `show evpn rmac vni all`
kept no change **sometimes**, it means the rmac of the removed peer maybe is
still in this box, and the traffic will be wrongly forwarded to the removed
peer.

The root cause is that the best path selection for type-5 routes maybe
keep no change and the best path is not routed to the removed peer, so `bgpd`
wrongly doesn't tell `zebra` to remove ( withdraw ) the type-5 routes owned
by the removed peer.

So, add a new flag to force the deletion.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-06-03 09:27:53 +08:00
Donatas Abraitis
d49700dd2f bgpd: Add an ability to control default-originate route-map timer
By default it's 5 seconds. That means, every 5 second it iterates over the
whole BGP table and checks if a route-map is kicked in (if route-map is defined).

Having a full feed with many of neighbors, this is a huge CPU-killer, and takes
a lot of time.

Thread statistics for bgpd:

Showing statistics for pthread default
--------------------------------------
                               CPU (user+system): Real (wall-clock):
Active   Runtime(ms)   Invoked Avg uSec Max uSecs Avg uSec Max uSecs  CPU_Warn Wall_Warn Starv_Warn Type   Thread
    0          0.487        10       48        84       49        85         0         0          0    T    (bgp_connect_timer)
    0          0.000         1        0         0        1         1         0         0          0    T    bgp_startup_timer_expire
    2          3.991       276       14      1032       14      1031         0         0          0  R      zclient_read
    0          0.010         4        2         6        3         6         0         0          0     E   _bfd_sess_send
    0          0.057        11        5        26        6        26         0         0          0   W     vtysh_write
    0         65.054       136      478     28907      484     28914         0         0          0     E   bgp_event
    0      11233.040        24   468043   2772209  1341293   7781145         0         3          0    T    subgroup_coalesce_timer
    2          3.649        33      110       394      111       395         0         0          0  R      bgp_accept
    0        468.837         5    93767    178929    93799    178960         0         0          0    T    (bgp_graceful_stale_timer_expire)
    0          0.462         9       51        77       51        78         0         0          0    T    (bgp_start_timer)
    1        415.825     14200       29       414       29       415         0         0          0  R      vtysh_accept
    0          0.052         3       17        47       18        49         0         0          1    T    bgp_config_finish
    0          0.011         1       11        11       12        12         0         0          0     E   frr_config_read_in
    0          0.022         4        5         8        6         9         0         0          0     E   bgp_nht_ifp_initial
    0          0.121        44        2        64        3        65         0         0          0    T    (bgp_routeadv_timer)
    0      34194.454         3 11398151  21874014 27937411  52641827         2         0          1    T    bgp_route_map_update_timer
    0      13246.820         8  1655852   3065476  4589606   8454782         0         4          1    T    bgp_announce_route_timer_expired
    0          0.035         2       17        26       18        27         0         0          0     E   zclient_connect
    0     279624.026    318778      877    571779     2808   1639624         0         0          5    T    work_queue_run
    0          0.097        32        3        21        3        23         0         0          0  RW     bgp_connect_check
    2       6005.738     43560      137    680012      138    680446         0         0          0  R      vtysh_read
    0       1605.840   1116298        1      1331        2     10152         0         0        133    T    (bgp_generate_updgrp_packets)
    0       1073.162        17    63127    222065    63175    222087         0         0          0     E   bgp_packet_process_error
    1   16744058.262     10691  1566182   1807248  1566900   1808301         0         0          5    T    update_group_refresh_default_originate_route_map
    0          0.000        11        0         0        0         1         0         0          0    T    update_subgroup_merge_check_thread_cb
    0      94544.034   1898726       49    225054       69    225156         0         0          0     E   bgp_process_packet

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-31 22:58:30 +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
Donatas Abraitis
be393ade4a bgpd: Refactor subgroup_announce_table() to reuse an existing helpers
Reuse subgroup_process_announce_selected(). It does the same as we do here
duplicating the logic.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-25 17:04:47 +03:00
Rajasekar Raja
be66fa05c9 bgpd: Fix the json output of show bgp all json to be in a valid format
In the json output of show bgp all json, the l2VpnEvpn afi-safi is
missing the 'routes' key making the json output format invalid.

Before Fix:
torm-11# sh bgp all json
{
<SNIP>....................
"l2VpnEvpn":{
{
  "27.0.0.15:2":{
    "rd":"27.0.0.15:2",
    "[4]:[03:44:38:39:ff:ff:01:00:00:01]:[32]:[27.0.0.15]":{
      "prefix":"[4]:[03:44:38:39:ff:ff:01:00:00:01]:[32]:[27.0.0.15]",
      "prefixLen":352,
      "paths":[
<SNIP>....................

After Fix:
torm-11# sh bgp all json
{
<SNIP>....................
"l2VpnEvpn":{
"routes":{
  "27.0.0.15:2":{
    "rd":"27.0.0.15:2",
    "[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]":{
      "prefix":"[1]:[0]:[03:44:38:39:ff:ff:01:00:00:01]:[128]:[::]:[0]",
      "prefixLen":352,
      "paths":[

Issue: 3472865
Ticket:#3472865

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2023-05-22 14:02:54 -07:00
Donatas Abraitis
98378a3546
Merge pull request #13564 from chiragshah6/fdev1
bgpd: aggregate route best path select and other fixes
2023-05-22 09:45:54 +03:00
Donatas Abraitis
e0b1c8ccdf bgpd: Initialize pfx_buf to zeros before using in bgp_path_info_cmp()
This can lead into some garbage outputs, that can't be decoded in utf-8 or so.

This was catched when testing 76b246aa1f.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-20 10:03:10 +03:00
Chirag Shah
e38e8edcf9 bgpd: fix memory leak in aggregate path info
Fix memory leak in aggregate route path info
comparison api.

Signed-off-by: Chirag shah <chirag@nvidia.com>
2023-05-19 14:45:49 -07:00
Chirag Shah
cd845be6a7 bgpd: fix aggregate route best path select
In ebgp+ ibgp deployment aggregate summary-only route
selected path should always be locally originated
summary route.
When aggregate route summary-only config is removed
The selected path is iBGP peer as its lower cost
Upon reconfiguring aggregate route summary-only,
the locally originated is not selected due to
always choosing first path attribute and bailing
out as no change in route update.

Ticket:#3467890
Issue:3467890
Testing Done:

Config:
------
TORC11(config-router)#router bgp
TORC11(config-router)# address-family ipv4 unicast
TORC11(config-router-af)# aggregate-address 184.123.0.0/16
        summary-only
TORC11(config-router-af)# no aggregate-address 184.123.0.0/16
        summary-only
TORC11(config-router-af)# aggregate-address 184.123.0.0/16
        summary-only

Before fix:
-----------
*> 184.123.0.0/16   ::(TORC11)               0         32768 i
*                   uplink1                                0 4435 5546 i
*                   uplink2                                0 4435 5546 i
* i                 peerlink-3               0    100      0 i

After fix:
----------
*> 184.123.0.0/16   ::(TORC11)               0         32768 i
* i                 peerlink-3               0    100      0 i
*                   uplink2                                0 4435 5546 i
*                   uplink1                                0 4435 5546 i

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-05-19 14:45:38 -07:00
Philippe Guibert
5dba25927d bgpd: correctly initialize the IP nexthop of redistributed routes
This is a preliminary work to export redistributed routes from
a given VRF in an VPN network. The exportation works well, when
the label allocation is based on an per-vrf mode, but not on
a per nexthop mode.

To associate a label with a connected nexthop, the nexthop
tracking contexts are used. Until today, there was no tracking
context for redistributed routes. But when using this vpn
allocation mode, one needs to know whether the route is directly
connected or not. When using the nexthop tracking context, the
nexthop attribute of the bgp update needs to have the nexthop
properly set. This was not the case for the mp_nexthop_global_in
attribute which was empty.

This commit is mandatory in order to later use nexthop tracking
context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00
Philippe Guibert
83b50eff9a bgpd: remove ATTR_NEXT_HOP for redistributed ipv6 nexthops
This commit addresses an issue with an MPLS VPN network
redistributing static routes that are exported to the VPN,
and where the labels are allocated per next-hop.

For that purpose, the nexthop of the static routes is
checked against the nexthop tracking. The validation
of a valid nexthop will trigger the use of a unique
label for all prefixes using that destination.

However, the nexthop fails to be validated, with the
following message:

 > evaluate_paths: prefix 172:31::14/128 (vrf vrf1), ignoring path due to
 > martian or self-next-hop

The reason is due to the way the attr is created.
By default, the ATTR_NEXTHOP attribute is set for
all prefixes, whereas this flag should only be valid
for IPv4. In the case there is an IPv6 nexthop, remove
the ATTR_NEXTHOP flag.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09 21:00:57 +02:00