Commit Graph

1420 Commits

Author SHA1 Message Date
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
aa53c036c0 bgpd: Change single value bitfield to a bool
The maxpaths same_clusterlen value was a uint16_t
with a single bit being used.  No other values are
being stored.  Let's remove the bitfield and simplify
to a bool.

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
Dmitrii Turlupov
5f933e1eca bgpd: fix size of esi_buf
Fixes: #11111
Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
2022-04-29 14:56:25 +03:00
Donald Sharp
8f904fdb45
Merge pull request #11095 from ecbaldwin/unlock-node-always
bgpd: ensure that the node gets unlocked in all cases
2022-04-26 15:26:03 -04:00
Carl Baldwin
067ea16598 bgpd: ensure that the node gets unlocked in all cases
The logic to unlock dest if iteration completed without iterating the
entire node was flawed. Specifically, if iteration terminated due to
`gr_deferred == 0` then the node would not get unlocked.

This change takes into account the fact that dest will be NULL only in
the case when the entire table was iterated and all nodes were already
unlocked. In any other case, it needs to be unlocked.

Signed-off-by: Carl Baldwin <carl@ecbaldwin.net>
2022-04-26 09:38:37 -06:00
Donatas Abraitis
db66cf7c17 bgpd: Drop inet_ntop for route_vty_out_overlay()
Reuse %pI4/%pI6/%pIA

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-25 20:34:51 +03:00
Donald Sharp
544be97911 *: Fix spelling of strucutre
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:19:37 -04:00
Donald Sharp
ce5002c659 *: Fix spelling of comparision
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:18:43 -04:00
Russ White
6a1dbeba2f
Merge pull request #11010 from opensourcerouting/feature/reuse_bgp_attr_set_community_for_flags
bgpd: Reuse bgp_attr_set_[el]community() for setting attribute flags
2022-04-13 14:54:30 -04:00
Russ White
a39df8492d
Merge pull request #11009 from opensourcerouting/fix/med_for_aggregate-address
bgpd: aggregate-address fixes
2022-04-13 14:53:14 -04: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
9d34440bf8 bgpd: Reuse bgp_attr_set_[l]community() for setting attribute flags
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:09:28 +03:00
Donatas Abraitis
764402feba bgpd: Fix styling for aggregate_addressv4_cmd
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-11 17:53:42 +03:00
Donatas Abraitis
cacba915d0 bgpd: Add autocomplete for aggregate-address ... route-map X
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-11 17:47:52 +03:00
Donatas Abraitis
c0945b7828 bgpd: Allow setting BGP [large]community in route-maps
Before:
```
spine1-debian-11(config-route-map)# bgp community alias 65001:65001 test1
spine1-debian-11(config)# route-map rm permit 10
spine1-debian-11(config-route-map)# set community 65001:65001
% Malformed communities attribute
```

After:
```
spine1-debian-11(config)# bgp community alias 65001:65001 test1
spine1-debian-11(config)# route-map rm permit 10
spine1-debian-11(config-route-map)# set community 65001:65001
spine1-debian-11(config-route-map)#
```

Same for large-communities.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-09 17:34:06 +03:00
Xiao Liang
7e7639f548 bgpd: Fix memory leak in subgroup_announce_check
Flush dummy attr to release objects allocated by route-map.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-04-02 17:02:35 +08:00
Donatas Abraitis
f70c91dcef bgpd: Add %pBP printfrr() extension to print IP(hostname) for BGP peer
Replace existing bgp_peer_hostname() function.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-31 21:20:11 +03:00
Russ White
8084c3325b
Merge pull request #10845 from opensourcerouting/feature/unify_bgp_logging
bgpd: Print hostname along with IP for most useful debug messages
2022-03-29 11:13:29 -04:00
Donald Sharp
a80d833f6b
Merge pull request #10878 from ton31337/fix/bgp_crash_vrf_all_all
bgpd: Fix crash for `show ip bgp vrf all all`
2022-03-28 08:27:19 -04:00
Donatas Abraitis
75ce3b14f3 bgpd: Fix crash for show ip bgp vrf all all neighbors 192.168.0.1 ...
When `all` is specified BGP pointer is always NULL, we need to iterate over
all instances separately.

