]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
4 years agoospf6d: prevent use after free
Donald Sharp [Sun, 31 Jan 2021 13:52:44 +0000 (08:52 -0500)]
ospf6d: prevent use after free

Valgrind reports:

2437395-==2437395== Invalid read of size 8
2437395:==2437395==    at 0x40B610: ospf6_asbr_update_route_ecmp_path (ospf6_asbr.c:327)
2437395-==2437395==    by 0x40BC7C: ospf6_asbr_lsa_add (ospf6_asbr.c:544)
2437395-==2437395==    by 0x40C5DF: ospf6_asbr_lsentry_add (ospf6_asbr.c:829)
2437395-==2437395==    by 0x42D88D: ospf6_top_brouter_hook_add (ospf6_top.c:185)
2437395-==2437395==    by 0x4188E3: ospf6_intra_brouter_calculation (ospf6_intra.c:2320)
2437395-==2437395==    by 0x42C624: ospf6_spf_calculation_thread (ospf6_spf.c:638)
2437395-==2437395==    by 0x4904B7E: thread_call (thread.c:1681)
2437395-==2437395==    by 0x48CAA27: frr_run (libfrr.c:1126)
2437395-==2437395==    by 0x40AF43: main (ospf6_main.c:232)
2437395-==2437395==  Address 0x5c668a8 is 24 bytes inside a block of size 256 free'd
2437395:==2437395==    at 0x48399AB: free (vg_replace_malloc.c:538)
2437395-==2437395==    by 0x429027: ospf6_route_delete (ospf6_route.c:419)
2437395-==2437395==    by 0x429027: ospf6_route_unlock (ospf6_route.c:460)
2437395-==2437395==    by 0x429027: ospf6_route_remove (ospf6_route.c:887)
2437395-==2437395==    by 0x40B343: ospf6_asbr_update_route_ecmp_path (ospf6_asbr.c:318)
2437395-==2437395==    by 0x40BC7C: ospf6_asbr_lsa_add (ospf6_asbr.c:544)
2437395-==2437395==    by 0x40C5DF: ospf6_asbr_lsentry_add (ospf6_asbr.c:829)
2437395-==2437395==    by 0x42D88D: ospf6_top_brouter_hook_add (ospf6_top.c:185)
2437395-==2437395==    by 0x4188E3: ospf6_intra_brouter_calculation (ospf6_intra.c:2320)
2437395-==2437395==    by 0x42C624: ospf6_spf_calculation_thread (ospf6_spf.c:638)
2437395-==2437395==    by 0x4904B7E: thread_call (thread.c:1681)
2437395-==2437395==    by 0x48CAA27: frr_run (libfrr.c:1126)
2437395-==2437395==    by 0x40AF43: main (ospf6_main.c:232)
2437395-==2437395==  Block was alloc'd at
2437395:==2437395==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
2437395-==2437395==    by 0x48D2A32: qcalloc (memory.c:115)
2437395-==2437395==    by 0x427CE4: ospf6_route_create (ospf6_route.c:402)
2437395-==2437395==    by 0x40BA8A: ospf6_asbr_lsa_add (ospf6_asbr.c:490)
2437395-==2437395==    by 0x40C5DF: ospf6_asbr_lsentry_add (ospf6_asbr.c:829)
2437395-==2437395==    by 0x42D88D: ospf6_top_brouter_hook_add (ospf6_top.c:185)
2437395-==2437395==    by 0x4188E3: ospf6_intra_brouter_calculation (ospf6_intra.c:2320)
2437395-==2437395==    by 0x42C624: ospf6_spf_calculation_thread (ospf6_spf.c:638)
2437395-==2437395==    by 0x4904B7E: thread_call (thread.c:1681)
2437395-==2437395==    by 0x48CAA27: frr_run (libfrr.c:1126)
2437395-==2437395==    by 0x40AF43: main (ospf6_main.c:232)

ospfv3 loops through the ecmp routes to decide what to clean up.  In some
situations the code free's up an existing route at the head of the list.
Cleaning the pointers in the list but never touching the original pointer.
In that case notice and update the old pointer.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agolib: Prevent unininted usage of data
Donald Sharp [Sat, 30 Jan 2021 21:19:08 +0000 (16:19 -0500)]
lib: Prevent unininted usage of data

Valgrind reports that some data being used in the
stack unwind of a crash is being used uninitailized.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agobfdd: Prevent storage of ifp pointer that has been deleted
Donald Sharp [Sat, 30 Jan 2021 20:41:35 +0000 (15:41 -0500)]
bfdd: Prevent storage of ifp pointer that has been deleted

On shutdown, interfaces are deleted but if the bfd session
is down we retain the interface pointer.  Remove the retained
pointer.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agobfdd: Prevent unininited data transmittal
Donald Sharp [Sat, 30 Jan 2021 19:31:47 +0000 (14:31 -0500)]
bfdd: Prevent unininited data transmittal

Valgrind reports:

2052866-==2052866==
2052866-==2052866== Syscall param sendmsg(msg.msg_name) points to uninitialised byte(s)
2052866:==2052866==    at 0x49C8E13: sendmsg (sendmsg.c:28)
2052866-==2052866==    by 0x11DC08: bp_udp_send (bfd_packet.c:823)
2052866-==2052866==    by 0x11DD76: ptm_bfd_echo_snd (bfd_packet.c:179)
2052866-==2052866==    by 0x114C2D: ptm_bfd_echo_xmt_TO (bfd.c:469)
2052866-==2052866==    by 0x114C2D: ptm_bfd_echo_start (bfd.c:498)
2052866-==2052866==    by 0x114C2D: bs_echo_timer_handler (bfd.c:1199)
2052866-==2052866==    by 0x11E478: bfd_recv_cb (bfd_packet.c:702)
2052866-==2052866==    by 0x4904846: thread_call (thread.c:1681)
2052866-==2052866==    by 0x48CB4DF: frr_run (libfrr.c:1126)
2052866-==2052866==    by 0x113044: main (bfdd.c:403)
2052866-==2052866==  Address 0x1ffefff3e8 is on thread 1's stack

In ptm_bfd_echo_snd, for the v4 case we were memsetting the v6 memory
then setting the v4 memory.  Just fix it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agoeigrpd: Prevent uninitialized value from being used
Donald Sharp [Sat, 30 Jan 2021 18:38:32 +0000 (13:38 -0500)]
eigrpd: Prevent uninitialized value from being used

valgrind is finding:

2141982-==2141982== Conditional jump or move depends on uninitialised value(s)
2141982:==2141982==    at 0x11A7A6: eigrp_metrics_is_same (eigrp_metric.c:134)
2141982-==2141982==    by 0x120360: eigrp_topology_update_distance (eigrp_topology.c:374)
2141982-==2141982==    by 0x124F01: eigrp_get_fsm_event (eigrp_fsm.c:284)
2141982-==2141982==    by 0x12519E: eigrp_fsm_event (eigrp_fsm.c:419)
2141982-==2141982==    by 0x1206A1: eigrp_topology_neighbor_down (eigrp_topology.c:518)
2141982-==2141982==    by 0x11AB3A: eigrp_nbr_delete (eigrp_neighbor.c:178)
2141982-==2141982==    by 0x124494: eigrp_finish_final (eigrpd.c:271)
2141982-==2141982==    by 0x1245A8: eigrp_finish (eigrpd.c:247)
2141982-==2141982==    by 0x124630: eigrp_terminate (eigrpd.c:240)
2141982-==2141982==    by 0x11344B: sigint (eigrp_main.c:112)
2141982-==2141982==    by 0x48F5F32: quagga_sigevent_process (sigevent.c:130)

Prevent this from happening.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agozebra: disallow resolution to duplicate nexthops
Stephen Worley [Wed, 27 Jan 2021 21:20:22 +0000 (16:20 -0500)]
zebra: disallow resolution to duplicate nexthops

Disallow the resolution to nexthops that are marked duplicate.
When we are resolving to an ecmp group, it's possible this
group has duplicates.

I found this when I hit a bug where we can have groups resolving
to each other and cause the resolved->next->next pointer to increase
exponentially. Sufficiently large ecmp and zebra will grind to a hault.

Like so:

```
D>  4.4.4.14/32 [150/0] via 1.1.1.1 (recursive), weight 1, 00:00:02
  *                       via 1.1.1.1, dummy1 onlink, weight 1, 00:00:02
                        via 4.4.4.1 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.2 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.3 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.4 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.5 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.6 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.7 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.8 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.9 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.10 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.11 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.12 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.13 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.15 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1 onlink, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1 onlink, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                        via 4.4.4.16 (recursive), weight 1, 00:00:02
                          via 1.1.1.1, dummy1 onlink, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
                          via 1.1.1.1, dummy1, weight 1, 00:00:02
D>  4.4.4.15/32 [150/0] via 1.1.1.1 (recursive), weight 1, 00:00:09
  *                       via 1.1.1.1, dummy1 onlink, weight 1, 00:00:09
                        via 4.4.4.1 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.2 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.3 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.4 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.5 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.6 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.7 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.8 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.9 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.10 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.11 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.12 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.13 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.14 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                        via 4.4.4.16 (recursive), weight 1, 00:00:09
                          via 1.1.1.1, dummy1 onlink, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
                          via 1.1.1.1, dummy1, weight 1, 00:00:09
D>  4.4.4.16/32 [150/0] via 1.1.1.1 (recursive), weight 1, 00:00:19
  *                       via 1.1.1.1, dummy1 onlink, weight 1, 00:00:19
                        via 4.4.4.1 (recursive), weight 1, 00:00:19
                          via 1.1.1.1, dummy1, weight 1, 00:00:19
                        via 4.4.4.2 (recursive), weight 1, 00:00:19

...............
................

and on...

```

You can repro the above via:

```
kernel routes:

1.1.1.1 dev dummy1 scope link

4.4.4.0/24 via 1.1.1.1 dev dummy1

==============================

config:

nexthop-group doof
 nexthop 1.1.1.1
 nexthop 4.4.4.1
 nexthop 4.4.4.10
 nexthop 4.4.4.11
 nexthop 4.4.4.12
 nexthop 4.4.4.13
 nexthop 4.4.4.14
 nexthop 4.4.4.15
 nexthop 4.4.4.16
 nexthop 4.4.4.2
 nexthop 4.4.4.3
 nexthop 4.4.4.4
 nexthop 4.4.4.5
 nexthop 4.4.4.6
 nexthop 4.4.4.7
 nexthop 4.4.4.8
 nexthop 4.4.4.9
!

===========================

Then use sharpd to install 4.4.4.16 -> 4.4.4.1 pointing to that nexthop
group in decending order.
```

With these changes it prevents the growing ecmp above by disallowing
duplicates to be in the resolution decision. These nexthops are not
installed anyways so why should we be resolving to them?

Signed-off-by: Stephen Worley <sworley@nvidia.com>
4 years agobgpd: Initialize bgp_notify.raw_data before passing to bgp_notify_receive()
Donatas Abraitis [Sun, 31 Jan 2021 14:20:36 +0000 (16:20 +0200)]
bgpd: Initialize bgp_notify.raw_data before passing to bgp_notify_receive()

```
2523558-==2523558==
2523558-==2523558== Conditional jump or move depends on uninitialised value(s)
2523558:==2523558==    at 0x47F242: bgp_notify_admin_message (bgp_debug.c:505)
2523558-==2523558==    by 0x47F242: bgp_notify_print (bgp_debug.c:534)
2523558-==2523558==    by 0x4BA9BC: bgp_notify_receive (bgp_packet.c:1905)
2523558-==2523558==    by 0x4BA9BC: bgp_process_packet (bgp_packet.c:2602)
2523558-==2523558==    by 0x4904B7E: thread_call (thread.c:1681)
2523558-==2523558==    by 0x48CAA27: frr_run (libfrr.c:1126)
2523558-==2523558==    by 0x474B1A: main (bgp_main.c:540)
2523558-==2523558==  Uninitialised value was created by a stack allocation
2523558:==2523558==    at 0x4BA33D: bgp_process_packet (bgp_packet.c:2529)
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agodoc: ebgp-requires-policy requires manuall session clearing
Donatas Abraitis [Thu, 28 Jan 2021 15:15:02 +0000 (17:15 +0200)]
doc: ebgp-requires-policy requires manuall session clearing

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agowatchfrr: fix SA warning
Rafael Zalamena [Tue, 26 Jan 2021 16:58:34 +0000 (13:58 -0300)]
watchfrr: fix SA warning

`valid_command` now causes static analyzer complaints since it no
longer assumes `optarg` is non-NULL. If this was the case then
`valid_command` would return `false` (or 0) because it would mean the
string is empty and doesn't contain the '%s' it expects.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agowatchfrr: fix crash on missing optional argument
Rafael Zalamena [Mon, 25 Jan 2021 11:33:01 +0000 (08:33 -0300)]
watchfrr: fix crash on missing optional argument

Fix `netns` command line handling for missing argument (it's optional).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agopimd: Prevent use after free
Donald Sharp [Tue, 26 Jan 2021 12:48:40 +0000 (07:48 -0500)]
pimd: Prevent use after free

Valgrind is reporting this:
==22220== Invalid read of size 4
==22220==    at 0x11DC2B: pim_if_delete (pim_iface.c:215)
==22220==    by 0x11DD71: pim_if_terminate (pim_iface.c:76)
==22220==    by 0x128E03: pim_instance_terminate (pim_instance.c:66)
==22220==    by 0x128E03: pim_vrf_delete (pim_instance.c:159)
==22220==    by 0x48E0010: vrf_delete (vrf.c:251)
==22220==    by 0x48E0010: vrf_delete (vrf.c:225)
==22220==    by 0x48E02FE: vrf_terminate (vrf.c:551)
==22220==    by 0x149495: pim_terminate (pimd.c:142)
==22220==    by 0x13C61B: pim_sigint (pim_signals.c:44)
==22220==    by 0x48CF862: quagga_sigevent_process (sigevent.c:103)
==22220==    by 0x48DD324: thread_fetch (thread.c:1404)
==22220==    by 0x48A926A: frr_run (libfrr.c:1122)
==22220==    by 0x11B85E: main (pim_main.c:167)
==22220==  Address 0x5912160 is 1,200 bytes inside a block of size 1,624 free'd
==22220==    at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==22220==    by 0x128E52: pim_instance_terminate (pim_instance.c:74)
==22220==    by 0x128E52: pim_vrf_delete (pim_instance.c:159)
==22220==    by 0x48E0010: vrf_delete (vrf.c:251)
==22220==    by 0x48E0010: vrf_delete (vrf.c:225)
==22220==    by 0x48F1353: zclient_vrf_delete (zclient.c:1896)
==22220==    by 0x48F1353: zclient_read (zclient.c:3511)
==22220==    by 0x48DD826: thread_call (thread.c:1585)
==22220==    by 0x48A925F: frr_run (libfrr.c:1123)
==22220==    by 0x11B85E: main (pim_main.c:167)
==22220==  Block was alloc'd at
==22220==    at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==22220==    by 0x48ADA4F: qcalloc (memory.c:110)
==22220==    by 0x128B9B: pim_instance_init (pim_instance.c:82)
==22220==    by 0x128B9B: pim_vrf_new (pim_instance.c:142)
==22220==    by 0x48E0C5A: vrf_get (vrf.c:217)
==22220==    by 0x48F13C9: zclient_vrf_add (zclient.c:1863)
==22220==    by 0x48F13C9: zclient_read (zclient.c:3508)
==22220==    by 0x48DD826: thread_call (thread.c:1585)
==22220==    by 0x48A925F: frr_run (libfrr.c:1123)
==22220==    by 0x11B85E: main (pim_main.c:167)

On pim vrf deletion, ensure that the vrf->info pointers are NULL as well
as the free'd pim pointer for ->vrf is NULL as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agodoc: Update bgp doc for more rfc-8212 talk
Donald Sharp [Thu, 21 Jan 2021 16:17:17 +0000 (11:17 -0500)]
doc: Update bgp doc for more rfc-8212 talk

The RFC 8212 changes keep being questioned.  Update the documentation
a bit more to help the end user figure it out themselves?

At the very least I can just now quote the doc link for this section
when someone asks the question.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agodocker: centos 7, 8 yang bump and repo fixes
Wesley Coakley [Wed, 20 Jan 2021 05:49:37 +0000 (00:49 -0500)]
docker: centos 7, 8 yang bump and repo fixes

Bump libyang version in centos containers to 1.0.184 and (1) change
"PowerTools" repository to "powertools" to accomodate CentOS Stream
changes

(1) https://bugs.centos.org/view.php?id=17920

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
4 years agodocker: prefer alpine:latest for building
Wesley Coakley [Wed, 20 Jan 2021 03:58:31 +0000 (22:58 -0500)]
docker: prefer alpine:latest for building

Building with alpine:edge caused some weirdness with our build
scripts, switching to the stable branch seems to have aleviated this.

We can also ditch the "edge" repositories as the main and community
repositories provide all packages we need

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
4 years agoMerge pull request #8092 from donaldsharp/7.5_track
Russ White [Tue, 16 Feb 2021 12:47:53 +0000 (07:47 -0500)]
Merge pull request #8092 from donaldsharp/7.5_track

[7.5]ospf6d: Track wait_timer and disable when needed

4 years agoMerge pull request #8090 from ton31337/fix/static_network_vrf_7.5
Donald Sharp [Tue, 16 Feb 2021 00:11:59 +0000 (19:11 -0500)]
Merge pull request #8090 from ton31337/fix/static_network_vrf_7.5

bgpd: [7.5] Check for peer->su_remote if not NULL when handling IPv6 nexthop

4 years agoospf6d: Track wait_timer and disable when needed 8092/head
Donald Sharp [Tue, 26 Jan 2021 13:10:49 +0000 (08:10 -0500)]
ospf6d: Track wait_timer and disable when needed

When removing ospfv3 from an interface that has been previously
put into wait state, there is a possible use after free of the
oi because the wait_timer could have been started for the interface.
This is because the wait_timer was not tracked by the interface
and we just created a thread for it without storing the thread
pointer.

Issue: #7932
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agobgpd: Check for peer->su_remote if not NULL when handling IPv6 nexthop 8090/head
Donatas Abraitis [Sun, 14 Feb 2021 15:49:19 +0000 (17:49 +0200)]
bgpd: Check for peer->su_remote if not NULL when handling IPv6 nexthop

```
(gdb) bt
0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
1  0x00007fe57ca4a42a in __GI_abort () at abort.c:89
2  0x00007fe57ddd1935 in core_handler (signo=6, siginfo=0x7ffc81067570, context=<optimized out>) at lib/sigevent.c:255
3  <signal handler called>
4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
5  0x00007fe57ca4a42a in __GI_abort () at abort.c:89
6  0x00007fe57ddd1935 in core_handler (signo=11, siginfo=0x7ffc81067e30, context=<optimized out>) at lib/sigevent.c:255
7  <signal handler called>
8  0x000055a7b25b923f in bgp_path_info_to_ipv6_nexthop (ifindex=ifindex@entry=0x7ffc810683c0, path=<optimized out>, path=<optimized out>) at bgpd/bgp_zebra.c:909
9  0x000055a7b25bb2e5 in bgp_zebra_announce (dest=dest@entry=0x55a7b5239c10, p=p@entry=0x55a7b5239c10, info=info@entry=0x55a7b5239cd0, bgp=bgp@entry=0x55a7b518b090, afi=afi@entry=AFI_IP6, safi=safi@entry=SAFI_UNICAST) at bgpd/bgp_zebra.c:1358
10 0x000055a7b256af6a in bgp_process_main_one (bgp=0x55a7b518b090, dest=0x55a7b5239c10, afi=AFI_IP6, safi=SAFI_UNICAST) at bgpd/bgp_route.c:2918
11 0x000055a7b256b0ee in bgp_process_wq (wq=<optimized out>, data=0x55a7b5221800) at bgpd/bgp_route.c:3027
12 0x00007fe57ddea2e0 in work_queue_run (thread=0x7ffc8106cd60) at lib/workqueue.c:291
13 0x00007fe57dde0781 in thread_call (thread=thread@entry=0x7ffc8106cd60) at lib/thread.c:1684
14 0x00007fe57dda84b8 in frr_run (master=0x55a7b48aaf00) at lib/libfrr.c:1126
15 0x000055a7b250a7da in main (argc=<optimized out>, argv=<optimized out>) at bgpd/bgp_main.c:540
(gdb)
```

This crashes with configs like:

```
router bgp 65534
 no bgp ebgp-requires-policy
 no bgp network import-check
 !
 address-family ipv6 unicast
  import vrf donatas <<<<<< Crashes when entering this command
 exit-address-family
