Commit Graph

32667 Commits

Author SHA1 Message Date
Louis Scalbert
f766bb0c0f bgpd: add 'show bgp mplsvpn-nh-label-bind' command
There is no 'show command' to use for troubleshooting
purposes.
Add a new show command to dump the cache entry of the
MPLS VPN nexthop label bind cache table.
> show bgp [vrf NAME] mplsvpn-nh-label-bind [detail]

The below command illustrates its output:
> dut# show bgp mplsvpn-nh-label-bind  detail
> Current BGP mpls-vpn nexthop label bind cache, VRF default
>  192.168.1.3, label 102, local label 18 #paths 3
>   interface r2-eth1
>   Last update: Mon May 22 14:39:42 2023
>   Paths:
>     1/3 172.31.3.0/24 VRF default flags 0x418
>     1/3 172.31.2.0/24 VRF default flags 0x418
>     1/3 172.31.1.0/24 VRF default flags 0x418
>  192.0.2.1, label 101, local label 19 #paths 1
>   interface r2-eth0
>   Last update: Mon May 22 14:39:43 2023
>   Paths:
>     1/3 172.31.0.0/24 VRF default flags 0x418

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
27f4deed0a bgpd: update the mpls entry to handle return traffic
When advertising an mpls vpn entry with a new label,
the return traffic is redirected to the local machine,
but the MPLS traffic is dropped.

Add an MPLS entry to handle MPLS packets which have
the new label value. Traffic is swapped to the original
label value from the mpls vpn next-hop entry; then it is
sent to the resolved next-hop of the original next-hop
from the mpls vpn next-hop entry.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
98c615f05a bgpd: advertise mpls vpn routes with appropriate label
The advertised label value from mpls vpn routes is not modified
when the advertised next-hop is modified to next-hop-self.

Actually, the original label value received is redistributed as
is, whereas the new_label value bound in the nexthop label
bind entry should be used.

Only the VPN entries that contain MPLS information, and that
are redistributed between distinct peers, will have a label
value to advertise.
- no SRv6 attribute
- no local prefix
- no exported VPN prefixes from a VRF

If the advertisement to a given peer has the next-hop modified,
then the new label value will be picked up. The considered cases
are peers configured with 'next-hop-self' option, or ebgp peerings
without the 'next-hop-unchanged' option.

Note that the the NLRI format will follow the rfc3107 format, as
multiple label values for MPLS VPN NLRIs are not supported (the
rfc8277 is not supported).
Note also that the case where an outgoing route-map is applied to
the outgoing neighbor is not considered in this commit.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
1069425868 bgpd: allocate label bound to received mpls vpn routes
Current implementation does not offer a new label to bind
to a received VPN route entry to redistribute with that new
label.

This commit allocates a label for VPN entries that have
a valid label, and a reachable next-hop interface that is
configured as follows:

> interface eth0
>  mpls bgp l3vpn-multi-domain-switching
> exit

An mplsvpn next-hop label binding entry is created in an mpls
vpn nexthop label bind hash table of the current BGP instance.
That mpls vpn next-hop label entry is indexed by the (next-hop,
orig_label) values provided by the incoming updates, and shared
with other updates having the same (next-hop, orig_label) values.

A new 'LP_TYPE_BGP_L3VPN_BIND' label value is picked up from the
zebra mpls label pool, and assigned to the new_label attribute.

The 'bgp_path_info' appends a 'bgp_mplsvpn_nh_label_bind' structure
to the 'mplsvpn' union structure. Both structures in the union are not
used at the same, as the paths are either VRF updates to export, or MPLS
VPN updates. Using an union gives a 24 bytes memory gain compared to if
the structures had not been in an union (24 bytes compared to 48 bytes).

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
28d5c6e531 bgpd: move label allocation code to a specific function
The label allocation mechanism is called implicitly for
labeled unicast paths. The check should be explicit, because
the current patch set will extend the mechanism for mpls vpn
paths, and the code should explicitly tell which safi calls
which code.

