Commit graph

197 commits

Author SHA1 Message Date
Donatas Abraitis db853cc97e bgpd: Implement Link-Local Next Hop capability
Related: https://datatracker.ietf.org/doc/html/draft-white-linklocal-capability

TL;DR; use 16 bytes long next-hops for point-to-point (unnumbered) links instead
of sending 32 bytes (::/LL, GUA/LL, LL/LL combinations).

For backward compatiblity we should handle even 32 bytes existing next hops.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-17 16:48:32 +02:00
Enke Chen 2a19daa830 bgpd: add debugging command for route aggregation
Add a new debugging command:

  debug bgp aggregate [prefix <A.B.C.D/M|X:X::X:X/M>]

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2025-01-07 22:52:41 -08:00
Donatas Abraitis 8a4d336d38 bgpd: Print ipv6 extended communities if debug updates is turned on
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-22 09:01:04 +03:00
sri-mohan1 bbfbf3e6b9 bgpd: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-09-10 10:37:04 +05:30
Louis Scalbert a6de910448 bgpd: store number of labels with 8 bits
8 bits are sufficient to store the number of labels because the current
maximum is 2.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-05 13:11:29 +02:00
Louis Scalbert bc529cf92b bgpd: cleanup references to debug bgp allow-martians
The debug command was removed in 17e9298e47 ("bgpd: Remove 'debug bgp
allow-martian'")

Cleanup all references to the debug command.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-04-17 09:55:54 +02:00
Donatas Abraitis 4967bf6d72 bgpd: Send "Send Hold Timer Expired" on such events notification
This is required by the current (latest/-02 draft).

IANA has registered code 8 for "Send Hold Timer Expired" in the "BGP
Error (Notification) Codes" sub-registry under the "Border Gateway
Protocol (BGP) Parameters" registry.

https://datatracker.ietf.org/doc/html/draft-ietf-idr-bgp-sendholdtimer

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-29 15:37:53 +02:00
Philippe Guibert fc7b905959 bgpd: add hooks for displaying module debug messages
when a plugin is attached, some debugs may be attached to that plugin.
For that, add one hook that is interacting with vty: a boolean indicates
what the usage is for: either for impacting the 'show running-config',
or for impacting the 'show debugging' command.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-11 14:38:23 +01:00
Donald Sharp 153ab6eb43
Merge pull request #15122 from opensourcerouting/fix/drop_packet_send_debugs
bgpd: Change printing format show debugging for debug bgp updates
2024-01-09 12:21:09 -05:00
Donatas Abraitis 546fe3144c bgpd: Change printing format show debugging for debug bgp updates
Before:

```
BGP debugging status:
  BGP updates debugging is on (inbound) for 127.0.0.1 with prefix-list rn-dummy 192.168.10.18 with prefix-list rn-dummy 1.1.1.1
```

After:

```
BGP debugging status:
  BGP updates debugging is on (inbound) for:
   127.0.0.1 with prefix-list rn-dummy
   192.168.10.18 with prefix-list rn-dummy
   192.168.10.20
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-09 10:08:54 +02:00
Donatas Abraitis 7a474b8754 bgpd: Add debug bgp updates detail command
When filtering with `debug bgp updates in x.x.x.x prefix-list plist`, we want
to filter out unnecessary messages like:

```
127.0.0.1(Unknown) rcvd UPDATE wlen 0 attrlen 20 alen 5
```

Such a line as above will be repeated for all the paths received and it's useless
without knowing the prefix (because NLRIs are not parsed yet).

But want to see only relevant ones:

```
127.0.0.1(Unknown) rcvd UPDATE w/ attr: nexthop 127.0.0.1, origin i, path 65002
127.0.0.1(Unknown) rcvd 10.255.255.1/32 IPv4 unicast
```

With `debug bgp updates detail` we can combine this to something like:

```
127.0.0.1(Unknown) rcvd UPDATE w/ attr: nexthop 127.0.0.1, origin i, path 65002
127.0.0.1(Unknown) rcvd UPDATE wlen 0 attrlen 20 alen 5
127.0.0.1(Unknown) rcvd 10.255.255.1/32 IPv4 unicast
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-07 16:17:11 +02:00
Donatas Abraitis 22f6b2bafe bgpd: Optimize prefix-list lookup for debug messages
Pass prefix-list pointers at configuration time.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-11-22 08:06:33 +02:00
Donatas Abraitis c0215ed188 bgpd: Add an ability to filter UPDATEs using neighbor with prefix-list
Before this patch we didn't have an option to filter debug UPDATE messages
by specifying an arbitrary prefix, prefix-list or so. We had/have only an option
to specify:

```
* debug bgp updates in 10.0.0.1
* debug bgp updates prefix 10.0.1.0/24
```

Now adding:

```
* debug bgp updates <in|out> 10.0.0.1 prefix-list plist
```

CLI output:

```
r2# show debugging
MGMT debugging status:

Zebra debugging status:

BGP debugging status:
  BGP updates debugging is on (inbound) for 192.168.2.6 with prefix-list debug

Staticd debugging status

r2# show running-config | include prefix-list debug
debug bgp updates in 192.168.2.6 prefix-list debug
r2#
```

Logs:

```
BGP: [PCFFM-WMARW] 192.168.2.3(r3) rcvd UPDATE wlen 0 attrlen 28 alen 5
BGP: [PCFFM-WMARW] 192.168.2.3(r3) rcvd UPDATE wlen 0 attrlen 28 alen 4
BGP: [PCFFM-WMARW] 192.168.2.3(r3) rcvd UPDATE wlen 0 attrlen 0 alen 0
BGP: [M59KS-A3ZXZ] bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.2.3 in vrf default
BGP: [PCFFM-WMARW] 192.168.2.4(r4) rcvd UPDATE wlen 0 attrlen 28 alen 5
BGP: [PCFFM-WMARW] 192.168.2.4(r4) rcvd UPDATE wlen 0 attrlen 28 alen 4
BGP: [PCFFM-WMARW] 192.168.2.4(r4) rcvd UPDATE wlen 0 attrlen 0 alen 0
BGP: [M59KS-A3ZXZ] bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.2.4 in vrf default
BGP: [PCFFM-WMARW] 192.168.1.1(r1) rcvd UPDATE wlen 0 attrlen 29 alen 5
BGP: [PCFFM-WMARW] 192.168.2.6(r6) rcvd UPDATE wlen 0 attrlen 28 alen 5
BGP: [XXWBM-V772F] 192.168.2.6(r6) rcvd UPDATE w/ attr: nexthop 192.168.2.6, origin ?, metric 0, path 65006
BGP: [YCKEM-GB33T] 192.168.2.6(r6) rcvd 172.16.16.254/32 IPv4 unicast <<<<<<<<<<<<
BGP: [PCFFM-WMARW] 192.168.2.6(r6) rcvd UPDATE wlen 0 attrlen 28 alen 4
BGP: [PCFFM-WMARW] 192.168.2.6(r6) rcvd UPDATE wlen 0 attrlen 0 alen 0
BGP: [M59KS-A3ZXZ] bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.2.6 in vrf default
BGP: [PCFFM-WMARW] 192.168.2.5(r5) rcvd UPDATE wlen 0 attrlen 28 alen 5
BGP: [PCFFM-WMARW] 192.168.2.5(r5) rcvd UPDATE wlen 0 attrlen 28 alen 4
BGP: [PCFFM-WMARW] 192.168.2.5(r5) rcvd UPDATE wlen 0 attrlen 0 alen 0
BGP: [M59KS-A3ZXZ] bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.2.5 in vrf default
BGP: [PCFFM-WMARW] 192.168.1.1(r1) rcvd UPDATE wlen 0 attrlen 29 alen 5
BGP: [PCFFM-WMARW] 192.168.7.7(r7) rcvd UPDATE wlen 0 attrlen 0 alen 0
BGP: [M59KS-A3ZXZ] bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.7.7 in vrf default
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-11-22 08:06:33 +02:00
Donald Sharp 68bae36376 Revert "bgpd: add linkstate debug"
This reverts commit de38eada9c.
2023-10-10 16:43:28 -04:00
Donald Sharp 60c38a99ac
Merge pull request #14342 from fdumontet6WIND/fix_crash_snmp
bgpd: fix crash in *bgpv2PeerErrorsTable"
2023-09-27 15:25:38 -04:00
Francois Dumontet b8f3f0b86f bgpd: initialization in bgp_notify_admin_message function
buffer buff is fully zeroed by a memset in bgp_notify_admin_message
function

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-19 14:25:18 +02:00
Louis Scalbert de38eada9c bgpd: add linkstate debug
Add the "debug bgp linkstate" command to display incoming link-states
prefixes.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18 15:06:17 +02:00
Francois Dumontet d5cb2d9e41 bgpd: fix crash in *bgpv2PeerErrorsTable
following crash occurs:
    at ./nptl/pthread_kill.c:44
    at ./nptl/pthread_kill.c:78
    at ./nptl/pthread_kill.c:89
    context=0x7ffd06d3d300)
    at /build/make-pkg/output/_packages/cp-routing/src/lib/sigevent.c:246
    length=0x7ffd06d3da88, exact=1, var_len=0x7ffd06d3da90, write_method=<optimized out>)
    at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_snmp_bgp4v2.c:364
    vp=vp@entry=0x7f7c88b584c0 <bgpv2_variables>, vp_len=vp_len@entry=102,
    ename=ename@entry=0x7f7c88b58440 <bgpv2_trap_oid>, enamelen=enamelen@entry=8,
    name=name@entry=0x7f7c88b58480 <bgpv2_oid>, namelen=namelen@entry=7,
    iname=0x7ffd06d3e7b0, index_len=1, trapobj=0x7f7c88b53b80 <bgpv2TrapBackListv6>,
    trapobjlen=6, sptrap=2 '\002')
    at /build/make-pkg/output/_packages/cp-routing/src/lib/agentx.c:382
    vp_len=vp_len@entry=102, ename=ename@entry=0x7f7c88b58440 <bgpv2_trap_oid>,
    enamelen=enamelen@entry=8, name=name@entry=0x7f7c88b58480 <bgpv2_oid>,
    namelen=namelen@entry=7, iname=0x7ffd06d3ec30, inamelen=16,
    trapobj=0x7f7c88b53b80 <bgpv2TrapBackListv6>, trapobjlen=6, sptrap=2 '\002')
    at /build/make-pkg/output/_packages/cp-routing/src/lib/agentx.c:298
    at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_snmp_bgp4v2.c:1496
    at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_fsm.c:48
    at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_fsm.c:1314
    event=Receive_NOTIFICATION_message)
    at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_fsm.c:2665
    at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_packet.c:3129
    at /build/make-pkg/output/_packages/cp-routing/src/lib/event.c:1979
    at /build/make-pkg/output/_packages/cp-routing/src/lib/libfrr.c:1213
    at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_main.c:510

it's due to function bgpv2PeerErrorsTable returning
return SNMP_STRING(msg_str);
with msg_str NULL rather the string ""

this commit avoid the issue.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2023-09-18 13:52:01 +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
Donald Sharp 8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Donald Sharp 988638bd8d bgpd: Remove extraneous include of version.h
It's not needed in these compiles.  So let's remove it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-10 09:07:46 -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
Donatas Abraitis cfd01fc0ac Revert "bgpd: optimal router reflection cli and fsm changes"
This reverts commit 70cd87ca02.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-17 18:15:28 +02:00
Donatas Abraitis e993b11c23 Revert "bgpd: code review comments addressed"
This reverts commit 80f6ea8b99.
2023-01-17 18:07:36 +02:00
Donatas Abraitis db3f8f3199 bgpd: Deprecate some unused BGP stuff
* BGP optional parameter type (Authentication)
* BGP UPDATE message error subcode for AS loop

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-14 21:30:35 +02:00
Rafael Zalamena 105331a3c6 bgpd: fix static analyzer warnings
Use `DEFPY` to provide the `struct prefix` required by the debug
insertion functions. While here exchange `int` with `bool` where
appropriated.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-12-20 15:44:02 -03:00
Donald Sharp 11bf2747ef bgpd: When allocating prefix, free it when we are already tracking it
Several functions had this pattern:

a) p = prefix_new
b) if (already_tracking)
      return

Let's just stop allocating the prefix and use a prefix on the
stack, especially since the function used to hold the value
actually copies it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-20 08:39:29 -05:00
Donatas Abraitis 073801481b bgpd: inet_ntop() adjustments
Use %pI4/%pI6 where possible, otherwise at least atjust stack buffer sizes
for inet_ntop() calls.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-29 17:36:13 +02: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
Madhuri Kuruganti 80f6ea8b99 bgpd: code review comments addressed
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:48:23 +05:30
Madhuri Kuruganti 70cd87ca02 bgpd: optimal router reflection cli and fsm changes
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
Donald Sharp cf00164b69 *: Create and use infrastructure to show debugs in lib
There are lib debugs being set but never show up in
`show debug` commands because there was no way to show
that they were being used.  Add a bit of infrastructure
to allow this and then use it for `debug route-map`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-07 12:39:05 -04:00
Madhuri Kuruganti 8093d7999c bgpd: adding debug command for conditional advertisement
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-06 12:17:27 +05:30
Donatas Abraitis c4f64ea94d bgpd: Use %pRD for prefix_rd2str()
Convert a bunch of prefix_rd2str() for json/vty stuff.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-22 13:12:11 +03:00
Lou Berger 613025ef10
Merge pull request #11093 from donaldsharp/allow_martians
Allow martians
2022-06-28 10:38:57 -04:00
Donald Sharp 17e9298e47 bgpd: Remove 'debug bgp allow-martian'
This command should not be in the code and is being
removed as per tech meeting decision.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-24 07:45:46 -04: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
Donald Sharp 442321664b bgpd, ospfd: Remove extra newline for show debugging
This extra newline was adding a weird output to `show debugging`
display where there would be extra newlines sometims and not
others.  Make it consistent.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-15 10:34:30 -04:00
Donatas Abraitis aebe2e379f bgpd: Add Notification CEASE BFD Down message
Related: https://datatracker.ietf.org/doc/html/draft-ietf-idr-bfd-subcode

When BFD Down notification comes and BGP is configured to track on BFD events,
send BGP Cease/BFD Down notification to the peer.

If RFC 8538 is enabled (Notification support for Graceful-Restart), notification
should be encapsulated into Hard Reset message.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-02 16:06:57 +03:00
Donald Sharp d032ddcedc bgpd: Make bgp_debug.[ch] take const struct peer * and return bool
Several functions in bgp_debug.[ch] take a const struct peer *
and also return a bool instead of an int.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-13 08:40:41 -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
Donatas Abraitis 7aad5e6a38 bgpd: Check and validate return value for str2ipaddr()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-12 10:28:06 +03:00
Donatas Abraitis 9b01d28988 bgpd: Check argv_find() value instead of the index
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-12 10:25:02 +03: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 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
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
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