Commit Graph

870 Commits

Author SHA1 Message Date
Russ White
a00621d8b9
Merge pull request #12034 from opensourcerouting/fix/gr_hard_notification
bgpd: Do not send Deconfig/Shutdown message when restarting
2022-10-06 10:05:11 -04:00
Russ White
a8ef436639
Merge pull request #12040 from opensourcerouting/fix/bgp_local_as_remote_as
bgpd: Allow using remote-as the same as local-as
2022-10-06 10:03:26 -04:00
Madhuri Kuruganti
e85e4a8d16 bgpd: conditional advertisement code cleanup
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-06 12:43:05 +05:30
Donatas Abraitis
95098d9611 bgpd: Do not send Deconfig/Shutdown message when restarting
We might disable sending unconfig/shutdown notifications when
Graceful-Restart is enabled and negotiated.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-30 09:50:21 +03:00
Donatas Abraitis
d6b0327c35 bgpd: Allow using remote-as the same as local-as
As an example, Arista EOS allows this behavior.

Configuration something like:

```
 neighbor PG peer-group
 neighbor PG remote-as 65001
 neighbor PG local-as 65001
 neighbor 192.168.10.124 peer-group PG
```

Or without peer-group.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-29 21:13:40 +03:00
Russ White
df779878fb
Merge pull request #11985 from opensourcerouting/fix/thread_off_llgr
bgpd: Stop LLGR thread when deleting a peer and/or GR flags changed
2022-09-27 11:29:54 -04:00
Madhuri Kuruganti
1285c4ace9 bgpd: conditional advertise-map unset on peer not re-advertising withdrawn routes
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-09-25 11:48:47 +05:30
Donatas Abraitis
344d81ceed
Merge pull request #11982 from samanvithab/bgp_mem_fix
bgpd: multiple memory leak issue fixes
2022-09-23 17:54:33 +03:00
Samanvitha B Bhargav
b96b4f1c5f bgpd: Cleanup memory leaks associated with t_deferral_timer
We are allocating temporary memory for information about
what to process in this thread, which is not being cleaned
up on thread cancelling.

Signed-off-by: Samanvitha B Bhargav <bsmanvitha@vmware.com>
2022-09-23 00:14:12 -07:00
Donatas Abraitis
c0539ff458 bgpd: Stop conditional advertisements thread when terminating
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-22 10:30:13 +03:00
Donatas Abraitis
172e4d9fa2 bgpd: Stop LLGR thread when deleting a peer and/or GR flags changed
Also valid when shutting down a BGP instance.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-21 17:13:28 +03:00
Samanvitha B Bhargav
2305e3e460 bgpd: memory leak issue fix
Memory allocated when 'import vrf route maps <>' is configured,
wasn't being freed when the entire bgp config
was deleted through 'no router bgp'.

Signed-off-by: Samanvitha B Bhargav <bsmanvitha@vmware.com>
2022-09-21 01:57:09 -07: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
Donatas Abraitis
511211bf56 bgpd: Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-25 14:35:27 +03: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
Donatas Abraitis
01da2d2691 bgpd: Add neighbor soo command
BGP SoO is a tag that is appended on BGP updates to allow a peer to mark
a particular peer as belonging to a particular site. In certain MPLS L3 VPN
configurations, the BGP AS-Path may not provide the granularity needed
prevent a loop in the control-plane. With this in mind, BGP SoO is designed
to fill this gap and prevent a routing loop that may occur.

If we configure for example, `neighbor soo 65000:1` at PEs, routes won't be
announced between CPEs if soo matches. This is especially needed when using
as-override or allowas-in.

Also, this is the automated way of the same behavior as configuring route-maps
for each peer like:

```
bgp extcommunity-list cpe permit soo 65000:1
!
route-map cpe permit 10
 set extcommunity soo 65000:1
...
route-map cpe deny 10
 match extcommunity cpe
route-map cpe permit 20
...
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-20 21:22:45 +03:00
Donatas Abraitis
0b1fb52c2a bgpd: Convert some int functions to void
The output is not checked, we can have void instead.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-12 13:26:38 +03:00
Donatas Abraitis
f1aa49293a bgpd: Send route update when modifying access/aspath/prefix lists
Handle ORF REMOVE_ALL events as well, because now we just silently return, and
a stale dynamic prefix-list is used instead of the new one.

Before this, soft clear/route refresh was needed. Don't know the reason, but
we didn't send updates when modifying the filters.

Probably due to a massive change of filters and to avoid automatic updates :/

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-05 15:06:00 +03:00
Donatas Abraitis
c41e93720a bgpd: Reset BGP sessions when changing the port
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-27 11:44:07 +03:00
Russ White
3bf3144517
Merge pull request #11523 from pguibert6WIND/bgp_no_retain
Bgp no retain
2022-07-26 08:50:59 -04:00
Donald Sharp
fa5806c318 bgpd: Remove various macros that overlap THREAD_OFF
Let's just use THREAD_OFF consistently in the code base
instead of each daemon having a special macro that needs to
be looked at and remembered what it does.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:27:36 -04:00
Donald Sharp
3f22218b48 bgpd: Prevent memory leak of listener on shutdown
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-19 13:54:10 -04:00
Philippe Guibert
a486300b26 bgpd: implement retain route-target all behaviour
A new command is available under SAFI_MPLS_VPN:

With this command, the BGP vpnvx prefixes received are
not kept, if there are no VRF interested in importing
those vpn entries.

A soft refresh is performed if there is a change of
configuration: retain cmd, vrf import settings, or
route-map change.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-07-18 08:57:19 +02:00
Iqra Siddiqui
42427e3908 bgpd: Update msg not being sent on removing route-map from default-originate config
Description:
- On removing just the route-map from the default-originate config,
  update message is not sent to the peer,
  and the properties set by route-map persists on peer's end,
  until we do a clear bgp.

Fix:
- The flag which is set when default route is originated,
  should be unset once "neighbor X.X.X.X default-orginate",
  to remove route-map from "neighbor X.X.X.X default-orginate route-map Y",
  so as to trigger the flow for sending an update.

Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2022-07-06 05:38:35 +00:00
Donatas Abraitis
06bb44c884 bgpd: Start conditional advertisement timer instantly
Do not wait for the configured timer to expire if we enable advertise-map.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-01 15:22:06 +03:00
Quentin Young
ecf2b628d9 bgpd: rename update_type enum values
These values were named WITHDRAW and UPDATE. Yeah, you guessed it, those
are already #define's elsewhere (bgp_debug.h). Hilarity ensues.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2022-07-01 15:22:04 +03:00
Donatas Abraitis
7dddd1f733 bgpd: Make sure peer-groups/unnumbered work too with BGP role
Just adding a support for peer-groups, because now it's not possible to
configure BGP role for peer-groups.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-28 18:32:11 +03:00
Lou Berger
613025ef10
Merge pull request #11093 from donaldsharp/allow_martians
Allow martians
2022-06-28 10:38:57 -04:00
Donatas Abraitis
83194f394b bgpd: Use uin64_t for peer->flags
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-27 17:22:54 +03:00
Donald Sharp
8666265e2e bgpd: Add bgp allow-martian-nexthop command
The command `debug bgp allow-martian` is not actually
a debug command it's a command that when entered allows
bgp to not reset a peering when a martian nexthop is
passed in the nlri.

Add the `bgp allow-martian-nexthop` command and allow it to be
used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-24 07:45:46 -04:00
Eugene Bogomazov
865a7e7b3a bgpd: move to switch clause in get name function
bgp_rpki_validation2str implements a switch statement to determine the
correct string response from the validation state. So, switch to a
switch statement when getting a name by role for code consistency.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-22 17:03:25 +03:00
Eugene Bogomazov
13896bde30 bgpd: simplify code fragment for RFC 9234
Roles cannot be applied to iBGP sessions, so we can move this check to
the top of the role configuration method. Thus, we simplify the internal
logic of branching.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-22 16:12:28 +03:00
Eugene Bogomazov
9a38a7b055 bgpd: simplify ebgp role check for RFC 9234
BGP Role is currently defined only for eBGP session. So, we don't
need to consider which roles can be applied on iBGP session and
thus simplify code fragment.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-22 15:09:06 +03:00
Eugene Bogomazov
8f2d6021f8 bgpd: Add patches for RFC9234 implementation
This commit fixes some issues that were noted by the reviewer

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-21 17:41:53 +03:00
Eugene Bogomazov
d864dd9eb1 bgpd: Add RFC9234 implementation
RFC9234 is a way to establish correct connection roles (Customer/
Provider, Peer or with RS) between bgp speakers. This patch:
- Add a new configuration/terminal option to set the appropriate local
role;
- Add a mechanism for checking used roles, implemented by exchanging
the corresponding capabilities in OPEN messages;
- Add strict mode to force other party to use this feature;
- Add basic support for a new transitive optional bgp attribute - OTC
(Only to Customer);
- Add logic for default setting OTC attribute and filtering routes with
this attribute by the edge speakers, if the appropriate conditions are
met;
- Add two test stands to check role negotiation and route filtering
during role usage.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-17 13:14:46 +03:00
Pavel Shirshov
425bd64be8 bgpd: Allow bgp to control the DSCP session TOS value
Allow BGP to control the TOS DSCP value in the tcp header
via a new command at the bgp global level `bgp session-dscp <0-63>`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Pavel Shirhov <pavelsh@microsoft.com>
2022-05-13 14:14:35 -04:00
Donald Sharp
f205a2309c
Merge pull request #11177 from opensourcerouting/fix/memset_memcpy
*: memcpy/memset zeroing
2022-05-13 07:40:58 -04:00
Donald Sharp
56b91d107f bgpd: Prevent crash when issuing various forms of bgp no-rib
The `bgp no-rib` command cycles through all the bgp rib tables
and removes them from zebra.  Modify the code so that FRR notices
that it is attempting to cycle through the safi's that are two level
tables.  In addition these safi's cannot just blindly remove the routes
from the rib as that there are none explicitly.

This code just prevents the crash in bgpd.  It does not properly cycle
through and remove the zebra changes made that are explicit to these afi's.
This should be handled as appropriate by the developers on these safi's when
it becomes important to them.

Fixes: #11178
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-12 10:20:28 -04:00
Donatas Abraitis
6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
Donatas Abraitis
00b0b74847
Merge pull request #11145 from donaldsharp/bgp_capability
Bgp capability
2022-05-05 22:28:56 +03:00
Donatas Abraitis
50f1f2e724
Merge pull request #11059 from anlancs/fix/bgpd-evnp-wrong-check-hashget
bgpd: fix memory leak for evpn
2022-05-04 21:19:51 +03:00
Donald Sharp
28168b1bf6 bgpd: peer groups should not toggle interface based nht tracking
Peer groups when various forms of `bgp capability extended-nexthop`
is entered on them are toggling the nexthop tracking status of peers
in their peer group.  This is ok when the peer is not interface based.
But it is not ok when the peer is interface based as that it will turn
off the ability of FRR to properly work with that peer type.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-04 07:51:20 -04:00
anlan_cs
8e3aae66ce *: remove the checking returned value for hash_get()
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-03 00:41:48 +08:00
Donatas Abraitis
eea685b6d3 bgpd: Implement CEASE/Hard Reset notification
Also, add N-Bit (Notification) flag for Graceful Restart.

This is a preparation for RFC8538.

More information: https://datatracker.ietf.org/doc/html/rfc8538

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-02 09:43:40 +03:00
Russ White
bd751c0700
Merge pull request #10987 from opensourcerouting/fix/bgp_conditional_advertisements_rmap_change_peer_groups
bgpd: Do not forget to update conditional advertisements rmaps for peer-groups
2022-04-13 15:00:14 -04:00
Donatas Abraitis
9c2fd3fe44 bgpd: Convert vpn_policy_direction_t to enum
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:13:55 +03:00
Donatas Abraitis
3061acc235 bgpd: Convert bgp_peer_sort_t to enum
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:13:55 +03:00
Donatas Abraitis
9118301e48 bgpd: Do not forget to update conditional advertisements rmaps for peer-groups
When the peer is configured for the first time:
```
neighbor P1 peer-group
neighbor P1 remote-as external
neighbor P1 advertise-map ADV exist-map EXIST
neighbor 10.10.10.1 peer-group P1
```

Conditional advertisements route-maps are not updated and cond. advertisements
do not work until FRR restarted. BGP sessions clear does not help.

Or even changing peer-group for a peer, causes this bug to kick in.

```
no neighbor 10.10.10.1
neighbor 10.10.10.1 peer-group P2
```

With this fix, cond. advertisements start working immediatelly.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-08 22:43:01 +03:00