]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
4 years agobgpd: fix large route-distinguisher's format
Hiroki Shirokura [Sun, 5 Jan 2020 13:56:14 +0000 (22:56 +0900)]
bgpd: fix large route-distinguisher's format

This commit is about #5629 's issue.
Before this commit, bgpd creates format string of
bgp-route-distinguisher as int32, but correctly format
is uint32. current bgpd's sh-run-cli generate int32 rd,
so if user sets the rd as 1:4294967295(0x1:0xffffffff),
sh-run cli generates 1: -1 as running-config. This
commit fix that issue.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
4 years agoMerge pull request #5575 from ton31337/fix/no_bgp_listen_range_peer-group_7.2
Quentin Young [Fri, 20 Dec 2019 15:37:37 +0000 (10:37 -0500)]
Merge pull request #5575 from ton31337/fix/no_bgp_listen_range_peer-group_7.2

bgpd: [7.2] Make sure we can use `no bgp listen range ...`

4 years agobgpd: Make sure we can use `no bgp listen range ...`
Donatas Abraitis [Thu, 19 Dec 2019 20:09:47 +0000 (22:09 +0200)]
bgpd: Make sure we can use `no bgp listen range ...`

Fixes:
```
exit1-debian-9(config-router)# no bgp listen range 192.168.10.0/24 peer-group TEST
% Peer-group does not exist
exit1-debian-9(config-router)#
```
Closes https://github.com/FRRouting/frr/issues/5570

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #5562 from mjstapp/fix_test_typelist_7_2
Quentin Young [Thu, 19 Dec 2019 16:00:50 +0000 (11:00 -0500)]
Merge pull request #5562 from mjstapp/fix_test_typelist_7_2

[7.2] tests: fix endian bug in test_typelist

4 years agotests: fix endian bug in test_typelist
Mark Stapp [Wed, 18 Dec 2019 15:52:08 +0000 (10:52 -0500)]
tests: fix endian bug in test_typelist

[7.2 version] Fix a byte-swapping bug that appeared on
big-endian arch but wasn't visible on little-endian.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
4 years agoMerge pull request #5518 from mjstapp/fix_evpn_state_7_2
Donald Sharp [Tue, 10 Dec 2019 22:14:46 +0000 (17:14 -0500)]
Merge pull request #5518 from mjstapp/fix_evpn_state_7_2

[7.2] zebra: use correct state when installing evpn macs

4 years agozebra: use correct state when installing evpn macs
Mark Stapp [Tue, 10 Dec 2019 15:10:56 +0000 (10:10 -0500)]
zebra: use correct state when installing evpn macs

[7.2 version] Use correct state/flags when installing EVPN macs;
when we converted from raw netlink to the zebra dataplane, a
state value got lost.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
4 years agoMerge pull request #5505 from m-varasteh/fix-if_update_to_new_vrf
Renato Westphal [Mon, 9 Dec 2019 13:32:53 +0000 (10:32 -0300)]
Merge pull request #5505 from m-varasteh/fix-if_update_to_new_vrf

lib: set entry to xpath in if_update_to_new_vrf

4 years agolib: set entry to xpath in if_update_to_new_vrf
Mahdi Varasteh [Sun, 8 Dec 2019 13:03:14 +0000 (16:33 +0330)]
lib: set entry to xpath in if_update_to_new_vrf

when vrf is changed, we change the interface running configuration
without using northbound layer. it causes the nb_running_get_entry to fail

Signed-off-by: Mahdi Varasteh <mahdy.varasteh@gmail.com>
4 years agoMerge pull request #5480 from mjstapp/fix_dplane_prov_flags_7_2
Jafar Al-Gharaibeh [Fri, 6 Dec 2019 05:01:41 +0000 (23:01 -0600)]
Merge pull request #5480 from mjstapp/fix_dplane_prov_flags_7_2

[7.2] zebra: capture dplane plugin flags

4 years agozebra: capture dplane plugin flags
Mark Stapp [Thu, 5 Dec 2019 21:33:51 +0000 (16:33 -0500)]
zebra: capture dplane plugin flags

[7.2 version]
The flags can be important - like "threaded" - so we need to
actually capture them when plugins are registered.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
4 years agoMerge pull request #5469 from k0ste/stable_7.2_backports
Donald Sharp [Wed, 4 Dec 2019 19:13:13 +0000 (14:13 -0500)]
Merge pull request #5469 from k0ste/stable_7.2_backports

[7.2] bgpd: Autocomplete neighbor for clear bgp

4 years agobgpd: Autocomplete neighbor for clear bgp
Donatas Abraitis [Wed, 27 Nov 2019 19:44:46 +0000 (21:44 +0200)]
bgpd: Autocomplete neighbor for clear bgp

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
(cherry picked from commit 453c92f6e2a981d024ec3433e804c02bd70f2a13)

4 years ago[7.2]bgpd: Prevent crash in bgp_table_range_lookup (#5454)
David Lamparter [Wed, 4 Dec 2019 00:48:37 +0000 (01:48 +0100)]
[7.2]bgpd: Prevent crash in bgp_table_range_lookup (#5454)

[7.2]bgpd: Prevent crash in bgp_table_range_lookup

Co-authored-by: Mark Stapp <mjs@voltanet.io>
4 years agoospfd,eigrpd: don't take address of packed struct member
Mark Stapp [Mon, 11 Nov 2019 17:22:38 +0000 (12:22 -0500)]
ospfd,eigrpd: don't take address of packed struct member

Use a local variable to avoid trying to take the address
of a packed struct member - an address from the ip header
in these cases.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
4 years agobgpd: Prevent crash in bgp_table_range_lookup
Donald Sharp [Mon, 2 Dec 2019 14:37:47 +0000 (09:37 -0500)]
bgpd: Prevent crash in bgp_table_range_lookup

The function bgp_table_range_lookup attempts to walk down
the table node data structures to find a list of matching
nodes.  We need to guard against the current node from
not matching and not having anything in the child nodes.
Add a bit of code to guard against this.

Traceback that lead me down this path:

Nov 24 12:22:38 frr bgpd[20257]: Received signal 11 at 1574616158 (si_addr 0x2, PC 0x46cdc3); aborting...
Nov 24 12:22:38 frr bgpd[20257]: Backtrace for 11 stack frames:
Nov 24 12:22:38 frr bgpd[20257]: /lib64/libfrr.so.0(zlog_backtrace_sigsafe+0x67) [0x7fd1ad445957]
Nov 24 12:22:38 frr bgpd[20257]: /lib64/libfrr.so.0(zlog_signal+0x113) [0x7fd1ad445db3]1ad445957]
Nov 24 12:22:38 frr bgpd[20257]: /lib64/libfrr.so.0(+0x70e65) [0x7fd1ad465e65]ad445db3]1ad445957]
Nov 24 12:22:38 frr bgpd[20257]: /lib64/libpthread.so.0(+0xf5f0) [0x7fd1abd605f0]45db3]1ad445957]
Nov 24 12:22:38 frr bgpd[20257]: /usr/lib/frr/bgpd(bgp_table_range_lookup+0x63) [0x46cdc3]445957]
Nov 24 12:22:38 frr bgpd[20257]: /usr/lib64/frr/modules/bgpd_rpki.so(+0x4f0d) [0x7fd1a934ff0d]57]
Nov 24 12:22:38 frr bgpd[20257]: /lib64/libfrr.so.0(thread_call+0x60) [0x7fd1ad4736e0]934ff0d]57]
Nov 24 12:22:38 frr bgpd[20257]: /lib64/libfrr.so.0(frr_run+0x128) [0x7fd1ad443ab8]e0]934ff0d]57]
Nov 24 12:22:38 frr bgpd[20257]: /usr/lib/frr/bgpd(main+0x2e3) [0x41c043]1ad443ab8]e0]934ff0d]57]
Nov 24 12:22:38 frr bgpd[20257]: /lib64/libc.so.6(__libc_start_main+0xf5) [0x7fd1ab9a5505]f0d]57]
Nov 24 12:22:38 frr bgpd[20257]: /usr/lib/frr/bgpd() [0x41d9bb]main+0xf5) [0x7fd1ab9a5505]f0d]57]
Nov 24 12:22:38 frr bgpd[20257]: in thread bgpd_sync_callback scheduled from bgpd/bgp_rpki.c:351#012; aborting...
Nov 24 12:22:38 frr watchfrr[6779]: [EC 268435457] bgpd state -> down : read returned EOF
Nov 24 12:22:38 frr zebra[5952]: [EC 4043309116] Client 'bgp' encountered an error and is shutting down.
Nov 24 12:22:38 frr zebra[5952]: zebra/zebra_ptm.c:1345 failed to find process pid registration
Nov 24 12:22:38 frr zebra[5952]: client 15 disconnected. 0 bgp routes removed from the rib