Fix this implicit call by checking the safi value. Move the
code to a specific function.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
76c803171b bgpd: move the label per nexthop structs of bgp_path to an union
The label per nexthop attributes take 24 bytes per bgp path
entry on AMD64 platform, and are only used for unicast paths.
The current patch-set introduces a similar attributes, but that
will be used only for l3vpn paths. To gain some memory on the
bgp_path_info structure in the next commit, do some changes.

Create an 'mplsvpn' union structure that will either include the
label per nexthop structs for ipv4 paths, or the l3vpn paths
structures. The 'label_nexthop_cache' and the 'label_nh_thread'
attributes of the 'bgp_path_info' structure are moved into an
union under a new structure called 'bgp_mplsvpn_label_nh_blnc'.
The flags attribute of 'bgp_path_info' is increased from 16 bits
to 32 bits, and the BGP_PATH_MPLSVPN_LABEL_NH flag is added to
know the 'mplsvpn' usage.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Louis Scalbert
29b49f67eb bgpd: add mpls vpn nh label bind cache struct and apis
In the context of the ASBR facing an EBGP neighbor, or
facing an IBGP neighbor where the BGP updates received
are re-advertised with a modified next-hop, a new local
label will be re-advertised too, to replace the original
one.

Create a binding table, in the form of a hash list, from the
original labels to the new labels. Since labels can be the
same on several routers, set the next-hop and the label as
the keys. Add the needed API functions to manage the hash
list.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Louis Scalbert
73e9ce89b9 bgpd: add LP_TYPE_BGP_L3VPN_BIND label type
Redistributing mpls vpn prefixes with a new label
requires picking up unused MPLS local labels.

Today, there is an MPLS label pool which is owned
by the zebra daemon. BGP gets a chunk of labels
that are shared with the multiple usage of the BGP
daemon. A label type attribute is used whenever
BGP needs a new label value.

The 'LP_TYPE_BGP_L3VPN_BIND' label type will be used
to allocate the MPLS labels that will be bound to
the original next-hop, and label value of an L3VPN
update.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
cd0e9bfbc4 bgpd: track mpls vpn nexthops
There is no nexthop reachability information for
received MPLS VPN prefixes.
This information is necessary when BGP also acts
as LSR device, and is needed to create an MPLS entry
between two BGP speakers: the next-hop to pick-up
in the MPLS entry has to be connected.

The nexthop reachability information is available
for other non MPLS VPN prefixes, and is handled
by the bgp nexthop cache (bnc) contexts.
Extend the usage of the BNC contexts for L3VPN
prefixes.

Note that the MPLS VPN routes had to be redistributed
as before, to avoid breaking existing deployments
that use FRR as route reflectors. Because of this, the
nexthop reachability status has been maintained to OK
for MPLS VPN prefixes.

Note also that the label allocation per nexthop tracking
was wrongly using the MPLS VPN safi to get a valid BNC
context, when choosing which label to return in the
'vpn_leak_from_vrf_get_per_nexthop_label()' function.
Fix this by using SAFI_UNICAST instead.

Fixes: 577be36a41 ("bgpd: add support for l3vpn per-nexthop label")
Link: https://github.com/FRRouting/frr/pull/13380
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
658c5ebe38 bgpd: fix label allocation per next-hop applied to unicast
The label allocation per next-hop functionality is calling
the 'bgp_find_or_add_nexthop()' method using the SAFI_MPLS_VPN
safi parameter, whereas the call is supposed to apply to
unicast paths.

Fix this by using the SAFI_UNICAST safi parameter in the call.
Simplify the vpn_leak_from_vrf_get_per_nexthop_label() API by
removing the safi parameter from the function.

Fixes: 577be36a41 ("bgpd: add support for l3vpn per-nexthop label")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Louis Scalbert
ef1fc25431 bgpd: add 'mpls bgp l3vpn-multi-domain-switching' command
When acting as intermediate device for BGP signaling, and
as transit device for data traffic, the device is not able
to modify the label value from incoming MPLS VPN updates:

- as BGP device, modifying the label value is necessary
when redistributing VPN prefixes with its own next-hop.
- as transit device that connects two ethernet segments
on separate interfaces, the return MPLS traffic must be
handled: the modified label value must be swapped with
the original label value and sent back to the original
next-hop.