!
router bgp 65534 vrf donatas
 no bgp ebgp-requires-policy
 no bgp network import-check
 neighbor fe80::c15a:ddab:1689:db86 remote-as 65025
 neighbor fe80::c15a:ddab:1689:db86 interface eth2
 neighbor fe80::c15a:ddab:1689:db86 update-source eth2
 neighbor fe80::c15a:ddab:1689:db86 capability extended-nexthop
 !
 address-family ipv6 unicast
  network 2a02:face::/32    <<<<<< Crashes due to static networks
  neighbor fe80::c15a:ddab:1689:db86 activate
 exit-address-family
!
```

Locally configured routes do not have peer->su_remote.

```
exit1-debian-9# show bgp ipv6 unicast
BGP table version is 3, local router ID is 192.168.100.1, vrf id 0
Default local pref 100, local AS 65534
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 2a02:abc::/64    fe80::c15a:ddab:1689:db86@5<
                                                           0 65025 i
   2a02:face::/32   ::@5<                    0         32768 i

Displayed  2 routes and 2 total paths
exit1-debian-9#

```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #8047 from pguibert6WIND/nhrp_shortcut_routes_75
Jafar Al-Gharaibeh [Wed, 10 Feb 2021 21:25:14 +0000 (15:25 -0600)]
Merge pull request #8047 from pguibert6WIND/nhrp_shortcut_routes_75

[7.5] nhrp: fix shortcut routes

4 years agoMerge pull request #8034 from qlyoung/fix-gnu-readline-bracketed-paste-7.5.1
Donatas Abraitis [Wed, 10 Feb 2021 09:01:24 +0000 (11:01 +0200)]
Merge pull request #8034 from qlyoung/fix-gnu-readline-bracketed-paste-7.5.1

vtysh: disable bracketed paste in readline [7.5.1]

4 years agonhrpd: replace nhrp route nexthop with onlink route when prefix=nh 8047/head
Philippe Guibert [Thu, 30 Jul 2020 16:16:16 +0000 (18:16 +0200)]
nhrpd: replace nhrp route nexthop with onlink route when prefix=nh

There are cases where nhrp wants to create a nhrp route to gre interface
with the nexthop which is the same the prefix. This is the case with
ipv6:

ipv6 route a:ff::ff:4/128 via a:ff::ff:4:/128 dev gre1

This route entry is false from zebra point of view, and to avoid that,
the nexthop is ignored in nhrp only if the prefix equals the nexthop.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
4 years agonhrpd: shortcut routes installed with nexthop.
Philippe Guibert [Thu, 23 Jul 2020 06:57:05 +0000 (08:57 +0200)]
nhrpd: shortcut routes installed with nexthop.

Previously, when a shortcut entry was created, its associated route was
created on system, with no nexthop, only gre device. eg:

[..]
N>* 192.168.2.0/24 [10/0] is directly connected, gre1, 00:01:04           <--- can not be resolved

[..]
Type     Prefix                   Via                      Identity
dynamic  192.168.2.0/24           10.255.255.2              <---- correct

This situation was forcing neighbor resolution on the first outgoing packet matching the route entry. for instance 192.168.2.1 could not be resolved at link layer, and was going to fail. Instead, nhrp nexthop should have been used.
This is what this commit intends to do, that is to say that when a
shortcut is installed by nhrp, the associated nexthop entry is used.

[..]
N>* 192.168.2.0/24 [10/0] via 10.255.255.2, gre1 onlink, 00:00:31

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
4 years agovtysh: disable bracketed paste in readline 8034/head
Quentin Young [Mon, 8 Feb 2021 01:15:24 +0000 (20:15 -0500)]
vtysh: disable bracketed paste in readline

GNU Readline 8.1 enables bracketed paste by default. This results in
newlines not ending the readline() call, which breaks the ability of
users to paste in configs to vtysh's interactive shell.

Disable bracketed paste.

Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
4 years agoMerge pull request #8018 from ton31337/fix/drop_aggregate_as_attribute_if_malformed_7.5
Donald Sharp [Fri, 5 Feb 2021 17:33:45 +0000 (12:33 -0500)]
Merge pull request #8018 from ton31337/fix/drop_aggregate_as_attribute_if_malformed_7.5

bgpd: [7.5] Drop aggregator_as attribute if malformed in case of BGP_AS_ZERO

4 years agobgpd: Unset only aggregator flag when AGGREGATOR_AS is 0 8018/head
Donatas Abraitis [Fri, 5 Feb 2021 14:47:55 +0000 (16:47 +0200)]
bgpd: Unset only aggregator flag when AGGREGATOR_AS is 0

Avoid mangling packet size which is expected to be the same as received.

Stream pointer advancing is necessary to avoid changing the packet and
reseting BGP sessions.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agobgpd: Drop aggregator_as attribute if malformed in case of BGP_AS_ZERO
Donatas Abraitis [Wed, 3 Feb 2021 12:58:23 +0000 (14:58 +0200)]
bgpd: Drop aggregator_as attribute if malformed in case of BGP_AS_ZERO

An UPDATE message that contains the AS number of zero in the AS_PATH
   or AGGREGATOR attribute MUST be considered as malformed and be
   handled by the procedures specified in [RFC7606].

An UPDATE message with a malformed AGGREGATOR attribute SHALL be
   handled using the approach of "attribute discard".

Attribute discard: In this approach, the malformed attribute MUST
      be discarded and the UPDATE message continues to be processed.
      This approach MUST NOT be used except in the case of an attribute
      that has no effect on route selection or installation.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #8005 from opensourcerouting/snap-libyang1-fix-75
Donald Sharp [Wed, 3 Feb 2021 14:18:30 +0000 (09:18 -0500)]
Merge pull request #8005 from opensourcerouting/snap-libyang1-fix-75

[7.5] Snap libyang1 fix

4 years agosnapcraft: Update rtrlib to 0.7.0 8005/head
Martin Winter [Thu, 7 Jan 2021 01:16:19 +0000 (02:16 +0100)]
snapcraft: Update rtrlib to 0.7.0

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
4 years agosnapcraft: Fix passthrough path for Libyang 1.x
Martin Winter [Thu, 7 Jan 2021 01:14:52 +0000 (02:14 +0100)]
snapcraft: Fix passthrough path for Libyang 1.x

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
4 years agoMerge pull request #7977 from ton31337/fix/allowas_in_reset_value_7.5
Donald Sharp [Fri, 29 Jan 2021 12:09:05 +0000 (07:09 -0500)]
Merge pull request #7977 from ton31337/fix/allowas_in_reset_value_7.5

bgpd: [7.5] Removing "neighbor <peer-group> allowas-in"

4 years agobgpd: Removing "neighbor <peer-group> allowas-in" 7977/head
Kishore Kunal [Thu, 28 Jan 2021 05:26:24 +0000 (05:26 +0000)]
bgpd: Removing "neighbor <peer-group> allowas-in"

Unconfig not resetting the peer-group member allowas_in[afi][safi]
This is causing remote route to be accept.

Signed-off-by: Kishore Kunal <kishorekunal01@broadcom.com>
4 years agoMerge pull request #7962 from ton31337/fix/bgpd_validate_community_7.5
Donald Sharp [Thu, 28 Jan 2021 14:17:17 +0000 (09:17 -0500)]
Merge pull request #7962 from ton31337/fix/bgpd_validate_community_7.5

bgpd: [7.5] community and large-community validation fixes

4 years agobgpd: separate lcommunity validation from tokenizer 7962/head
Wesley Coakley [Tue, 5 Jan 2021 09:22:57 +0000 (04:22 -0500)]
bgpd: separate lcommunity validation from tokenizer

`lcommunity_gettoken` expects a space-delimeted list of 0 or more large
communities. `lcommunity_list_valid` can perform this check.
`lcommunity_list_valid` now validates large community lists more
accurately based on the following condition: Each quantity in a standard bgp
large community must:

1. Contain at least one digit
2. Fit within 4 octets
3. Contain only digits unless the lcommunity is "expanded"
4. Contain a valid regex if the lcommunity is "expanded"

Moreover we validate that each large community list contains exactly 3
such values separated by a single colon each.

One quirk of our validation which is worth documenting is:

```
bgp large-community-list standard test2 permit 1:c:3
bgp large-community-list expanded test1 permit 1:c:3
```

The first line will throw an error complaining about a "malformed community-list
value". The second line will be accepted because the each value is each treated as
a regex when matching large communities, it simply will never match anything so
it's rather useless.

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
4 years agobgpd: Validate community list if they are not malformed
Donatas Abraitis [Wed, 30 Dec 2020 21:02:03 +0000 (23:02 +0200)]
bgpd: Validate community list if they are not malformed

Before fix:
```
root@exit1-debian-9:~/frr# /usr/local/bin/vtysh  -c 'c' -c 'route-map test permit 10' -c 'set community 65535:429496723296'
root@exit1-debian-9:~/frr#