I am not really 100% sure what we are really trying to do with this function, but we must
guard against child nodes not having any data.

Fixes: #5440
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agoMerge pull request #5447 from donaldsharp/7.2_bgp_show_json_mem_leak
Donatas Abraitis [Mon, 2 Dec 2019 07:59:37 +0000 (09:59 +0200)]
Merge pull request #5447 from donaldsharp/7.2_bgp_show_json_mem_leak

[7.2]bgpd: Fix memory leak in json output of show commands

4 years agobgpd: Fix memory leak in json output of show commands
Donald Sharp [Sun, 1 Dec 2019 14:29:32 +0000 (09:29 -0500)]
bgpd: Fix memory leak in json output of show commands

When dumping a large bit of table data via bgp_show_table
and if there is no information to display for a particular
`struct bgp_node *` the data allocated via json_object_new_array()
is leaked.  Not a big deal on small tables but if you have a full
bgp feed and issue a show command that does not match any of
the route nodes ( say `vtysh -c "show bgp ipv4 large-community-list FOO"`)
then we will leak memory.

Before code change and issuing the above show bgp large-community-list command 15-20 times:
Memory statistics for bgpd:
System allocator statistics:
  Total heap allocated:  > 2GB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  > 2GB
  Free small blocks:     31 MiB
  Free ordinary blocks:  616 KiB
  Ordinary blocks:       0
  Small blocks:          0
  Holding blocks:        0

After:

Memory statistics for bgpd:
System allocator statistics:
  Total heap allocated:  924 MiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  558 MiB
  Free small blocks:     26 MiB
  Free ordinary blocks:  340 MiB
  Ordinary blocks:       0
  Small blocks:          0
  Holding blocks:        0

Please note the 340mb of free ordinary blocks is from the fact I issued a
`show bgp ipv4 uni json` command and generated a large amount of data.

Fixes: #5445
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agoMerge pull request #5391 from opensourcerouting/bfd-vrf-fix
Donald Sharp [Thu, 21 Nov 2019 15:00:32 +0000 (10:00 -0500)]
Merge pull request #5391 from opensourcerouting/bfd-vrf-fix

[7.2] bfdd: fix multiple VRF handling

4 years agoMerge pull request #5392 from ton31337/fix/update_rib_on_bgp_distance_changes_7.2
Donald Sharp [Thu, 21 Nov 2019 14:59:08 +0000 (09:59 -0500)]
Merge pull request #5392 from ton31337/fix/update_rib_on_bgp_distance_changes_7.2

bgpd: [7.2] Reflect the distance in RIB when it is changed for an arbitrary afi/safi

4 years agoMerge pull request #5395 from ton31337/fix/send_BGP_NOTIFY_CEASE_PEER_UNCONFIG_after_...
Donald Sharp [Thu, 21 Nov 2019 14:57:48 +0000 (09:57 -0500)]
Merge pull request #5395 from ton31337/fix/send_BGP_NOTIFY_CEASE_PEER_UNCONFIG_after_no_neighbor_7.2

 bgpd: [7.2] Notify "Peer De-configured" after entering 'no neighbor <neighbor> cmd'

4 years agobgpd: Notify "Peer De-configured" after entering 'no neighbor <neighbor> cmd'
Donatas Abraitis [Tue, 5 Nov 2019 12:33:31 +0000 (14:33 +0200)]
bgpd: Notify "Peer De-configured" after entering 'no neighbor <neighbor> cmd'

Before changes:

~# vtysh -c 'show ip bgp neighbors 192.168.0.2 json' | \
jq '."192.168.0.2".lastNotificationReason'
null

After changes:

~# vtysh -c 'show ip bgp neighbors 192.168.0.2 json' | \
jq '."192.168.0.2".lastNotificationReason'
"Cease/Peer Unconfigured"

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agotests: Test if `distance bgp (1-255) (1-255) (1-255)` works
Donatas Abraitis [Thu, 31 Oct 2019 09:17:45 +0000 (11:17 +0200)]
tests: Test if `distance bgp (1-255) (1-255) (1-255)` works

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agobgpd: Reflect the distance in RIB when it is changed for an arbitrary afi/safi
Donatas Abraitis [Thu, 31 Oct 2019 07:53:18 +0000 (09:53 +0200)]
bgpd: Reflect the distance in RIB when it is changed for an arbitrary afi/safi

debian-9# show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [20/0] via 192.168.0.1, eth1, 00:15:22
debian-9# conf
debian-9(config)# router bgp 100
debian-9(config-router)# address-family ipv4
debian-9(config-router-af)# distance bgp 123 123 123
debian-9(config-router-af)# do show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [123/0] via 192.168.0.1, eth1, 00:00:09
debian-9(config-router-af)# no distance bgp
debian-9(config-router-af)# do show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [20/0] via 192.168.0.1, eth1, 00:00:02
debian-9(config-router-af)#

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #5387 from donaldsharp/7.2_cherrys
Donatas Abraitis [Wed, 20 Nov 2019 18:36:41 +0000 (20:36 +0200)]
Merge pull request #5387 from donaldsharp/7.2_cherrys

[7.2] cherrys

4 years agobfdd: fix multiple VRF handling
Rafael Zalamena [Wed, 20 Nov 2019 18:10:10 +0000 (15:10 -0300)]
bfdd: fix multiple VRF handling

Use the interface VRF information instead of relying on the VRF specific
socket information.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agopimd: fix bsm buflen check to include pim hdr
Quentin Young [Wed, 20 Nov 2019 02:47:40 +0000 (21:47 -0500)]
pimd: fix bsm buflen check to include pim hdr

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
4 years agopimd: Various buffer overflow reads and crashes
Donald Sharp [Wed, 20 Nov 2019 00:36:19 +0000 (19:36 -0500)]
pimd: Various buffer overflow reads and crashes

A variety of buffer overflow reads and crashes
that could occur if you fed bad info into pim.

1) When type is setup incorrectly we were printing the first 8 bytes
of the pim_parse_addr_source, but the min encoding length is
4 bytes.  As such we will read beyond end of buffer.

2) The RP(pim, grp) macro can return a NULL value
Do not automatically assume that we can deref
the data.

3) BSM parsing was not properly sanitizing data input from wire
and we could enter into situations where we would read beyond
the end of the buffer.  Prevent this from happening, we are
probably left in a bad way.

4) The received bit length cannot be greater than 32 bits,
refuse to allow it to happen.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agopimd: Fix possible read beyond end of data received
Donald Sharp [Tue, 19 Nov 2019 13:22:50 +0000 (08:22 -0500)]
pimd: Fix possible read beyond end of data received