```
Received signal 11 at 1648199394 (si_addr 0x30, PC 0x562e96597090); aborting...
 /usr/local/lib/libfrr.so.0(zlog_backtrace_sigsafe+0x5e) [0x7f378a57ff6e]
 /usr/local/lib/libfrr.so.0(zlog_signal+0xe6) [0x7f378a580146]
 /usr/local/lib/libfrr.so.0(+0xcd4c2) [0x7f378a5aa4c2]
 /lib/x86_64-linux-gnu/libpthread.so.0(+0x14140) [0x7f378a33e140]
 /usr/lib/frr/bgpd(bgp_afi_safi_peer_exists+0) [0x562e96597090]
 /usr/lib/frr/bgpd(+0x15c3b8) [0x562e9654a3b8]
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-25 11:53:47 +02:00
Donatas Abraitis
fa5ac37865 bgpd: Fix crash for show ip bgp vrf all all
When `all` is specified BGP pointer is always NULL, we need to iterate over
all instances separately.

```
BGP[170822]: Received signal 11 at 1648199394 (si_addr 0x30, PC 0x562e96597090); aborting...
BGP[170822]: /usr/local/lib/libfrr.so.0(zlog_backtrace_sigsafe+0x5e) [0x7f378a57ff6e]
BGP[170822]: /usr/local/lib/libfrr.so.0(zlog_signal+0xe6) [0x7f378a580146]
BGP[170822]: /usr/local/lib/libfrr.so.0(+0xcd4c2) [0x7f378a5aa4c2]
BGP[170822]: /lib/x86_64-linux-gnu/libpthread.so.0(+0x14140) [0x7f378a33e140]
BGP[170822]: /usr/lib/frr/bgpd(bgp_afi_safi_peer_exists+0) [0x562e96597090]
BGP[170822]: /usr/lib/frr/bgpd(+0x15c3b8) [0x562e9654a3b8]
BGP[170822]: /usr/local/lib/libfrr.so.0(+0x75a9e) [0x7f378a552a9e]
BGP[170822]: /usr/local/lib/libfrr.so.0(cmd_execute_command+0x5d) [0x7f378a552e2d]
BGP[170822]: /usr/local/lib/libfrr.so.0(cmd_execute+0xc0) [0x7f378a553070]
BGP[170822]: /usr/local/lib/libfrr.so.0(+0xe3697) [0x7f378a5c0697]
BGP[170822]: /usr/local/lib/libfrr.so.0(+0xe3db1) [0x7f378a5c0db1]
BGP[170822]: /usr/local/lib/libfrr.so.0(+0xe6c30) [0x7f378a5c3c30]
BGP[170822]: /usr/local/lib/libfrr.so.0(thread_call+0x73) [0x7f378a5bb743]
BGP[170822]: /usr/local/lib/libfrr.so.0(frr_run+0xd0) [0x7f378a578750]
BGP[170822]: /usr/lib/frr/bgpd(main+0x344) [0x562e964cf3f4]
BGP[170822]: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7f378a18bd0a]
BGP[170822]: /usr/lib/frr/bgpd(_start+0x2a) [0x562e964d10ea]
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-25 11:41:16 +02:00
Donatas Abraitis
a7d91a8c79 bgpd: Print hostname along with IP for most useful debug messages
Examples:

```
%ADJCHANGE: neighbor 192.168.0.1(exit1-debian-11) in vrf default Up
192.168.0.1(exit1-debian-11) graceful restart stalepath timer expired
192.168.0.1(exit1-debian-11) sending route-refresh (BoRR) for IPv4/unicast
192.168.0.1(exit1-debian-11) graceful restart timer started for 120 sec
192.168.0.1(exit1-debian-11) graceful restart stalepath timer started for 120 sec
192.168.0.1(exit1-debian-11) graceful restart timer stopped
%MAXPFXEXCEED: No. of IPv4 Unicast prefix received from 192.168.0.1(exit1-debian-11) 9 exceed, limit 1
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-22 21:59:58 +02:00
Donald Sharp
7baebfb715
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
*: Fix JSON keys with whitespaces and PascalCase
2022-03-13 18:19:33 -04:00
Donald Sharp
e3015d915b bgpd: Fix continue/break change from old commit
Commit: ea47320b1d

Modified the bgp_clear_stale_route function to have
better indentation, but in the process changed some
`continue;` statements to `break;` which modified
the looping and caused stale paths to not always be
removed upon an update.

To reproduce:  A ---- B, setup with addpath and GR
One side has a prefix with nhop1 and nhop2, kill one
side and then resend the same prefix with nhop3,
paths nhop1 and 2 become stale and never removed.

Code inspection clearly shows that that `continue`
statements became `break` statements causing the
loop over all paths to stop prematurely.

The fix is to change the break back to continue
statements so the loop can continue instead of
stopping.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-07 11:28:28 -05:00
Rafael Zalamena
5be6fa9bf0 bgpd: fix 'show bgp detail json' output
Include the BGP_SHOW_OPT_DETAIL flag in the 'detail' version of the
command.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-03-03 18:26:03 -03:00
Russ White
d2dfd26697
Merge pull request #10636 from ton31337/fix/use_get_set_for_communities
bgpd: Reuse get/set helpers for attr->community
2022-02-28 09:52:50 -05:00
Ryoga Saito
ea7cd161b2 bgpd: change the treatment for SRv6 routes
This patch adds transpostion_offset and transposition_len to bgp_sid_info,
and transposes SID only at bgp_zebra_announce.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-02-25 15:34:28 +00:00
Donatas Abraitis
9a706b42fb bgpd: Reuse get/set helpers for attr->community
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-25 10:02:30 +02:00
Donald Sharp
cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Igor Ryzhov
474f8e031d
Merge pull request #10585 from ton31337/feature/advmap_set
bgpd: Allow setting attributes over route-maps for conditional advert…
2022-02-23 19:23:03 +03:00
Donatas Abraitis
51c3a7deed bgpd: Allow setting attributes over route-maps for conditional advertisements
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-18 11:46:05 +02:00
Donald Sharp
b17826b715 bgp: Add a 15 minute warning to missing policy
Add a 15 minute warning to the logging system when
bgp policy is not setup properly.  Operators keep asking
about the missing policy( on upgrade typically ).  Let's
try to give them a bit more of a hint when something is
going wrong as that they are clearly missing the other
various places FRR tells them about it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-15 12:40:38 -05:00
Donatas Abraitis
1bcf3a96de bgpd: Use get/set helpers for attr->lcommunity
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-10 11:04:03 +02:00
Donatas Abraitis
584fbadf83
Merge pull request #10550 from idryzhov/bgp-attr-undup
bgpd: remove bgp_attr_undup
2022-02-10 09:02:02 +02:00
Igor Ryzhov
d498917efd bgpd: remove bgp_attr_undup
bgp_attr_undup does the same thing as bgp_attr_flush – frees the
temporary data that might be allocated when applying a route-map. There
is no need to have two separate functions for that.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-10 01:43:37 +03:00
Igor Ryzhov
afb254d792 bgpd: fix aspath memory leak in aggr_suppress_map_test
aspth_empty a couple of lines earlier creates an aspath and it must be
freed.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-10 01:20:03 +03:00
Igor Ryzhov
4dbf2038ea bgpd: fix missing bgp_attr_flush on errors in bgp_update
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-10 01:15:57 +03:00
Donald Sharp
518223c161
Merge pull request #10496 from ton31337/fix/move_struct_ecommunity_to_extra
bgpd: Use bgp_attr_[sg]et_ecommunity for struct ecommunity
2022-02-08 14:12:15 -05:00
Donatas Abraitis
024945804a bgpd: Print route-map name for filtred outgoing prefixes
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-07 12:04:10 +02:00
Donatas Abraitis
686826e90e bgpd: Flush temporary attributes after route-map apply
Fixes crash:

```
Received signal 6 at 1644222173 (si_addr 0x6f000012d2, PC 0x7f79274cbfb7); aborting...
/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0(zlog_backtrace_sigsafe+0x6d) [0x7f79282e079d]
/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0(zlog_signal+0xf3) [0x7f79282e0993]
/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0(+0xbd881) [0x7f792830b881]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12980) [0x7f7927890980]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7) [0x7f79274cbfb7]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141) [0x7f79274cd921]
/lib/x86_64-linux-gnu/libc.so.6(+0x89967) [0x7f7927516967]
/lib/x86_64-linux-gnu/libc.so.6(+0x909da) [0x7f792751d9da]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x620) [0x7f7927525050]
/usr/lib/frr/bgpd(+0x1e7c1c) [0x55b5c53b1c1c]
/usr/lib/frr/bgpd(aspath_free+0x28) [0x55b5c53b1c78]
/usr/lib/frr/bgpd(bgp_attr_flush+0x245) [0x55b5c52abc15]
/usr/lib/frr/bgpd(subgroup_announce_check+0x1137) [0x55b5c530c5d7]
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-07 10:50:33 +02:00
Donald Sharp
cd44428d62 bgpd: Prevent use after variable goes out of scope
`struct prefix p` was declared inside an if statement
where we assign the address of to a pointer that is
then passed to a sub function.  This will eventually
leave us in a bad state.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-04 10:29:38 -05:00
Donatas Abraitis
b53e67a389 bgpd: Use bgp_attr_[sg]et_ecommunity for struct ecommunity
This is an extra work before moving attr->ecommunity to attra_extra struct.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-04 15:56:20 +02:00
Donatas Abraitis
77a2f8e592 *: Add camelCase JSON keys in addition to PascalCase
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-03 10:48:06 +02:00
Igor Ryzhov
3b216639d7
Merge pull request #10430 from ton31337/fix/addpath_maximum-prefix-out
bgpd: Add bgp_check_selected() helper and just consistency changes
2022-02-01 18:38:57 +03:00
Donatas Abraitis
be92fc9f1a bgpd: Convert bgp_addpath_encode_[tr]x() to bool from int
Rename addpath_encode[d] to addpath_capable to be consistent.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-01 13:31:16 +02:00
Igor Ryzhov
515ae0c090
Merge pull request #10442 from ton31337/fix/reuse_bgp_path_info_extra_get
bgpd: Reuse bgp_path_info_extra_get() for allocating new bgp path info
2022-02-01 12:19:23 +03:00
Donatas Abraitis
3757f96485 bgpd,pimd,isisd,nhrpd: Convert to vty_json()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-31 21:20:41 +02:00
Donatas Abraitis
53d3a0a80d bgpd: Reuse bgp_path_info_extra_get() for allocating new bgp path info
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-28 21:11:12 +02:00
Donatas Abraitis
9d56cc8750
Merge pull request #10159 from taspelund/retain-peer-asn
bgpd: retain peer asn even with remove-private-AS
2022-01-28 09:22:06 +02:00
Donatas Abraitis
6766acddbf
Merge pull request #9880 from louis-oui/maximum-prefix-out
bgpd: fixes maximum prefix out
2022-01-27 08:49:31 +02:00
Trey Aspelund
179d5a0e26 bgpd: retain peer asn even with remove-private-AS
In situations where remove-private-AS is configured for eBGP peers
residing in a private ASN, the peer's ASN was not being retained
in the AS-Path which can allow loops to occur. This was addressed
in a prior commit but it only addressed cases where the "replace-AS"
keyword was configured.
This commit ensures we retain the peer's ASN when using
"remove-private-AS" for eBGP peers in a private ASN regardless of other
keywords.