root@exit1-debian-9:~/frr# vtysh -c 'c' -c 'bgp community-list standard test permit 65535:4294967296'
root@exit1-debian-9:~/frr#

root@exit1-debian-9:~/frr# /usr/local/bin/vtysh  -c 'c' -c 'route-map test permit 10' -c 'set community 65535'
root@exit1-debian-9:~/frr# /usr/local/bin/vtysh  -c 'c' -c 'route-map test permit 10' -c 'set community 65535:'
% Malformed communities attribute
```

After fix:
```
root@exit1-debian-9:~/frr# /usr/local/bin/vtysh  -c 'c' -c 'route-map test permit 10' -c 'set community 65535:4294967296'
% Malformed communities attribute

root@exit1-debian-9:~/frr# vtysh -c 'c' -c 'bgp community-list standard test permit 65535:4294967299'
% Malformed community-list value

root@exit1-debian-9:~/frr# /usr/local/bin/vtysh  -c 'c' -c 'route-map test permit 10' -c 'set community 65535:'
% Malformed communities attribute
root@exit1-debian-9:~/frr# /usr/local/bin/vtysh  -c 'c' -c 'route-map test permit 10' -c 'set community 65535'
% Malformed communities attribute
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #7912 from idryzhov/7.5-backports-2021-01
Donald Sharp [Fri, 22 Jan 2021 20:49:29 +0000 (15:49 -0500)]
Merge pull request #7912 from idryzhov/7.5-backports-2021-01

7.5 backports

4 years agobgpd : multiple memory leak fixes in show commands 7912/head
Sarita Patra [Tue, 12 Jan 2021 10:46:35 +0000 (02:46 -0800)]
bgpd : multiple memory leak fixes in show commands

Issue: bgpd got kill due to out of memory, when show bgp
neighbor json and show ip bgp neighbor <ip> routes json
commands executed multiple times in a setup having 320554
routes.

RCA: Heap allocated for bgpd keeps increasing. This is verified
using top command and show memory command.

Memleak Fix-1: show ip bgp route json command
When dumping a large bit of table data via bgp_show_route
and if there is no information to display for a particular
struct bgp_node *` the data allocated via json_object_new_array()
is not freed. This is resolved now.

Memleak Fix-2:
The function bgp_peer_counts() doesn't free the memory allocated for
json_loop when there is No such neighbor or address family. This is
fixed now.

Signed-off-by: Sarita Patra <saritap@vmware.com>
4 years agotools: fix frr-reload BFD profile support
Rafael Zalamena [Tue, 19 Jan 2021 11:49:23 +0000 (08:49 -0300)]
tools: fix frr-reload BFD profile support

Fix the handling of multiple BFD profiles by adding the appropriated
code to push/pop contexts inside BFD configuration node.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agoospfd: fix area removal at interface level
ckishimo [Wed, 2 Dec 2020 08:06:55 +0000 (00:06 -0800)]
ospfd: fix area removal at interface level

Areas created via interface command are not being deleted when
executing the command `no ip ospf area x`

With the following configuration:
!
interface eth1
 ip address 10.0.12.2/24
 ip ospf area 0.0.0.100
!
router ospf
!

r2# sh ip ospf
 OSPF Routing Process, Router ID: 2.2.2.2
 Supports only single TOS (TOS0) routes
 ....
 Number of opaque AS LSA 0. Checksum Sum 0x00000000
 Number of areas attached to this router: 1     <--- ***
 Area ID: 0.0.0.100                             <--- ***
   Shortcutting mode: Default, S-bit consensus: ok
   Number of interfaces in this area: Total: 1, Active: 1
   Number of fully adjacent neighbors in this area: 0
   Area has no authentication
   Number of full virtual adjacencies going through this area: 0
   SPF algorithm executed 1 times
   Number of LSA 1
   Number of router LSA 1. Checksum Sum 0x0000f3d4
   Number of network LSA 0. Checksum Sum 0x00000000
   Number of summary LSA 0. Checksum Sum 0x00000000
   Number of ASBR summary LSA 0. Checksum Sum 0x00000000
   Number of NSSA LSA 0. Checksum Sum 0x00000000
   Number of opaque link LSA 0. Checksum Sum 0x00000000
   Number of opaque area LSA 0. Checksum Sum 0x00000000

However when removing the area from the interface, the command
above displays the same information

r2# conf t
r2(config)# int eth1
r2(config-if)# no ip ospf area 0.0.0.100
r2(config-if)# exit
r2(config)# exit

r2# sh ip ospf
 OSPF Routing Process, Router ID: 2.2.2.2
 Supports only single TOS (TOS0) routes
 ....
 Number of opaque AS LSA 0. Checksum Sum 0x00000000
 Number of areas attached to this router: 1       <--- ***
 Area ID: 0.0.0.100                               <--- ***
   Shortcutting mode: Default, S-bit consensus: ok
   Number of interfaces in this area: Total: 0, Active: 0
   Number of fully adjacent neighbors in this area: 0
   Area has no authentication
   Number of full virtual adjacencies going through this area: 0
   SPF algorithm executed 2 times
   Number of LSA 1
   Number of router LSA 1. Checksum Sum 0x0000e26e
   Number of network LSA 0. Checksum Sum 0x00000000
   Number of summary LSA 0. Checksum Sum 0x00000000
   Number of ASBR summary LSA 0. Checksum Sum 0x00000000
   Number of NSSA LSA 0. Checksum Sum 0x00000000
   Number of opaque link LSA 0. Checksum Sum 0x00000000
   Number of opaque area LSA 0. Checksum Sum 0x00000000

r2# sh run
!
interface eth1
 ip address 10.0.12.2/24
!
router ospf
!
end

This PR removes the area when executing `no ip ospf area` command

r2# sh ip ospf
 OSPF Routing Process, Router ID: 2.2.2.2
 Supports only single TOS (TOS0) routes
 ....
 Number of opaque AS LSA 0. Checksum Sum 0x00000000
 Number of areas attached to this router: 0

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
4 years agobfdd: update vrf of received packet
Philippe Guibert [Fri, 8 Jan 2021 09:38:04 +0000 (09:38 +0000)]
bfdd: update vrf of received packet

on vrf-lite environment, all incoming bfd packets are received by the
same socket on the default namespace. the vrfid is not relevant and
needs to be updated based on the incoming interface where traffic has
been received. If the traffic is received from an interface belonging to
a separate vrf, update the vrfid value accordingly.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
4 years agobfdd: enable bfd session if vrf interface available
Philippe Guibert [Fri, 8 Jan 2021 09:34:20 +0000 (09:34 +0000)]
bfdd: enable bfd session if vrf interface available

The vrf interface notification and interface notifications are separated
on zapi interface between the system (zebra daemon) and other daemons
(bfd for instance). In the case of bfd, the initial code was waiting for
vrf notification to create the socket. Actually, in vrf-lite world, we
need to wait the vrf interface to be present, in order to create the
socket and bind to the vrf interface (this is the usual way to work with
vrf-lite).
On bfd, the changes consist in delaying the socket creation first, then
when interface is created, check the interface name presence instead of
checking the interface configuration.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
4 years agobfdd: socket should be bound to vrf interface by default
Philippe Guibert [Fri, 8 Jan 2021 07:51:33 +0000 (07:51 +0000)]
bfdd: socket should be bound to vrf interface by default

When running in vrf-lite mode, the socket used in a vrf environment
should be bound to an interface belonging to the vrf. If no one is
selected, then the vrf interface itself should be bound to that socket,
so that outgoing packets are being applied routing rules for that vrf.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
4 years agobgpd: Allow peer-groups to have `ttl-security hops` configured
Donald Sharp [Fri, 15 Jan 2021 13:14:49 +0000 (08:14 -0500)]
bgpd: Allow peer-groups to have `ttl-security hops` configured

The command `neighbor PGROUP ttl-security hops X` was being
accepted but ignored.  Allow it to be stored.  I am still
not sure that this is applied correctly, but that is another
problem.

Fixes: #7848
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agoconfigure.ac: Correct library name for sysrepo
Bo Zhang [Sat, 16 Jan 2021 05:38:18 +0000 (21:38 -0800)]
configure.ac: Correct library name for sysrepo

Northbound_sysrepo: Correct sysrepo library name in configure.ac

Signed-off-by: Bo Zhang <logbob0401@gmail.com>
4 years agobgpd: Handle IPv6 prefixes with IPv4 nexthops for zebra
Donatas Abraitis [Fri, 4 Dec 2020 15:37:36 +0000 (17:37 +0200)]
bgpd: Handle IPv6 prefixes with IPv4 nexthops for zebra

Prevent from crashing as well here:

```
(gdb) bt
0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
1  0x00007ff54ec5242a in __GI_abort () at abort.c:89
2  0x00007ff54ffb1dd5 in core_handler (signo=11, siginfo=0x7fff189328f0, context=<optimized out>) at lib/sigevent.c:255
3  <signal handler called>
4  update_ipv6nh_for_route_install (api_nh=0x7fff1893309c, is_evpn=<optimized out>, best_pi=0x55c18854f220,
    pi=0x55c18854f220, ifindex=0, nexthop=0x0, nh_bgp=0x55c18850db20, nh_othervrf=<optimized out>) at bgpd/bgp_zebra.c:1099
5  bgp_zebra_announce (dest=dest@entry=0x55c188553020, p=p@entry=0x55c188553020, info=info@entry=0x55c18854f220,
    bgp=bgp@entry=0x55c18850db20, afi=afi@entry=AFI_IP6, safi=safi@entry=SAFI_UNICAST) at bgpd/bgp_zebra.c:1381
6  0x000055c1858ffa3a in bgp_process_main_one (bgp=0x55c18850db20, dest=0x55c188553020, afi=AFI_IP6, safi=SAFI_UNICAST)
    at bgpd/bgp_route.c:2908