If a register packet is received that is less than the PIM_MSG_REGISTER_LEN
in size we can have a possible situation where the data being
checksummed is just random data from the buffer we read into.

2019/11/18 21:45:46 warnings: PIM: int pim_if_add_vif(struct interface *, _Bool, _Bool): could not get address for interface fuzziface ifindex=0
==27636== Invalid read of size 4
==27636==    at 0x4E6EB0D: in_cksum (checksum.c:28)
==27636==    by 0x4463CC: pim_pim_packet (pim_pim.c:194)
==27636==    by 0x40E2B4: main (pim_main.c:117)
==27636==  Address 0x771f818 is 0 bytes after a block of size 24 alloc'd
==27636==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==27636==    by 0x40E261: main (pim_main.c:112)
==27636==

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agozebra: Router Advertisement socket mess up
Donald Sharp [Tue, 19 Nov 2019 20:46:42 +0000 (15:46 -0500)]
zebra: Router Advertisement socket mess up

The code for when a new vrf is created to properly handle
router advertisement for it is messed up in several ways:

1) Generation of the zrouter data structure should set the rtadv
socket to -1 so that we don't accidently close someone elses
open file descriptor
2) When you created a new zvrf instance *after* bootup we are XCALLOC'ing
the data structure so the zvrf->fd was 0.  The shutdown code was looking
for the >= 0 to know if the fd existed (since fd 0 is valid!)

This sequence of events would cause zebra to consume 100% of the
cpu:

Run zebra by itself ( no other programs )
ip link add vrf1 type vrf table 1003
ip link del vrf vrf1
vtysh -c "configure" -c "no interface vrf1"

This commit fixes this issue.

Fixes: #5376
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agoMerge pull request #5374 from opensourcerouting/snap-vrrpd-7.2
Donald Sharp [Tue, 19 Nov 2019 22:47:24 +0000 (17:47 -0500)]
Merge pull request #5374 from opensourcerouting/snap-vrrpd-7.2

snapcraft: Add vrrpd to the snapcraft package [7.2]

4 years agosnapcraft: Add vrrpd to the snapcraft package
Martin Winter [Sat, 9 Nov 2019 15:27:04 +0000 (16:27 +0100)]
snapcraft: Add vrrpd to the snapcraft package

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
4 years agoMerge pull request #5365 from ton31337/fix/addpath_total_peer_update_7.2
Donald Sharp [Tue, 19 Nov 2019 12:41:17 +0000 (07:41 -0500)]
Merge pull request #5365 from ton31337/fix/addpath_total_peer_update_7.2

bgpd: [7.2] Fix per afi/safi addpath peer counting

4 years agobgpd: Fix per afi/safi addpath peer counting
Mitch Skiba [Thu, 14 Nov 2019 19:28:23 +0000 (19:28 +0000)]
bgpd: Fix per afi/safi addpath peer counting

The total_peercount table was created as a short cut for queries about
if addpath was enabled at all on a particular afi/safi. However, the
values weren't updated, so BGP would act as if addpath wasn't enabled
when determining if updates should be sent out. The error in behavior
was much more noticeable in tx-all than best-per-as, since changes in
what is sent by best-per-as would often trigger updates even if addpath
wasn't enabled.

Signed-off-by: Mitchell Skiba <mskiba@amazon.com>
4 years agoMerge pull request #5362 from donaldsharp/72_pim_crash_rp
Jafar Al-Gharaibeh [Tue, 19 Nov 2019 04:04:30 +0000 (22:04 -0600)]
Merge pull request #5362 from donaldsharp/72_pim_crash_rp

[7.2] pim crash rp

4 years agopimd: Create pimreg interface when we start any interface config
Donald Sharp [Mon, 18 Nov 2019 16:43:52 +0000 (11:43 -0500)]
pimd: Create pimreg interface when we start any interface config

When you configure interface configuration without explicitly
configuring pim on that interface, we were not creating the pimreg
interface and as such we would crash in an attempted register
since the pimreg device is non-existent.

The crash is this:
==8823== Invalid read of size 8
==8823==    at 0x468614: pim_channel_add_oif (pim_oil.c:392)
==8823==    by 0x46D0F1: pim_register_join (pim_register.c:61)
==8823==    by 0x449AB3: pim_mroute_msg_nocache (pim_mroute.c:242)
==8823==    by 0x449AB3: pim_mroute_msg (pim_mroute.c:661)
==8823==    by 0x449AB3: mroute_read (pim_mroute.c:707)
==8823==    by 0x4FC0676: thread_call (thread.c:1549)
==8823==    by 0x4EF3A2F: frr_run (libfrr.c:1064)
==8823==    by 0x40DCB5: main (pim_main.c:162)
==8823==  Address 0xc8 is not stack'd, malloc'd or (recently) free'd

pim_register_join calls pim_channel_add_oif with:

pim_channel_add_oif(up->channel_oil, pim->regiface,
    PIM_OIF_FLAG_PROTO_PIM);

We just need to make srue pim->regiface exists once we start configuring
pim.

Fixes: #5358
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agopimd: Dissallow obvious addresses from being the RP
Donald Sharp [Mon, 18 Nov 2019 15:48:49 +0000 (10:48 -0500)]
pimd: Dissallow obvious addresses from being the RP

When configuring a RP, dissallow the choice of 0.0.0.0 or
255.255.255.255 as the address as that they make no sense
what so ever.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agoMerge pull request #5336 from opensourcerouting/ldpd-buffer-overflow-7.2
Sri Mohana Singamsetty [Fri, 15 Nov 2019 23:39:14 +0000 (15:39 -0800)]
Merge pull request #5336 from opensourcerouting/ldpd-buffer-overflow-7.2

[7.2] ldpd: add missing sanity check in the parsing of label messages

4 years agoMerge pull request #5347 from ton31337/fix/bgp_dampening_per_afi_safi_7.2
Donald Sharp [Fri, 15 Nov 2019 12:34:58 +0000 (07:34 -0500)]
Merge pull request #5347 from ton31337/fix/bgp_dampening_per_afi_safi_7.2

bgpd: [7.2] Rework BGP dampening to be per AFI/SAFI

4 years agodoc: Append documentation for `bgp dampening` command
Donatas Abraitis [Tue, 12 Nov 2019 11:23:24 +0000 (13:23 +0200)]
doc: Append documentation for `bgp dampening` command

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agobgpd: Rework BGP dampening to be per AFI/SAFI
Donatas Abraitis [Sun, 10 Nov 2019 18:13:20 +0000 (20:13 +0200)]
bgpd: Rework BGP dampening to be per AFI/SAFI

Before we had:

!
router bgp 65031
 bgp dampening 1 2 3 4
!

exit2-debian-9(config)# router bgp 65031
exit2-debian-9(config-router)# address-family ipv4 multicast
exit2-debian-9(config-router-af)# bgp dampening 5 6 7 8
exit2-debian-9(config-router-af)# end
exit2-debian-9# show running-config

!
router bgp 65031
 bgp dampening 1 2 3 4
!

After fix:

!
router bgp 65031
 neighbor 192.168.1.2 remote-as 100
 !
 address-family ipv4 unicast
  bgp dampening 1 2 3 4
 exit-address-family
 !
 address-family ipv4 multicast
  bgp dampening 5 6 7 8
 exit-address-family
!

exit2-debian-9# show ip bgp ipv4 unicast dampening parameters
Half-life time: 1 min
Reuse penalty: 2
Suppress penalty: 3
Max suppress time: 4 min
Max suppress penalty: 32