The border router use case can be taken as example, when
it acts both as transit and as BGP device:
- When receiving updates from a border router peer, and where
interior traffic is expected to transit through the local
border router.
- When receiving updates from interior devices, and where
exterior traffic will transit through the local border router.

In those two situations, a new label is bound to the received
entry, and the entry is advertised to a new peer with the new
label. In the same time, an MPLS entry is created to handle
return traffic with the new mpls label: the traffic would be
swapped to the original MPLS label and the original next-hop.

This is the first commit of a series of patches, that address
the above mentioned issue.
The first commit introduces a new per-interface command:

> interface eth0
>  [no] mpls bgp l3vpn-multi-domain-switching
> exit

This command will authorise mpls vpn updates to have a new
label value bound to the mpls vpn routes received over that
interface.

Link: https://www.rfc-editor.org/rfc/rfc3107.html#section-3

> When a BGP speaker redistributes a route, the label(s) assigned to
> that route must not be changed (except by omission), unless the
> speaker changes the value of the Next Hop attribute of the route.

Link: https://www.rfc-editor.org/rfc/rfc3031.html#section-4.6
Link: https://www.rfc-editor.org/rfc/rfc4364.html#section-10
sub-chapter b.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Philippe Guibert
162c5d83ad bgpd: add a function to compare two label lists
Create a bgp_labels_same() function that does the
same operations as the static function labels_same from
bgp_mplsvpn.c.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-06-16 10:54:58 +02:00
Igor Ryzhov
9f6dade90e Revert "ripngd: Cleanup memory allocations on shutdown"
This reverts commit b1d29673ca.

This commit introduced a crash. When the VRF is deleted, the RIPNG
instance should not be freed, because the NB infrastructure still stores
the pointer to it. The instance should be deleted only when it's actually
deleted from the configuration.

To reproduce the crash:
```
frr# conf t
frr(config)# vrf vrf1
frr(config-vrf)# exit
frr(config)# router ripng vrf vrf1
frr(config-router)# exit
frr(config)# no vrf vrf1
frr(config)# no router ripng vrf vrf1
vtysh: error reading from ripngd: Resource temporarily unavailable (11)Warning: closing connection to ripngd because of an I/O error!
frr(config)#
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-06-15 17:43:58 +03:00
Igor Ryzhov
054ca9b9ee Revert "ripd: Cleanup memory allocations on shutdown"
This reverts commit 3d1588d8ed.

This commit introduced a crash. When the VRF is deleted, the RIP instance
should not be freed, because the NB infrastructure still stores the
pointer to it. The instance should be deleted only when it's actually
deleted from the configuration.

To reproduce the crash:
```
frr# conf t
frr(config)# vrf vrf1
frr(config-vrf)# exit
frr(config)# router rip vrf vrf1
frr(config-router)# exit
frr(config)# no vrf vrf1
frr(config)# no router rip vrf vrf1
vtysh: error reading from ripd: Resource temporarily unavailable (11)Warning: closing connection to ripd because of an I/O error!
frr(config)#
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-06-15 17:43:40 +03:00
Donald Sharp
4d616f022f bgpd: some safi's do not mix with bgp suppress-fib
BGP cannot decide to disseminate the safi based upon the
bgp suppress-fib command.  Modify the code to look at
the safi for the decision to communicate to a peer the
particular node.

Ticket: #3402926
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-14 15:15:13 -04:00
Mark Stapp
0fb1630520
Merge pull request #13742 from sri-mohan1/srib-ldpd1
ldpd: changes for code maintainability
2023-06-14 11:14:16 -04:00
anlan_cs
ee7457a1c0 doc: Fix one syntax error for code block
The code block doesn't work because blank line is missing.
So, just make it work.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-06-14 22:23:15 +08:00
sri-mohan1
8443d112b3 ldpd: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2023-06-14 16:42:26 +05:30
Donald Sharp
22c329ed32
Merge pull request #13793 from LabNConsulting/aceelindem/coverity-doc-update
doc: Update Coverity workflow in developer documentation.
2023-06-14 06:57:57 -04:00
Donald Sharp
ee7fd22a27
Merge pull request #13783 from opensourcerouting/fix/some_gcc13_nits
GCC13 nits
2023-06-14 06:56:40 -04:00
Carmine Scarpitta
2a9e0824a7 isisd: Fix use beyond end of stream of ASLA Sub-TLV parsing
Fixes a crash associated with attempting to read beyond the end of the
stream when parsing ASLA Sub-TLV.

