]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
19 months agobgpd: Fix `show bgp all rpki notfound` 14327/head
Ryo Nakano [Fri, 1 Sep 2023 02:44:03 +0000 (11:44 +0900)]
bgpd: Fix `show bgp all rpki notfound`

The command "show bgp all rpki notfound" includes not only RPKI
notfound routes but also RPKI valid and invalid routes in its results.

Fix the code to display only RPKI notfound routes.

Old output:
```
frr# show bgp all rpki notfound

For address family: IPv4 Unicast
BGP table version is 0, local router ID is 10.0.0.1, vrf id 0
Default local pref 100, local AS 64512
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
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
N   x.x.x.0/18       a.a.a.a                       100      0 64513 i
V   y.y.y.0/19       a.a.a.a                       200      0 64513 i
I   z.z.z.0/16       a.a.a.a                        10      0 64513 i

Displayed  3 routes and 3 total paths
```

New output:
```
frr# show bgp all rpki notfound

For address family: IPv4 Unicast
BGP table version is 0, local router ID is 10.0.0.1, vrf id 0
Default local pref 100, local AS 64512
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
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
N   x.x.x.0/18       a.a.a.a                       100      0 64513 i

Displayed  1 routes and 3 total paths
```

Signed-off-by: Ryo Nakano <ryo.z.nakano@gmail.com>
19 months agoMerge pull request #14325 from donaldsharp/peerhash_take_two
Donatas Abraitis [Fri, 1 Sep 2023 05:28:13 +0000 (08:28 +0300)]
Merge pull request #14325 from donaldsharp/peerhash_take_two

bgpd: Add peers back to peer hash when peer_xfer_conn fails

19 months agoMerge pull request #14323 from donaldsharp/name_pretty
Donatas Abraitis [Fri, 1 Sep 2023 05:18:12 +0000 (08:18 +0300)]
Merge pull request #14323 from donaldsharp/name_pretty

bgpd: When using `show bgp peerhash` don't display (NULL)

19 months agobgpd: Add peers back to peer hash when peer_xfer_conn fails 14325/head
Donald Sharp [Wed, 30 Aug 2023 11:25:06 +0000 (07:25 -0400)]
bgpd: Add peers back to peer hash when peer_xfer_conn fails

It was noticed that occassionally peering failed in a testbed
upon investigation it was found that the peer was not in the
peer hash and we saw these failure messages:

Aug 25 21:31:15 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: %NOTIFICATION: sent to neighbor 2001:cafe:1ead:4::4 4/0 (Hold Timer Expired) 0 bytes
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] Can't get remote address and port: Transport endpoint is not connected
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] %bgp_getsockname() failed for  peer 2001:cafe:1ead:4::4 fd 27 (from_peer fd -1)
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 33554464] %Neighbor failed in xfer_conn

root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr# vtysh -c 'show bgp peerhash' | grep 2001:cafe:1ead:4::4
root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr#

Upon looking at the code the peer_xfer_conn function can fail
and the bgp_establish code will then return before adding the
peer back to the peerhash.

This is only part of the failure.  The peer also appears to
be in a state where it is no longer initiating connection attempts
but that will be another commited fix when we figure that one out.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
19 months agobgpd: When using `show bgp peerhash` don't display (NULL) 14323/head
Donald Sharp [Thu, 31 Aug 2023 15:01:44 +0000 (11:01 -0400)]
bgpd: When using `show bgp peerhash` don't display (NULL)

Fix up the output to not display a (NULL) output for the bgp name

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
19 months agoMerge pull request #14322 from opensourcerouting/fix/revert_6f8c927b03c454aa309b84cef...
Donald Sharp [Thu, 31 Aug 2023 15:01:10 +0000 (11:01 -0400)]
Merge pull request #14322 from opensourcerouting/fix/revert_6f8c927b03c454aa309b84cefccc4faa31e0c03f

Revert "bgpd: Add peers back to peer hash when peer_xfer_conn fails"

19 months agoRevert "bgpd: Add peers back to peer hash when peer_xfer_conn fails" 14322/head
Donatas Abraitis [Thu, 31 Aug 2023 14:33:57 +0000 (17:33 +0300)]
Revert "bgpd: Add peers back to peer hash when peer_xfer_conn fails"

peer is NULL, but we pass it to hash_get().

This reverts commit 6f8c927b03c454aa309b84cefccc4faa31e0c03f.

19 months agoMerge pull request #14282 from pguibert6WIND/fix_redistribute_table_flush
Donatas Abraitis [Thu, 31 Aug 2023 09:41:30 +0000 (12:41 +0300)]
Merge pull request #14282 from pguibert6WIND/fix_redistribute_table_flush

bgpd: fix redistribute table command after bgp restarts

19 months agoMerge pull request #14304 from donaldsharp/ospf_use_after_flumple
Jafar Al-Gharaibeh [Thu, 31 Aug 2023 05:24:44 +0000 (00:24 -0500)]
Merge pull request #14304 from donaldsharp/ospf_use_after_flumple

ospfd: Prevent use after free( and crash of ospf ) when no router ospf

19 months agoMerge pull request #14302 from donaldsharp/pim_pim_pim_pim
Jafar Al-Gharaibeh [Thu, 31 Aug 2023 01:21:02 +0000 (20:21 -0500)]
Merge pull request #14302 from donaldsharp/pim_pim_pim_pim

pimd: When receiving a packet be more careful with length in pim_pim_…

19 months agoMerge pull request #14301 from donaldsharp/bgp_lost_hash
Jafar Al-Gharaibeh [Thu, 31 Aug 2023 01:11:46 +0000 (20:11 -0500)]
Merge pull request #14301 from donaldsharp/bgp_lost_hash

bgpd: Add peers back to peer hash when peer_xfer_conn fails

20 months agoMerge pull request #14118 from GaladrielZhao/master
Donatas Abraitis [Wed, 30 Aug 2023 14:43:29 +0000 (17:43 +0300)]
Merge pull request #14118 from GaladrielZhao/master

bgpd: Convert from struct bgp_node to struct bgp_dest

20 months agoospfd: Prevent use after free( and crash of ospf ) when no router ospf 14304/head
Donald Sharp [Wed, 30 Aug 2023 14:33:29 +0000 (10:33 -0400)]
ospfd: Prevent use after free( and crash of ospf ) when no router ospf

Consider this config:

router ospf
  redistribute kernel

Then you issue:

no router ospf

ospf will crash with a use after free.

The problem is that the event's associated with the
ospf pointer were shut off then the ospf_external_delete
was called which rescheduled the event.  Let's just move
event deletion to the end of the no router ospf.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agoMerge pull request #14300 from opensourcerouting/fix/set_role_as_undefined_when_capab...
Donald Sharp [Wed, 30 Aug 2023 13:22:12 +0000 (09:22 -0400)]
Merge pull request #14300 from opensourcerouting/fix/set_role_as_undefined_when_capability_unset

bgpd: Unset role when receiving UNSET action for dynamic capability

20 months agopimd: When receiving a packet be more careful with length in pim_pim_packet 14302/head
Donald Sharp [Wed, 30 Aug 2023 12:54:33 +0000 (08:54 -0400)]
pimd: When receiving a packet be more careful with length in pim_pim_packet

a) If the length passed is the header length then it is possible that
assignment of data will happen without data actually existing.

b) Just move the assignment to after we ensure that the pim packet
received is the minimum possible length that can be received.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agoMerge pull request #14284 from opensourcerouting/fix/bgp_dynamic_capability_zlog
Mark Stapp [Wed, 30 Aug 2023 12:00:45 +0000 (08:00 -0400)]
Merge pull request #14284 from opensourcerouting/fix/bgp_dynamic_capability_zlog

bgpd: Use zlog_err and not zlog_info when we have an error for dynamic capability

20 months agobgpd: Add peers back to peer hash when peer_xfer_conn fails 14301/head
Donald Sharp [Wed, 30 Aug 2023 11:25:06 +0000 (07:25 -0400)]
bgpd: Add peers back to peer hash when peer_xfer_conn fails

It was noticed that occassionally peering failed in a testbed
upon investigation it was found that the peer was not in the
peer hash and we saw these failure messages:

Aug 25 21:31:15 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: %NOTIFICATION: sent to neighbor 2001:cafe:1ead:4::4 4/0 (Hold Timer Expired) 0 bytes
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] Can't get remote address and port: Transport endpoint is not connected
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] %bgp_getsockname() failed for  peer 2001:cafe:1ead:4::4 fd 27 (from_peer fd -1)
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 33554464] %Neighbor failed in xfer_conn