exit2-debian-9# show ip bgp ipv4 multicast dampening parameters
Half-life time: 5 min
Reuse penalty: 6
Suppress penalty: 7
Max suppress time: 8 min
Max suppress penalty: 18

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoldpd: add missing sanity check in the parsing of label messages
Renato Westphal [Thu, 14 Nov 2019 00:51:06 +0000 (21:51 -0300)]
ldpd: add missing sanity check in the parsing of label messages

Validate that the FEC prefix length is within the allowed limit
(depending on the FEC address family) in order to prevent possible
buffer overflows.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
4 years agoMerge pull request #5316 from k0ste/stable_7.2_backports
Donald Sharp [Tue, 12 Nov 2019 15:20:02 +0000 (10:20 -0500)]
Merge pull request #5316 from k0ste/stable_7.2_backports

[7.2] lib: Remove include of deprecated sysctl.h

4 years agolib: Remove include of deprecated sysctl.h
Mark Stapp [Wed, 23 Oct 2019 13:08:21 +0000 (09:08 -0400)]
lib: Remove include of deprecated sysctl.h

Stop including deprecated header file; appears to be unused and
it has been deprecated in recent linux.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
(cherry picked from commit 15e84e5abbf32ab6ad470ee3dbdcfa27c87e455f)

4 years agoMerge pull request #5173 from opensourcerouting/72-bfdd-vrf-socket
Donatas Abraitis [Fri, 8 Nov 2019 09:12:15 +0000 (11:12 +0200)]
Merge pull request #5173 from opensourcerouting/72-bfdd-vrf-socket

[7.2] bfdd: VRF security improvement

4 years agoMerge pull request #5264 from dslicenc/ospf-bfd-72
Rafael Zalamena [Fri, 1 Nov 2019 16:06:29 +0000 (13:06 -0300)]
Merge pull request #5264 from dslicenc/ospf-bfd-72

ospf: 7.2 BFD down not tearing down OSPF adjacency for point-to-point net…

4 years agoospf: BFD down not tearing down OSPF adjacency for point-to-point network
Radhika Mahankali [Mon, 9 Apr 2018 22:30:32 +0000 (15:30 -0700)]
ospf: BFD down not tearing down OSPF adjacency for point-to-point network

Root Cause:
Lookup for the point-to-point neighbor was failing because the neighbor
lookup was based on neighbor interface IP address. But, for point-to-point
neighbor the key is router-id for lookup. Lookup failure was causing the
BFD updates from PTM to get dropped.

Fix:
Added walk of the neighbor list if the network type is point-to-point to
find the appropriate neighbor. The match is based on source IP address of
the neighbor since that’s the address registered with BFD for monitoring.

Ticket: CM-20411
Signed-off-by: Radhika Mahankali <radhika@cumulusnetworks.com>
4 years agoMerge pull request #5254 from ton31337/fix/doc_bgp_redistribute_vpn_7.2
Donald Sharp [Thu, 31 Oct 2019 14:25:17 +0000 (10:25 -0400)]
Merge pull request #5254 from ton31337/fix/doc_bgp_redistribute_vpn_7.2

doc: [7.2] Add redistribute vnc-direct command and fix typo in redistribute vnc

4 years agodoc: Add redistribute vnc-direct command
Donatas Abraitis [Mon, 28 Oct 2019 14:53:40 +0000 (16:53 +0200)]
doc: Add redistribute vnc-direct command

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agodoc: redistribute vpn --> redistribute vnc
Donatas Abraitis [Mon, 28 Oct 2019 14:53:11 +0000 (16:53 +0200)]
doc: redistribute vpn --> redistribute vnc

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #5243 from ton31337/fix/do_not_include_nexthop_dash_dash_7.2
Donald Sharp [Tue, 29 Oct 2019 17:02:45 +0000 (13:02 -0400)]
Merge pull request #5243 from ton31337/fix/do_not_include_nexthop_dash_dash_7.2

bgpd: [7.2] Do not send next-hop as :: in MP_REACH_NLRI if no link-local ex…

4 years agobgpd: Do not send next-hop as :: in MP_REACH_NLRI if no link-local exists
Donatas Abraitis [Fri, 6 Sep 2019 09:12:23 +0000 (12:12 +0300)]
bgpd: Do not send next-hop as :: in MP_REACH_NLRI if no link-local exists

This is the unusual case when you have global IPv6 address and no link-local
on interface attached. Like here:

eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
 link/ether 08:00:27:65:c6:82 brd ff:ff:ff:ff:ff:ff
 inet6 2a02:4780:face::1/64 scope global
    valid_lft forever preferred_lft forever

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #5230 from ton31337/fix/noip_nhrp_map_7.2
Donald Sharp [Sat, 26 Oct 2019 02:25:34 +0000 (22:25 -0400)]
Merge pull request #5230 from ton31337/fix/noip_nhrp_map_7.2

nhrp: [7.2] Make sure `no ip nhrp map <something>` works as expected

4 years agoMerge pull request #5227 from ton31337/fix/override_peers_ttl_if_peer_group_configure...
Donald Sharp [Sat, 26 Oct 2019 02:24:48 +0000 (22:24 -0400)]
Merge pull request #5227 from ton31337/fix/override_peers_ttl_if_peer_group_configured_7.2

bgpd: [7.2] Override peer's TTL only if peer-group is configured with TTL

4 years agoMerge pull request #5233 from ton31337/feature/doc_access_list_sequence_numbers_7.2
Donald Sharp [Sat, 26 Oct 2019 02:23:59 +0000 (22:23 -0400)]
Merge pull request #5233 from ton31337/feature/doc_access_list_sequence_numbers_7.2

doc: [7.2] Update documentation for access-list with sequence numbers

4 years agodoc: Update documentation for access-list with sequence numbers
Donatas Abraitis [Mon, 21 Oct 2019 15:04:39 +0000 (18:04 +0300)]
doc: Update documentation for access-list with sequence numbers

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agonhrp: Make sure `no ip nhrp map <something>` works as expected
Donatas Abraitis [Fri, 25 Oct 2019 10:01:02 +0000 (13:01 +0300)]
nhrp: Make sure `no ip nhrp map <something>` works as expected

We passed peer as NULL and nothing happened.

exit2-debian-9# conf
exit2-debian-9(config)# int gre1
exit2-debian-9(config-if)# ip nhrp map 1.1.1.1 local
exit2-debian-9(config-if)# ip nhrp map 2.2.2.2 3.3.3.3
exit2-debian-9(config-if)# do sh run
...
!
interface gre1
 ip nhrp map 1.1.1.1 local
 ip nhrp map 2.2.2.2 3.3.3.3
!
...
exit2-debian-9(config-if)# no ip nhrp map 1.1.1.1
exit2-debian-9(config-if)# do sh run
...
!
interface gre1
 ip nhrp map 2.2.2.2 3.3.3.3
!

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agobgpd: Override peer's TTL only if peer-group is configured with TTL
Donatas Abraitis [Wed, 23 Oct 2019 14:56:23 +0000 (17:56 +0300)]
bgpd: Override peer's TTL only if peer-group is configured with TTL

When a peer-group is configured for an already configured eBGP neighbor,
ebgp-multihop command is removed for that peer.

This fix remains configured peer's ebgp-multihop value if peer-group does
not have ebgp-multihop configured.

!
router bgp 100
 neighbor A8 peer-group
 neighbor A9 peer-group
 neighbor A9 ebgp-multihop 12
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 ebgp-multihop 255
 neighbor 4.4.4.4 remote-as 123
 !