Setup:
=========
router bgp 4200000002
 neighbor enp1s0 interface v6only remote-as external
 neighbor enp6s0 interface v6only remote-as external
 !
 address-family ipv4 unicast
  neighbor enp6s0 remove-private-AS
 exit-address-family

ub18# show ip bgp sum | include 420000
BGP router identifier 100.64.0.111, local AS number 4200000002 vrf-id 0    <<<<< local asn 4200000002
ub20(enp1s0)    4 4200000001        22        22        0    0    0 00:00:57            1        1
ub20(enp6s0)    4 4200000001        21        22        0    0    0 00:00:57            0        1   <<<< peer asn 4200000001

ub18# show ip bgp | include 0.2
Default local pref 100, local AS 4200000002
*> 100.64.0.2/32    enp1s0                   0             0 4200000001 4200000004 4200000005 4200000001 i

Before ("remote-private-AS" only):
=========
ub18# show ip bgp neighbors enp6s0 advertised-routes | include 100.64.0.2
*> 100.64.0.2/32    ::                                     0 i     <<<<<  empty as-path, no way to prevent loop

After ("remote-private-AS" only):
=========
ub18# show ip bgp neighbors enp6s0 advertised-routes | include 100.64.0.2
*> 100.64.0.2/32    ::                                     0 4200000001 4200000001 i    <<<< retain peer's asn, breaks loop

Ticket: 2857047
Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-01-24 20:06:50 +00:00
Russ White
6ab0d40e87
Merge pull request #10380 from ton31337/feature/show_graceful_restart_timer_per_prefix
bgpd: Show Graceful Restart seconds remaining per prefix
2022-01-24 07:51:19 -05:00
Louis Scalbert
d0bf49ecd5 bgpd: apply maximum-prefix-out without clearing the neighbor
Abstract:
- The command "neighbor PEER maximum-prefix-out NUMBER" cannot be applied
  without clearing the BGP neighbor.