root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr# vtysh -c 'show bgp peerhash' | grep 2001:cafe:1ead:4::4
root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr#

Upon looking at the code the peer_xfer_conn function can fail
and the bgp_establish code will then return before adding the
peer back to the peerhash.

This is only part of the failure.  The peer also appears to
be in a state where it is no longer initiating connection attempts
but that will be another commited fix when we figure that one out.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Unset role when receiving UNSET action for dynamic capability 14300/head
Donatas Abraitis [Wed, 30 Aug 2023 09:33:16 +0000 (12:33 +0300)]
bgpd: Unset role when receiving UNSET action for dynamic capability

Capability was unset, but forgot to unset the role.

Fixes: 5ad080d37a26d72b56ecd0b796593bb7fc3aa6ad ("bgpd: Handle Role capability via dynamic capabilities for SET/UNSET properly")
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agoMerge pull request #14288 from opensourcerouting/fix/warn_the_user_if_keepalive_was_c...
Jafar Al-Gharaibeh [Wed, 30 Aug 2023 03:30:03 +0000 (22:30 -0500)]
Merge pull request #14288 from opensourcerouting/fix/warn_the_user_if_keepalive_was_changed

bgpd: Add a warning for the operator that keepalive was changed

20 months agoMerge pull request #14290 from opensourcerouting/fix/bgpd_encap_tunnel_handling
Chirag Shah [Tue, 29 Aug 2023 23:51:53 +0000 (16:51 -0700)]
Merge pull request #14290 from opensourcerouting/fix/bgpd_encap_tunnel_handling

bgpd: Use treat-as-withdraw for tunnel encapsulation attribute

20 months agobgpd: Use zlog_err and not zlog_info when we have an error for dynamic capability 14284/head
Donatas Abraitis [Tue, 29 Aug 2023 10:31:22 +0000 (13:31 +0300)]
bgpd: Use zlog_err and not zlog_info when we have an error for dynamic capability

Also change the outputs a bit to be consistent and more detailed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agobgpd: Use treat-as-withdraw for tunnel encapsulation attribute 14290/head
Donatas Abraitis [Thu, 13 Jul 2023 19:32:03 +0000 (22:32 +0300)]
bgpd: Use treat-as-withdraw for tunnel encapsulation attribute

Before this path we used session reset method, which is discouraged by rfc7606.

Handle this as rfc requires.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agoMerge pull request #14243 from opensourcerouting/fix/bgpd_ebgp_multihop_vty_out
Russ White [Tue, 29 Aug 2023 12:57:51 +0000 (08:57 -0400)]
Merge pull request #14243 from opensourcerouting/fix/bgpd_ebgp_multihop_vty_out

bgpd: Do not explicitly print MAXTTL value for ebgp-multihop vty output

20 months agobgpd: Add a warning for the operator that keepalive was changed 14288/head
Donatas Abraitis [Tue, 29 Aug 2023 12:11:52 +0000 (15:11 +0300)]
bgpd: Add a warning for the operator that keepalive was changed

```
donatas-pc(config-router)# timers bgp 8 12
% keeplive value 8 is larger than 1/3 of the holdtime, setting to 4
donatas-pc(config-router)# do sh run | include timers bgp
 timers bgp 4 12
donatas-pc(config-router)#
```

Closes https://github.com/FRRouting/frr/issues/14287

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agoMerge pull request #14283 from opensourcerouting/fix/dynamic_capability_role_unset
Russ White [Tue, 29 Aug 2023 12:07:18 +0000 (08:07 -0400)]
Merge pull request #14283 from opensourcerouting/fix/dynamic_capability_role_unset

bgpd: Handle Role capability via dynamic capabilities for SET/UNSET properly

20 months agoMerge pull request #14274 from opensourcerouting/fix/staticd_with_blackhole_nexthop_h...
Russ White [Tue, 29 Aug 2023 12:06:49 +0000 (08:06 -0400)]
Merge pull request #14274 from opensourcerouting/fix/staticd_with_blackhole_nexthop_handling

staticd: Accept full blackhole typed keywords for ip_route_cmd

20 months agoMerge pull request #14262 from Keelan10/ospfd6-memleak
Russ White [Tue, 29 Aug 2023 12:06:04 +0000 (08:06 -0400)]
Merge pull request #14262 from Keelan10/ospfd6-memleak

ospf6d: Free Newly Created LSA when Non-Self-Originated Grace LSA is …

20 months agoMerge pull request #14252 from LabNConsulting/ziemba-pbr-bugfix-match-dscp-numeric
Russ White [Tue, 29 Aug 2023 12:05:17 +0000 (08:05 -0400)]
Merge pull request #14252 from LabNConsulting/ziemba-pbr-bugfix-match-dscp-numeric

pbrd: fix dscp field value computation

20 months agoMerge pull request #14257 from Keelan10/lib-memleak
Russ White [Tue, 29 Aug 2023 12:04:01 +0000 (08:04 -0400)]
Merge pull request #14257 from Keelan10/lib-memleak

lib: Fix memory leaks in LS Update Functions

20 months agobgpd: fix redistribute table command after bgp restarts 14282/head
Philippe Guibert [Mon, 28 Aug 2023 10:23:24 +0000 (12:23 +0200)]
bgpd: fix redistribute table command after bgp restarts

When the BGP 'redistribute table' command is used for a given route
table, and BGP configuration is flushed and rebuilt, the redistribution
does not work.

Actually, when flushing the BGP configuration with the 'no router bgp'
command, the BGP redistribute entries related to the 'redistribute table'
entries are not flushed. Actually, at BGP deletion, the table number is
not given as parameter in bgp_redistribute_unset() function, and the
redistribution entry is not removed in zebra.
Fix this by adding some code to flush all the redistribute table
instances.

Fixes: 7c8ff89e9346 ("Multi-Instance OSPF Summary")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
20 months agobgpd: Handle Role capability via dynamic capabilities for SET/UNSET properly 14283/head
Donatas Abraitis [Tue, 29 Aug 2023 07:10:04 +0000 (10:10 +0300)]
bgpd: Handle Role capability via dynamic capabilities for SET/UNSET properly

It was missed to handle UNSET Role capability using dynamic capabilities.

Also move length check before actually handling Role capability.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agoMerge pull request #14276 from donaldsharp/bgp_fsm_problemos
Russ White [Sat, 26 Aug 2023 19:24:56 +0000 (15:24 -0400)]
Merge pull request #14276 from donaldsharp/bgp_fsm_problemos

Bgp fsm problemos

20 months agoMerge pull request #14256 from rodecker/rt-table-id
Donald Sharp [Fri, 25 Aug 2023 21:33:52 +0000 (17:33 -0400)]
Merge pull request #14256 from rodecker/rt-table-id

zebra: Make main routing table (RT_TABLE_MAIN) configurable

20 months agoMerge pull request #14264 from lkClare/master_0823
Donatas Abraitis [Fri, 25 Aug 2023 15:16:50 +0000 (18:16 +0300)]
Merge pull request #14264 from lkClare/master_0823

bgpd: fix bug in a place about label validation

20 months agobgpd: Prevent use after free 14276/head
Donald Sharp [Fri, 25 Aug 2023 14:43:56 +0000 (10:43 -0400)]
bgpd: Prevent use after free

When bgp_stop finishes and it deletes the peer it is sending
back a return code stating that the peer was deleted, but
the code was operating like it was not deleted and continued
to access the data structure.  Fix.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: bgp_event_update switch to a switch
Donald Sharp [Fri, 25 Aug 2023 14:28:02 +0000 (10:28 -0400)]
bgpd: bgp_event_update switch to a switch

The return code from a event handling perspective
is an enum.  Let's intentionally make it a switch
so that all cases are ensured to be covered now
and in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: bgp_event_update mixes enum's with a non-enum
Donald Sharp [Fri, 25 Aug 2023 14:03:14 +0000 (10:03 -0400)]
bgpd: bgp_event_update mixes enum's with a non-enum

Straighten out the code to not mix the two.  Especially
since bgp was assigning non enum values to the enum.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agostaticd: Accept full blackhole typed keywords for ip_route_cmd 14274/head
Donatas Abraitis [Thu, 24 Aug 2023 15:06:17 +0000 (18:06 +0300)]
staticd: Accept full blackhole typed keywords for ip_route_cmd