spine1-debian-9#
spine1-debian-9# conf
spine1-debian-9(config)# router bgp 100
spine1-debian-9(config-router)# neighbor 3.3.3.3 peer-group A8
spine1-debian-9(config-router)# do sh run

!
router bgp 100
 neighbor A8 peer-group
 neighbor A9 peer-group
 neighbor A9 ebgp-multihop 12
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 peer-group A8
 neighbor 3.3.3.3 ebgp-multihop 255
 neighbor 4.4.4.4 remote-as 123
!

spine1-debian-9(config-router)# neighbor 4.4.4.4 peer-group A9
spine1-debian-9(config-router)# do sh run

!
router bgp 100
 neighbor A8 peer-group
 neighbor A9 peer-group
 neighbor A9 ebgp-multihop 12
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 peer-group A8
 neighbor 3.3.3.3 ebgp-multihop 255
 neighbor 4.4.4.4 remote-as 123
 neighbor 4.4.4.4 peer-group A9
!

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #5221 from dslicenc/remove-afi-saf-msg-72
Donatas Abraitis [Fri, 25 Oct 2019 05:37:18 +0000 (08:37 +0300)]
Merge pull request #5221 from dslicenc/remove-afi-saf-msg-72

bgpd: 7.2 - remove error message for unkown afi/safi combination

4 years agobgpd: remove error message for unkown afi/safi combination
Don Slice [Wed, 23 Oct 2019 16:30:28 +0000 (16:30 +0000)]
bgpd: remove error message for unkown afi/safi combination

Problem reported with error messages appearing in the log
complaining about invalid afi/safi combinations.  Determined
that the error messages were recently added in the function
that turns afi and safi values to strings.  Unfortunately,
the function is called from places using FOREACH_AFI_SAFI,
which spins thru every afi and safi number including some
that are not legal together (ipv4 evpn and l2vpn multicast
for example.)   This fix removes these error messages since
it is not necessarily an error to call it with invalid
combinations.

Ticket: CM-26883
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
4 years agoMerge pull request #5198 from manuhalo/fix_bgp_oot_7.2
Donatas Abraitis [Mon, 21 Oct 2019 10:07:38 +0000 (13:07 +0300)]
Merge pull request #5198 from manuhalo/fix_bgp_oot_7.2

[7.2]bgpd: fix include path for bgp_bmp_clippy.c

4 years agobgpd: fix include path for bgp_bmp_clippy.c
Emanuele Di Pascale [Wed, 18 Sep 2019 09:49:24 +0000 (11:49 +0200)]
bgpd: fix include path for bgp_bmp_clippy.c

not using a relative path was breaking out-of-tree compilation

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
4 years agoMerge pull request #5157 from sworleys/Fix-IF-Infinite-Loop-7.2
Donatas Abraitis [Wed, 16 Oct 2019 12:06:41 +0000 (15:06 +0300)]
Merge pull request #5157 from sworleys/Fix-IF-Infinite-Loop-7.2

[7.2] Fix Interface Infinite Loop Walk

4 years agoMerge pull request #5162 from ton31337/fix/do_not_reconnect_if_prefix_overflow_7.2
Donald Sharp [Wed, 16 Oct 2019 11:03:59 +0000 (07:03 -0400)]
Merge pull request #5162 from ton31337/fix/do_not_reconnect_if_prefix_overflow_7.2

bgpd: [7.2] Keep the session down if maximum-prefix is reached

4 years agotests: Remove sleep from test_bgp_maximum_prefix_invalid_update
Donatas Abraitis [Thu, 3 Oct 2019 11:08:51 +0000 (14:08 +0300)]
tests: Remove sleep from test_bgp_maximum_prefix_invalid_update

Sleep is not needed here while we fail instantly if maximum is reached.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agobgpd: Keep the session down if maximum-prefix is reached
Donatas Abraitis [Wed, 2 Oct 2019 15:06:37 +0000 (18:06 +0300)]
bgpd: Keep the session down if maximum-prefix is reached

Under high load instances with hundreds of thousands of prefixes this
could result in very unstable systems.

When maximum-prefix is set, but restart timer is not set then the session
flaps between Idle(Pfx) -> Established -> Idle(Pfx) states.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agolib: Don't add/del from name tree if name isnt set
Stephen Worley [Wed, 9 Oct 2019 23:35:46 +0000 (19:35 -0400)]
lib: Don't add/del from name tree if name isnt set

If the name has not been set yet (we were only passed the
ifindex in some cases like with master/slave timings) then
do not add/del it from the ifname rb tree on the vrf struct.

Doing so causes duplicate entries on the tree and infinte loops
can happen when iterating over it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Use correct if compare function in tree proto
Stephen Worley [Wed, 9 Oct 2019 20:43:27 +0000 (16:43 -0400)]
lib: Use correct if compare function in tree proto

We were using the incorrect comparison function for the
ifindex-based rb tree. Luckily, we were using the correct one
in RB_GENERATE so I guess that overwrote what was declared in the
prototype?

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agoMerge pull request #5160 from donaldsharp/7.2_bgp_backports
Mark Stapp [Tue, 15 Oct 2019 19:38:23 +0000 (15:38 -0400)]
Merge pull request #5160 from donaldsharp/7.2_bgp_backports

7.2 bgp backports

4 years agobfdd: bind VRF sockets to devices
Rafael Zalamena [Tue, 15 Oct 2019 17:56:27 +0000 (14:56 -0300)]
bfdd: bind VRF sockets to devices

Always bind the created sockets to their respective VRF devices. With
this it should be possible to run BFD on VRFs without needing to weaken
the security setting `net.ipv4.udp_l3mdev_accept=1`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agoMerge pull request #5158 from opensourcerouting/72-bfdd-bug-fixes
Donald Sharp [Tue, 15 Oct 2019 17:33:39 +0000 (13:33 -0400)]
Merge pull request #5158 from opensourcerouting/72-bfdd-bug-fixes

[7.2] bfdd: pack of bug fixes

4 years agolib: Fix read beyond end of data structure
Donald Sharp [Thu, 10 Oct 2019 12:52:54 +0000 (08:52 -0400)]
lib: Fix read beyond end of data structure