- Apply the maximum-prefix-out value as soon as it is modified without
  clearing the neighbor.

subgroup_update_packet() and subgroup_withdraw_packet() respectively
manages the announcement and withdrawal BGP message to the peer.
subgrp->scount counter counts the number of sent prefixes.

Before the patch, the maximum out prefix limitation was applied in
subgroup_update_packet() in order that subgrp->scount never exceeds the
limit. Setting a limit inferior to the effective number of sent prefix
did not result in sending any withdrawal message to reduce the number of
sent prefixes. Without clearing the BGP neighbor, the limitation only
applied to the announcement of new prefixes when the limitation was
over.

With the patch, the limitation is checked in subgroup_announce_check().
The function is intended to say whether a prefix has to be announced in
regards to the prefix-list, route-map... Now when a maximum-prefix-out
value is changed/removed, the neighbor AFI/SAFI table is re-parsed in
the same way as for the application of route-map, prefix-lists...

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-01-20 18:19:37 +01:00
Igor Ryzhov
860e740b36 bgpd: replace custom union gw_addr with struct ipaddr
BGP EVPN custom `union gw_addr` is basically the same thing as a common
`struct ipaddr` but it lacks the address family which is needed in some
cases.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-19 23:13:04 +03:00
Igor Ryzhov
b04c1e9997 bgpd: fix populating the attribute
This code is populating a temporary variable `add` instead of the attr.
Initially this variable was later copied to the attr but the copying was
erroneously deleted by 0a50c2481. Directly populate the attr to restore
the correct behavior.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-19 23:02:11 +03:00
Igor Ryzhov
8f2661b01d bgpd: remove wrong overlay index comparison
Here we try to compare the new attr with the existing one but this call
compares the existing index with zero instead. attrhash_cmp already
compares indexes using overlay_index_same so this call is both wrong and
useless.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-19 22:55:44 +03:00
Donatas Abraitis
d92646a4b7 bgpd: Add an empty line after new variable assignment
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-19 19:14:40 +02:00
Donatas Abraitis
848e8cf6c6 bgpd: Show Graceful Restart seconds remaining per prefix
```
exit1-debian-11# sh ip bgp 10.10.10.10/32
BGP routing table entry for 10.10.10.10/32, version 14
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  65000, (stale)
    192.168.0.2 from 192.168.0.2 (0.0.0.0)
      Origin incomplete, metric 0, valid, external, best (First path received)
      Last update: Wed Jan 19 17:13:51 2022
      Time until Graceful Restart stale route deleted: 117
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-19 19:14:19 +02:00
Trey Aspelund
c1984955b7 bgpd: fix advertisedRoutes json key
'show bgp ... neighbor [routes|received-routes]' both incorrectly
used a json key of 'advertisedRoutes'.
This corrects the key to be 'receivedRoutes' for commands where
the displayed routes were received, not advertised.

before:
unet> r3 show ip bgp neigh 10.2.30.2 received-routes json | include Routes
  "advertisedRoutes":{

after:
ub18# show ip bgp neighbors enp1s0 received-routes json | include Routes
  "receivedRoutes":{
ub18# show ip bgp neighbors enp1s0 advertised-routes json | include Routes
  "advertisedRoutes":{

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-01-14 22:03:11 +00:00
Donatas Abraitis
48ebba0476 bgpd: Show Long-lived Graceful Restart timer remaining per prefix
```
exit1-debian-11# sh ip bgp 100.100.100.100/32
BGP routing table entry for 100.100.100.100/32, version 7
Paths: (2 available, best #2, table default)
  Advertised to non peer-group peers:
  home-spine1.donatas.net(192.168.0.2)
  65002, (stale)
    192.168.10.17 from donatas-pc(192.168.10.17) (0.0.0.0)
      Origin incomplete, valid, external
      Community: llgr-stale
      Last update: Thu Jan 13 08:58:08 2022
      Time until Long-lived stale route deleted: 18
  65001
    192.168.0.2 from home-spine1.donatas.net(192.168.0.2) (2.2.2.2)
      Origin incomplete, metric 0, valid, external, best (First path received)
      Last update: Thu Jan 13 08:57:56 2022
```

```
~# vtysh -c 'show ip bgp 100.100.100.100/32 json' | jq '."paths"[] | ."llgrSecondsRemaining"'
17
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-13 12:19:32 +02:00
Donatas Abraitis
8ac66010c5 bgpd: Avoid additional check for json output under show ip bgp route
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-13 10:34:04 +02:00
Donatas Abraitis
83fc30745d
Merge pull request #10266 from opensourcerouting/bgp-aggr-rm
bgpd: fix aggregate route unsuppression bug
2022-01-12 23:18:58 +02:00
Donald Sharp
52979c3baa bgpd: Remove unneeded loop over all peers
The bgp_notify_conditional_adv_scanner function was/is looping
over all peers.  And only matching on the passed in peer,
based upon the subgroup.  As such we do not need to loop
over everything and just cut-to-the chase and just modify
the peer structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-12 09:53:15 -05:00
Rafael Zalamena
92b175bd40 bgpd: fix aggregate route unsuppression bug
Unsuppress route part of the aggregation when route-map configuration
is removed before the aggregation itself.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-01-11 13:44:54 -03:00
Kantesh Mundaragi
641065d4fc bgpd: VRF-Lite fix to clear stale leaked routes
Description:
Change is intended for fixing the issue related to
clearing of stale leaked routes:
- Whenever BGP goes down,
  after bringing down tcp connection and renegotiating capabilities,
  once we reestablish connection,
  we are not handling clear of VRF leaked route in the bgp_clear_stale_route.

- While bgp is clearing stale routes,
  we need to handle withdraw of routes for VRF route-leaking.

Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2022-01-08 10:21:10 -08:00
Donatas Abraitis
a30fec23f8 bgpd: Increase maximum supress threshold for dampening to 50,000
rfc7196 recommends:

In addition, BGP implementations have an internal constant, which we
   will call the 'maximum penalty', and the current computed penalty may
   not exceed it.

Router Maximum Penalty:  The internal constant for the maximum
      penalty value MUST be raised to at least 50,000.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-06 10:09:05 +02:00
Donatas Abraitis
1479ed2fb3 bgpd: Implement LLGR helper mode
Tested between GoBGP and FRR (this commit).

```
┌───────────┐             ┌────────────┐
│           │             │            │
│ GoBGPD    │             │ FRRouting  │
│ (restart) │             │            │
│           │             │            │
└──────┬────┘             └───────┬────┘
       │                          │
       │                          │
       │                          │
       │     ┌───────────┐        │
       │     │           │        │
       │     │           │        │
       └─────┤ FRRouting ├────────┘
             │ (helper)  │
             │           │
             └───────────┘

// GoBGPD
% cat /etc/gobgp/config.toml
[global.config]
    as = 65002
    router-id = "2.2.2.2"
    port = 179

[[neighbors]]
    [neighbors.config]
        peer-as = 65001
        neighbor-address = "2a02🔤:123"
    [neighbors.graceful-restart.config]
        enabled = true
        restart-time = 3
        long-lived-enabled = true
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-unicast"
        [neighbors.afi-safis.mp-graceful-restart.config]
            enabled = true
        [neighbors.afi-safis.long-lived-graceful-restart.config]
            enabled = true
            restart-time = 10
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-unicast"
        [neighbors.afi-safis.mp-graceful-restart.config]
            enabled = true
        [neighbors.afi-safis.long-lived-graceful-restart.config]
            enabled = true
            restart-time = 20

% ./gobgp global rib add -a ipv6 2001:db8:4::/64
% ./gobgp global rib add -a ipv6 2001:db8:5::/64 community 65535:7
% ./gobgp global rib add -a ipv4 100.100.100.100/32
% ./gobgp global rib add -a ipv4 100.100.100.200/32 community 65535:7
```

1. When killing GoBGPD, graceful restart timer starts in FRR helper router;
2. When GR timer expires in helper router:
   a) LLGR_STALE community is attached to routes to be retained;
   b) Clear stale routes that have NO_LLGR community attached;
   c) Start LLGR timer per AFI/SAFI;
   d) Recompute bestpath and reannounce routes to peers;
   d) When LLGR timer expires, clear all routes on particular AFI/SAFI.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-12-28 16:07:59 +02:00
