Commit Graph

102 Commits

Author SHA1 Message Date
Farid Mihoub
3104d482e9 bmp: fix vty_out for monitor afi loc-rib
"show run" displays BMP monitor AFI in upper case.

> bmp targets bmp1
>  bmp monitor IPv4 unicast loc-rib

Display it in lower case.

> bmp targets bmp1
>  bmp monitor ipv4 unicast loc-rib

Signed-off-by: Farid Mihoub <farid.mihoub@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-27 19:12:19 +01:00
Donald Sharp
f38687b8f5 lib, bgpd, nhrpd: Cleanup memory in lib/resolver on shutdown
This memory was not being cleaned up on shutdown.  Fix this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-16 09:18:41 -05:00
Donatas Abraitis
88db20c4c8 bgpd: Fix frrtrace arguments for bmp_eor tracing
Arguments number was wrong.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-11-20 12:21:13 +02:00
Maxou
d6940cc886 bgpd: bmp bgp asn & router_id coverity fix
Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-15 14:37:03 +01:00
Maxence Younsi
9607070acd bgpd: bmp unset v6 flag + address PR#14188 comments
use CHECK_FLAG
fix comment spaces
change zlog_debug to zlog_warn
safeguard on updated_route
added doc/developer/bmp.rst to subdir.am
other qol changes

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
Maxence Younsi
fa17129752 bgpd: skip bmp messages when vrf id is unknown
changed result type of bmp_get_peer_distinguisher to int
added result pointer parameter to bmp_get_peer_distinguisher
bmp_get_peer_distinguisher returns 0 means the result is valid else
  error occured do not use result

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01: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
1cca53e5c6 bgpd: applied styling and fixed warnings
frrbot found style &/| linter errors
fixed bmp_process_one return value warnings and added safety checks
fixed const modifier warning in bmp_put_vrftablename_info_tlv
added unused attribute to bmp_put_vrftablename_info_tlv
remove unused variables in bmp_process_one and bmp_route_update

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
Maxou
19b3ead3f0 bgpd: bmp locrib monitoring unlock node after lookup
bgp_afi_node_lookup calls bgp_node_lookup which locks the node, unlocking it safely after function is finished

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
Maxou
6da477b395 bgpd: refactored bmp_route_update & cleanup TODOs
TODOs that are done/un-necessary now deleted
refactored bmp_route_update to use a modified bmp_process_one function call instead of duplicating similar code

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
Maxou
0a09b4905e bgpd: removed temporary dev logs
dev logs cleanup

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
Maxou
257ca34e94 bgpd: cleanup bmp_get_peer_distinguisher function
cleaner implementation and use of the new get peer distinguisher function
can be now used for other cases of RFC7854 that are not supported atm

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
6691e1dc61 bgpd: temporary set timestamp to 0 for loc rib monitoring messages
set timestamp to 0 for loc rib monitoring messages as path selection time is not available atm
this is temporary and tv is meant to be set to the path selection/install time at some point

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
bbf6cb6867 bgpd: bmp loc-rib end-of-rib message add peer distinguisher
added peer distinguisher for BMP_PEER_TYPE_LOC_RIB_INSTANCE in bmp_eor

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
24f3d9ff1a bgpd: safer vrf/table name (RFC9069) info tlv
vrf_id_to_name is used for display values only and returns "Unknown" when the vrf is not found
doing a manual lookup and not providing any tlv when the vrf is not found should be better

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
f83857832f bgpd: bmp loc-rib RFC9069 compliant monitoring messages
set field peer bgp id to the peer's remote id in every case except loc-rib (RFC9069 case) in which we put the bgp instance's router-id if available or 0-filled if not available
set field peer asn to local primary bgp asn in case of loc-rib instance (RFC9069) else it's set to the peer's asn
set field peer address to 0 in loc-rib instance (RFC9069 case) and to the peer's address in other cases
had to pass struct bgp reference to bmp_per_peer_hdr to access router-id and such, but it's always safely accessed when used

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
f9af3476db bgpd: bmp set peer distinguisher with RD
peer distinguisher set to vrf RD if there is one or to vrf_id if in a vrf
set to 0 if in default vrf

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
c5512950f5 bgpd: bmp afi/safi sync for loc-rib
added afi/safi monitoring synchronisation for loc-rib
added peer_type_flag to bmp_eor signature, only set to BMP_PEER_TYPE_LOC_RIB and to 0 in other cases like it was before
updated tracelog to include peer_type_flag value

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
3d07f70f95 bgpd: fixed bmp vpnv4 monitoring withdraws instead of updates
vpnv4 monitoring always sends withdraws bc of wrong lookup call, fixes this

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
8f0a017e4f bgpd: peer distinguisher set to vrf id
set peer distinguisher to vrf id temporarily until i find out how to use the rd set for export on the vrf instance associated to this bgp instance

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:48 +01:00
mxyns
2c1900e0d1 bgpd: correct loc rib update queue cleanup
empties out and free the locrib specific queue's memory on bmp_close call

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-11-04 12:17:47 +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
Donald Sharp
0c3a70c644 bgpd: Move the peer->su to connection->su
The sockunion is per connection.  So let's move it over.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10 08:31:25 -04:00
Donald Sharp
7b1158b169 bgpd: peer_established should be connection oriented
The peer_established function should be connection oriented.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-10 08:31:25 -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
Donald Sharp
3e5a31b24e bgpd: Convert struct peer_connection to dynamically allocated
As part of the conversion to a `struct peer_connection` it will
be desirable to have 2 pointers one for when we open a connection
and one for when we receive a connection.  Start this actual
conversion over to this in `struct peer`.  If this sounds confusing
take a look at the bgp state machine for connections and how
it resolves the processing of this router opening -vs- this
router receiving an open.  At some point in time the state
machine decides that we are keeping one of the two connections.