Before this patch we allow entering next-hop interface address as any string.

Like, we can type: `ip route 10.10.10.10/32 bla`, but this will create a blackhole
route instead of using an interface `bla`.

The same is with reject.

After the patch:

```
$ vtysh -c 'con' -c 'ip route 10.10.10.100/32 bla'
ERROR: SET_CONFIG request failed, Error: nexthop interface name must be (reject, blackhole)

$ ip link show dev bla
472: bla: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether fa:45:bd:f1:f8:f0 brd ff:ff:ff:ff:ff:ff

$ vtysh -c 'sh run | include ip route'
$ vtysh -c 'con' -c 'ip route 10.10.10.100/32 blac'
$ vtysh -c 'sh run | include ip route'
ip route 10.10.10.100/32 blackhole

$ vtysh -c 'con' -c 'no ip route 10.10.10.100/32 blac'
$ vtysh -c 'sh run | include ip route'
$ vtysh -c 'con' -c 'ip route 10.10.10.100/32 blackhole'
$ vtysh -c 'sh run | include ip route'
ip route 10.10.10.100/32 blackhole

$ vtysh -c 'con' -c 'no ip route 10.10.10.100/32 blackhole'
$ vtysh -c 'sh run | include ip route'
$ vtysh -c 'con' -c 'ip route 10.10.10.100/32 Null0'
$ vtysh -c 'sh run | include ip route'
ip route 10.10.10.100/32 Null0

$ vtysh -c 'con' -c 'no ip route 10.10.10.100/32 Null0'
$ vtysh -c 'sh run | include ip route'
$
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agoMerge pull request #14253 from bigbanglwb/frr_master
Donatas Abraitis [Fri, 25 Aug 2023 05:34:54 +0000 (08:34 +0300)]
Merge pull request #14253 from bigbanglwb/frr_master

configure.ac: fix protobuf config

20 months agoMerge pull request #14260 from opensourcerouting/fix/do_not_process_nlri_if_attribute...
Donald Sharp [Thu, 24 Aug 2023 14:55:51 +0000 (10:55 -0400)]
Merge pull request #14260 from opensourcerouting/fix/do_not_process_nlri_if_attribute_len_is_0

bgpd: Do not process NLRIs if the attribute length is zero

20 months agoMerge pull request #14232 from opensourcerouting/fix/aigp_validation_bytes
Donald Sharp [Thu, 24 Aug 2023 11:43:59 +0000 (07:43 -0400)]
Merge pull request #14232 from opensourcerouting/fix/aigp_validation_bytes

bgpd: Make sure we have enough data to read two bytes when validating AIGP

20 months agobgpd: fix bug in a place about label validation 14264/head
Valerian_He [Wed, 23 Aug 2023 10:17:08 +0000 (10:17 +0000)]
bgpd: fix bug in a place about label validation

Shouldn't validate the label after 'decode_label'. If we validate
the label after 'decode_label', even the 'MPLS_INVALID_LABEL' will
be valid then.

Signed-off-by: Valerian_He <1826906282@qq.com>
20 months agoconfigure.ac: fix protobuf config 14253/head
乐倚 [Wed, 23 Aug 2023 08:42:33 +0000 (08:42 +0000)]
configure.ac: fix protobuf config

  Bug description: frr_init load zebra_fpm.so error. Zebra can't
  find function `zfpm_protobuf_encode_route` in symbol table.

  Bug trigger condition ( CI have this set ):
    ./configure --enable-protobuf=no --enable-fpm=yes
    /usr/lib/frr/zebra -M fpm

  Cause: Macro `HAVE_PROTOBUF` and compile condition variable
  `HAVE_PROTOBUF`  in `configure.ac ` is not consistent. When
  configure `disable-protobuf`, compile condition variable
  `HAVE_PROTOBUF` is 0, but the macro is 1. It leads to zebra
  load protobuf module, but protobuf module is not linked.

  Fix: add a same condition statement to the macro define.

Signed-off-by: 乐倚 <lwb406054@alibaba-inc.com>
20 months agoMerge pull request #14255 from gromit1811/gromit1811-patch-1
Donatas Abraitis [Wed, 23 Aug 2023 08:28:55 +0000 (11:28 +0300)]
Merge pull request #14255 from gromit1811/gromit1811-patch-1

debian: Don't install sample dplane plugin

20 months agoMerge pull request #14251 from donaldsharp/protodown_rc_issue
Donatas Abraitis [Wed, 23 Aug 2023 08:08:30 +0000 (11:08 +0300)]
Merge pull request #14251 from donaldsharp/protodown_rc_issue

zebra: Prevent protodown_rc from going Bzonkas

20 months agoospf6d: Free Newly Created LSA when Non-Self-Originated Grace LSA is Discarded 14262/head
Keelan10 [Wed, 23 Aug 2023 05:23:48 +0000 (09:23 +0400)]
ospf6d: Free Newly Created LSA when Non-Self-Originated Grace LSA is Discarded

The newly created LSA `new` is now properly freed to prevent memory leaks when
a non-self-originated Grace LSA which is not in LSDB is received.

The ASan leak log for reference:

```
Direct leak of 400 byte(s) in 2 object(s) allocated from:
    #0 0x7f70e984bd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f70e92481c5 in qcalloc lib/memory.c:105
    #2 0x55b35068c975 in ospf6_lsa_alloc ospf6d/ospf6_lsa.c:710
    #3 0x55b35068c9f9 in ospf6_lsa_create ospf6d/ospf6_lsa.c:725
    #4 0x55b35065ab2c in ospf6_receive_lsa ospf6d/ospf6_flood.c:912
    #5 0x55b3506a1413 in ospf6_lsupdate_recv ospf6d/ospf6_message.c:1621
    #6 0x55b3506a1413 in ospf6_read_helper ospf6d/ospf6_message.c:1896
    #7 0x55b3506a1413 in ospf6_receive ospf6d/ospf6_message.c:1925
    #8 0x7f70e92e6ccb in event_call lib/event.c:1979
    #9 0x7f70e922b488 in frr_run lib/libfrr.c:1213
    #10 0x55b35064345e in main ospf6d/ospf6_main.c:250
    #11 0x7f70e8843c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 72 byte(s) in 2 object(s) allocated from:
    #0 0x7f70e984bb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7f70e9247ee5 in qmalloc lib/memory.c:100
    #2 0x55b35068c987 in ospf6_lsa_alloc ospf6d/ospf6_lsa.c:711
    #3 0x55b35068c9f9 in ospf6_lsa_create ospf6d/ospf6_lsa.c:725
    #4 0x55b35065ab2c in ospf6_receive_lsa ospf6d/ospf6_flood.c:912
    #5 0x55b3506a1413 in ospf6_lsupdate_recv ospf6d/ospf6_message.c:1621
    #6 0x55b3506a1413 in ospf6_read_helper ospf6d/ospf6_message.c:1896
    #7 0x55b3506a1413 in ospf6_receive ospf6d/ospf6_message.c:1925
    #8 0x7f70e92e6ccb in event_call lib/event.c:1979
    #9 0x7f70e922b488 in frr_run lib/libfrr.c:1213
    #10 0x55b35064345e in main ospf6d/ospf6_main.c:250
    #11 0x7f70e8843c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 472 byte(s) leaked in 4 allocation(s).
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
20 months agobgpd: Do not process NLRIs if the attribute length is zero 14260/head
Donatas Abraitis [Tue, 22 Aug 2023 19:52:04 +0000 (22:52 +0300)]
bgpd: Do not process NLRIs if the attribute length is zero

