Commit Graph

30591 Commits

Author SHA1 Message Date
Rafael Zalamena
ab80e474f2 zebra: fix possible null dereference
Don't attempt to dereference `ifp` directly if it might be null: there
is a check right before this usage: `ifp ? ifp->info : NULL`.

In this context it should be safe to assume `ifp` is not NULL because
the only caller of this function checks that for this `ifindex`. For
consistency we'll check for null anyway in case this ever changes (and
with this the coverity scan warning gets silenced).

Found by Coverity Scan (CID 1519776)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-19 10:32:18 -03:00
Donatas Abraitis
69306c44e8
Merge pull request #12657 from anlancs/fix/lib-debug-empty-ip
lib: show "(null)" for empty IP address
2023-01-19 09:12:04 +02:00
anlan_cs
927c633dd9 lib: show "(null)" for empty IP address
Use "(null)" for empty IP address.

One example in `bgp_zebra_send_remote_macip()` to install mac:

Before:
```
2023/01/18 02:09:09 BGP: [SCHS5-AK960] Tx ADD MACIP, VNI 200 MAC 06:6b:7c:db:83:72 IP  flags 0x0 seq 0 remote VTEP 88.88.88.88 esi -
```

After:
```
2023/01/18 20:19:57 BGP: [SCHS5-AK960] Tx ADD MACIP, VNI 200 MAC 06:6b:7c:db:83:72 IP (null) flags 0x0 seq 0 remote VTEP 88.88.88.88 esi -
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-01-19 09:30:49 +08:00
Donald Sharp
133b0b5a7e
Merge pull request #12659 from opensourcerouting/fpm-cs
zebra: fix fpm netlink encode out of bounds read
2023-01-18 20:20:45 -05:00
Russ White
bb1d52b3c0
Merge pull request #12604 from donaldsharp/distance_metric_offload_fixes
Distance/metric offload fixes
2023-01-18 15:57:48 -05:00
Rafael Zalamena
18b7958e47 zebra: fix fpm netlink encode out of bounds read
Don't attempt to encode the pointer address instead pass the pointer
directly so the real contents can be accessed.

(`ri->pref_src` type is `union g_addr *`)

Found by Coverity Scan (CID 1482162)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-18 15:53:10 -03:00
Mark Stapp
405227b519
Merge pull request #12653 from opensourcerouting/netns-cs
zebra: make sure string is null terminated
2023-01-18 07:32:15 -05:00
Mark Stapp
e7523b9a94
Merge pull request #12648 from opensourcerouting/gmtime-fix
lib: fix gmtime_assafe potential issues
2023-01-17 16:25:35 -05:00
Donald Sharp
f9341ad6a1
Merge pull request #12588 from LabNConsulting/chopps/unet-aflags
tests: replace -a (all) with individual flags for nsenter
2023-01-17 15:55:31 -05:00
Rafael Zalamena
da5bd13c08 zebra: make sure string is null terminated
Do extra inotify data structure checks and copy the file name to a stack
buffer making sure it is null byte terminated.

Found by Coverity Scan (CID 1465494)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-17 17:08:23 -03:00
Christian Hopps
7cec6e4359 tests: replace -a (all) with individual flags for nsenter
- required for old OSs like centos 7
- fixes #11924

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-01-17 11:33:27 -05:00
Donatas Abraitis
7475ed3330
Merge pull request #12449 from chiragshah6/mdev1
zebra: vrf-id support for show vrf vni json cmd
2023-01-17 18:25:01 +02:00
Russ White
e2fd75fce2
Merge pull request #12584 from pguibert6WIND/bgp_imported_distance
bgpd: imported vpn entries get appropriate distance
2023-01-17 10:16:46 -05:00
Russ White
f31c35993d
Merge pull request #12644 from opensourcerouting/rib-uaf
zebra: fix use after free on RIB processing
2023-01-17 09:40:58 -05:00
Russ White
775ce087f1
Merge pull request #12643 from opensourcerouting/fix/cosmetic_log_changes
bgpd: Drop redundant `vrf` keyword in BGP debug log changes
2023-01-17 09:40:28 -05:00
Russ White
6664d74505
Merge pull request #12641 from samanvithab/bgpd_crash
bgpd: Fix crash during shutdown due to race condition
2023-01-17 09:40:05 -05:00
Russ White
00d7261e20
Merge pull request #12636 from opensourcerouting/fix/bgp_accept-own_connected_routes
bgpd: Allow importing local routes with accept-own mechanism
2023-01-17 09:31:37 -05:00
Russ White
c542606e56
Merge pull request #12603 from opensourcerouting/fix/deprecate_bgp_stuff_some
bgpd: Deprecate some stuff
2023-01-17 09:12:39 -05:00
Russ White
2a71812153
Merge pull request #12601 from opensourcerouting/feature/bgp_neighbor_path-attribute_discard
bgpd: Add `neighbor path-attribute discard` command
2023-01-17 09:12:17 -05:00
Russ White
3b506eccc1
Merge pull request #12597 from opensourcerouting/fix/bgp_sender_as_path_prevention
bgpd: Do not send routes back received from a peer
2023-01-17 09:11:53 -05:00
Russ White
13e9afe9e4
Merge pull request #12424 from opensourcerouting/static-route-bfd
staticd: BFD static route monitoring
2023-01-17 09:09:24 -05:00
Rafael Zalamena
0839d0c742 lib: fix gmtime_assafe potential issues
Changes:
- Convert `unsigned int` to `time_t` to satisfy time truncation warnings
  even though at this point we had already used the modulus operator.

- Avoid trying to access outside the bounds of the array

  `months` array has a size of 13 elements, but the code inside the loop
  uses `i + 1` to peek on the next month.

Found by Coverity Scan (CID 1519752 and 1519769)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-17 10:21:39 -03:00
Philippe Guibert
a04f1c42eb bgpd: imported vpn entries get appropriate distance
MPLS VPN networks can either peer with iBGP or eBGP. When
calculating the distance to send to zebra, the imported prefix
is never sent with distance information, even if the vty
command is used under the ipv4 unicast address family:

router bgp 65505 vrf vrf1
 address-family ipv4 unicast
  distance bgp 26 27 28
  [vpn config]

The observation is that the distance sent to zebra for an
imported prefix is still 20:

[..]
VRF vrf1:
B>  192.168.0.0/24 [20/0] via 2.2.2.2 (vrf default) (recursive), label 20, weight 1, 00:00:12
  *                          via 10.125.0.6, ntfp3 (vrf default), label implicit-null/20, weight 1, 00:00:12

The expectation is that the incoming prefix has to follow the
distance that is configured, or the distance derived from the peer
relationship established by the parent prefix.

In the case, an iBGP relationship is done, and no distance
configuration is done, the below show is expected:

   [..]
   VRF vrf1:
   B*>  192.168.0.0/24 [200/0] via 192.168.0.2, r1-gre0 (vrf default), label 20, weight 1, 00:00:12

In the case an iBGP relationship is done, and distance configuration
is performed as below:
   [..]
   distance bgp 21 201 41
   [..]

Then the below show is expected:

   [..]
   VRF vrf1:
   B*>  192.168.0.0/24 [201/0] via 192.168.0.2, r1-gre0 (vrf default), label 20, weight 1, 00:00:12

To get this behaviour, get the peer origin where the prefix is coming
from.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-01-17 13:24:33 +01:00
Rafael Zalamena
e96817f877 zebra: fix use after free on RIB processing
After calling `rib_unlink` the variable `re` will point to `free()`d
memory, so don't attempt to use it after this point.

Found by Coverity Scan (Coverity ID 1519784)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-16 17:40:54 -03:00
Donatas Abraitis
b2a100e439 bgpd: Drop redundant vrf keyword in BGP debug log changes
Before:

```
nexthop is not valid (in vrf VRF vrf100)
updating RD 65001:100, 10.100.1.1/32 to vrf VRF vrf200
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-16 21:36:08 +02:00
Donatas Abraitis
2273550f04
Merge pull request #12621 from donaldsharp/route_scale_failure_micronet
tests: route_scale tests are failing on micronet
2023-01-16 14:32:26 +02:00
Samanvitha B Bhargav
8c9d306c8d bgpd: Fix crash during shutdown due to race condition
[New LWP 2524]
[New LWP 2539]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/opt/avi/bin/bgpd -f /run/frr/avi_ns3_bgpd.config -i /opt/avi/etc/avi_ns3_bgpd.'.
Program terminated with signal SIGABRT, Aborted.
[Current thread is 1 (Thread 0x7f92ac8f1740 (LWP 2524))]
0  0x00007f92acb3800b in raise () from /lib/x86_64-linux-gnu/libc.so.6
[Current thread is 1 (Thread 0x7f92ac8f1740 (LWP 2524))]
0  0x00007f92acb3800b in raise () from /lib/x86_64-linux-gnu/libc.so.6
1  0x00007f92acb17859 in abort () from /lib/x86_64-linux-gnu/libc.so.6
2  0x00007f92acb17729 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
3  0x00007f92acb28fd6 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
4  0x00007f92accf2164 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
5  0x000055b46be1ef63 in bgp_keepalives_wake () at bgpd/bgp_keepalives.c:311
6  0x000055b46be1f111 in bgp_keepalives_stop (fpt=0x55b46cfacf20, result=<optimized out>) at bgpd/bgp_keepalives.c:323
7  0x00007f92acea9521 in frr_pthread_stop (fpt=0x55b46cfacf20, result=result@entry=0x0) at lib/frr_pthread.c:176
8  0x00007f92acea9586 in frr_pthread_stop_all () at lib/frr_pthread.c:188
9  0x000055b46bdde54a in bgp_pthreads_finish () at bgpd/bgpd.c:8150
10 0x000055b46bd696ca in bgp_exit (status=0) at bgpd/bgp_main.c:210
11 sigint () at bgpd/bgp_main.c:154
12 0x00007f92acecc1e9 in quagga_sigevent_process () at lib/sigevent.c:105
13 0x00007f92aced689a in thread_fetch (m=m@entry=0x55b46cf23540, fetch=fetch@entry=0x7fff95379238) at lib/thread.c:1487
14 0x00007f92aceb2681 in frr_run (master=0x55b46cf23540) at lib/libfrr.c:1010
15 0x000055b46bd676f4 in main (argc=11, argv=0x7fff953795a8) at bgpd/bgp_main.c:482