Future commits will allow us to untangle the peer/doppelganger
duality with this abstraction.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-18 09:29:04 -04: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
Maxence Younsi
9e681c84fa bgpd: bmp fix peer-up ports byte order
added htons to ports in the peer-up message to fix byte order

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2023-04-03 17:19:32 +02:00
Donald Sharp
24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
4f830a0799 *: Convert thread_timer_remain_XXX to event_timer_remain_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
cb37cb336a *: Rename thread.[ch] to event.[ch]
This is a first in a series of commits, whose goal is to rename
the thread system in FRR to an event system.  There is a continual
problem where people are confusing `struct thread` with a true
pthread.  In reality, our entire thread.c is an event system.

In this commit rename the thread.[ch] files to event.[ch].

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:16 -04:00
Donatas Abraitis
59d6b4d6ab bgpd: Rename bgp_afi_node_lookup() to bgp_safi_node_lookup()
afi not used in this function, reduce a bit.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-14 12:01:56 +02:00
Donald Sharp
0884f1644b lib, bgpd: bmp was not specifying l2vpn afi
The l2vpn afi was not being properly displayed
when a show run was being issued.  Add a
afi2str_lower function and use it.

Fixes: #12867
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-23 14:23:24 -05:00
David Lamparter
acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp
d7cde18c63
Merge pull request #12196 from opensourcerouting/xref-vtysh
*: rewrite `extract.pl` using `xref` infra
2022-11-03 08:54:09 -04:00
David Lamparter
89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
Donatas Abraitis
97a52c82a5 bgpd: Implement Accumulated IGP Metric Attribute for BGP
https://www.rfc-editor.org/rfc/rfc7311.html

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-10-26 11:26:57 +03:00
Donald Sharp
ad9b47e65e
Merge pull request #11691 from mxyns/bmp-vpnv4monupd-fix
bgpd: fixed bmp vpnv4 monitoring sending withdraws instead of updates
2022-08-01 07:49:18 -04:00
mxyns
e7e1561fbb bgpd: fixed bmp vpnv4 monitoring are withdraws instead of updates
fixes the recent support bmp monitor of VPNv4 afi/safi
the bmp updates messages (MP_REACH_NLRI) are never sent for VPNv4 and bmp withdraws (MP_UNREACH_NRLI) are sent instead
this is caused by bgp_node_lookup which fails to find VPNv4 bgp_node in the rib which results in NULL path info attributes passed to bmp_monitor
using bgp_afi_node_lookup instead of bgp_node_lookup solves the problem

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
2022-07-29 20:07:21 +02:00
Donatas Abraitis
a25ae82fd4 bgpd: Unlock bgp_node after bgp_node_lookup
bgp_node_lookup increments lock, we should decrement it after use.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-28 14:36:38 +03:00
Donatas Abraitis
00e6edb97d bgpd: Add constants for some repetitive CLI strings
"Address Family\n"
"Address Family modifier\n"

Before:

```
donatas-laptop(config-router)# address-family ipv4
  <cr>
  flowspec         Address Family Modifier
  labeled-unicast  Address Family modifier
  multicast        Address Family modifier
  unicast          Address Family Modifier
  vpn              Address Family modifier
```

After:

```
donatas-laptop(config-router)# address-family
  ipv4   Address Family
  ipv6   Address Family
  l2vpn  Address Family
donatas-laptop(config-router)# address-family ipv4
  <cr>
  flowspec         Address Family modifier
  labeled-unicast  Address Family modifier
  multicast        Address Family modifier
  unicast          Address Family modifier
  vpn              Address Family modifier
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-18 10:12:57 +03:00
Francois Dumontet
5dde29654e bmp: add L3VPN support
Support for BMP L3VPN monitoring messages through SAFI_MPLS_VPN address
family.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2022-07-13 17:28:37 +02:00
Donatas Abraitis
5cb3a15300 bgpd: Free memory for BMP listeners when deleting BGP instance
When using `no router bgp` we MUST free the memory for the listeners too.

Replicate with:
```
router bgp 100
bmp targets server1
bmp listener 0.0.0.0 port 65535
no router bgp
router bgp 100
bmp targets server1
bmp listener 0.0.0.0 port 65535
no router bgp
router bgp 100
bmp targets server1
bmp listener 0.0.0.0 port 65535
no router bgp
```

Before:
```
Type                          : Current#   Size       Total     Max#  MaxBytes
BMP targets                   :        0    240           0        1       248
BMP targets name              :        0      8           0        1        24
BMP listener                  :       12    152        1824       12      1824
BMP instance state            :        0     88           0        1        88
```

After:
```
Type                          : Current#   Size       Total     Max#  MaxBytes
BMP targets                   :        0    240           0        1       248
BMP targets name              :        0      8           0        1        24
BMP listener                  :        0    152           0        1       152
BMP instance state            :        0     88           0        1        88
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-06 22:27:23 +03:00