Donatas Abraitis
f5827f3689 bgpd: Drop if 0 blocks
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-12-23 14:41:11 +02:00
Donald Sharp
be785e356a bgpd, tests: Add code to handle failed installations
Currently the Wait for Install code ( bgp_suppress_fib ) does
not properly handle two states from zebra:  ROUTE_INSTALL_FAILED
and BETTER_ADMIN_DISTANCE_WON.  Pre this change the WFI code
would just never notify our peers about a route install failure
but more is needed.  In the ROUTE_INSTALL_FAILED and the
BETTER_ADMIN_DISTANCE_WON we need to notify our peers with
a withdrawal about the route, else we will continue to
draw traffic to us when we cannot legally do so.

Why is this needed?  In either case imagine that we've already
received a bgp route, installed it and sent to our peers.
In the Better admin distance won case, say a static route is installed
at this point in time we must stop advertising the route through
us since we are not installed.  As such a withdrawal must be sent.

In the ROUTE_INSTALL_FAILED case, the code was not properly handling
the situation where we have Route A, it was successfully installed
and then we received a update to Route A that was attempted to be
installed but failed.  In this case we also need to send a withdrawal

Finally update the bgp_suppress_fib topotest to test both of these
situations.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-12-17 13:28:56 -05:00
Mark Stapp
907707db48 bgpd: clearer safi handling for BGP-LU route updates
Don't hide the LABELED_UNICAST safi when processing route
updates; map it where necessary (to use the UNICAST table
for instance).

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2021-12-01 07:56:38 -05:00
Russ White
f1f6716d4a
Merge pull request #9610 from iqras23/best_path
bgpd: VRF-Lite fix best path selection
2021-11-30 16:14:34 -05:00
Igor Ryzhov
cb3fa0a612
Merge pull request #10124 from ton31337/feature/vty_json 2021-11-29 02:11:29 +03:00
Russ White
d41e9fe0cb
Merge pull request #9203 from opensourcerouting/bgpd-show-json
bgpd: add "json" option to a few more show commands
2021-11-27 08:30:04 -05:00
Donatas Abraitis
75eeda9323 bgpd: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:51:12 +02:00
Donatas Abraitis
746a6eda2f *: Remove unused variables
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:35:55 +02:00
Donatas Abraitis
67d7e256a3 bgpd: Replace prefix2str for JSON to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:34:17 +02:00
Renato Westphal
fe0f234d13 bgpd: add "json" option to "show ip bgp ... dampening parameters"
Also:
* rename show_ip_bgp_cmd to show_ip_bgp_dampening_params_cmd;
* rename show_ip_bgp_json_cmd to show_ip_bgp_cmd.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 15:14:08 -03:00
Renato Westphal
39c3c7364d bgpd: add "json" option to "show ip bgp ... longer-prefixes"
Move the "longer-prefixes" option from show_ip_bgp_cmd to
show_ip_bgp_json_cmd so that is has access to JSON output.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 15:14:08 -03:00
Renato Westphal
bf1a944ace bgpd: add "json" option to "show ip bgp ... route-map"
Move the "route-map" option from show_ip_bgp_cmd to
show_ip_bgp_json_cmd so that is has access to JSON output.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 15:14:08 -03:00
Renato Westphal
a71293475b bgpd: add "json" option to "show ip bgp ... filter-list"
Move the "filter-list" option from show_ip_bgp_cmd to
show_ip_bgp_json_cmd so that is has access to JSON output.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 15:14:08 -03:00
Renato Westphal
6deaf5794d bgpd: add "json" option to "show ip bgp ... prefix-list"
Move the "prefix-list" option from show_ip_bgp_cmd to
show_ip_bgp_json_cmd so that is has access to JSON output.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 15:14:08 -03:00
Renato Westphal
707999834a bgpd: add "json" option to "show ip bgp ... community-list"
Move the "community-list" option from show_ip_bgp_cmd to
show_ip_bgp_json_cmd so that is has access to JSON output.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 14:36:58 -03:00
Renato Westphal
2391833ecf bgpd: use void pointer to reduce code duplication
There's no need to have different calls to bgp_show() when the only
difference is one argument that corresponds to a "void *" parameter.