Root cause:
This is due to race condition between main thread & keepalive thread during clean-up.

This happens when the keepalive thread is processing a wake signal owning the mutex, when meanwhile the main thread tries to stop the keepalives thread.

In main thread, the keepalive thread’s running bit (fpt->running) is set to false, without taking the mutex & then it blocks on mutex.
Meanwhile, keepalive thread which owns the mutex sees that the running bit is false & executes bgp_keepalives_finish() which also frees up mutex.
Main thread that is waiting on mutex with pthread_mutex_lock() will cause core while trying to access mutex.

Fix:
Take the lock in main thread while setting the fpt->running to false.

Signed-off-by: Samanvitha B Bhargav <bsamanvitha@vmware.com>
2023-01-16 04:22:11 -08:00
Donatas Abraitis
d9e1fe38a6
Merge pull request #12642 from anlancs/fix/bgpd-debug-name
bgpd: fix wrong vrf name for debug
2023-01-16 14:16:43 +02:00
anlan_cs
6bb58de0a5 bgpd: fix wrong vrf name for debug
For vrf name in debug, use `bgp->name_pretty` instead of `bgp->name`.

Before:
```
2023/01/15 05:04:19 BGP: [P4GAZ-JHRM3] evpn vrf VRF default nh init
2023/01/15 05:04:19 BGP: [ZZKY3-FX5JH] bgp_get: Registering BGP instance (null) to zebra <-
2023/01/15 05:04:19 BGP: [TNK7N-FJF7K] Registering VRF 0
```

