Commit graph

25 commits

Author SHA1 Message Date
Mark Stapp 660cbf5651 bgpd: clean up variable-shadowing compiler warnings
Clean up -Wshadow warnings in bgp.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Philippe Guibert d95f9a35d4 bgpd, doc: add bgp snmp traps rfc4382 command
Add a trap command to disable or enable the traps defined by
the RFC4382.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-08-11 19:28:50 +00:00
Donald Sharp 0b81a7524d bgpd: MTYPE_BGP was being overused split up
The MTYPE_BGP memory type was being over used as
both the handler for the bgp instance itself as
well as memory associated with name strings.
Let's separate out the two.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 12:41:18 -05:00
Donald Sharp bc479b1b17 bgpd: Coverity mistakenly believes we can fall through
Coverity has incorrectly found that a switch statement
can be fallen through.  It is missing the fact that the
previous case statement has a return through every path
it can get too.  Let's just appease coverity

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 07:57:19 -04: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 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 9dc5d874a0 bgpd: Free memory allocated by ecommunity_ecom2str()
Return local string, copied from returned value of ecom2str.

```
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690:Direct leak of 528 byte(s) in 8 object(s) allocated from:
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690-    0 0x7efcde5d6037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690-    1 0x7efcde1dc7e2 in qcalloc lib/memory.c:105
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690-    2 0x5628a0592704 in ecommunity_ecom2str bgpd/bgp_ecommunity.c:947
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690-    3 0x7efcdaa558c8 in mplsL3vpnVrfRtTable bgpd/bgp_mplsvpn_snmp.c:1152
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690-    4 0x7efcda784139 in netsnmp_old_api_helper helpers/old_api.c:332
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690-
./bgp_snmp_mplsl3vpn.test_bgp_snmp_mplsvpn/r1.bgpd.asan.2925690-SUMMARY: AddressSanitizer: 528 byte(s) leaked in 8 allocation(s).
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-14 11:07:48 +02:00
Russ White ba755d35e5
Merge pull request #12248 from pguibert6WIND/bgpasdot
lib, bgp: add initial support for asdot format
2023-02-21 08:01:03 -05:00
Philippe Guibert 4a8cd6ad7f bgpd: support for as notation format for route distinguisher
RD may be built based on an AS number. Like for the AS, the RD
may use the AS notation. The two below examples can illustrate:

RD 1.1:20 stands for an AS4B:NN RD with AS4B=65536 in dot format.
RD 0.1:20 stands for an AS2B:NNNN RD with AS2B=0.1 in dot+ format.

This commit adds the asnotation mode to prefix_rd2str() API so as
to pick up the relevant display.

Two new printfrr extensions are available to display the RD with
the two above display methods.
- The pRDD extension stands for dot asnotation format
- The pRDE extension stands for dot+ asnotation format.
- The pRD extension has been renamed to pRDP extension

The code is changed each time '%pRD' printf extension is called.
Possibly, the asnotation may change the output, then a macro defines
the asnotation mode to use. A side effect of forging the mode to
use is that the string could not be concatenated with other strings
in vty_out and snprintfrr. Those functions have been called multiple
times. When zlog_debug needs to display the RD with some other string,
the prefix_rd2str() old API is used instead of the printf extension.

Some code has been kept untouched:
- code related to running-config. Actually, wherever an RD is displayed,
its configured name should be dumped.
- bgp rfapi code
- bgp evpn multihoming code (partially done), since the logic is
missing to get the asnotation of 'struct bgp_evpn_es'.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-10 10:27:23 +01: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 58cf0823bf bgpd: Add missing enum's to case statement
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 12:29:08 -05:00
Louis Scalbert 6f27419975 bgpd: display the IGP metric of the ultimate path in snmp
Display the IGP metric of the ultimate path in the SNMP OID
mplsL3VpnVrfRteInetCidrMetric1.

Fixes: da0c0ef70c ("bgpd: VRF-Lite fix best path selection")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-15 17:10:59 +01:00
David Lamparter 09781197b6 build: make builddir include path consistent
... by referencing all autogenerated headers relative to the root
directory.  (90% of the changes here is `version.h`.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-21 15:42:33 +02:00
Pat Ruddy 9e26322126 lib, bgpd: add a specific oid_copy function for IPv6 addrs
Do not overload the v4 oid_copy_addr function for ipv6
coverity does not like this kind of thing.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-03-25 15:24:50 +00:00
Pat Ruddy 5a224c19f1 bgpd, lib: add oid2in6_addr utility and use it
The existing code was using the oid2in_addr API to copy IPv6
addresses passing an IPv6 length. Create a utility to do this
properly and avoid annoying coverity with type checking.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-17 13:35:31 +00:00
Pat Ruddy 23b88a967d bgpd: mplsvpn snmp: NULL check correct pointer
Check the dereferenced pointer to the bgp instance and not the
pointer to it.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-17 13:33:59 +00:00
Pat Ruddy f01828a1d7 bgpd: mplsvpn SNMP correctly validate incoming rt_index
check that RT index is in the allowed range

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-17 13:33:58 +00:00
Donald Sharp 227b6af0d7 bgpd: Prevent store but never read of i
The new bgp_mplsvpn_snmp.c code increments i and
never uses that value.  Comment the code out
to make the clang SA analyzer happy.  Shouldn't
be a problem since this code will never probably
be touched again(ha!).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-02-14 16:08:07 -05:00
Pat Ruddy 8db8e86a91 bgp: add mplsl3vpn notifications
Add support for mplsL3VpnVrfUp and mplsL3VpnVrfDown notifications
from [RFC4382]

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:15 +00:00
Pat Ruddy 98a9144fb4 bgpd: implement mplsL3VpnVrfRtTable
add code to support the route target table from [RFC4382]

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:13 +00:00
Pat Ruddy 62e66e55bf bgpd: add SNMP support for mplsL3VpnRte Table
Add MIB support for the route table in RFC4382

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:12 +00:00
Pat Ruddy 7fd28dd245 bgpd: add mplsL3VpnVrfPerfTable support
support for counts of per-vrf routes:
added
deleted
current

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:10 +00:00
Pat Ruddy 1ea16ac016 bgpd: add SNMP mplsL3vpnIfConfTable support
Add infrastucture to return the mplsL3vpnIfConfTable from
[RFC4382]

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:09 +00:00
Pat Ruddy 0d020cd6d9 bgpd, lib: add mplsL3VpnVrf table
Add SNMP support for L3vpn Vrf table as defined in [RFC4382]
Keep track of vrf status for the table and for future traps.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:06 +00:00
Pat Ruddy aa53f69348 bgpd: add MPLSVPN SNMP boilerplate
Add infrastructure for mplsvpn MIB (RFC-4382) and the top level
ScalarGroup.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-02 09:37:05 +00:00