7  0x000055c1858ffbbe in bgp_process_wq (wq=<optimized out>, data=0x55c1885550a0) at bgpd/bgp_route.c:3017
8  0x00007ff54ffca560 in work_queue_run (thread=0x7fff189373e0) at lib/workqueue.c:291
9  0x00007ff54ffc0a91 in thread_call (thread=thread@entry=0x7fff189373e0) at lib/thread.c:1681
10 0x00007ff54ff8b978 in frr_run (master=0x55c187caaed0) at lib/libfrr.c:1110
11 0x000055c1858a165b in main (argc=6, argv=0x7fff18937648) at bgpd/bgp_main.c:523
```

```
5  bgp_zebra_announce (dest=dest@entry=0x55c188553020, p=p@entry=0x55c188553020, info=info@entry=0x55c18854f220,
    bgp=bgp@entry=0x55c18850db20, afi=afi@entry=AFI_IP6, safi=safi@entry=SAFI_UNICAST) at bgpd/bgp_zebra.c:1381
        ifindex = 0
        nexthop = 0x0
        nh_weight = 0
```

Reproduce:

```
~# echo "announce route 2a02:4780:1::abdc/128 next-hop 192.168.0.2" > /run/exabgp.in
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agozebra: zebra route-map delay-timer is global not per vrf
Donald Sharp [Wed, 6 Jan 2021 16:29:43 +0000 (11:29 -0500)]
zebra: zebra route-map delay-timer is global not per vrf

The zebra route-map delay timer value is a global value
not a per vrf change.  As such we should only print it
out one time.

We are seeing this:

zebra route-map delay-timer 33
 exit-vrf
zebra route-map delay-timer 33

When we have 2 vrf's configured.

Fix the code to only write it out for the default vrf

Ticket: CM-32888
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agobgpd: Fix default-originate clearing from peer-groups.
zyxwvu Shi [Tue, 5 Jan 2021 06:15:07 +0000 (06:15 +0000)]
bgpd: Fix default-originate clearing from peer-groups.

Fix `peer_default_originate_unset` so default route can be withdrawn
when `default-originate` option is being unset from a peer-group.

The loop calling `bgp_default_originate` is clearing default-originate
from the peer-group peer `peer` instead of the peer-group member peer
`member`.

Signed-off-by: zyxwvu Shi <shiyuchen.syc@bytedance.com>
4 years agoisisd: When last area address is removed, resign if we were DR
Karen Schoener [Tue, 5 Jan 2021 21:27:32 +0000 (16:27 -0500)]
isisd: When last area address is removed, resign if we were DR

When last area address is removed, resign if we were DR.

This fixes an issue where: when the ISIS area address is changed, ISIS fails
to elect a new DR.

Signed-off-by: Karen Schoener <karen@voltanet.io>
4 years agovrrpd.yang bug fix: modify augment path to comply with rfc 7950
Bo Zhang [Sun, 3 Jan 2021 01:31:16 +0000 (17:31 -0800)]
vrrpd.yang bug fix: modify augment path to comply with rfc 7950

Signed-off-by: Bo Zhang <logbob0401@gmail.com>
4 years agoospfd: fix no show database output when selecting vrf
Louis Scalbert [Thu, 24 Dec 2020 13:41:31 +0000 (14:41 +0100)]
ospfd: fix no show database output when selecting vrf

No output when selecting a vrf
frr# show ip ospf vrf default database router adv-router 10.125.0.1
VRF Name: default

       OSPF Router with ID (10.125.0.1)

In comparison with:
frr# show ip ospf database router adv-router 10.125.0.1

       OSPF Router with ID (10.125.0.1)

                Router Link States (Area 0.0.0.0)

  LS age: 155
  Options: 0x2  : *|-|-|-|-|-|E|-
(...)

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
4 years agoospf6d: ospfv3 disable on the interface, but interface prefix still shown in the...
Yash Ranjan [Tue, 1 Dec 2020 06:21:04 +0000 (22:21 -0800)]
ospf6d: ospfv3 disable on the interface, but interface prefix still shown in the output

When the ospfv3 interface is disabled by the command "no interface <eth> area <area-id>
the linked interface prefixes does not get flushed

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
4 years agoospf6d: Link LSA is not updated when router priority is modified
Mobashshera Rasool [Mon, 14 Dec 2020 07:45:47 +0000 (07:45 +0000)]
ospf6d: Link LSA is not updated when router priority is modified

Issue: #7727

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
4 years agobgpd: fix evpn route-map vni filter at origin
Chirag Shah [Thu, 10 Dec 2020 21:59:56 +0000 (13:59 -0800)]
bgpd: fix evpn route-map vni filter at origin

evpn route-map match (filter) on vni is not working
at the origin of the routes.

evpn match vni route checks for encap type as vxlan.
the source route attribute is not set with vxlan encap
thus the match filter wouldn't work.

Ticket:CM-32554
Reviewed By:CCR-11056
Testing Done:

At source have match vni plus set statement in route-map.
Validate the origin of the route's outbound correctly sets
the 'set' statment based on match vni filter.

At origin:
route-map RM-EVPN-TE-Matches permit 10
 match evpn vni 4001
  set large-community 10:10:119

Receiving end:

Route [5]:[0]:[24]:[78.41.1.0] VNI 4001
5550
  27.0.0.15 from TORS1(downlink-5) (27.0.0.15)
    Origin incomplete, metric 0, valid, external, bestpath-from-AS 5550, best (First path received)
    Extended Community: RT:5550:4001 ET:8 Rmac:00:02:00:00:00:4d
    Large Community: 10:10:119    <--- Large community stamped
    Last update: Thu Dec 10 22:19:26 2020

Signed-off-by: Chirag Shah <chirag@nvidia.com>
4 years agoMerge pull request #7877 from vishaldhingra/static_7_5
Mark Stapp [Fri, 15 Jan 2021 21:21:11 +0000 (16:21 -0500)]
Merge pull request #7877 from vishaldhingra/static_7_5

[7.5] staticd: correct table-id handling for static routes

4 years agostaticd: Backend cofiguration code to fix table-id problem 7877/head
vdhingra [Fri, 15 Jan 2021 18:43:28 +0000 (10:43 -0800)]
staticd: Backend cofiguration code to fix table-id problem

problem: table-id gets overwritten for a given route.

RCA: table-id was getting overwritten from the NB layer,
     So route was getting installed with the latest table-id.

Fix: make the table-id as the key in the NB layer.
     This will program the route in zebra correctly.

- Removed the table-id modify callbacks.
- Moved the validate and apply table-id changes to path-list creation

issue #7347

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
4 years agostaticd: autogenerated code modifications due to yang changes
vdhingra [Fri, 15 Jan 2021 18:42:23 +0000 (10:42 -0800)]
staticd: autogenerated code modifications due to yang changes

updated callback methods based on autogenerated code.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
4 years agostaticd: make table-id as the key for path-list
vdhingra [Fri, 15 Jan 2021 18:41:11 +0000 (10:41 -0800)]
staticd: make table-id as the key for path-list

modified the yang model for path-list.
table-id should be a key, as one route can have
multiple table-ids.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>
4 years agoMerge pull request #7778 from mjstapp/fix_rnh_default_7_5
Donatas Abraitis [Tue, 22 Dec 2020 07:25:33 +0000 (09:25 +0200)]
Merge pull request #7778 from mjstapp/fix_rnh_default_7_5

[7.5] zebra: nht resolve-via-default doesn't need force

4 years agozebra: nht resolve-via-default doesn't need force 7778/head
Mark Stapp [Mon, 21 Dec 2020 15:10:40 +0000 (10:10 -0500)]
zebra: nht resolve-via-default doesn't need force

We don't need to use the 'force' flag when processing the
resolve-via-default clis for ip and ipv6: we can just do normal
nht processing. [7.5 version]

Signed-off-by: Mark Stapp <mjs@voltanet.io>
4 years agoMerge pull request #7771 from donaldsharp/7.5_rm_fix
Donatas Abraitis [Sun, 20 Dec 2020 19:05:18 +0000 (21:05 +0200)]
Merge pull request #7771 from donaldsharp/7.5_rm_fix

[7.5]lib: Fix dependency of match types in route-map code

4 years agolib: Fix dependency of match types in route-map code 7770/head 7771/head
Donald Sharp [Fri, 18 Dec 2020 19:22:09 +0000 (14:22 -0500)]
lib: Fix dependency of match types in route-map code

Route-maps contain a hash of hash's that contain the
container type name ( say community or access list or whatever )
and then it has a hash of route-maps that this maps too

Suppose you have this:

!
frr version 7.3.1
frr defaults traditional
hostname eva
log stdout
!
debug route-map
!
router bgp 239
 neighbor 192.168.161.2 remote-as external
 !
 address-family ipv4 unicast
  neighbor 192.168.161.2 route-map foo in
 exit-address-family
!
bgp community-list standard 7000:40002 permit 7000:40002
bgp community-list standard 7000:40002 permit 7000:40003
!
route-map foo deny 20
 match community 7000:40002
!
route-map foo permit 10
!
line vty
!
end

You have a community hash which has an

7000:40002 entry

This entry has a hash of routemaps that are referencing it.  In this above
example it would have `foo` as the single entry.

Given the above config if you do this:

eva# conf
eva(config)# route-map foo deny 20
eva(config-route-map)# match community 7000:4003
eva(config-route-map)#

We would expect the `7000:40002` community hash to no longer have
a reference to the `foo` routemap.  Instead we see the code doing this:

2020/12/18 13:47:12 BGP: bgpd 7.3.1 starting: vty@2605, bgp@<all>:179
2020/12/18 13:47:47 BGP: Add route-map foo
2020/12/18 13:47:47 BGP: Route-map foo add sequence 10, type: permit
2020/12/18 13:47:57 BGP: Route-map foo add sequence 20, type: deny
2020/12/18 13:48:05 BGP: Adding dependency for filter 7000:40002 in route-map foo
2020/12/18 13:48:05 BGP: route_map_print_dependency: Dependency for 7000:40002: foo
2020/12/18 13:48:41 BGP: bgp_update_receive: rcvd End-of-RIB for IPv4 Unicast from 192.168.161.2 in vrf default
2020/12/18 13:49:19 BGP: Deleting dependency for filter 7000:4003 in route-map foo
2020/12/18 13:49:19 BGP: Adding dependency for filter 7000:4003 in route-map foo
2020/12/18 13:49:19 BGP: route_map_print_dependency: Dependency for 7000:4003: foo

Note how the code attempts to remove the dependency for `7000:4003` instead of the
dependency for `7000:40002`.  Then we create a new hash for `7000:4003` and then
install the routemap name in it.

This is wrong.  We should remove the `7000:40002` dependency and then install
a dependency for `7000:4003`.

Fix the code to do the right thing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agoMerge pull request #7710 from opensourcerouting/75-acl-compat-fix
Mark Stapp [Tue, 15 Dec 2020 17:33:10 +0000 (12:33 -0500)]
Merge pull request #7710 from opensourcerouting/75-acl-compat-fix

[7.5] lib: restore previous access/prefix list behaviour

4 years agoMerge pull request #7732 from deastoe/dplane-fpm-routes-stuck-in-queued_7.5
Russ White [Tue, 15 Dec 2020 12:20:34 +0000 (07:20 -0500)]
Merge pull request #7732 from deastoe/dplane-fpm-routes-stuck-in-queued_7.5

[7.5] Routes stuck with 'q' flag when dplane_fpm_nl is in use

4 years agoMerge pull request #7609 from wesleycoakley/apline-docker-fix-for-75
Russ White [Tue, 15 Dec 2020 12:09:09 +0000 (07:09 -0500)]
Merge pull request #7609 from wesleycoakley/apline-docker-fix-for-75

[7.5] Port Alpine / Docker build fix

4 years agozebra: routes stuck with 'q' when using dplane FPM 7732/head
Duncan Eastoe [Fri, 11 Dec 2020 11:07:59 +0000 (11:07 +0000)]
zebra: routes stuck with 'q' when using dplane FPM

New work enqueued to the dplane_fpm_nl provider is initially de-queued
and re-enqueued, in fpm_nl_process(), to be processed by the provider's
own thread.

After performing this initial de-queue/enqueue we return to
dplane_thread_loop() and check the dplane_fpm_nl output queue for any
work which has been completed.

Since this work is being processed in another thread it is very likely
that there will be some (or all) work still outstanding at this point.
The dataplane thread finishes up any other tasks and then waits until
it is next scheduled. In the meantime the dplane_fpm_nl thread is
processing its work queue until completion.

The issue arises here as the dataplane thread is not explicitly
re-scheduled once dplane_fpm_nl has drained its work queue and
populated its output queue with completed work.

This completed work can sit in the output queue for an indeterminate
period of time, depending upon when the dataplane thread is next
scheduled for other work. If the RIB has reached a stable state then
this could be a significant period of time. During this period zebra
marks these routes as queued, even though they have actually been
processed by all dataplane providers.

An un-related RIB change which triggers a FIB update will result in
the dataplane thread being scheduled and this completed work then
being processed. At this point the routes will then no longer be
marked as queued by zebra. However this new FIB update might itself
then fall victim to the same scenario!

We can observe the above behaviour in these detailed dplane logs.

    11:24:47 zebra[7282]: dplane: incoming new work counter: 2
    11:24:47 zebra[7282]: dplane enqueues 2 new work to provider 'Kernel'
    11:24:47 zebra[7282]: dplane provider 'Kernel': processing
    11:24:47 zebra[7282]: Dplane NEIGH_DISCOVER, ip 192.168.2.2, ifindex 9
    11:24:47 zebra[7282]: Dplane NEIGH_DISCOVER, ip 192.168.2.2, ifindex 9
    11:24:47 zebra[7282]: dplane dequeues 2 completed work from provider Kernel
    11:24:47 zebra[7282]: dplane enqueues 2 new work to provider 'dplane_fpm_nl'
    11:24:47 zebra[7282]: dplane dequeues 1 completed work from provider dplane_fpm_nl
    11:24:47 zebra[7282]: dplane has 1 completed, 0 errors, for zebra main

2 contexts (all incoming work) have been queued to dplane_fpm_nl - all good.
1 completed context was de-queued, so there is outstanding work.

    11:24:58 zebra[7282]: dplane: incoming new work counter: 2
    11:24:58 zebra[7282]: dplane enqueues 2 new work to provider 'Kernel'
    11:24:58 zebra[7282]: dplane provider 'Kernel': processing
    11:24:58 zebra[7282]: ID (193) Dplane nexthop update ctx 0x55c429b6fed0 op NH_INSTALL
    11:24:58 zebra[7282]: 0:5.5.5.5/32 Dplane route update ctx 0x55c429b79690 op ROUTE_INSTALL
    11:24:58 zebra[7282]: dplane dequeues 2 completed work from provider Kernel
    11:24:58 zebra[7282]: dplane enqueues 2 new work to provider 'dplane_fpm_nl'
    11:24:58 zebra[7282]: dplane dequeues 2 completed work from provider dplane_fpm_nl
    11:24:58 zebra[7282]: dplane has 2 completed, 0 errors, for zebra main

A further 2 contexts (all incoming work) have been queued to dplane_fpm_nl - all good.
2 completed contexts were de-queued, which sounds good as that is what we en-queued.
However, there is an outstanding context from earlier, so there is still outstanding
work.

Indeed the new 5.5.5.5/32 route is marked as queued:

    O>q 5.5.5.5/32 [110/10] via 192.168.2.2, dp0p1s3, weight 1, 00:01:19

This remains the case until we trigger a FIB update by installation of the
(eg.) 10.10.10.10/32 route:

    11:26:41 zebra[7282]: dplane: incoming new work counter: 2
    11:26:41 zebra[7282]: dplane enqueues 2 new work to provider 'Kernel'
    11:26:41 zebra[7282]: dplane provider 'Kernel': processing
    11:26:41 zebra[7282]: ID (195) Dplane nexthop update ctx 0x55c429b78ce0 op NH_INSTALL
    11:26:41 zebra[7282]: 0:10.10.10.10/32 Dplane route update ctx 0x55c429b7a040 op ROUTE_INSTALL
    11:26:41 zebra[7282]: dplane dequeues 2 completed work from provider Kernel
    11:26:41 zebra[7282]: dplane enqueues 2 new work to provider 'dplane_fpm_nl'
    11:26:41 zebra[7282]: dplane dequeues 2 completed work from provider dplane_fpm_nl
    11:26:41 zebra[7282]: dplane has 2 completed, 0 errors, for zebra main
    11:26:41 zebra[7282]: zebra2proto: Please add this protocol(2) to proper rt_netlink.c handling
    11:26:41 zebra[7282]: Nexthop dplane ctx 0x55c429b6fed0, op NH_INSTALL, nexthop ID (193), result SUCCESS
    11:26:41 zebra[7282]: default(0:254):5.5.5.5/32 Processing dplane result ctx 0x55c429b79690, op ROUTE_INSTALL result SUCCESS

We observe the same 2 enqueues and 2 dequeues as before, which again suggests
that there is outstanding work.

As expected, the 5.5.5.5/32 route is no longer marked as queued:

    O>* 5.5.5.5/32 [110/10] via 192.168.2.2, dp0p1s3, weight 1, 00:02:06

But the 10.10.10.10/32 route is, as we have not yet processed the completed
context:

    C>q 10.10.10.10/32 is directly connected, lo, 00:26:05

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
(cherry picked from commit 164d8e86081fdf33992b6c45af446bac6103e20c)

4 years agozebra: dplane API to get provider output q length
Duncan Eastoe [Fri, 11 Dec 2020 11:03:53 +0000 (11:03 +0000)]
zebra: dplane API to get provider output q length

Returns the current number of (completed) contexts in the provider's
output queue (dp_ctx_out_q), allowing access to this data from the
provider itself.

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
(cherry picked from commit 53706b4e5114e18a68ad3ab2a4cd9ca9433e4cb2)

4 years agodplane_fpm_nl: queue peak counter never increments
Duncan Eastoe [Fri, 11 Dec 2020 10:26:54 +0000 (10:26 +0000)]
dplane_fpm_nl: queue peak counter never increments

The context queue length peak counter is always set to its current
value, hence never increments.

Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
(cherry picked from commit 7545bda0a4b0114c6d73552fdbdce016f58572c0)

4 years agoMerge pull request #7714 from ranjanyash54/2371_7.5
Donald Sharp [Sat, 12 Dec 2020 01:59:12 +0000 (20:59 -0500)]
Merge pull request #7714 from ranjanyash54/2371_7.5

ospf6d: [7.5]Fix the prefix walking for show database command for intra-prefix and link

4 years agoMerge pull request #7715 from idryzhov/7.5-backports-again
Donald Sharp [Sat, 12 Dec 2020 01:41:01 +0000 (20:41 -0500)]
Merge pull request #7715 from idryzhov/7.5-backports-again

7.5 backports

4 years agozebra: anticipate zns creation at vrf creation when backend is vrf-lite 7715/head
Philippe Guibert [Tue, 8 Dec 2020 11:11:05 +0000 (11:11 +0000)]
zebra: anticipate zns creation at vrf creation when backend is vrf-lite

in the case the namespace pointer is already available, feed it at vrf
creation. this prevents from crashing if the netlink parsing already
began, and the vrf-lite is not enabled yet.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
4 years agobgpd: local routes use non-default distance
Chirag Shah [Wed, 9 Dec 2020 05:04:50 +0000 (21:04 -0800)]
bgpd: local routes use non-default distance