After:
```
2023/01/15 21:38:16 BGP: [P4GAZ-JHRM3] evpn vrf VRF default nh init
2023/01/15 21:38:16 BGP: [ZZKY3-FX5JH] bgp_get: Registering BGP instance VRF default to zebra <-
2023/01/15 21:38:16 BGP: [TNK7N-FJF7K] Registering VRF 0
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-01-16 13:07:56 +08:00
Donald Sharp
0fe10eb8eb
Merge pull request #12611 from vfreex/reload-missing-daemons
tools: Add missing daemons
2023-01-15 17:45:21 -05:00
Donatas Abraitis
8a02d9fe1e bgpd: Set nh ifindex to VRF's interface, not the real
The kernel will lookup the real interface later.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-15 12:43:37 +02:00
Louis Scalbert
b2cfd204a8 lib: add a function to get the VRF or loopback interface
Add a function to find the VRF or the loopback interface: the loopback
interface for the default VRF and the VRF master interface otherwise.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-15 12:22:24 +02:00
Donatas Abraitis
b4710d034d tests: Check if connected routes are leaked between VRFs using accept-own
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-15 12:22:12 +02:00
Donatas Abraitis
c479b28e51 bgpd: Allow importing local routes with accept-own mechanism
Before this patch we allowed importing routes between VRFs in the same node,
only for external routes, but not for local (e.g.: redistribute).

Relax here a bit, and allow importing local routes between VRFs when the RT
list is modified using route reflectors.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-15 12:21:36 +02:00
Donald Sharp
483b322821 tests: route_scale tests are failing on micronet
I'm seeing test failures after in micronet runs in CI
after 7 seconds * 30 attempts at seeing if it succeeds.
Let's see if another 60 seconds of attempts allows
this to work properly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-15 10:13:04 +00:00
Yuxiang Zhu
559f208ea5 tools: Add missing daemons
Got `ERROR: Daemon babeld is not a valid option for 'show running-config'` when using `frr-reload.py --reload --daemon babeld`.

Adds `babeld` and `nhrpd` as valid daemons.

Signed-off-by: Yuxiang Zhu <vfreex@gmail.com>
2023-01-15 10:57:53 +08:00
Donatas Abraitis
be251beef2
Merge pull request #12639 from donaldsharp/breakup_bgp_vrf_dynamic_route_leak_topo4
tests: Breakup bgp_vrf_dynamic_route_leak_topo4
2023-01-14 22:26:43 +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
Donatas Abraitis
25851bf0a1 bgpd: Do not send routes back received from a peer
Before this patch, we needed to explicitly define a neighbor to be SOLO
(= separate update-group). Let's ease this functionality for an operator to
avoid confusions.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-14 21:30:07 +02:00
Donatas Abraitis
c7fe4786dc tests: Check if routes are not sent back from the sender
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-14 21:30:07 +02:00
Donatas Abraitis
a5c6a9b18e bgpd: Add neighbor path-attribute discard command
The idea is to drop unwanted attributes from the BGP UPDATE messages and
continue by just ignoring them. This improves the security, flexiblity, etc.

This is the command that Cisco has also.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-14 21:29:41 +02:00
Donatas Abraitis
563212ee3e doc: Add neighbor path-attribute discard command
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-14 21:29:41 +02:00
Donatas Abraitis
760aee9ac2 tests: Check if we can discard unwanted attributes from the paths
Using `neighbor path-attribute discard ...` command.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-14 21:29:41 +02:00
Chirag Shah
4300ed1004 doc: add documentation for show vrf vni
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-01-13 13:49:21 -08:00
Sindhu Parvathi Gopinathan
3cff8acb33 zebra: Adding FRR support for show vrf vrf-id vni
cli & json support extended for show vrf vrf-id vni

commands:

 - existing: show vrf vni
 - show vrf <vrf-name> vni
 - show vrf all vni
 - show vrf <vrf-name> vni json
 - show vrf all vni json

Before:
```
tor-1# show vrf vni
VRF                                   VNI        VxLAN IF
L3-SVI               State Rmac
default                               100        None
None                 Down  None
sym_1                                 8888       vxlan99
vlan490_l3           Up    44:38:39:ff:ff:25
sym_2                                 8889       vxlan99
vlan491_l3           Up    44:38:39:ff:ff:25
sym_3                                 8890       vxlan99
vlan492_l3           Up    44:38:39:ff:ff:25
sym_4                                 8891       vxlan99
vlan493_l3           Up    44:38:39:ff:ff:25
sym_5                                 8892       vxlan99
vlan494_l3           Up    44:38:39:ff:ff:25
tor-1#
```

After:
```
tor-1# show vrf default vni json
{
  "vrfs":[
    {
      "vrf":"default",
      "vni":100,
      "vxlanIntf":"None",
      "sviIntf":"None",
      "state":"Down",
      "routerMac":"None"
    }
  ]
}