Our Address Sanitizer CI is finding this issue:
error 09-Oct-2019 19:28:33 r4: bgpd triggered an exception by AddressSanitizer
error 09-Oct-2019 19:28:33 ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdd425b060 at pc 0x00000068575f bp 0x7ffdd4258550 sp 0x7ffdd4258540
error 09-Oct-2019 19:28:33 READ of size 1 at 0x7ffdd425b060 thread T0
error 09-Oct-2019 19:28:33     #0 0x68575e in prefix_cmp lib/prefix.c:776
error 09-Oct-2019 19:28:33     #1 0x5889f5 in rfapiItBiIndexSearch bgpd/rfapi/rfapi_import.c:2230
error 09-Oct-2019 19:28:33     #2 0x5889f5 in rfapiBgpInfoFilteredImportVPN bgpd/rfapi/rfapi_import.c:3520
error 09-Oct-2019 19:28:33     #3 0x58b909 in rfapiProcessWithdraw bgpd/rfapi/rfapi_import.c:4071
error 09-Oct-2019 19:28:33     #4 0x4c459b in bgp_withdraw bgpd/bgp_route.c:3736
error 09-Oct-2019 19:28:33     #5 0x484122 in bgp_nlri_parse_vpn bgpd/bgp_mplsvpn.c:237
error 09-Oct-2019 19:28:33     #6 0x497f52 in bgp_nlri_parse bgpd/bgp_packet.c:315
error 09-Oct-2019 19:28:33     #7 0x49d06d in bgp_update_receive bgpd/bgp_packet.c:1598
error 09-Oct-2019 19:28:33     #8 0x49d06d in bgp_process_packet bgpd/bgp_packet.c:2274
error 09-Oct-2019 19:28:33     #9 0x6b9f54 in thread_call lib/thread.c:1531
error 09-Oct-2019 19:28:33     #10 0x657037 in frr_run lib/libfrr.c:1052
error 09-Oct-2019 19:28:33     #11 0x42d268 in main bgpd/bgp_main.c:486
error 09-Oct-2019 19:28:33     #12 0x7f806032482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
error 09-Oct-2019 19:28:33     #13 0x42bcc8 in _start (/usr/lib/frr/bgpd+0x42bcc8)
error 09-Oct-2019 19:28:33
error 09-Oct-2019 19:28:33 Address 0x7ffdd425b060 is located in stack of thread T0 at offset 240 in frame
error 09-Oct-2019 19:28:33     #0 0x483945 in bgp_nlri_parse_vpn bgpd/bgp_mplsvpn.c:103
error 09-Oct-2019 19:28:33
error 09-Oct-2019 19:28:33   This frame has 5 object(s):
error 09-Oct-2019 19:28:33     [32, 36) 'label'
error 09-Oct-2019 19:28:33     [96, 108) 'rd_as'
error 09-Oct-2019 19:28:33     [160, 172) 'rd_ip'
error 09-Oct-2019 19:28:33     [224, 240) 'prd' <== Memory access at offset 240 overflows this variable
error 09-Oct-2019 19:28:33     [288, 336) 'p'
error 09-Oct-2019 19:28:33 HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
error 09-Oct-2019 19:28:33       (longjmp and C++ exceptions *are* supported)
error 09-Oct-2019 19:28:33 SUMMARY: AddressSanitizer: stack-buffer-overflow lib/prefix.c:776 prefix_cmp
error 09-Oct-2019 19:28:33 Shadow bytes around the buggy address:
error 09-Oct-2019 19:28:33   0x10003a8435b0: 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 00 00 00
error 09-Oct-2019 19:28:33   0x10003a8435c0: 00 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3
error 09-Oct-2019 19:28:33   0x10003a8435d0: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
error 09-Oct-2019 19:28:33   0x10003a8435e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
error 09-Oct-2019 19:28:33   0x10003a8435f0: f1 f1 04 f4 f4 f4 f2 f2 f2 f2 00 04 f4 f4 f2 f2
error 09-Oct-2019 19:28:33 =>0x10003a843600: f2 f2 00 04 f4 f4 f2 f2 f2 f2 00 00[f4]f4 f2 f2
error 09-Oct-2019 19:28:33   0x10003a843610: f2 f2 00 00 00 00 00 00 f4 f4 f3 f3 f3 f3 00 00
error 09-Oct-2019 19:28:33   0x10003a843620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
error 09-Oct-2019 19:28:33   0x10003a843630: 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 02 f4
error 09-Oct-2019 19:28:33   0x10003a843640: f4 f4 f2 f2 f2 f2 04 f4 f4 f4 f2 f2 f2 f2 00 00
error 09-Oct-2019 19:28:33   0x10003a843650: f4 f4 f2 f2 f2 f2 00 00 00 00 f2 f2 f2 f2 00 00
error 09-Oct-2019 19:28:33 Shadow byte legend (one shadow byte represents 8 application bytes):
error 09-Oct-2019 19:28:33   Addressable:           00
error 09-Oct-2019 19:28:33   Partially addressable: 01 02 03 04 05 06 07
error 09-Oct-2019 19:28:33   Heap left redzone:       fa
error 09-Oct-2019 19:28:33   Heap right redzone:      fb
error 09-Oct-2019 19:28:33   Freed heap region:       fd
error 09-Oct-2019 19:28:33   Stack left redzone:      f1
error 09-Oct-2019 19:28:33   Stack mid redzone:       f2
error 09-Oct-2019 19:28:33   Stack right redzone:     f3
error 09-Oct-2019 19:28:33   Stack partial redzone:   f4
error 09-Oct-2019 19:28:33   Stack after return:      f5
error 09-Oct-2019 19:28:33   Stack use after scope:   f8
error 09-Oct-2019 19:28:33   Global redzone:          f9
error 09-Oct-2019 19:28:33   Global init order:       f6
error 09-Oct-2019 19:28:33   Poisoned by user:        f7
error 09-Oct-2019 19:28:33   Container overflow:      fc
error 09-Oct-2019 19:28:33   Array cookie:            ac
error 09-Oct-2019 19:28:33   Intra object redzone:    bb
error 09-Oct-2019 19:28:33   ASan internal:           fe
error 09-Oct-2019 19:28:36 r3: Daemon bgpd not running

This is the result of this code pattern in rfapi/rfapi_import.c:

prefix_cmp((struct prefix *)&bpi_result->extra->vnc.import.rd,
   (struct prefix *)prd))

Effectively prd or vnc.import.rd are `struct prefix_rd` which
are being typecast to a `struct prefix`.  Not a big deal except commit
1315d74de97be2944d7b005b2f9a50e9ae5eff4d modified the prefix_cmp
function to allow for a sorted prefix_cmp.  In prefix_cmp
we were looking at the offset and shift.  In the case
of vnc we were passing a prefix length of 64 which is the exact length of
the remaining data structure for struct prefix_rd.  So we calculated
a offset of 8 and a shift of 0.  The data structures for the prefix
portion happened to be equal to 64 bits of data. So we checked that
with the memcmp got a 0 and promptly read off the end of the data
structure for the numcmp.  The fix is if shift is 0 that means thei
the memcmp has checked everything and there is nothing to do.

Please note: We will still crash if we set the prefixlen > then
~312 bits currently( ie if the prefixlen specifies a bit length
longer than the prefix length ).  I do not think there is
anything to do here( nor am I sure how to correct this either )
as that we are going to have some severe problems when we muck
up the prefixlen.

Fixes: #5025
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobgpd: When creating extra from stack ensure it is zero'ed out
Donald Sharp [Thu, 10 Oct 2019 00:19:56 +0000 (20:19 -0400)]
bgpd: When creating extra from stack ensure it is zero'ed out

BGP code assumes that the extra data is zero'ed out.  Ensure that we
are not leaving any situation that the data on the stack is actually all
0's when we pass it around as a pointer later.

Please note in issue #5025, Lou reported a different valgrind
issue, which is not the same issue:

==7313== Conditional jump or move depends on uninitialised value(s)
==7313== at 0x181F9F: subgroup_announce_check (bgp_route.c:1555)
==7313== by 0x1A112B: subgroup_announce_table (bgp_updgrp_adv.c:641)
==7313== by 0x1A1340: subgroup_announce_route (bgp_updgrp_adv.c:704)
==7313== by 0x1A13E3: subgroup_coalesce_timer (bgp_updgrp_adv.c:331)
==7313== by 0x4EBA615: thread_call (thread.c:1531)
==7313== by 0x4E8AC37: frr_run (libfrr.c:1052)
==7313== by 0x1429E0: main (bgp_main.c:486)
==7313==
==7313== Conditional jump or move depends on uninitialised value(s)
==7313== at 0x201C0E: rfapi_vty_out_vncinfo (rfapi_vty.c:429)
==7313== by 0x18D0D6: route_vty_out (bgp_route.c:7481)
==7313== by 0x18DD76: bgp_show_table (bgp_route.c:9365)
==7313== by 0x1930C4: bgp_show_table_rd (bgp_route.c:9471)
==7313== by 0x1932A3: bgp_show (bgp_route.c:9510)
==7313== by 0x193E68: show_ip_bgp_json (bgp_route.c:10284)
==7313== by 0x4E6D024: cmd_execute_command_real.isra.2 (command.c:1072)
==7313== by 0x4E6F51E: cmd_execute_command (command.c:1131)
==7313== by 0x4E6F686: cmd_execute (command.c:1285)
==7313== by 0x4EBF9C4: vty_command (vty.c:516)
==7313== by 0x4EBFB9F: vty_execute (vty.c:1285)
==7313== by 0x4EC250F: vtysh_read (vty.c:2119)
==7313==