Use user provided AD for local routes (aggregate).

 address-family ipv4 unicast
  distance bgp 20 200 210
  network 47.2.2.8/30
  aggregate-address 51.1.0.0/16

Testing Done:

Before aggr route uses default 200 AD even user provided local AD.
B>* 51.1.0.0/16 [200/0] unreachable (blackhole), weight 1, 00:01:14

After:
B>* 51.1.0.0/16 [210/0] unreachable (blackhole), weight 1, 00:00:01

Signed-off-by: Chirag Shah <chirag@nvidia.com>
4 years agoospf6d: Fix for "show ipv6 ospf6 database link" 7714/head
Yash Ranjan [Fri, 11 Dec 2020 05:19:55 +0000 (21:19 -0800)]
ospf6d: Fix for "show ipv6 ospf6 database link"

Some prefixes were not shown in the link database
show command, due to issues with pointer calculation.

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
4 years agoospf6d: Fix for "show ipv6 ospf6 database intra-prefix"
Yash Ranjan [Fri, 11 Dec 2020 05:16:37 +0000 (21:16 -0800)]
ospf6d: Fix for "show ipv6 ospf6 database intra-prefix"

Some prefixes were not shown in the intra-prefix database
show command, due to issues with pointer calculation.

Signed-off-by: Yash Ranjan <ranjany@vmware.com>
4 years agolib: prevent libyang abstraction memory leak 7710/head
Rafael Zalamena [Wed, 9 Dec 2020 12:57:28 +0000 (09:57 -0300)]
lib: prevent libyang abstraction memory leak

Call `ly_set_free()` on `YANG_ITER_STOP` as well.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 4e32d023cdf9fc5326b09ea6aa16d465bc948147)

4 years agolib: silently ignore duplicated values
Rafael Zalamena [Mon, 7 Dec 2020 15:10:42 +0000 (12:10 -0300)]
lib: silently ignore duplicated values

Keep the previous CLI behavior of silently ignoring access lists which
contain the same value.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 866f48f2df2e9de260080f31edbde9f17622fc03)

4 years agolib: disallow prefix list duplicated values
Rafael Zalamena [Mon, 7 Dec 2020 15:08:44 +0000 (12:08 -0300)]
lib: disallow prefix list duplicated values

Don't allow users to create multiple entries in the same list with the
same value to keep the behavior previously to northbound migration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 54d153f7864c8197d883cbaafe55bddf940a6db0)

4 years agolib: silently ignore duplicated values
Rafael Zalamena [Fri, 4 Dec 2020 21:12:58 +0000 (18:12 -0300)]
lib: silently ignore duplicated values

Keep the previous CLI behavior of silently ignoring access lists which
contain the same value.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 208dc372cd1069ab0a9efee2815b04481934f856)

4 years agolib: disallow access list duplicated values
Rafael Zalamena [Fri, 4 Dec 2020 21:11:45 +0000 (18:11 -0300)]
lib: disallow access list duplicated values

Don't allow users to create multiple rules in the same list with the
same value to keep the behavior previously to northbound migration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit f414129b0ce109550bd3a61f6020d7a9af6f9c35)

4 years agoMerge pull request #7701 from mjstapp/fix_ospfd_finish_sa_7_5
Donald Sharp [Wed, 9 Dec 2020 21:47:54 +0000 (16:47 -0500)]
Merge pull request #7701 from mjstapp/fix_ospfd_finish_sa_7_5

ospfd: clean up SA (7.5 version)

4 years agoisisd: fix null pointer dereference when parsing LSP
Renato Westphal [Thu, 3 Dec 2020 15:19:06 +0000 (12:19 -0300)]
isisd: fix null pointer dereference when parsing LSP

In some extraordinary circumstances an LSP might not have any
TLV. Add a null check to prevent a crash when that happens.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
4 years agofrr-reload: ignore-case in the es-id and es-sys-mac config comparisons
Anuradha Karuppiah [Thu, 19 Nov 2020 22:15:44 +0000 (14:15 -0800)]
frr-reload: ignore-case in the es-id and es-sys-mac config comparisons

MAC address can be configured as lower/upper hex characters but is
always rendered as lower case in "show run". Avoid incorrect "change
detection" by ignoring case.

Ticket: CM-32235

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
4 years agofrr-reload: fixup ipv6 address normalization
Anuradha Karuppiah [Thu, 19 Nov 2020 19:59:35 +0000 (11:59 -0800)]
frr-reload: fixup ipv6 address normalization

The condition to normalize ipv6 addresses was accidentally broken via -
[
e238920df07be0b61e483f0a58e0b99ab3d2e0ea tools: Fix reload with 'ipv6 address...' in interface
]

The condition was supposed to be skipped only if "ipv6 add" was present
in the line.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
4 years agobgpd: Let's actually track if the nh was updated
Donald Sharp [Fri, 4 Dec 2020 13:01:31 +0000 (08:01 -0500)]
bgpd: Let's actually track if the nh was updated

In bgp_zebra_announce when iterating over multipath
we were checking to ensure that the nexthop was updated
but never initially clearing the nh_updated variable.
Thus leading to a situation where we could crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agoospfd: Restore POINTOMULTIPOINT to working order
Donald Sharp [Sat, 28 Nov 2020 20:35:18 +0000 (15:35 -0500)]
ospfd: Restore POINTOMULTIPOINT to working order

Commit: 1d376ff539508f336cb5872c5592b780e3db180b removed
the code to find nexthops for the POINTOMULTIPOINT and
replaced it with a generic bit of code that was
supposed to handle both POINTOPOINT and POINTOMULTIPOINT
the problem is that the ospf rfc states that the
network mask on point to multipoint should be /32
which will not allow you to properly do a prefix match
on it against the network.

Restore original behavior as much as possible and leave
the new POINTOPOINT code alone.

Fixes: #7624
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agoospfd: Set Curr_mtu to when we get the mtu
Donald Sharp [Tue, 1 Dec 2020 20:37:03 +0000 (15:37 -0500)]
ospfd: Set Curr_mtu to when we get the mtu

Currently if you start ospfd, bring up neighbors and then issue
a tcpdump on a interface ospf is peering over, this causes the neighbor
relationship to be restarted:

root@spectrum301(mlx-4600c-01):mgmt:~# tcpdump -i vlan402
2020-11-13T21:25:38.059671+00:00 spectrum301 ospfd[29953]: AdjChg: Nbr 202.0.0.3(default) on vlan402:200.0.3.1: Full -> Deleted (KillNbr)
2020-11-13T21:25:38.065520+00:00 spectrum301 ospfd[29953]: ospfTrapNbrStateChange: trap sent: 200.0.3.2 now Deleted/DROther
2020-11-13T21:25:38.065922+00:00 spectrum301 ospfd[29953]: ospfTrapIfStateChange: trap sent: 200.0.3.1 now Down
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on vlan402, link-type EN10MB (Ethernet), capture size 262144 bytes
21:25:38.072330 IP 200.0.3.1 > igmp.mcast.net: igmp v3 report, 1 group record(s)
2020-11-13T21:25:38.080430+00:00 spectrum301 ospfd[29953]: ospfTrapIfStateChange: trap sent: 200.0.3.1 now Point-To-Point
2020-11-13T21:25:38.080654+00:00 spectrum301 ospfd[29953]: SPF Processing Time(usecs): 9734
2020-11-13T21:25:38.080829+00:00 spectrum301 ospfd[29953]:             SPF Time: 6422
2020-11-13T21:25:38.080991+00:00 spectrum301 ospfd[29953]:            InterArea: 1572
2020-11-13T21:25:38.081152+00:00 spectrum301 ospfd[29953]:                Prune: 67
2020-11-13T21:25:38.081329+00:00 spectrum301 ospfd[29953]:         RouteInstall: 1396
2020-11-13T21:25:38.081548+00:00 spectrum301 ospfd[29953]: Reason(s) for SPF: N, S, ABR, ASBR
21:25:38.092510 IP 200.0.3.1 > ospf-all.mcast.net: OSPFv2, Hello, length 44

This is happening because the curr_mtu is not being properly stored.  It was being set
on interface creation( but we have not actually read in the mtu part of the interface data, so
it is still 0 ).

Modify the code to store the curr_mtu at a point in interface creation *After* we have read
in interface data.

Ticket: CM-32276
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agozebra: fix show ip route vrf X summary
Emanuele Di Pascale [Tue, 1 Dec 2020 17:24:46 +0000 (18:24 +0100)]
zebra: fix show ip route vrf X summary

The lookup for non default VRFs was always using a tableId; if not
provided, we were defaulting to RT_TABLE_MAIN. This is fine for the
default VRF but not for others. As a result, the command was silently
failing for non-default VRFs unless we also specified the correct tableId.

Fix this by only performing the lookup using the tableId if it is
provided; else use zebra_vrf_table.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
4 years agoMerge pull request #7698 from mjstapp/fix_zebra_writen_7_5
Donald Sharp [Wed, 9 Dec 2020 19:19:58 +0000 (14:19 -0500)]
Merge pull request #7698 from mjstapp/fix_zebra_writen_7_5

zebra: [7.5] use zserv_send_message instead of writen

4 years agoospfd: clean up SA (7.5 version) 7701/head
Mark Stapp [Wed, 9 Dec 2020 17:31:41 +0000 (12:31 -0500)]
ospfd: clean up SA (7.5 version)

Clean up a dead initialization in ospf_finish_final().

Signed-off-by: Mark Stapp <mjs@voltanet.io>
4 years agozebra: use zserv_send_message instead of writen 7698/head
Mark Stapp [Wed, 9 Dec 2020 14:17:25 +0000 (09:17 -0500)]
zebra: use zserv_send_message instead of writen

Following functions is using writen to dispatch message
into socket, but another function uses zserv_send_message.
This commit does tiny unification for zapi's socket messaging.