tor-1# show vrf default vni
VRF                                   VNI        VxLAN IF
L3-SVI               State Rmac
default                               100        None
None                 Down  None
tor-1#

tor-1# show vrf all vni
VRF                                   VNI        VxLAN IF
L3-SVI               State Rmac
default                               100        None
None                 Down  None
sym_1                                 8888       vxlan99
vlan490_l3           Up    44:38:39:ff:ff:25
sym_2                                 8889       vxlan99
vlan491_l3           Up    44:38:39:ff:ff:25
sym_3                                 8890       vxlan99
vlan492_l3           Up    44:38:39:ff:ff:25
sym_4                                 8891       vxlan99
vlan493_l3           Up    44:38:39:ff:ff:25
sym_5                                 8892       vxlan99
vlan494_l3           Up    44:38:39:ff:ff:25
tor-1#
tor-1#

tor-1#
tor-1#
tor-1#
tor-1# show vrf all vni json
{
  "vrfs":[
    {
      "vrf":"default",
      "vni":100,
      "vxlanIntf":"None",
      "sviIntf":"None",
      "state":"Down",
      "routerMac":"None"
    },
    {
      "vrf":"sym_1",
      "vni":8888,
      "vxlanIntf":"vxlan99",
      "sviIntf":"vlan490_l3",
      "state":"Up",
      "routerMac":"44:38:39:ff:ff:25"
    },
    {
      "vrf":"sym_2",
      "vni":8889,
      "vxlanIntf":"vxlan99",
      "sviIntf":"vlan491_l3",
      "state":"Up",
      "routerMac":"44:38:39:ff:ff:25"
    },
    {
      "vrf":"sym_3",
      "vni":8890,
      "vxlanIntf":"vxlan99",
      "sviIntf":"vlan492_l3",
      "state":"Up",
      "routerMac":"44:38:39:ff:ff:25"
    },
    {
      "vrf":"sym_4",
      "vni":8891,
      "vxlanIntf":"vxlan99",
      "sviIntf":"vlan493_l3",
      "state":"Up",
      "routerMac":"44:38:39:ff:ff:25"
    },
    {
      "vrf":"sym_5",
      "vni":8892,
      "vxlanIntf":"vxlan99",
      "sviIntf":"vlan494_l3",
      "state":"Up",
      "routerMac":"44:38:39:ff:ff:25"
    }
  ]
}
tor-1#
```

Ticket:#3260835
Issue:3260835

Testing: UT done

Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2023-01-13 13:49:21 -08:00
Donald Sharp
329dc20704
Merge pull request #12635 from LabNConsulting/ziemba/topotests-lutil-wait-strict
topotests/lib/lutil.py: luSetWaitType("strict"|"nostrict")
2023-01-13 16:22:00 -05:00
Donald Sharp
186b9ab8c5 tests: Breakup bgp_vrf_dynamic_route_leak_topo4
Single run of this test suite on my machine was 8 minutes.
Breaking this up into 3 test suites halves the run time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-13 15:30:33 -05:00
G. Paul Ziemba
25cdcf1fac topotests/lib/lutil.py: luSetWaitType("strict"|"nostrict")
This change alters the behavior of existing test code. The
    default mode (before any call to luSetWaitType()) is now
    "strict".

    The historical behavior of luCommand(op="wait) is to ignore
    failures to match the specified regexp in the specified time.
    In those cases, no result was logged and no error was signaled.

    This change introduces a new "strict" mode for luCommand(op="wait):
    in "strict" wait mode, each invocation of luCommand(op="wait)
    generates an explicit, logged failure result when it fails to match
    the specified regexp in the specified time. These failures signal
    an error for the test.

    Calling luSetWaitType("nostrict") restores the historical behavior.

    Calling luSetWaitType("strict") (re)enables the new strict behavior.

    Individual calls to luCommand() may also specify op="wait-nostrict"
    to override any default and use the historical behavior.

    Individual calls to luCommand() may also specify op="wait-strict"
    to override any default and use the new behavior.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-01-13 10:53:36 -08:00
Philippe Guibert
b27499d6ba staticd: add debug static bfd command
This command helps in troubleshooting static bfd feature.
Add traces upon bfd events.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-13 15:32:12 -03:00
Rafael Zalamena
771fdeaf39 topotests: test BFD static route integration
Test that BFD static monitoring works:
When BFD session is up the routes are installed in the RIB and
distributed with routing protocol (in this case BGP). When the session
is down it is removed from RIB and propagated.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-13 15:32:12 -03:00