Code duplication should be reduced to a minimum to avoid bugs like
the one fixed in the previous commit.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 14:27:25 -03:00
Renato Westphal
db58b09fea bgpd: fix crash in "show ip bgp ... all alias ALIAS"
Like done in the other places (when "all" isn't used), pass the
actual alias name to bgp_show() instead of a null pointer.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 14:27:25 -03:00
Donald Sharp
d32c92a4c0
Merge pull request #10057 from ton31337/fix/we_shouldn_send_LLA_for_RS
bgpd: Do not send LLA for route-server-client peers
2021-11-22 12:06:36 -05:00
Kantesh Mundaragi
da0c0ef70c bgpd: VRF-Lite fix best path selection
Description:
Incorrect behavior during best path selection for the imported routes.
Imported routes are always treated as eBGP routes.

Change is intended for fixing the issues related to
bgp best path selection for leaked routes:
- FRR does ecmp for the imported routes,
  even without any ecmp related config.
  If the same prefix is imported from two different VRFs,
  then we configure the route with ecmp even without
  any ecmp related config.
- Locally imported routes are preferred over imported
  eBGP routes.
  If there is a local route and eBGP learned route
  for the same prefix, if we import both the routes,
  imported local route is selected as best path.
- Same route is imported from multiple tenant VRFs,
  both imported routes point to the same VRF in nexthop.
- When the same route with same nexthop in two different VRFs
  is imported from those two VRFs, route is not installed as ecmp,
  even though we had ecmp config.

- During best path selection, while comparing the paths for imported routes,
  we should correctly refer to the original route i.e. the ultimate path.
- When the same route is imported from multiple VRF,
  use the correct VRF while installing in the FIB.
- When same route is imported from two different tenant VRFs,
  while comparing bgp path info as part of bgp best path selection,
  we should ideally also compare corresponding VRFs.

See-also: https://github.com/FRRouting/frr/files/7169555/FRR.and.Cisco.VRF-Lite.Behaviour.pdf

Co-authored-by: Santosh P K <sapk@vmware.com>
Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2021-11-19 07:33:22 +05:30
Donatas Abraitis
4e9a98636f *: Remove unused variables
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:41 +02:00
Donatas Abraitis
c949c77101 bgpd: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 11:35:29 +02:00
David Lamparter
de48804c01
Merge pull request #10046 from donaldsharp/bgp_instance_del 2021-11-15 10:49:31 +01:00
Donatas Abraitis
2d02e34eab bgpd: Do not send LLA for route-server-client peers
We should send only 16bytes next hop, no need for 32bytes, third party
next hops kinda for LLA does not work here.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-15 08:51:26 +02:00
Donald Sharp
4378495a27 bgpd: Add vrf information to best path debugging
When debugging issues for routes in multiple vrf's.  It would
be extremely useful if the debug output had which vrf we
are acting on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-12 13:24:04 -05:00
Donald Sharp
e36f61b507 *: Rename quagga_timestamp with frr_timestamp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11 14:41:27 -05:00
Donatas Abraitis
37b6787730
Merge pull request #9700 from mjstapp/add_json_det_attrs
bgpd: Add 'show bgp <afi> <safi> json detail' header data
2021-11-10 16:42:30 +02:00
Donatas Abraitis
458c1475ab bgpd: Set afi by default to AFI_IP6 for show bgp vrf/view detail
AFI/SAFI is handled in bgp_vty_find_and_parse_afi_safi_bgp() properly for
IPv4, but not for IPv6. Let's have it enabled for IPv6 by default.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-06 15:54:20 +02:00
Donatas Abraitis
54d05dea57 bgpd: Set afi by default to AFI_IP6 for show bgp vrf/view all
AFI/SAFI is handled in bgp_vty_find_and_parse_afi_safi_bgp() properly for
IPv4, but not for IPv6. Let's have it enabled for IPv6 by default.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-06 15:50:56 +02:00
Igor Ryzhov
12bc8a4068
Merge pull request #9791 from opensourcerouting/bgp-json-mem-fix
bgpd: Fix json object memory leaks and double-free
2021-10-26 18:06:47 +03:00
Donald Sharp
d9654571f9
Merge pull request #9316 from ton31337/fix/send_best_path_reason_for_zebra
bgpd: Send BGP best path reason to Zebra
2021-10-25 11:09:20 -04:00
Russ White
61a7ec774c
Merge pull request #9783 from mjstapp/fix_bgp_lu_lsp
bgpd, tests: BGP-labeled-unicast advertise implicit-null in more cases
2021-10-20 18:22:01 -04:00
Donatas Abraitis
de71d43e04 bgpd: Add autocomplete for filter-list
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-19 18:03:54 +03:00