```
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
    subtlv_len=13 '\r') at isisd/isis_tlvs.c:1473
    at isisd/isis_tlvs.c:3264
    context=<optimized out>, mtid=<optimized out>) at isisd/isis_tlvs.c:6078
    indent=4) at isisd/isis_tlvs.c:6142
    avail_len=<optimized out>, context=<optimized out>) at isisd/isis_tlvs.c:7032
    at isisd/isis_tlvs.c:7054
(gdb)
```

Caught by fuzzer.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-06-14 08:31:32 +02:00
Acee Lindem
4d2fe4a4de doc: Update Coverity workflow in developer documentation.
Signed-off-by: Acee Lindem <aceelindem@gmail.com>
2023-06-13 16:10:48 -04:00
Igor Ryzhov
2b21ec2c49
Merge pull request #13766 from LabNConsulting/chopps/mgmtd-cleanup
mgmtd cleanup/simplify some code
2023-06-13 22:50:39 +03:00
Igor Ryzhov
ea4c53412e
Merge pull request #13768 from LabNConsulting/chopps/mgmt-better-logs
mgmtd: improvements in logging and commentary
2023-06-13 22:43:11 +03:00
Igor Ryzhov
5aa4dc2313
Merge pull request #13764 from LabNConsulting/chopps/robust1
lib: mgmtd: make error handling more robust
2023-06-13 22:25:13 +03:00
Donald Sharp
f89d090230
Merge pull request #13755 from LabNConsulting/ziemba/zebra-dplane-priority
zebra: bugfix dplane priority sorting
2023-06-13 10:36:57 -04:00
Donald Sharp
e35f0668e5
Merge pull request #13589 from mjstapp/fix_pbr_zebra
pbrd, zebra: fix zapi and netlink rule encoding
2023-06-13 10:23:46 -04:00
Russ White
609491fe0d
Merge pull request #13612 from chiragshah6/fdev1
ospfd: fix interface param type update
2023-06-13 09:55:07 -04:00
Donatas Abraitis
cc280c74ce bgpd: Use enum bgp_create_error_code as argument in header
```
bgpd/bgp_vty.c:865:5: warning: conflicting types for ‘bgp_vty_return’ due to enum/integer mismatch; have ‘int(struct vty *, enum bgp_create_error_code)’ [-Wenum-int-mismatch]
  865 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret)
      |     ^~~~~~~~~~~~~~
In file included from ./bgpd/bgp_mplsvpn.h:15,
                 from bgpd/bgp_vty.c:48:
./bgpd/bgp_vty.h:148:12: note: previous declaration of ‘bgp_vty_return’ with type ‘int(struct vty *, int)’
  148 | extern int bgp_vty_return(struct vty *vty, int ret);
      |            ^~~~~~~~~~~~~~
```