```
3  0x00007f423aa42476 in __GI_raise (sig=sig@entry=11) at ../sysdeps/posix/raise.c:26
4  0x00007f423aef9740 in core_handler (signo=11, siginfo=0x7fffc414deb0, context=<optimized out>) at lib/sigevent.c:246
5  <signal handler called>
6  0x0000564dea2fc71e in route_set_aspath_prepend (rule=0x564debd66d50, prefix=0x7fffc414ea30, object=0x7fffc414e400)
    at bgpd/bgp_routemap.c:2258
7  0x00007f423aeec7e0 in route_map_apply_ext (map=<optimized out>, prefix=prefix@entry=0x7fffc414ea30,
    match_object=match_object@entry=0x7fffc414e400, set_object=set_object@entry=0x7fffc414e400, pref=pref@entry=0x0) at lib/routemap.c:2690
8  0x0000564dea2d277e in bgp_input_modifier (peer=peer@entry=0x7f4238f59010, p=p@entry=0x7fffc414ea30, attr=attr@entry=0x7fffc414e770,
    afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_UNICAST, rmap_name=rmap_name@entry=0x0, label=0x0, num_labels=0, dest=0x564debdd5130)
    at bgpd/bgp_route.c:1772
9  0x0000564dea2df762 in bgp_update (peer=peer@entry=0x7f4238f59010, p=p@entry=0x7fffc414ea30, addpath_id=addpath_id@entry=0,
    attr=0x7fffc414eb50, afi=afi@entry=AFI_IP, safi=<optimized out>, safi@entry=SAFI_UNICAST, type=9, sub_type=0, prd=0x0, label=0x0,
    num_labels=0, soft_reconfig=0, evpn=0x0) at bgpd/bgp_route.c:4374
10 0x0000564dea2e2047 in bgp_nlri_parse_ip (peer=0x7f4238f59010, attr=attr@entry=0x7fffc414eb50, packet=0x7fffc414eaf0)
    at bgpd/bgp_route.c:6249
11 0x0000564dea2c5a58 in bgp_nlri_parse (peer=peer@entry=0x7f4238f59010, attr=attr@entry=0x7fffc414eb50,
    packet=packet@entry=0x7fffc414eaf0, mp_withdraw=mp_withdraw@entry=false) at bgpd/bgp_packet.c:339
12 0x0000564dea2c5d66 in bgp_update_receive (peer=peer@entry=0x7f4238f59010, size=size@entry=109) at bgpd/bgp_packet.c:2024
13 0x0000564dea2c901d in bgp_process_packet (thread=<optimized out>) at bgpd/bgp_packet.c:2933
14 0x00007f423af0bf71 in event_call (thread=thread@entry=0x7fffc414ee40) at lib/event.c:1995
15 0x00007f423aebb198 in frr_run (master=0x564deb73c670) at lib/libfrr.c:1213
16 0x0000564dea261b83 in main (argc=<optimized out>, argv=<optimized out>) at bgpd/bgp_main.c:505
```

With the configuration:

```
frr version 9.1-dev-MyOwnFRRVersion
frr defaults traditional
hostname ip-172-31-13-140
log file /tmp/debug.log
log syslog
service integrated-vtysh-config
!
debug bgp keepalives
debug bgp neighbor-events
debug bgp updates in
debug bgp updates out
!
router bgp 100
 bgp router-id 9.9.9.9
 no bgp ebgp-requires-policy
 bgp bestpath aigp
 neighbor 172.31.2.47 remote-as 200
 !
 address-family ipv4 unicast
  neighbor 172.31.2.47 default-originate
  neighbor 172.31.2.47 route-map RM_IN in
 exit-address-family
exit
!
route-map RM_IN permit 10
 set as-path prepend 200
exit
!
```

The issue is that we try to process NLRIs even if the attribute length is 0.

Later bgp_update() will handle route-maps and a crash occurs because all the
attributes are NULL, including aspath, where we dereference.

According to the RFC 4271:

A value of 0 indicates that neither the Network Layer
         Reachability Information field nor the Path Attribute field is
         present in this UPDATE message.

But with a fuzzed UPDATE message this can be faked. I think it's reasonable
to skip processing NLRIs if both update_len and attribute_len are 0.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agoMerge pull request #14217 from LabNConsulting/ziemba-pbr-action-drop
Russ White [Tue, 22 Aug 2023 16:16:01 +0000 (12:16 -0400)]
Merge pull request #14217 from LabNConsulting/ziemba-pbr-action-drop

pbrd: add advisory flag PBR_ACTION_DROP

20 months agoMerge pull request #14214 from opensourcerouting/fix/handle_rfc7606_attr_len_remainin...
Russ White [Tue, 22 Aug 2023 16:15:24 +0000 (12:15 -0400)]
Merge pull request #14214 from opensourcerouting/fix/handle_rfc7606_attr_len_remaining_data

bgpd: Treat-as-withdraw attribute if remaining data is not enough

20 months agoMerge pull request #14142 from zays26/fix/zebra-assert
Russ White [Tue, 22 Aug 2023 14:25:59 +0000 (10:25 -0400)]
Merge pull request #14142 from zays26/fix/zebra-assert

zebra: fix assert in process_subq_route

20 months agoMerge pull request #14146 from opensourcerouting/ospfv3-auth-interop
Russ White [Tue, 22 Aug 2023 14:25:24 +0000 (10:25 -0400)]
Merge pull request #14146 from opensourcerouting/ospfv3-auth-interop

OSPFv3 authentication trailer interop

20 months agozebra: Make main routing table (RT_TABLE_MAIN) configurable 14256/head
Martin Pels [Tue, 22 Aug 2023 11:27:59 +0000 (13:27 +0200)]
zebra: Make main routing table (RT_TABLE_MAIN) configurable

Signed-off-by: Martin Pels <mpels@ripe.net>
20 months agolib: Fix memory leaks in LS Update Functions 14257/head
Keelan10 [Tue, 22 Aug 2023 13:19:51 +0000 (17:19 +0400)]
lib: Fix memory leaks in LS Update Functions

Previously when updating vertices, edges and subnets, when no update was required
due to existing value matching the new one, memory associated with the new object
was not being freed leading to memory leaks. This commit fixes memory leak by
freeing memory associated with new object when update is unnecessary.

The ASan leak log for reference:

```
Direct leak of 312 byte(s) in 3 object(s) allocated from:
    #0 0x7faf3afbfa37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7faf3ab5dbcf in qcalloc ../lib/memory.c:105
    #2 0x7faf3ab42e00 in ls_parse_prefix ../lib/link_state.c:1323
    #3 0x7faf3ab43c87 in ls_parse_msg ../lib/link_state.c:1373
    #4 0x7faf3ab476a5 in ls_stream2ted ../lib/link_state.c:1885
    #5 0x564e045046aa in sharp_opaque_handler ../sharpd/sharp_zebra.c:792
    #6 0x7faf3aca35a9 in zclient_read ../lib/zclient.c:4410
    #7 0x7faf3ac47474 in event_call ../lib/event.c:1979
    #8 0x7faf3ab318b4 in frr_run ../lib/libfrr.c:1213
    #9 0x564e044fdc6f in main ../sharpd/sharp_main.c:177
    #10 0x7faf3a6f4d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 312 byte(s) leaked in 3 allocation(s).
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
20 months agoMerge pull request #14239 from Keelan10/fix-cspf-leak
Donald Sharp [Tue, 22 Aug 2023 11:53:57 +0000 (07:53 -0400)]
Merge pull request #14239 from Keelan10/fix-cspf-leak

lib: Clear Computed Path Pointer to Destination on Clean

20 months agodebian: Don't install sample dplane plugin 14255/head
Martin Buck [Tue, 22 Aug 2023 08:57:47 +0000 (10:57 +0200)]
debian: Don't install sample dplane plugin

Without this, the Debian package build fails because dplane_sample_plugin.so gets compiled but not installed.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
20 months agobgpd: Convert from struct bgp_node to struct bgp_dest 14118/head
Yuqing Zhao [Mon, 31 Jul 2023 12:34:48 +0000 (20:34 +0800)]
bgpd: Convert from struct bgp_node to struct bgp_dest

This is based on @donaldsharp's work

The current code base is the struct bgp_node data structure.
The problem with this is that it creates a bunch of
extra data per route_node.
The table structure generates ‘holder’ nodes
that are never going to receive bgp routes,
and now the memory of those nodes is allocated
as if they are a full bgp_node.

After splitting up the bgp_node into bgp_dest and route_node,
the memory of ‘holder’ node which does not have any bgp data
will be allocated as the route_node, not the bgp_node,
and the memory usage is reduced.
The memory usage of BGP node will be reduced from 200B to 96B.
The total memory usage optimization of this part is ~16.00%.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Yuqing Zhao <xiaopanghu99@163.com>
20 months agopbrd: fix dscp field value computation 14252/head
G. Paul Ziemba [Mon, 21 Aug 2023 20:27:50 +0000 (13:27 -0700)]
pbrd: fix dscp field value computation

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
20 months agozebra: Prevent protodown_rc from going Bzonkas 14251/head
Donald Sharp [Mon, 21 Aug 2023 19:37:32 +0000 (15:37 -0400)]
zebra: Prevent protodown_rc from going Bzonkas

The code that handles the protodown_rc setting for
VRRP interfaces in zebra is sending a interface
to be set into a protodown state *before* the
interface has been learned by the kernel.  Resulting
in crashes when the data plane sends the ctx back
to us saying hey man you are uncool.

Additionally change the protodown code to refuse
to send any protodown_rc codes *until* the interface
has actually been learned about from the kernel.

Ticket: 3582375
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agoMerge pull request #8790 from donaldsharp/peer_connection
Donatas Abraitis [Mon, 21 Aug 2023 17:22:53 +0000 (20:22 +0300)]
Merge pull request #8790 from donaldsharp/peer_connection

Peer connection

20 months agoMerge pull request #14241 from opensourcerouting/fix/software_version_capability_hand...
Donald Sharp [Mon, 21 Aug 2023 13:33:18 +0000 (09:33 -0400)]
Merge pull request #14241 from opensourcerouting/fix/software_version_capability_handling_len

bgpd: Check the length of the rcv software version

20 months agoMerge pull request #14245 from opensourcerouting/fix/check_if_the_first_byte_is_not_n...
Donald Sharp [Mon, 21 Aug 2023 13:32:32 +0000 (09:32 -0400)]
Merge pull request #14245 from opensourcerouting/fix/check_if_the_first_byte_is_not_null_orf

bgpd: Don't read the first byte of ORF header if we are ahead of stream

20 months agoMerge pull request #14244 from donaldsharp/static_simple
Donatas Abraitis [Mon, 21 Aug 2023 08:53:45 +0000 (11:53 +0300)]
Merge pull request #14244 from donaldsharp/static_simple

tests: static_simple gives up after 3 seconds

20 months agolib: Clear Computed Path Pointer to Destination on Clean 14239/head
Keelan10 [Sat, 19 Aug 2023 21:16:48 +0000 (01:16 +0400)]
lib: Clear Computed Path Pointer to Destination on Clean

This commit ensures proper cleanup by clearing the `algo->pdst` pointer if it points to a path that is being deleted.
It addresses memory leaks by freeing memory held by `algo->pdst` that might not have been released during the cleanup of processed paths.

The ASan leak log for reference:

```
Direct leak of 96 byte(s) in 1 object(s) allocated from:
    #0 0x7fbffcec9a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fbffca67a81 in qcalloc ../lib/memory.c:105
    #2 0x7fbffc9d1a54 in cpath_new ../lib/cspf.c:44
    #3 0x7fbffc9d2829 in cspf_init ../lib/cspf.c:256
    #4 0x7fbffc9d295d in cspf_init_v4 ../lib/cspf.c:287
    #5 0x5601dcd34d3f in show_sharp_cspf_magic ../sharpd/sharp_vty.c:1262
    #6 0x5601dcd2c2be in show_sharp_cspf sharpd/sharp_vty_clippy.c:1869
    #7 0x7fbffc9afd61 in cmd_execute_command_real ../lib/command.c:993
    #8 0x7fbffc9b00ee in cmd_execute_command ../lib/command.c:1052
    #9 0x7fbffc9b0dc0 in cmd_execute ../lib/command.c:1218
    #10 0x7fbffcb611c7 in vty_command ../lib/vty.c:591
    #11 0x7fbffcb660ac in vty_execute ../lib/vty.c:1354
    #12 0x7fbffcb6c4aa in vtysh_read ../lib/vty.c:2362
    #13 0x7fbffcb51324 in event_call ../lib/event.c:1979
    #14 0x7fbffca3b872 in frr_run ../lib/libfrr.c:1213
    #15 0x5601dcd11c6f in main ../sharpd/sharp_main.c:177
    #16 0x7fbffc5ffd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7fbffcec9a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fbffca67a81 in qcalloc ../lib/memory.c:105
    #2 0x7fbffca3c108 in list_new ../lib/linklist.c:49
    #3 0x7fbffc9d1acc in cpath_new ../lib/cspf.c:47
    #4 0x7fbffc9d2829 in cspf_init ../lib/cspf.c:256
    #5 0x7fbffc9d295d in cspf_init_v4 ../lib/cspf.c:287
    #6 0x5601dcd34d3f in show_sharp_cspf_magic ../sharpd/sharp_vty.c:1262
    #7 0x5601dcd2c2be in show_sharp_cspf sharpd/sharp_vty_clippy.c:1869
    #8 0x7fbffc9afd61 in cmd_execute_command_real ../lib/command.c:993
    #9 0x7fbffc9b00ee in cmd_execute_command ../lib/command.c:1052
    #10 0x7fbffc9b0dc0 in cmd_execute ../lib/command.c:1218
    #11 0x7fbffcb611c7 in vty_command ../lib/vty.c:591
    #12 0x7fbffcb660ac in vty_execute ../lib/vty.c:1354
    #13 0x7fbffcb6c4aa in vtysh_read ../lib/vty.c:2362
    #14 0x7fbffcb51324 in event_call ../lib/event.c:1979
    #15 0x7fbffca3b872 in frr_run ../lib/libfrr.c:1213
    #16 0x5601dcd11c6f in main ../sharpd/sharp_main.c:177
    #17 0x7fbffc5ffd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
20 months agotests: static_simple gives up after 3 seconds 14244/head
Donald Sharp [Sun, 20 Aug 2023 22:43:48 +0000 (18:43 -0400)]
tests: static_simple gives up after 3 seconds

Under heavy system load we can see that the static_simple
test is giving up too early in this micronet run:

8-17 15:00:27,105 DEBUG: topo: Waiting for [0.1]s as initial delay
2023-08-17 15:00:27,206 DEBUG: r1: cmd_status("/bin/bash -c 'ip -4 route show'")
2023-08-17 15:00:28,209 DEBUG: r1:
stdout: 101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1
2023-08-17 15:00:28,209 DEBUG: topo: checking kernel routing table:
101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1

2023-08-17 15:00:28,210  INFO: topo: Function raised exception: Failed to find
  '10.0.0.0/8(?: nhid [0-9]+)? via 101.0.0.2 dev r1-eth0 proto (static|196) metric 20'
   in
  '101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1
  '
assert None
 +  where None = <function search at 0x7f405b7bb0a0>('10.0.0.0/8(?: nhid [0-9]+)? via 101.0.0.2 dev r1-eth0 proto (static|196) metric 20', '101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1 \n')
 +    where <function search at 0x7f405b7bb0a0> = re.search
2023-08-17 15:00:28,210 DEBUG: topo: Sleeping 2s until next retry with 3.0 retry time left
2023-08-17 15:00:30,211 DEBUG: r1: cmd_status("/bin/bash -c 'ip -4 route show'")
2023-08-17 15:00:31,703 DEBUG: r1:
stdout: 101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1
2023-08-17 15:00:31,703 DEBUG: topo: checking kernel routing table:
101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1

2023-08-17 15:00:31,704  INFO: topo: Function raised exception: Failed to find
  '10.0.0.0/8(?: nhid [0-9]+)? via 101.0.0.2 dev r1-eth0 proto (static|196) metric 20'
   in
  '101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1
  '
assert None
 +  where None = <function search at 0x7f405b7bb0a0>('10.0.0.0/8(?: nhid [0-9]+)? via 101.0.0.2 dev r1-eth0 proto (static|196) metric 20', '101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1 \n')
 +    where <function search at 0x7f405b7bb0a0> = re.search
2023-08-17 15:00:31,704  INFO: topo: Retry timeout of 3s reached
2023-08-17 15:00:31,704  INFO: topo: Spawn collection of support bundle for r1
2023-08-17 15:00:31,704 DEBUG: r1: cmd_status("/bin/bash -c 'mkdir -p /tmp/topotests/static_simple.test_static_simple/r1/support_bundles/test_static_cli'")
2023-08-17 15:00:31,710 DEBUG: r1: popen("/usr/lib/frr/generate_support_bundle.py --log-dir=/tmp/topotests/static_simple.test_static_simple/r1/support_bundles/test_static_cli")
2023-08-17 15:00:31,711 DEBUG: topo: Waiting on support bundle for r1
2023-08-17 15:00:31,751 DEBUG: topo: RETRY DIAG: [failure] Sleeping 2s until next retry with 2.2 retry time left - too see if timeout was too short
2023-08-17 15:00:33,751 DEBUG: r1: cmd_status("/bin/bash -c 'ip -4 route show'")
2023-08-17 15:00:35,137 DEBUG: r1:
stdout: 10.0.0.0/8 nhid 12 via 101.0.0.2 dev r1-eth0 proto 196 metric 20...
2023-08-17 15:00:35,137 DEBUG: topo: checking kernel routing table:
10.0.0.0/8 nhid 12 via 101.0.0.2 dev r1-eth0 proto 196 metric 20
101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1