Funcs:
- zsend_assign_label_chunk_response()
- zsend_label_manager_connect_response()

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
Signed-off-by: Mark Stapp <mjs@voltanet.io>
4 years agoMerge pull request #7672 from idryzhov/7.5-bfd-fix-session-lookup
Rafael Zalamena [Mon, 7 Dec 2020 13:09:46 +0000 (10:09 -0300)]
Merge pull request #7672 from idryzhov/7.5-bfd-fix-session-lookup

[7.5] bfd: fix session lookup

4 years agobfd: fix session lookup 7672/head
Igor Ryzhov [Fri, 4 Dec 2020 11:37:36 +0000 (14:37 +0300)]
bfd: fix session lookup

local-address is optional for both IPv4 and IPv6.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
4 years agoMerge pull request #7654 from idryzhov/7.5-ospf-init-instance
Donald Sharp [Wed, 2 Dec 2020 13:53:53 +0000 (08:53 -0500)]
Merge pull request #7654 from idryzhov/7.5-ospf-init-instance

[7.5] ospf: fix instance initialization when using multi-instance mode

4 years agoospf: fix instance initialization when using multi-instance mode 7654/head
Igor Ryzhov [Wed, 2 Dec 2020 00:36:10 +0000 (03:36 +0300)]
ospf: fix instance initialization when using multi-instance mode

OSPF instance initialization was moved from "router ospf" vty command to
ospf_get function some time ago but the same thing must be done in
ospf_get_instance function used when multi-instance mode is enabled.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
4 years agoMerge pull request #7616 from idryzhov/more-7.5-backports
Donald Sharp [Mon, 30 Nov 2020 12:48:41 +0000 (07:48 -0500)]
Merge pull request #7616 from idryzhov/more-7.5-backports

[7.5] backport fixes

4 years agoMerge pull request #7622 from idryzhov/7.5-fix-cisco-access-list
Rafael Zalamena [Mon, 30 Nov 2020 12:17:19 +0000 (09:17 -0300)]
Merge pull request #7622 from idryzhov/7.5-fix-cisco-access-list

[7.5] yang: fix cisco access list source value

4 years agoyang: fix cisco access list source value 7622/head
Igor Ryzhov [Fri, 27 Nov 2020 18:53:25 +0000 (21:53 +0300)]
yang: fix cisco access list source value

Source value must be a choice between host, network and any, not a set
of all three.

Fixes #7599.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
4 years agoldpd: Prevent usage after free 7616/head
Donald Sharp [Thu, 26 Nov 2020 23:23:57 +0000 (18:23 -0500)]
ldpd: Prevent usage after free

error 26-Nov-2020 14:35:02 ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55cefae977e9 bp 0x7ffdd3546860 sp 0x7ffdd3546850
error 26-Nov-2020 14:35:02 READ of size 4 at 0x631000024838 thread T0
error 26-Nov-2020 14:35:02     #0 0x55cefae977e8 in ldpe_imsg_compose_parent_sync ldpd/ldpe.c:256
error 26-Nov-2020 14:35:02     #1 0x55cefae9ab13 in vlog ldpd/log.c:53
error 26-Nov-2020 14:35:02     #2 0x55cefae9b21f in log_info ldpd/log.c:102
error 26-Nov-2020 14:35:02     #3 0x55cefae96eae in ldpe_shutdown ldpd/ldpe.c:237
error 26-Nov-2020 14:35:02     #4 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585
error 26-Nov-2020 14:35:02     #5 0x55cefaf93875 in thread_call lib/thread.c:1681
error 26-Nov-2020 14:35:02     #6 0x55cefae97304 in ldpe ldpd/ldpe.c:136
error 26-Nov-2020 14:35:02     #7 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error 26-Nov-2020 14:35:02     #8 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 26-Nov-2020 14:35:02     #9 0x55cefae525e9 in _start (/usr/lib/frr/ldpd+0xb35e9)
error 26-Nov-2020 14:35:02
error 26-Nov-2020 14:35:02 0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860)
error 26-Nov-2020 14:35:02 freed by thread T0 here:
error 26-Nov-2020 14:35:02     #0 0x7f4ef21e37a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
error 26-Nov-2020 14:35:02     #1 0x55cefae96e91 in ldpe_shutdown ldpd/ldpe.c:234
error 26-Nov-2020 14:35:02     #2 0x55cefae99254 in ldpe_dispatch_main ldpd/ldpe.c:585
error 26-Nov-2020 14:35:02     #3 0x55cefaf93875 in thread_call lib/thread.c:1681
error 26-Nov-2020 14:35:02     #4 0x55cefae97304 in ldpe ldpd/ldpe.c:136
error 26-Nov-2020 14:35:02     #5 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error 26-Nov-2020 14:35:02     #6 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 26-Nov-2020 14:35:02
error 26-Nov-2020 14:35:02 previously allocated by thread T0 here:
error 26-Nov-2020 14:35:02     #0 0x7f4ef21e3d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
error 26-Nov-2020 14:35:02     #1 0x55cefae9725d in ldpe ldpd/ldpe.c:127
error 26-Nov-2020 14:35:02     #2 0x55cefae5a2e2 in main ldpd/ldpd.c:322
error 26-Nov-2020 14:35:02     #3 0x7f4ef0c33b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

Clean this problem up in the same way as the previous commit

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agoldpd: Prevent usage after free
Donald Sharp [Wed, 25 Nov 2020 12:36:43 +0000 (07:36 -0500)]
ldpd: Prevent usage after free

We are using data after it has been freed and handed back to the
OS.
Address Sanitizer output:

error 23-Nov-2020 18:53:57 ERROR: AddressSanitizer: heap-use-after-free on address 0x631000024838 at pc 0x55f825998f58 bp 0x7fffa5b0f5b0 sp 0x7fffa5b0f5a0
error 23-Nov-2020 18:53:57 READ of size 4 at 0x631000024838 thread T0
error 23-Nov-2020 18:53:57     #0 0x55f825998f57 in lde_imsg_compose_parent_sync ldpd/lde.c:226
error 23-Nov-2020 18:53:57     #1 0x55f8259ca9ed in vlog ldpd/log.c:48
error 23-Nov-2020 18:53:57     #2 0x55f8259cb1c8 in log_info ldpd/log.c:102
error 23-Nov-2020 18:53:57     #3 0x55f82599e841 in lde_shutdown ldpd/lde.c:208
error 23-Nov-2020 18:53:57     #4 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666
error 23-Nov-2020 18:53:57     #5 0x55f825ac3815 in thread_call lib/thread.c:1681
error 23-Nov-2020 18:53:57     #6 0x55f825998d5e in lde ldpd/lde.c:160
error 23-Nov-2020 18:53:57     #7 0x55f82598a289 in main ldpd/ldpd.c:320
error 23-Nov-2020 18:53:57     #8 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 23-Nov-2020 18:53:57     #9 0x55f825982579 in _start (/usr/lib/frr/ldpd+0xb3579)
error 23-Nov-2020 18:53:57
error 23-Nov-2020 18:53:57 0x631000024838 is located 65592 bytes inside of 65632-byte region [0x631000014800,0x631000024860)
error 23-Nov-2020 18:53:57 freed by thread T0 here:
error 23-Nov-2020 18:53:57     #0 0x7fe3f8a4d7a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
error 23-Nov-2020 18:53:57     #1 0x55f82599e830 in lde_shutdown ldpd/lde.c:206
error 23-Nov-2020 18:53:57     #2 0x55f8259a2703 in lde_dispatch_parent ldpd/lde.c:666
error 23-Nov-2020 18:53:57     #3 0x55f825ac3815 in thread_call lib/thread.c:1681
error 23-Nov-2020 18:53:57     #4 0x55f825998d5e in lde ldpd/lde.c:160
error 23-Nov-2020 18:53:57     #5 0x55f82598a289 in main ldpd/ldpd.c:320
error 23-Nov-2020 18:53:57     #6 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 23-Nov-2020 18:53:57
error 23-Nov-2020 18:53:57 previously allocated by thread T0 here:
error 23-Nov-2020 18:53:57     #0 0x7fe3f8a4dd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
error 23-Nov-2020 18:53:57     #1 0x55f825998cb7 in lde ldpd/lde.c:151
error 23-Nov-2020 18:53:57     #2 0x55f82598a289 in main ldpd/ldpd.c:320
error 23-Nov-2020 18:53:57     #3 0x7fe3f749db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
error 23-Nov-2020 18:53:57

The fix is to put this in global space.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
4 years agoisisd: check vertex type before checking its data
Renato Westphal [Fri, 20 Nov 2020 22:26:45 +0000 (19:26 -0300)]
isisd: check vertex type before checking its data

vertex->N is an union whose "id" and "ip" fields are only valid
depending on the vertex type (IS adjacency or IP reachability
information). As such, add a vertex type check before consulting
vertex->N.id in order to prevent unexpected behavior from happening.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
4 years agoisisd: fix some crashes with --tcli
Renato Westphal [Fri, 6 Nov 2020 13:02:16 +0000 (10:02 -0300)]
isisd: fix some crashes with --tcli

The "ifp" variable returned by nb_running_get_entry() might be
NULL when using the transactional CLI mode. Make the required
modifications to avoid null pointer dereferences.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
4 years agobgpd: sh running config is not considering values provided via -e for max-paths
vdhingra [Thu, 19 Nov 2020 12:46:39 +0000 (04:46 -0800)]
bgpd: sh running config is not considering values provided via -e for max-paths

problem
1. run the bgp with -e1 option
2. c t
   router bgp 100
3. show running config
    !
     address-family ipv6 multicast
      maximum-paths 1
      maximum-paths ibgp 1
     exit-address-family
    !
address families should not dump maximum-paths if there
value is same as value provided at run time.

fix
if the maxpaths_ebgp value is same as multipath_num global
object, don't dump maximum-paths.

Signed-off-by: vishaldhingra <vdhingra@vmware.com>