Fixing stuff regarding GCC13.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-13 16:08:24 +03:00
Donatas Abraitis
58a92cb810 bgpd: Use enum bgp_fsm_state_progress for bgp_stop()
```
bgpd/bgp_fsm.c:1360:29: warning: conflicting types for ‘bgp_stop’ due to enum/integer mismatch; have ‘enum bgp_fsm_state_progress(struct peer *)’ [-Wenum-int-mismatch]
 1360 | enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
      |                             ^~~~~~~~
In file included from bgpd/bgp_fsm.c:29:
./bgpd/bgp_fsm.h:111:12: note: previous declaration of ‘bgp_stop’ with type ‘int(struct peer *)’
  111 | extern int bgp_stop(struct peer *peer);
      |            ^~~~~~~~
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-13 16:01:40 +03:00
Loganaden Velvindron
56e52d830b vrrp: check return value for turning off multicast for v6
CID1519841: check return value and set error

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
2023-06-13 16:56:12 +04:00
David Lamparter
a0a839feff
Merge pull request #13775 from mobash-rasool/fixes2 2023-06-13 12:50:06 +02:00
Christian Hopps
78dfcceeae
Merge pull request #13767 from opensourcerouting/fix/convert_rip_topo1_to_polling
tests: Convert rip/ripng tests using run_and_expect
2023-06-13 04:20:49 -04:00
Christian Hopps
96f9e7853b lib: mgmtd: improvements in logging and commentary
- log names of datastores not numbers
- improve logging for mgmt_msg_read
- Rather than use a bool, instead store the pending const string name of
the command being run that has postponed the CLI. This adds some nice
information to the logging when enabled.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-13 04:11:29 -04:00
Donatas Abraitis
e0db9a05bd
Merge pull request #13763 from LabNConsulting/mgmtd/simplify
fix 'exit' bug in config file processing, et al.
2023-06-13 11:10:18 +03:00
Mobashshera Rasool
8ebcc02328 pimd,pim6d: Correct the socket to send reg-stop msg
We were using the pim interface socket to send the register
stop msg, it works fine in cases where the interface on which
register msg is received and the interface on which the register-stop
msg is supposed to be sent is the same.
But when the interfaces are different, msg send fails because
the outgoing interface is not right.

Fixes: #13774

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2023-06-12 22:51:44 -07:00
Mark Stapp
a32d40a676 zebra: clarify interface-level mpls config
We have both interface-level configuration to enable mpls,
and runtime mpls status. They need to be distinct.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-06-12 16:41:27 -04:00
Mark Stapp
4112baec9f pbrd, zebra: fix zapi and netlink rule encoding
In pbrd, don't encode a rule without a table. There are cases
where the zapi encoding was incorrect because the 4-octet
table id was missing. In zebra, mask off the ECN bits in the
TOS byte when encoding an iprule to match netlink's
expectation.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-06-12 16:39:26 -04:00
David Lamparter
b8396c9cb0
Merge pull request #13704 from donaldsharp/flowspec_support_bundle 2023-06-12 18:47:55 +02:00
Donald Sharp
c1ce67e26c bgpd: Add some color to why nexthop_set failed
We are seeing some frequent test failures with
setting the nexthop correctly.  At this point
in time, I have no idea what is going wrong,
but I don't have a bunch of information either,
so let's add the local and remote values.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-12 09:22:51 -04:00
Donald Sharp
6ec1065217 tests: test_bgp_flowspec_topo.py changes as per linter
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-12 09:22:51 -04:00
Donald Sharp
773376a3c3 tests: The bgp_flowspec frequently fails try to gather more data
Add a bit of code to allow the bgp_flowspec topotest to gather
data when something goes wrong.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-12 09:22:51 -04:00
Donatas Abraitis
7ac46d8a08 tests: Check if neighbor X advertised-routes cmd works for peer-groups
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-12 15:20:08 +03:00
Donatas Abraitis
c4d4682ae1 bgpd: Handle peer-group also when showing advertised routes
When trying to list advertised-routes for instance, it's not possible for now.

Relax this a bit, and allow doing this, instead of returning an error:

% Malformed address or name.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-12 15:15:42 +03:00
Christian Hopps
c9d153e5e9 mgmtd: complex redux in txn cleanup
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 07:23:54 -04:00
Christian Hopps
70ff6bb80b lib: mgmtd: simplify implicit commit code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 07:22:30 -04:00
Christian Hopps
d694cd40f2 lib: mgmtd: make error handling more robust
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 07:21:47 -04:00
Donatas Abraitis
48008be43f tests: Apply black formatting for rip_topo1/ripng_topo1
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-12 11:45:03 +03:00
Donatas Abraitis
717f180a49 tests: Use run_and_expect() for ripng_topo1
Avoid checking once and failing immediately.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-12 11:40:09 +03:00
Donatas Abraitis
3349754a80 tests: Use run_and_expect() for rip_topo1
Avoid checking once and failing immediately.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-12 11:38:01 +03:00