2023-08-17 15:00:35,137 DEBUG: topo: Function returned None
2023-08-17 15:00:35,138  WARN: topo: RETRY DIAGNOSTIC: SUCCEED after FAILED with requested timeout of 3.0s; however, succeeded in 8.0s, investigate timeout timing
2023-08-17 15:00:35,138  INFO: topo: Function raised exception: Failed to find
  '10.0.0.0/8(?: nhid [0-9]+)? via 101.0.0.2 dev r1-eth0 proto (static|196) metric 20'
   in
  '101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1
  '
assert None
 +  where None = <function search at 0x7f405b7bb0a0>('10.0.0.0/8(?: nhid [0-9]+)? via 101.0.0.2 dev r1-eth0 proto (static|196) metric 20', '101.0.0.0/24 dev r1-eth0 proto kernel scope link src 101.0.0.1 \n')
 +    where <function search at 0x7f405b7bb0a0> = re.search
2023-08-17 15:00:35,138 DEBUG: topo: RETRY DIAG: [failure] Sleeping 2s until next retry with 0.2 retry time left - too see if timeout was too short
2023-08-17 15:00:37,139 DEBUG: r1: cmd_status("/bin/bash -c 'ip -4 route show'")
2023-08-17 15:00:37,247 DEBUG: r1:
stdout: 10.0.0.0/8 nhid 12 via 101.0.0.2 dev r1-eth0 proto 196 metric 20...

Of course it works in the extra couple of times it tries but the test still fails.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Do not explicitly print MAXTTL value for ebgp-multihop vty output 14243/head
Donatas Abraitis [Sun, 20 Aug 2023 21:01:42 +0000 (00:01 +0300)]
bgpd: Do not explicitly print MAXTTL value for ebgp-multihop vty output

1. Create /etc/frr/frr.conf
```
frr version 7.5
frr defaults traditional
hostname centos8.localdomain
no ip forwarding
no ipv6 forwarding
service integrated-vtysh-config
line vty
router bgp 4250001000
  neighbor 192.168.122.207 remote-as 65512
  neighbor 192.168.122.207 ebgp-multihop
```

2. Start FRR
`# systemctl start frr
`
3. Show running configuration. Note that FRR explicitly set and shows the default TTL (225)

```
Building configuration...

Current configuration:
!
frr version 7.5
frr defaults traditional
hostname centos8.localdomain
no ip forwarding
no ipv6 forwarding
service integrated-vtysh-config
!
router bgp 4250001000
 neighbor 192.168.122.207 remote-as 65512
 neighbor 192.168.122.207 ebgp-multihop 255
!
line vty
!
end
```
4. Copy initial frr.conf to frr.conf.new (no changes)
`# cp /etc/frr/frr.conf /root/frr.conf.new
`
5. Run frr-reload.sh:

```
$ /usr/lib/frr/frr-reload.py --test  /root/frr.conf.new
2023-08-20 20:15:48,050  INFO: Called via "Namespace(bindir='/usr/bin', confdir='/etc/frr', daemon='', debug=False, filename='/root/frr.conf.new', input=None, log_level='info', overwrite=False, pathspace=None, reload=False, rundir='/var/run/frr', stdout=False, test=True, vty_socket=None)"
2023-08-20 20:15:48,050  INFO: Loading Config object from file /root/frr.conf.new
2023-08-20 20:15:48,124  INFO: Loading Config object from vtysh show running

Lines To Delete
===============
router bgp 4250001000
 no neighbor 192.168.122.207 ebgp-multihop 255

Lines To Add
============
router bgp 4250001000
 neighbor 192.168.122.207 ebgp-multihop
```

Closes https://github.com/FRRouting/frr/issues/14242

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agobgpd: Don't read the first byte of ORF header if we are ahead of stream 14245/head
Donatas Abraitis [Sun, 20 Aug 2023 19:15:27 +0000 (22:15 +0300)]
bgpd: Don't read the first byte of ORF header if we are ahead of stream

Reported-by: Iggy Frankovic iggyfran@amazon.com
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agoMerge pull request #14226 from Keelan10/fix-pbrd-leak
Donatas Abraitis [Sun, 20 Aug 2023 19:32:21 +0000 (22:32 +0300)]
Merge pull request #14226 from Keelan10/fix-pbrd-leak

pbrd: Correct Handling of Sequence Deletion

20 months agobgpd: Check the length of the rcv software version 14241/head
Donatas Abraitis [Sun, 20 Aug 2023 18:37:25 +0000 (21:37 +0300)]
bgpd: Check the length of the rcv software version

Make sure we don't exceed the maximum of BGP_MAX_SOFT_VERSION.

The Capability Length SHOULD be no greater than 64.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agobgpd: Make sure we have enough data to read two bytes when validating AIGP 14232/head
Donatas Abraitis [Fri, 18 Aug 2023 08:28:03 +0000 (11:28 +0300)]
bgpd: Make sure we have enough data to read two bytes when validating AIGP

Found when fuzzing:

```
==3470861==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xffff77801ef7 at pc 0xaaaaba7b3dbc bp 0xffffcff0e760 sp 0xffffcff0df50
READ of size 2 at 0xffff77801ef7 thread T0
    0 0xaaaaba7b3db8 in __asan_memcpy (/home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgpd+0x363db8) (BuildId: cc710a2356e31c7f4e4a17595b54de82145a6e21)
    1 0xaaaaba81a8ac in ptr_get_be16 /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/./lib/stream.h:399:2
    2 0xaaaaba819f2c in bgp_attr_aigp_valid /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgp_attr.c:504:3
    3 0xaaaaba808c20 in bgp_attr_aigp /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgp_attr.c:3275:7
    4 0xaaaaba7ff4e0 in bgp_attr_parse /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgp_attr.c:3678:10
```

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
20 months agopbrd: Correct Handling of Sequence Deletion 14226/head
Keelan10 [Thu, 17 Aug 2023 19:54:33 +0000 (23:54 +0400)]
pbrd: Correct Handling of Sequence Deletion

This commit ensures that sequence data
and associated structures are correctly deleted to prevent memory leaks