that is causing the actual crash.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobgpd: Ensure that struct prefix_rd rd is zero'ed out
Donald Sharp [Thu, 10 Oct 2019 12:52:13 +0000 (08:52 -0400)]
bgpd: Ensure that struct prefix_rd rd is zero'ed out

We are passing around the created rd, Just make sure that
the data is zero'ed out.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobgpd: AS paths are uint32_t instead of integers
Donald Sharp [Wed, 9 Oct 2019 20:10:44 +0000 (16:10 -0400)]
bgpd: AS paths are uint32_t instead of integers

We have some JSON output that was displaying high order
AS path data as negative numbers:

{
 "paths":[
    {
      "aspath":{
        "string":"4200010118 4200010000 20473 1299",
        "segments":[
          {
            "type":"as-sequence",
            "list":[
              -94957178,
              -94957296,
              20473,
              1299
            ]
          }
        ],

Notice "String" output -vs- the list.

With fixed code:

  "paths":[
    {
      "aspath":{
        "string":"64539 4294967000 15096 6939 7922 7332 4249",
        "segments":[
          {
            "type":"as-sequence",
            "list":[
              64539,
              4294967000,
              15096,
              6939,
              7922,
              7332,
              4249
            ]
          }
        ],

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobgpd: Soft reconfig-in should find the right bgp_path_info
Donald Sharp [Tue, 15 Oct 2019 12:27:22 +0000 (08:27 -0400)]
bgpd: Soft reconfig-in should find the right bgp_path_info

When using soft reconfiguration inbound we are storing packet
data on the side for replaying when necessary.  The problem here
is that we are just grabbing the first bgp_path_info and using
that as the base.  What happens when we have soft-reconfig turned
on with multiple bgp_path_info's for a path?  This was introduced
in commit 8692c506520f6b268525b80890702432c95f13c4, yes back
in 2012!  I would argue, though, that it was just broken
in a different way before this.

Choose the correct bgp_path_info that corresponds to the peer
we received the data from for rethinking.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agoFRRouting Release 7.2 frr-7.2
Martin Winter [Tue, 15 Oct 2019 14:44:47 +0000 (16:44 +0200)]
FRRouting Release 7.2

ALL Daemons
    -N <namespace> to allow for config file locating when running FRR
      inside of a namespace
    Impoved Testing across all daemons
BFD
    VRF Support
    Conversion to Northbound interface
BGP
    Aggregate-address add route-map support
    BMP Support
    Improved JSON output for many commands
    `show bgp afi safi summary failed` command
    `clear bop *` clears all peers
    Show FQDN for `show bgp ipv4 uni` commands
    Display BestPath selection reason as part of show commands
EIGRP
    Infrastructure changes to allow VRF's
    SIGHUP signals the config reload
    Conversion to Northbound interface
ISIS
    BFD Support
    Support for circuits with MTU > 8192
PBRD
    fwmark support as part of match criteria
    autocompletion of PBRMAPS
    Improved Nexthop Support
PIMD
    PIM-BSM receive support
     Improved debugging support
    Store ECMP paths that are not currently legal for use
    Disallow igmp query from a non-connected source
    Many new cli improvements and changes
VRRPD
    Add Support for RFC 3768 and RFC 5798
Route-Maps
    Add sequence numbers to access-lists
    Add `match ip next-hop type blackhole`
    Improved ability to notice dependency changes
SHARPD
    `sharp watch [import|nexthop]` you can now specify a prefix instead
     of assuming a /32
STATICD
    Significantly Improved NHT
ZEBRA
    Many dataplane improvements for routes, neighbor table and EVPN
    NHT cli can now be specified per VRF and improved ability to control
     NHT data being shown
    Removed duplicate processing of routes
    Improved debugablility
    RMAC and VxLan support for the FPM
LIB
    RCU support
    Nexthop Group Improvements
    `log-filter WORD` added
Building
    openssl support
    libcap should be used as part of build or significant slowdowns will
     be experienced
    Lua builds have been fixed
    Improved Cross building
Snapcraft
    Add Fabricd
    Add Libyan
    Update rtrlib and rpki

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
4 years agobfdd: don't allow link-local without interface
Rafael Zalamena [Fri, 11 Oct 2019 19:54:51 +0000 (16:54 -0300)]
bfdd: don't allow link-local without interface

When using link-local addresses we must provide scope-id to the
operating system so it knows where to send packets.

Spotted by Pavel Ivashchenko (@zays26).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agobfdd: simplify session observers code
Rafael Zalamena [Fri, 11 Oct 2019 19:13:24 +0000 (16:13 -0300)]
bfdd: simplify session observers code

Don't be selective about what to observe, always observe all possible
aspects of the session that may change on run-time (i.e. bind address,
interface and VRF existence).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agobfdd: set session down after disabling it
Rafael Zalamena [Fri, 11 Oct 2019 16:12:26 +0000 (13:12 -0300)]
bfdd: set session down after disabling it

If a session is no longer able to send/receive packets, it is very
likely it will be down in a few milliseconds so lets speed up the
process and correctly mark it as down.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agobfdd: disable sockets polling before closing it
Rafael Zalamena [Fri, 11 Oct 2019 14:15:56 +0000 (11:15 -0300)]
bfdd: disable sockets polling before closing it

Otherwise the `thread_read` will keep waking us up to handle closing
sockets which are never unregistered.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
4 years agobfdd: upon vrf disable, unlink bfd session with vrf
Philippe Guibert [Thu, 10 Oct 2019 07:07:21 +0000 (09:07 +0200)]
bfdd: upon vrf disable, unlink bfd session with vrf

bfd session has a vrf pointer that needs to be reset, when vrf is
disabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
4 years agobfdd: Fixing coredump in log
SumitAgarwal123 [Thu, 19 Sep 2019 10:04:48 +0000 (03:04 -0700)]
bfdd: Fixing coredump in log

Param missing in debug log, leading to coredump

Signed-off-by: Sayed Mohd Saquib <sayed.saquib@broadcom.com>
4 years agoMerge pull request #5115 from ton31337/feature/maximum-prefix_uint64_to_uint32_7.2
Quentin Young [Wed, 9 Oct 2019 19:33:22 +0000 (15:33 -0400)]
Merge pull request #5115 from ton31337/feature/maximum-prefix_uint64_to_uint32_7.2

bgpd: [7.2] Use uint32_t for maximum-prefix

4 years agobgpd: Use uint32_t for maximum-prefix
Donatas Abraitis [Thu, 3 Oct 2019 21:30:28 +0000 (00:30 +0300)]
bgpd: Use uint32_t for maximum-prefix

Currently we have unsigned long which is not what we defined
in CLI (1-4294967295).

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #5096 from donaldsharp/72_static_fix_for_ROUTE_ALL
Renato Westphal [Wed, 2 Oct 2019 19:22:07 +0000 (16:22 -0300)]
Merge pull request #5096 from donaldsharp/72_static_fix_for_ROUTE_ALL

[7.2]zebra: Fix redistribution deletion for ZEBRA_ROUTE_ALL

4 years agoMerge pull request #5076 from ak503/libfrr_crash_7_2
Donald Sharp [Wed, 2 Oct 2019 14:13:24 +0000 (10:13 -0400)]
Merge pull request #5076 from ak503/libfrr_crash_7_2

7.2: zebra: if_is_loopback_or_vrf crash if if_lookup_by_index return …

4 years agoMerge pull request #5073 from ton31337/fix/no_aggregate-address_command_for_route...
Donald Sharp [Wed, 2 Oct 2019 14:12:21 +0000 (10:12 -0400)]
Merge pull request #5073 from ton31337/fix/no_aggregate-address_command_for_route-map_7.2

bgpd: [7.2] Accept no aggregate-address <IP> route-map <RMAP> commands

4 years agoMerge pull request #5091 from sworleys/Fix-Vrf_ID-Decode_7.2
Donatas Abraitis [Wed, 2 Oct 2019 14:11:46 +0000 (17:11 +0300)]
Merge pull request #5091 from sworleys/Fix-Vrf_ID-Decode_7.2

[7.2] lib: Decode vrf_id update appropriately from zapi

4 years agozebra: Fix redistribution deletion for ZEBRA_ROUTE_ALL
Donald Sharp [Wed, 2 Oct 2019 13:29:19 +0000 (09:29 -0400)]
zebra: Fix redistribution deletion for ZEBRA_ROUTE_ALL

commit ee8a72f315013aecd45bc9c3aaf7ea81b2ca747a

broke the usage of ZEBRA_ROUTE_ALL as a valid redistribution
command.  This commit puts it back in.  LDP uses ZEBRA_ROUTE_ALL
as an option to say it is interested in all REDISTRIBUTION events.

Fixes: #5072
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agolib: Decode vrf_id update appropriately from zapi
Stephen Worley [Tue, 1 Oct 2019 23:02:33 +0000 (19:02 -0400)]
lib: Decode vrf_id update appropriately from zapi

The vrf_id in `zsend_interface_vrf_update()` is encoded as
a long via `stream_putl()`, we should decode it as such
as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agoMerge pull request #5089 from cfra/fix/7.2/isis-threeway
Donald Sharp [Tue, 1 Oct 2019 23:13:47 +0000 (19:13 -0400)]
Merge pull request #5089 from cfra/fix/7.2/isis-threeway

isisd: Fix handling of neighbor circuit id in three way handshake

4 years agoisisd: Fix handling of neighbor circuit id in three way handshake
Christian Franke [Mon, 30 Sep 2019 23:53:44 +0000 (01:53 +0200)]
isisd: Fix handling of neighbor circuit id in three way handshake

RFC 5303 states:

      If the system ID and Extended Local Circuit ID of the neighboring
      system are known (in adjacency three-way state Initializing or
      Up), the neighbor's system ID SHALL be reported in the Neighbor
      System ID field, and the neighbor's Extended Local Circuit ID
      SHALL be reported in the Neighbor Extended Local Circuit ID field.

There is nothing written about only setting the Extended circuit ID of the
adjacency only when we bring the three-way adjacency up.

In fact, we should always update it, to avoid the problem described in #4783.

Fixes: #4783
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
4 years ago7.2: zebra: if_is_loopback_or_vrf crash if if_lookup_by_index return NULL
dturlupov [Fri, 27 Sep 2019 08:23:27 +0000 (11:23 +0300)]
7.2: zebra: if_is_loopback_or_vrf crash if if_lookup_by_index return NULL

Function if_lookup_by_index() can return NULL, but in if_is_loopback_or_vrf() we don't chech NULL and get next:

Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(zlog_backtrace_sigsafe+0x48) [0x7fb5f704cf18]
Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(zlog_signal+0x378) [0x7fb5f704d728]
Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(+0x6b495) [0x7fb5f706b495]
Sep 2 07:44:34 XXX zebra[4616]: /lib64/libpthread.so.0(+0x123b0) [0x7fb5f6d573b0]
Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(if_is_loopback+0) [0x7fb5f7045160]
Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(if_is_loopback_or_vrf+0x11) [0x7fb5f7045191]
Sep 2 07:44:34 XXX zebra[4616]: /usr/sbin/zebra() [0x43b26d]
Sep 2 07:44:34 XXX zebra[4616]: /usr/sbin/zebra() [0x43db6f]
Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(work_queue_run+0xc8) [0x7fb5f7080de8]
Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(thread_call+0x47) [0x7fb5f7077d27]
Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(frr_run+0xd8) [0x7fb5f704b448]

Signed-off-by: Dmitrii Turlupov dturlupov@factor-ts.ru
4 years agobgpd: Accept no aggregate-address <IP> route-map <RMAP> commands
Donatas Abraitis [Thu, 26 Sep 2019 14:35:25 +0000 (17:35 +0300)]
bgpd: Accept no aggregate-address <IP> route-map <RMAP> commands

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agoMerge pull request #5071 from ton31337/fix/aggregate-address_for_ipv6_summary-only_mi...
Donald Sharp [Thu, 26 Sep 2019 21:10:38 +0000 (17:10 -0400)]
Merge pull request #5071 from ton31337/fix/aggregate-address_for_ipv6_summary-only_missreading_7.2

bgpd: [7.2] aggregate-address X:X::X:X/M summary-only was missreading config

4 years agoMerge pull request #5069 from donaldsharp/7.2_aggregate_address
Donatas Abraitis [Thu, 26 Sep 2019 18:54:10 +0000 (21:54 +0300)]
Merge pull request #5069 from donaldsharp/7.2_aggregate_address

7.2: bgpd: aggregate-address A.B.C.D A.B.C.D summary-only was missreading …

4 years agobgpd: aggregate-address X:X::X:X/M summary-only was missreading config
Donatas Abraitis [Thu, 26 Sep 2019 18:47:55 +0000 (21:47 +0300)]
bgpd: aggregate-address X:X::X:X/M summary-only was missreading config

Entering:
aggregate-address 2a02:4780::/48 summary-only

Will transform this to:
aggregate-address 2a02:4780::/48 summary-only route-map summary-only

This patch fixes that.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
4 years agobgpd: aggregate-address A.B.C.D A.B.C.D summary-only was missreading config
Donald Sharp [Thu, 26 Sep 2019 16:37:28 +0000 (12:37 -0400)]
bgpd: aggregate-address A.B.C.D A.B.C.D summary-only was missreading config

The `aggregate-address 30.0.5.0 255.255.255.0 summary-only` command
was missreading the inputed data and translating it into:

`aggregate-address 30.0.5.0/24 summary-only route-map summary-only`

This is not quite correct.  Fix this behavior:

donna.cumulusnetworks.com# conf
donna.cumulusnetworks.com(config)# router bgp
donna.cumulusnetworks.com(config-router)# aggregate-address 30.0.5.0 255.255.255.0 summary-only
donna.cumulusnetworks.com(config-router)# do show run
Building configuration...

Current configuration:
!
frr version 7.3-dev
frr defaults datacenter
hostname donna.cumulusnetworks.com
log file /var/log/frr/frr.log
no ipv6 forwarding
frr version 7.2-dev
!
router bgp 500
 neighbor 192.168.209.1 remote-as external
 neighbor 192.168.209.1 ebgp-multihop 255
 neighbor 192.168.210.1 remote-as external
 !
 address-family ipv4 unicast
  network 192.168.9.0/24
  network 192.168.10.0/24
  aggregate-address 30.0.5.0/24 summary-only
 exit-address-family
!

Issue: #5054
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agoMerge pull request #5057 from dslicenc/bgp-next-hop-routemap-72
Donatas Abraitis [Thu, 26 Sep 2019 13:03:46 +0000 (16:03 +0300)]
Merge pull request #5057 from dslicenc/bgp-next-hop-routemap-72

7.2: bgpd: stop sending nexthop set by "route-map in" to eBGP peers