The ASan leak log for reference:
```
Direct leak of 432 byte(s) in 1 object(s) allocated from:
    #0 0x7f911ebaba37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f911e749a4e in qcalloc ../lib/memory.c:105
    #2 0x564fd444b2d3 in pbrms_get ../pbrd/pbr_map.c:527
    #3 0x564fd443a82d in pbr_map ../pbrd/pbr_vty.c:90
    #4 0x7f911e691d61 in cmd_execute_command_real ../lib/command.c:993
    #5 0x7f911e6920ee in cmd_execute_command ../lib/command.c:1052
    #6 0x7f911e692dc0 in cmd_execute ../lib/command.c:1218
    #7 0x7f911e843197 in vty_command ../lib/vty.c:591
    #8 0x7f911e84807c in vty_execute ../lib/vty.c:1354
    #9 0x7f911e84e47a in vtysh_read ../lib/vty.c:2362
    #10 0x7f911e8332f4 in event_call ../lib/event.c:1979
    #11 0x7f911e71d828 in frr_run ../lib/libfrr.c:1213
    #12 0x564fd4425795 in main ../pbrd/pbr_main.c:168
    #13 0x7f911e2e1d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
20 months agoMerge pull request #14216 from LabNConsulting/ziemba-coverity-pbr-230816
Donald Sharp [Sat, 19 Aug 2023 20:17:14 +0000 (16:17 -0400)]
Merge pull request #14216 from LabNConsulting/ziemba-coverity-pbr-230816

pbrd: address coverity issues reported 230815

20 months agoMerge pull request #14238 from Keelan10/ospf-leak-fix
Donald Sharp [Sat, 19 Aug 2023 20:12:08 +0000 (16:12 -0400)]
Merge pull request #14238 from Keelan10/ospf-leak-fix

ospfd: Delete `q_space->vertex_list` on No Backup Path

20 months agoMerge pull request #14236 from Keelan10/bgpd-memleak
Donald Sharp [Sat, 19 Aug 2023 20:11:30 +0000 (16:11 -0400)]
Merge pull request #14236 from Keelan10/bgpd-memleak

bgpd: Free memory in set_aspath_exclude_access_list

20 months agoospfd: Delete `q_space->vertex_list` on No Backup Path 14238/head
Keelan10 [Sat, 19 Aug 2023 14:38:14 +0000 (18:38 +0400)]
ospfd: Delete `q_space->vertex_list` on No Backup Path

In scenarios where no backup paths are available, ensure proper
memory management by deleting `q_space->vertex_list`. This prevents
memory leaks.

The ASan leak log for reference:

```
Direct leak of 80 byte(s) in 2 object(s) allocated from:
    #0 0x7fcf8c70aa37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fcf8c2a8a45 in qcalloc ../lib/memory.c:105
    #2 0x7fcf8c27d0cc in list_new ../lib/linklist.c:49
    #3 0x55d6e8385e35 in ospf_spf_init ../ospfd/ospf_spf.c:540
    #4 0x55d6e838c30d in ospf_spf_calculate ../ospfd/ospf_spf.c:1736
    #5 0x55d6e83933cf in ospf_ti_lfa_generate_q_spaces ../ospfd/ospf_ti_lfa.c:673
    #6 0x55d6e8394214 in ospf_ti_lfa_generate_p_space ../ospfd/ospf_ti_lfa.c:812
    #7 0x55d6e8394c63 in ospf_ti_lfa_generate_p_spaces ../ospfd/ospf_ti_lfa.c:923
    #8 0x55d6e8396390 in ospf_ti_lfa_compute ../ospfd/ospf_ti_lfa.c:1101
    #9 0x55d6e838ca48 in ospf_spf_calculate_area ../ospfd/ospf_spf.c:1811
    #10 0x55d6e838cd73 in ospf_spf_calculate_areas ../ospfd/ospf_spf.c:1840
    #11 0x55d6e838cfb0 in ospf_spf_calculate_schedule_worker ../ospfd/ospf_spf.c:1871
    #12 0x7fcf8c3922e4 in event_call ../lib/event.c:1979
    #13 0x7fcf8c27c828 in frr_run ../lib/libfrr.c:1213
    #14 0x55d6e82eeb6d in main ../ospfd/ospf_main.c:249
    #15 0x7fcf8bd59d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
20 months agobgpd: Free memory in set_aspath_exclude_access_list 14236/head
Keelan10 [Sat, 19 Aug 2023 10:00:17 +0000 (14:00 +0400)]
bgpd: Free memory in set_aspath_exclude_access_list

Properly free the dynamically allocated memory held by `str` after its use.
The change also maintains the return value of `nb_cli_apply_changes` by using `ret` variable.

The ASan leak log for reference:

```
Direct leak of 55 byte(s) in 2 object(s) allocated from:
    #0 0x7f16f285f867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f16f23fda11 in qmalloc ../lib/memory.c:100
    #2 0x7f16f23a01a0 in frrstr_join ../lib/frrstr.c:89
    #3 0x7f16f23418c7 in argv_concat ../lib/command.c:183
    #4 0x55aba24731f2 in set_aspath_exclude_access_list_magic ../bgpd/bgp_routemap.c:6327
    #5 0x55aba2455cf4 in set_aspath_exclude_access_list bgpd/bgp_routemap_clippy.c:836
    #6 0x7f16f2345d61 in cmd_execute_command_real ../lib/command.c:993
    #7 0x7f16f23460ee in cmd_execute_command ../lib/command.c:1052
    #8 0x7f16f2346dc0 in cmd_execute ../lib/command.c:1218
    #9 0x7f16f24f7197 in vty_command ../lib/vty.c:591
    #10 0x7f16f24fc07c in vty_execute ../lib/vty.c:1354
    #11 0x7f16f250247a in vtysh_read ../lib/vty.c:2362
    #12 0x7f16f24e72f4 in event_call ../lib/event.c:1979
    #13 0x7f16f23d1828 in frr_run ../lib/libfrr.c:1213
    #14 0x55aba2269e52 in main ../bgpd/bgp_main.c:510
    #15 0x7f16f1dbfd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
20 months agopbrd: address 230815 coverity: pbr_vty.c vrf_name 14216/head
G. Paul Ziemba [Fri, 18 Aug 2023 18:19:05 +0000 (11:19 -0700)]
pbrd: address 230815 coverity: pbr_vty.c vrf_name

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
20 months agopbrd: address 230815 coverity: pbr_vty.c pbrms
G. Paul Ziemba [Fri, 18 Aug 2023 18:14:25 +0000 (11:14 -0700)]
pbrd: address 230815 coverity: pbr_vty.c pbrms

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
20 months agopbrd: address 230815 coverity: pbr_vty.c pend/strtoul
G. Paul Ziemba [Fri, 18 Aug 2023 18:13:20 +0000 (11:13 -0700)]
pbrd: address 230815 coverity: pbr_vty.c pend/strtoul

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
20 months agopbrd: address 230815 coverity: r.action.flags reordering
G. Paul Ziemba [Fri, 18 Aug 2023 18:11:17 +0000 (11:11 -0700)]
pbrd: address 230815 coverity: r.action.flags reordering

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
20 months agoMerge pull request #14223 from donaldsharp/interface_fies
Mark Stapp [Fri, 18 Aug 2023 15:56:20 +0000 (11:56 -0400)]
Merge pull request #14223 from donaldsharp/interface_fies

zebra: Fix crashes in interface change

20 months agobgpd: Separate out mtype for peer and connection 8790/head
Donald Sharp [Thu, 15 Jun 2023 14:38:49 +0000 (10:38 -0400)]
bgpd: Separate out mtype for peer and connection

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Cleanup bgp_start declarations
Donald Sharp [Tue, 10 Aug 2021 04:55:40 +0000 (00:55 -0400)]
bgpd: Cleanup bgp_start declarations

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Convert FSM to use `struct peer_connection`
Donald Sharp [Tue, 10 Aug 2021 04:52:53 +0000 (00:52 -0400)]
bgpd: Convert FSM to use `struct peer_connection`

The BGP FSM was using the peer as the unit of work
but the FSM is connection focused.  So let's switch
it over to using that.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Convert `struct peer_connection` to dynamically allocated
Donald Sharp [Tue, 10 Aug 2021 03:43:46 +0000 (23:43 -0400)]
bgpd: Convert `struct peer_connection` to dynamically allocated

As part of the conversion to a `struct peer_connection` it will
be desirable to have 2 pointers one for when we open a connection
and one for when we receive a connection.  Start this actual
conversion over to this in `struct peer`.  If this sounds confusing
take a look at the bgp state machine for connections and how
it resolves the processing of this router opening -vs- this
router receiving an open.  At some point in time the state
machine decides that we are keeping one of the two connections.

Future commits will allow us to untangle the peer/doppelganger
duality with this abstraction.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Move t_process_packet and t_process_packet_error to connection
Donald Sharp [Tue, 10 Aug 2021 03:01:32 +0000 (23:01 -0400)]
bgpd: Move t_process_packet and t_process_packet_error to connection

The t_process_packet thread events should be managed by the connection.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Move status and ostatus to `struct peer_connection`
Donald Sharp [Thu, 3 Jun 2021 21:13:52 +0000 (17:13 -0400)]
bgpd: Move status and ostatus to `struct peer_connection`

The status and ostatus are a function of the `struct peer_connection`
move it into that data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: READ and WRITE flags are a part of the connection
Donald Sharp [Thu, 3 Jun 2021 19:20:11 +0000 (15:20 -0400)]
bgpd: READ and WRITE flags are a part of the connection

Move PEER_THREAD_WRITES_ON and PEER_THREAD_READS_ON to
be a part of the `struct peer_connection` since this is
a connection oriented bit of data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Move t_write and t_read into `struct peer_connection`
Donald Sharp [Fri, 30 Apr 2021 23:02:00 +0000 (19:02 -0400)]
bgpd: Move t_write and t_read into `struct peer_connection`

Move the peer->t_write and peer->t_read into `struct peer_connection`
as that these are properties of the connection.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
P# Please enter the commit message for your changes. Lines starting

20 months agobgpd: Convert bgp_io.c to take `struct peer_connection`
Donald Sharp [Fri, 30 Apr 2021 20:39:40 +0000 (16:39 -0400)]
bgpd: Convert bgp_io.c to take `struct peer_connection`

bgp_io.c is clearly connection oriented so let's convert
it over to using `struct peer_connection`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Add peer backpointer to `struct peer_connection`
Donald Sharp [Fri, 30 Apr 2021 19:33:15 +0000 (15:33 -0400)]
bgpd: Add peer backpointer to `struct peer_connection`

We will need the peer backpointer for a `struct peer_connection`
Let's add it in.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Create a _new function for `struct peer_connection`
Donald Sharp [Fri, 30 Apr 2021 19:29:37 +0000 (15:29 -0400)]
bgpd: Create a _new function for `struct peer_connection`

Nothing fancy here allow us to create the needed buffers
in an abstract way.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Create destructor function for `struct peer_connection`
Donald Sharp [Fri, 30 Apr 2021 19:26:08 +0000 (15:26 -0400)]
bgpd: Create destructor function for `struct peer_connection`

Create a destructor function to free up memory associated
with the io buffers.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Start abstraction of `struct peer_connection`
Donald Sharp [Fri, 30 Apr 2021 18:55:40 +0000 (14:55 -0400)]
bgpd: Start abstraction of `struct peer_connection`

BGP tracks connections based upon the peer.  But the problem
with this is that the doppelganger structure for it is being
created.  This has introduced a bunch of fragileness in that
the peer exists independently of the connections to it.

The whole point of the doppelganger structure was to allow
BGP to both accept and initiate tcp connections and then
when we get one to a `good` state we collapse into the
appropriate one.  The problem with this is that having
2 peer structures for this creates a situation where
we have to make sure we are configing the `right` one
and also make sure that we collapse the two independent
peer structures into 1 acting peer.  This makes no sense
let's abstract out the peer into having 2 connection
one for incoming connections and one for outgoing connections
then we can easily collapse down without having to do crazy
stuff.  In addition people adding new features don't need
to have to go touch a million places in the code.

This is the start of this abstraction.  In this commit
we'll just pull out the fd and input/output buffers
into a connection data structure.  Future commits
will abstract further.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agoMerge pull request #14224 from Keelan10/fix-bgpd-leak
Donatas Abraitis [Fri, 18 Aug 2023 07:21:50 +0000 (10:21 +0300)]
Merge pull request #14224 from Keelan10/fix-bgpd-leak

bgpd: Free memory in set_aspath_replace_access_list

20 months agobgpd: Free memory in set_aspath_replace_access_list 14224/head
Keelan10 [Thu, 17 Aug 2023 16:42:11 +0000 (20:42 +0400)]
bgpd: Free memory in set_aspath_replace_access_list

Properly free the dynamically allocated memory held by `str` after its use.
The change also maintains the return value of `nb_cli_apply_changes` by using 'ret' variable.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in bgp_set_aspath_replace.test_bgp_set_aspath_replace/r1.asan.bgpd.11586

=================================================================
==11586==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 92 byte(s) in 3 object(s) allocated from:
    #0 0x7f4e2951db40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7f4e28f19ea2 in qmalloc lib/memory.c:100
    #2 0x7f4e28edbb08 in frrstr_join lib/frrstr.c:89
    #3 0x7f4e28e9a601 in argv_concat lib/command.c:183
    #4 0x56519adf8413 in set_aspath_replace_access_list_magic bgpd/bgp_routemap.c:6174
    #5 0x56519adf8942 in set_aspath_replace_access_list bgpd/bgp_routemap_clippy.c:683
    #6 0x7f4e28e9d548 in cmd_execute_command_real lib/command.c:993
    #7 0x7f4e28e9da0c in cmd_execute_command lib/command.c:1051
    #8 0x7f4e28e9de8b in cmd_execute lib/command.c:1218
    #9 0x7f4e28fc4f1c in vty_command lib/vty.c:591
    #10 0x7f4e28fc53c7 in vty_execute lib/vty.c:1354
    #11 0x7f4e28fcdc8d in vtysh_read lib/vty.c:2362
    #12 0x7f4e28fb8c8b in event_call lib/event.c:1979
    #13 0x7f4e28efd445 in frr_run lib/libfrr.c:1213
    #14 0x56519ac85d81 in main bgpd/bgp_main.c:510
    #15 0x7f4e27f40c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 92 byte(s) leaked in 3 allocation(s).
***********************************************************************************

***********************************************************************************
Address Sanitizer Error detected in bgp_set_aspath_exclude.test_bgp_set_aspath_exclude/r1.asan.bgpd.10385

=================================================================
==10385==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 55 byte(s) in 2 object(s) allocated from:
    #0 0x7f6814fdab40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7f68149d6ea2 in qmalloc lib/memory.c:100
    #2 0x7f6814998b08 in frrstr_join lib/frrstr.c:89
    #3 0x7f6814957601 in argv_concat lib/command.c:183
    #4 0x5570e05117a1 in set_aspath_exclude_access_list_magic bgpd/bgp_routemap.c:6327
    #5 0x5570e05119da in set_aspath_exclude_access_list bgpd/bgp_routemap_clippy.c:836
    #6 0x7f681495a548 in cmd_execute_command_real lib/command.c:993
    #7 0x7f681495aa0c in cmd_execute_command lib/command.c:1051
    #8 0x7f681495ae8b in cmd_execute lib/command.c:1218
    #9 0x7f6814a81f1c in vty_command lib/vty.c:591
    #10 0x7f6814a823c7 in vty_execute lib/vty.c:1354
    #11 0x7f6814a8ac8d in vtysh_read lib/vty.c:2362
    #12 0x7f6814a75c8b in event_call lib/event.c:1979
    #13 0x7f68149ba445 in frr_run lib/libfrr.c:1213
    #14 0x5570e03a0d81 in main bgpd/bgp_main.c:510
    #15 0x7f68139fdc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 55 byte(s) leaked in 2 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
20 months agoMerge pull request #14218 from Pdoijode/pdoijode/frr-bgp-nexthop-find-fix
Mark Stapp [Thu, 17 Aug 2023 13:56:36 +0000 (09:56 -0400)]
Merge pull request #14218 from Pdoijode/pdoijode/frr-bgp-nexthop-find-fix

bgpd: Set ifindex to find the correct nexthop

20 months agozebra: Fix crashes in interface change 14223/head
Donald Sharp [Mon, 14 Aug 2023 19:06:30 +0000 (15:06 -0400)]
zebra: Fix crashes in interface change

Upon some internal testing some crashes were found.  This fixes
the several crashes and normalizes the code to be closer in
it's execution pre and post changes to use the data plane.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
20 months agobgpd: Set ifindex to find the correct nexthop 14218/head
Pooja Jagadeesh Doijode [Wed, 16 Aug 2023 22:27:38 +0000 (15:27 -0700)]
bgpd: Set ifindex to find the correct nexthop

Problem:
    On GR helper, paths learnt from an interface based peer were linked
    to bnc with ifindex=0. During restart of GR peer, BGP (unnumbered)
    session (with GR restarter peer) goes down on GR helper but the routes
    are retained. Later, when BGP receives an interface up event, it
    will process all the paths associated with BNC whose ifindex matches the
    ifindex of the interface for which UP event is received. However, paths
    associated with bnc that has ifindex=0 were not being reinstalled since
    ifindex=0 doesn't match ifindex of any interfaces. This results in
    BGP routes not being reinstalled in zebra and kernel.

Fix:
    For paths learnt from an interface based peer, set the
    ifindex to peer's interface ifindex so that correct
    peer based nexthop can be found and linked to the path.

Signed-off-by: Donald Sharp sharpd@nvidia.com
Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
20 months agoospf6d: introduce OSPFv3 Cryptographic Protocol ID constant 14146/head
Renato Westphal [Fri, 11 Aug 2023 23:33:19 +0000 (20:33 -0300)]
ospf6d: introduce OSPFv3 Cryptographic Protocol ID constant

Create a constant OSPFV3_CRYPTO_PROTO_ID to replace the hard-coded
Cryptographic Protocol ID in the OSPFv3 authentication trailer
code. This enhances code clarity and maintainability.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
20 months agoospf6d: fix interoperability issue in auth trailer digest computation
Renato Westphal [Fri, 4 Aug 2023 12:03:02 +0000 (09:03 -0300)]
ospf6d: fix interoperability issue in auth trailer digest computation

Ensure the OSPFv3 Cryptographic Protocol ID is encoded in network
byte order when appending it to the authentication key. This solves
interoperability issues with other implementations such as BIRD
and IOS-XR.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>