]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
9 months agoisisd: fix crash when calculating the neighbor spanning tree based on the fragmented LSP 16396/head
zhou-run [Thu, 11 Jul 2024 03:35:34 +0000 (11:35 +0800)]
isisd: fix crash when calculating the neighbor spanning tree based on the fragmented LSP

1. When the root IS regenerates an LSP, it calls lsp_build() -> lsp_clear_data() to free the TLV memory of the first fragment and all other fragments. If the number of fragments in the regenerated LSP decreases or if no fragmentation is needed, the extra LSP fragments are not immediately deleted. Instead, lsp_seqno_update() -> lsp_purge() is called to set the remaining time to zero and start aging, while also notifying other IS nodes to age these fragments. lsp_purge() usually does not reset lsp->hdr.seqno to zero because the LSP might recover during the aging process.
2. When other IS nodes receive an LSP, they always call process_lsp() -> isis_unpack_tlvs() to allocate TLV memory for the LSP. This does not differentiate whether the received LSP has a remaining lifetime of zero. Therefore, it is rare for an LSP of a non-root IS to have empty TLVs. Of course, if an LSP with a remaining time of zero and already corrupted is received, lsp_update() -> lsp_purge() will be called to free the TLV memory of the LSP, but this scenario is rare.
3. In LFA calculations, neighbors of the root IS are traversed, and each neighbor is taken as a new root to compute the neighbor SPT. During this process, the old root IS will serve as a neighbor of the new root IS, triggering a call to isis_spf_process_lsp() to parse the LSP of the old root IS and obtain its IP vertices and neighboring IS vertices. However, isis_spf_process_lsp() only checks whether the TLVs in the first fragment of the LSP exist, and does not check the TLVs in the fragmented LSP. If the TLV memory of the fragmented LSP of the old root IS has been freed, it can lead to a null pointer access, causing the current crash.

Additionally, for the base SPT, there are only two places where the LSP of the root IS is parsed:
1. When obtaining the UP neighbors of the root IS via spf_adj_list_parse_lsp().
2. When preloading the IP vertices of the root IS via isis_lsp_iterate_ip_reach().
Both of these checks ensure that frag->tlvs is not null, and they do not subsequently call isis_spf_process_lsp() to parse the root IS's LSP. It is very rare for non-root IS LSPs to have empty TLVs unless they are corrupted LSPs awaiting deletion. If it happens, a crash will occur.

The backtrace is as follows:
(gdb) bt
#0  0x00007f3097281fe1 in raise () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007f30973a2972 in core_handler (signo=11, siginfo=0x7ffce66c2870, context=0x7ffce66c2740) at ../lib/sigevent.c:261
#2  <signal handler called>
#3  0x000055dfa805512b in isis_spf_process_lsp (spftree=0x55dfa950eee0, lsp=0x55dfa94cb590, cost=10, depth=1, root_sysid=0x55dfa950ef6c "", parent=0x55dfa952fca0)
    at ../isisd/isis_spf.c:898
#4  0x000055dfa805743b in isis_spf_loop (spftree=0x55dfa950eee0, root_sysid=0x55dfa950ef6c "") at ../isisd/isis_spf.c:1688
#5  0x000055dfa805784f in isis_run_spf (spftree=0x55dfa950eee0) at ../isisd/isis_spf.c:1808
#6  0x000055dfa8037ff5 in isis_spf_run_neighbors (spftree=0x55dfa9474440) at ../isisd/isis_lfa.c:1259
#7  0x000055dfa803ac17 in isis_spf_run_lfa (area=0x55dfa9477510, spftree=0x55dfa9474440) at ../isisd/isis_lfa.c:2300
#8  0x000055dfa8057964 in isis_run_spf_with_protection (area=0x55dfa9477510, spftree=0x55dfa9474440) at ../isisd/isis_spf.c:1827
#9  0x000055dfa8057c15 in isis_run_spf_cb (thread=0x7ffce66c38e0) at ../isisd/isis_spf.c:1889
#10 0x00007f30973bbf04 in thread_call (thread=0x7ffce66c38e0) at ../lib/thread.c:1990
#11 0x00007f309735497b in frr_run (master=0x55dfa91733c0) at ../lib/libfrr.c:1198
#12 0x000055dfa8029d5d in main (argc=5, argv=0x7ffce66c3b08, envp=0x7ffce66c3b38) at ../isisd/isis_main.c:273
(gdb) f 3
#3  0x000055dfa805512b in isis_spf_process_lsp (spftree=0x55dfa950eee0, lsp=0x55dfa94cb590, cost=10, depth=1, root_sysid=0x55dfa950ef6c "", parent=0x55dfa952fca0)
    at ../isisd/isis_spf.c:898
898     ../isisd/isis_spf.c: No such file or directory.
(gdb) p te_neighs
$1 = (struct isis_item_list *) 0x120
(gdb) p lsp->tlvs
$2 = (struct isis_tlvs *) 0x0
(gdb) p lsp->hdr
$3 = {pdu_len = 27, rem_lifetime = 0, lsp_id = "\000\000\000\000\000\001\000\001", seqno = 4, checksum = 59918, lsp_bits = 1 '\001'}

The backtrace provided above pertains to version 8.5.4, but it seems that the same issue exists in the code of the master branch as well.

I have reviewed the process for calculating the SPT based on the LSP, and isis_spf_process_lsp() is the only function that does not check whether the TLVs in the fragments are empty. Therefore, I believe that modifying this function alone should be sufficient. If the TLVs of the current fragment are already empty, we do not need to continue processing subsequent fragments. This is consistent with the behavior where we do not process fragments if the TLVs of the first fragment are empty.
Of course, one could argue that lsp_purge() should still retain the TLV memory, freeing it and then reallocating it if needed. However, this is a debatable point because in some scenarios, it is permissible for the LSP to have empty TLVs. For example, after receiving an SNP (Sequence Number PDU) message, an empty LSP (with lsp->hdr.seqno = 0) might be created by calling lsp_new. If the corresponding LSP message is discarded due to domain or area authentication failure, the TLV memory wouldn't be allocated.

Test scenario:
In an LFA network, importing a sufficient number of static routes to cause LSP fragmentation, and then rolling back the imported static routes so that the LSP is no longer fragmented, can easily result in this issue.

Signed-off-by: zhou-run <zhou.run@h3c.com>
(cherry picked from commit e905177a8c9d67713682d46934c7a87a0913c250)

9 months agoMerge pull request #16388 from FRRouting/mergify/bp/stable/10.0/pr-16373
Jafar Al-Gharaibeh [Tue, 16 Jul 2024 13:56:22 +0000 (09:56 -0400)]
Merge pull request #16388 from FRRouting/mergify/bp/stable/10.0/pr-16373

staticd: fix missing static routes (backport #16373)

9 months agozebra: fix missing static routes 16388/head
anlan_cs [Fri, 12 Jul 2024 09:03:03 +0000 (17:03 +0800)]
zebra: fix missing static routes

Use `vtysh` with this input file:
```
ip route A nh1
ip route A nh2
ip route B nh1
ip route B nh2
```

When running "ip route B" with "nh1" and "nh2", the procedure maybe is:
1) Create the two nexthops: "nh1" and "nh2".
2) Register "nh1" with `static_zebra_nht_register()`, then the states of both
   "nh1" and "nht2" are set to "STATIC_SENT_TO_ZEBRA".
3) Register "nh2" with `static_zebra_nht_register()`, then only the routes with
   nexthop of "STATIC_START" will be sent to zebra.

So, send the routes with the nexthop of "STATIC_SENT_TO_ZEBRA" to zebra.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
(cherry picked from commit 4518d386f7683289b079708fcdb0c42ced4754d9)

9 months agoMerge pull request #16329 from FRRouting/mergify/bp/stable/10.0/pr-16303
Donald Sharp [Wed, 3 Jul 2024 13:37:36 +0000 (09:37 -0400)]
Merge pull request #16329 from FRRouting/mergify/bp/stable/10.0/pr-16303

isisd: fix crash when obtaining the next hop to calculate LFA on LAN links (backport #16303)

9 months agoMerge pull request #16336 from FRRouting/mergify/bp/stable/10.0/pr-16226
Donatas Abraitis [Wed, 3 Jul 2024 09:57:21 +0000 (11:57 +0200)]
Merge pull request #16336 from FRRouting/mergify/bp/stable/10.0/pr-16226

ldpd: fix wrong gtsm count (backport #16226)

9 months agoMerge pull request #16313 from FRRouting/mergify/bp/stable/10.0/pr-16305
Jafar Al-Gharaibeh [Tue, 2 Jul 2024 20:56:19 +0000 (16:56 -0400)]
Merge pull request #16313 from FRRouting/mergify/bp/stable/10.0/pr-16305

bgpd: Ignore RFC8212 for BGP Confederations (backport #16305)

9 months agoMerge pull request #16327 from FRRouting/mergify/bp/stable/10.0/pr-15716
Jafar Al-Gharaibeh [Tue, 2 Jul 2024 20:55:29 +0000 (16:55 -0400)]
Merge pull request #16327 from FRRouting/mergify/bp/stable/10.0/pr-15716

isisd: Fix memory leaks when the transition of neighbor state from non-UP to DOWN (backport #15716)

9 months agoldpd: fix wrong gtsm count 16336/head
anlan_cs [Sat, 15 Jun 2024 12:34:20 +0000 (20:34 +0800)]
ldpd: fix wrong gtsm count

In linux networking stack, the received mpls packets will be processed
by the host *twice*, one as mpls packet, the other as ip packet, so
its ttl decreased 1.

So, we need release the `IP_MINTTL` value if gtsm is enabled, it is for the
mpls packets of neighbor session caused by the command:
`label local advertise explicit-null`.

This change makes the gtsm mechanism a bit deviation.

Fix PR #8313

Signed-off-by: anlan_cs <vic.lan@pica8.com>
(cherry picked from commit 1919df3a64d3fe6d4084c1d0b050b3e368860170)

9 months agoisisd: fix crash when obtaining the next hop to calculate LFA on LAN links 16329/head
zhou-run [Thu, 27 Jun 2024 03:51:02 +0000 (11:51 +0800)]
isisd: fix crash when obtaining the next hop to calculate LFA on LAN links

When a neighbor connection is disconnected, it may trigger LSP re-generation as a timer task, but this process may be delayed. As a result, the list of neighbors in area->adjacency_list may be inconsistent with the neighbors in lsp->tlvs->oldstyle_reach/extended_reach. For example, the area->adjacency_list may lack certain neighbors even though they are present in the LSP. When computing SPF, the call to isis_spf_build_adj_list() generates the spftree->sadj_list, which reflects the real neighbors in the area->adjacency_list. However, in the case of LAN links, spftree->sadj_list may include additional pseudo neighbors.
The pre-loading of tents through the call to isis_spf_preload_tent involves two steps:
1. isis_spf_process_lsp() is called to generate real neighbor vertices based on the root LSP and pseudo LSP.
2. isis_spf_add_local() is called to add corresponding next hops to the vertex->Adj_N list for the real neighbor vertices.
In the case of LAN links, the absence of corresponding real neighbors in the spftree->sadj_list prevents the execution of the second step. Consequently, the vertex->Adj_N list for the real neighbor vertices lacks corresponding next hops. This leads to a null pointer access when isis_lfa_compute() is called to calculate LFA.
As for P2P links, since there are no pseudo neighbors, only the second step is executed, which does not create real neighbor vertices and therefore does not encounter this issue.
The backtrace is as follows:
(gdb) bt
#0  0x00007fd065277fe1 in raise () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007fd065398972 in core_handler (signo=11, siginfo=0x7ffc5c0636b0, context=0x7ffc5c063580) at ../lib/sigevent.c:261
#2  <signal handler called>
#3  0x00005564d82f8408 in isis_lfa_compute (area=0x5564d8b143f0, circuit=0x5564d8b21d10, spftree=0x5564d8b06bf0, resource=0x7ffc5c064410) at ../isisd/isis_lfa.c:2134
#4  0x00005564d82f8d78 in isis_spf_run_lfa (area=0x5564d8b143f0, spftree=0x5564d8b06bf0) at ../isisd/isis_lfa.c:2344
#5  0x00005564d8315964 in isis_run_spf_with_protection (area=0x5564d8b143f0, spftree=0x5564d8b06bf0) at ../isisd/isis_spf.c:1827
#6  0x00005564d8315c15 in isis_run_spf_cb (thread=0x7ffc5c064590) at ../isisd/isis_spf.c:1889
#7  0x00007fd0653b1f04 in thread_call (thread=0x7ffc5c064590) at ../lib/thread.c:1990
#8  0x00007fd06534a97b in frr_run (master=0x5564d88103c0) at ../lib/libfrr.c:1198
#9  0x00005564d82e7d5d in main (argc=5, argv=0x7ffc5c0647b8, envp=0x7ffc5c0647e8) at ../isisd/isis_main.c:273
(gdb) f 3
#3  0x00005564d82f8408 in isis_lfa_compute (area=0x5564d8b143f0, circuit=0x5564d8b21d10, spftree=0x5564d8b06bf0, resource=0x7ffc5c064410) at ../isisd/isis_lfa.c:2134
2134    ../isisd/isis_lfa.c: No such file or directory.
(gdb) p vadj_primary
$1 = (struct isis_vertex_adj *) 0x0
(gdb) p vertex->Adj_N->head
$2 = (struct listnode *) 0x0
(gdb) p (struct isis_vertex *)spftree->paths->l.list->head->next->next->next->next->data
$8 = (struct isis_vertex *) 0x5564d8b5b240
(gdb) p $8->type
$9 = VTYPE_NONPSEUDO_TE_IS
(gdb) p $8->N.id
$10 = "\000\000\000\000\000\002"
(gdb) p $8->Adj_N->count
$11 = 0
(gdb) p (struct isis_vertex *)spftree->paths->l.list->head->next->next->next->next->next->data
$12 = (struct isis_vertex *) 0x5564d8b73dd0
(gdb) p $12->type
$13 = VTYPE_NONPSEUDO_TE_IS
(gdb) p $12->N.id
$14 = "\000\000\000\000\000\003"
(gdb) p $12->Adj_N->count
$15 = 0
(gdb) p area->adjacency_list->count
$16 = 0
The backtrace provided above pertains to version 8.5.4, but it seems that the same issue exists in the code of the master branch as well.
The scenario where a vertex has no next hop is normal. For example, the "clear isis neighbor" command invokes isis_vertex_adj_del() to delete the next hop of a vertex. Upon reviewing all the instances where the vertex->Adj_N list is used, I found that only isis_lfa_compute() lacks a null check. Therefore, I believe that modifying this part will be sufficient. Additionally, the vertex->parents list for IP vertices is guaranteed not to be empty.
Test scenario:
Setting up LFA for LAN links and executing the "clear isis neighbor" command easily reproduces the issue.

Signed-off-by: zhou-run <zhou.run@h3c.com>
(cherry picked from commit a970bb51b5fe32335c783860a03bb02ce74a49aa)

9 months agoMerge pull request #16319 from FRRouting/mergify/bp/stable/10.0/pr-16233
Russ White [Tue, 2 Jul 2024 11:59:41 +0000 (07:59 -0400)]
Merge pull request #16319 from FRRouting/mergify/bp/stable/10.0/pr-16233

ripd/ripd.c - rip_auth_md5 : Change the start value of sequence 1 to 0 (backport #16233)

9 months agoisisd: Fix memory leaks when the transition of neighbor state from non-UP to DOWN 16327/head
zhou-run [Tue, 9 Apr 2024 13:04:39 +0000 (21:04 +0800)]
isisd: Fix memory leaks when the transition of neighbor state from non-UP to DOWN

When receiving a hello packet, if the neighbor state transitions directly from a non-ISIS_ADJ_UP state (such as ISIS_ADJ_INITIALIZING) to ISIS_ADJ_DOWN state, the neighbor entry cannot be deleted. If the neighbor is removed or the neighbor's System ID changes, it may result in memory leakage in the neighbor entry.

Test Scenario:
LAN link between Router A and Router B is established. Router A does not configure neighbor authentication, while Router B is configured with neighbor authentication. When the neighbor entry on Router B ages out, the neighbor state on Router A transitions to INIT. If Router B is then removed, the neighbor state on Router A transitions to DOWN and persists.

Signed-off-by: zhou-run <166502045+zhou-run@users.noreply.github.com>
fix frrbot styling issues found.

fix frrbot styling issues found.

Signed-off-by: zhou-run <166502045+zhou-run@users.noreply.github.com>
(cherry picked from commit 5009f7539ad6bf496158499917dcf3f7ab760753)

9 months agoripd: Change the start value of sequence 1 to 0 16319/head
T-Nicolas [Mon, 17 Jun 2024 13:05:58 +0000 (15:05 +0200)]
ripd: Change the start value of sequence 1 to 0

Signed-off-by: T-Nicolas <github@toselli.email>
(cherry picked from commit 1a64fe4254759245a67fb279d67478922e00255e)

9 months agotests: Test if RFC 8212 is not involved for BGP confederations 16313/head
Donatas Abraitis [Thu, 27 Jun 2024 19:53:24 +0000 (22:53 +0300)]
tests: Test if RFC 8212 is not involved for BGP confederations

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit dd6a679e3a0e9415827643942bcc103c48a89adb)

9 months agobgpd: Ignore RFC8212 for BGP Confederations
Donatas Abraitis [Thu, 27 Jun 2024 19:46:58 +0000 (22:46 +0300)]
bgpd: Ignore RFC8212 for BGP Confederations

RFC 8212 should be restricted for eBGP peers.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit fa2cc09d45d3f843564f7bd1e02346373c5741a8)

10 months agoMerge pull request #16283 from FRRouting/mergify/bp/stable/10.0/pr-15838
Russ White [Tue, 25 Jun 2024 11:31:50 +0000 (07:31 -0400)]
Merge pull request #16283 from FRRouting/mergify/bp/stable/10.0/pr-15838

 bgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issue (backport #15838)

10 months agoMerge pull request #16292 from FRRouting/mergify/bp/stable/10.0/pr-16214
Russ White [Tue, 25 Jun 2024 11:30:54 +0000 (07:30 -0400)]
Merge pull request #16292 from FRRouting/mergify/bp/stable/10.0/pr-16214

bgpd: A couple more fixes for Tunnel encapsulation handling (backport #16214)

10 months agoMerge pull request #16290 from FRRouting/mergify/bp/stable/10.0/pr-16273
Russ White [Tue, 25 Jun 2024 11:30:34 +0000 (07:30 -0400)]
Merge pull request #16290 from FRRouting/mergify/bp/stable/10.0/pr-16273

bgpd: Relax OAD (One-Administration-Domain) for RFC8212 (backport #16273)

10 months agoMerge pull request #16282 from FRRouting/mergify/bp/stable/10.0/pr-16213
Russ White [Tue, 25 Jun 2024 11:29:54 +0000 (07:29 -0400)]
Merge pull request #16282 from FRRouting/mergify/bp/stable/10.0/pr-16213

bgpd: Check if we have really enough data before doing memcpy for FQDN capability (backport #16213)

10 months agobgpd: Check if we have real stream data for tunnel encapsulation sub-tlvs 16292/head
Donatas Abraitis [Thu, 13 Jun 2024 06:00:21 +0000 (09:00 +0300)]
bgpd: Check if we have real stream data for tunnel encapsulation sub-tlvs

When the packet is malformed it can use whatever values it wants. Let's check
what the real data we have in a stream instead of relying on malformed values.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 9929486d6bdb28469a5b626a17d5bc9991c83ce3)

10 months agobgpd: Adjust the length of tunnel encap sub-tlv by sub-tlv type
Donatas Abraitis [Thu, 13 Jun 2024 05:43:21 +0000 (08:43 +0300)]
bgpd: Adjust the length of tunnel encap sub-tlv by sub-tlv type

Fixes: 79563af564ad0fe5b9c8d95bf080d570f87b1859 ("bgpd: Get 1 or 2 octets for Sub-TLV length (Tunnel Encap attr)")
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 34b209f0ae2caca0d1ebcde9d4095375ac31b562)

10 months agobgpd: Relax OAD (One-Administration-Domain) for RFC8212 16290/head
Donatas Abraitis [Mon, 24 Jun 2024 17:16:16 +0000 (20:16 +0300)]
bgpd: Relax OAD (One-Administration-Domain) for RFC8212

RFC 8212 defines leak prevention for eBGP peers, but BGP-OAD defines a new
peering type One Administrative Domain (OAD), where multiple ASNs could be used
inside a single administrative domain. OAD allows sending non-transitive attributes,
so this prevention should be relaxed too.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 3b98ddf5018cf7526b50c15018cbaf71a38fa752)

10 months agoMerge pull request #16279 from FRRouting/mergify/bp/stable/10.0/pr-16211
Donatas Abraitis [Tue, 25 Jun 2024 10:48:05 +0000 (13:48 +0300)]
Merge pull request #16279 from FRRouting/mergify/bp/stable/10.0/pr-16211

bgpd: Check if we have really enough data before doing memcpy for software version (backport #16211)

10 months agoMerge pull request #16275 from FRRouting/mergify/bp/stable/10.0/pr-16242
Jafar Al-Gharaibeh [Tue, 25 Jun 2024 05:25:42 +0000 (01:25 -0400)]
Merge pull request #16275 from FRRouting/mergify/bp/stable/10.0/pr-16242

bgpd: Set last reset reason to admin shutdown if it was manually (backport #16242)

10 months agoMerge pull request #16268 from louis-6wind/show-isis-database-crash-bp
Russ White [Mon, 24 Jun 2024 21:18:26 +0000 (17:18 -0400)]
Merge pull request #16268 from louis-6wind/show-isis-database-crash-bp

isisd: fix crash when displaying asla in json

10 months agotests: improve tests for aspath exclude and bgp access list 16283/head
Francois Dumontet [Wed, 24 Apr 2024 12:34:48 +0000 (14:34 +0200)]
tests: improve tests for aspath exclude and bgp access list

add some match in route map rules
add some set unset bgp access path list
add another prefix for better tests discrimination
update expected results

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
(cherry picked from commit 0df2e149970beff39915d0095614d56d5859f3ff)

10 months agobgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issues
Francois Dumontet [Tue, 23 Apr 2024 09:16:24 +0000 (11:16 +0200)]
bgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issues

whith the following config

router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 192.168.1.2 remote-as external
 neighbor 192.168.1.2 timers 3 10
 !
 address-family ipv4 unicast
  neighbor 192.168.1.2 route-map r2 in
 exit-address-family
exit
!
bgp as-path access-list FIRST seq 5 permit ^65
bgp as-path access-list SECOND seq 5 permit 2$
!
route-map r2 permit 6
 match ip address prefix-list p2
 set as-path exclude as-path-access-list SECOND
exit
!
route-map r2 permit 10
 match ip address prefix-list p1
 set as-path exclude 65003
exit
!
route-map r2 permit 20
 match ip address prefix-list p3
 set as-path exclude all
exit

making some
no bgp as-path access-list SECOND permit 2$
bgp as-path access-list SECOND permit 3$

clear bgp *

no bgp as-path access-list SECOND permit 3$
bgp as-path access-list SECOND permit 2$

clear bgp *

will induce some crashes

thus  we rework the links between aslists and aspath_exclude

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
(cherry picked from commit 094dcc3cdac19d3da65b38effc45aa88d960909f)

10 months agobgpd: Check if we have really enough data before doing memcpy for FQDN capability 16282/head
Donatas Abraitis [Thu, 13 Jun 2024 05:12:10 +0000 (08:12 +0300)]
bgpd: Check if we have really enough data before doing memcpy for FQDN capability

We advance data pointer (data++), but we do memcpy() with the length that is 1-byte
over, which is technically heap overflow.

```
==411461==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x50600011da1a at pc 0xc4f45a9786f0 bp 0xffffed1e2740 sp 0xffffed1e1f30
READ of size 4 at 0x50600011da1a thread T0
    0 0xc4f45a9786ec in __asan_memcpy (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x3586ec) (BuildId: e794c5f796eee20c8973d7efb9bf5735e54d44cd)
    1 0xc4f45abf15f8 in bgp_dynamic_capability_fqdn /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3457:4
    2 0xc4f45abdd408 in bgp_capability_msg_parse /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3911:4
    3 0xc4f45abdbeb4 in bgp_capability_receive /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3980:9
    4 0xc4f45abde2cc in bgp_process_packet /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:4109:11
    5 0xc4f45a9b6110 in LLVMFuzzerTestOneInput /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_main.c:582:3
```

Found by fuzzing.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit b685ab5e1bdec0848502c20e9596b9716b236639)

10 months agobgpd: Check if we have really enough data before doing memcpy for software version 16279/head
Donatas Abraitis [Wed, 12 Jun 2024 19:54:45 +0000 (22:54 +0300)]
bgpd: Check if we have really enough data before doing memcpy for software version

If we receive CAPABILITY message (software-version), we SHOULD check if we really
have enough data before doing memcpy(), that could also lead to buffer overflow.

(data + len > end) is not enough, because after this check we do data++ and later
memcpy(..., data, len). That means we have one more byte.

Hit this through fuzzing by

```
    0 0xaaaaaadf872c in __asan_memcpy (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x35872c) (BuildId: 9c6e455d0d9a20f5a4d2f035b443f50add9564d7)
    1 0xaaaaab06bfbc in bgp_dynamic_capability_software_version /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3713:3
    2 0xaaaaab05ccb4 in bgp_capability_msg_parse /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3839:4
    3 0xaaaaab05c074 in bgp_capability_receive /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3980:9
    4 0xaaaaab05e48c in bgp_process_packet /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:4109:11
    5 0xaaaaaae36150 in LLVMFuzzerTestOneInput /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_main.c:582:3
```

Hit this again by Iggy \m/

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 5d7af51c4f7980507135babd94d392ca179c1bf7)

10 months agobgpd: Remove redundant whitespace before printing the reason of the failed peer 16275/head
Donatas Abraitis [Wed, 19 Jun 2024 11:32:16 +0000 (14:32 +0300)]
bgpd: Remove redundant whitespace before printing the reason of the failed peer

Before:

```
Neighbor        EstdCnt DropCnt ResetTime Reason
127.0.0.1             0       0     never  Waiting for peer OPEN (n/a)
```

After:

```
Neighbor        EstdCnt DropCnt ResetTime Reason
127.0.0.1             0       0     never Waiting for peer OPEN (n/a)
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit b5bd626a82b2541bee8e3120139e19ba05e444c8)

10 months agobgpd: Set last reset reason to admin shutdown if it was manually
Donatas Abraitis [Wed, 19 Jun 2024 11:09:00 +0000 (14:09 +0300)]
bgpd: Set last reset reason to admin shutdown if it was manually

Before this patch, we always printed the last reason "Waiting for OPEN", but
if it's a manual shutdown, then we technically are not waiting for OPEN.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit c25c7e929d550c2faca3af74a29593b8c0b75db3)

10 months agoMerge pull request #16265 from FRRouting/mergify/bp/stable/10.0/pr-16252
Donatas Abraitis [Sat, 22 Jun 2024 18:07:49 +0000 (21:07 +0300)]
Merge pull request #16265 from FRRouting/mergify/bp/stable/10.0/pr-16252

zebra: fix evpn mh bond member proto reinstall (backport #16252)

10 months agoisisd: fix crash when displaying asla in json 16268/head
Louis Scalbert [Tue, 21 May 2024 09:48:58 +0000 (11:48 +0200)]
isisd: fix crash when displaying asla in json

Fix crash when displaying ASLAs (Application Specific Link-Attributes)
with JSON

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 1c397942a46999a850ada62ea015a658373150c6)

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agoMerge pull request #16263 from FRRouting/mergify/bp/stable/10.0/pr-16260
Donatas Abraitis [Fri, 21 Jun 2024 14:50:30 +0000 (17:50 +0300)]
Merge pull request #16263 from FRRouting/mergify/bp/stable/10.0/pr-16260

bgpd: fix do not use api.backup_nexthop in ZAPI message (backport #16260)

10 months agozebra: fix evpn mh bond member proto reinstall 16265/head
Chirag Shah [Wed, 19 Jun 2024 00:21:49 +0000 (17:21 -0700)]
zebra: fix evpn mh bond member proto reinstall

In case of EVPN MH bond, a member port going in
protodown state due to external reason (one case being linkflap),
frr updates the state correctly but upon manually
clearing external reason trigger FRR to reinstate
protodown without any reason code.

Fix is to ensure if the protodown reason was external
and new state is to have protodown 'off' then do no reinstate
protodown.

Ticket: #3947432
Testing:
switch:#ip link show swp1
4: swp1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 9216 qdisc
   pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen
   1000
       link/ether 1c:34:da:2c:aa:68 brd ff:ff:ff:ff:ff:ff protodown on
       protodown_reason <linkflap>

switch:#ip link set swp1 protodown off protodown_reason linkflap off
switch:#ip link show swp1
 4: swp1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 9216 qdisc
    pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen
    1000
        link/ether 1c:34:da:2c:aa:68 brd ff:ff:ff:ff:ff:ff

Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit e4d843b438ae7cbae89ae47af0754fb1db153c6c)

10 months agobgpd: fix do not use api.backup_nexthop in ZAPI message 16263/head
Philippe Guibert [Thu, 20 Jun 2024 16:02:26 +0000 (18:02 +0200)]
bgpd: fix do not use api.backup_nexthop in ZAPI message

The backup_nexthop entry list has been populated by mistake,
and should not. Fix this by reverting the introduced behavior.

Fixes: 237ebf8d4503 ("bgpd: rework bgp_zebra_announce() function, separate nexthop handling")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
(cherry picked from commit d4390fc21795b09b84a6b95b1f8fa1ac2b3dcda9)

10 months agoMerge pull request #16203 from FRRouting/mergify/bp/stable/10.0/pr-16191
Donatas Abraitis [Fri, 14 Jun 2024 12:31:52 +0000 (15:31 +0300)]
Merge pull request #16203 from FRRouting/mergify/bp/stable/10.0/pr-16191

lib: fix copy srte_color from zapi_nexthop structure (backport #16191)

10 months agoMerge pull request #16212 from FRRouting/mergify/bp/stable/10.0/pr-16210
Jafar Al-Gharaibeh [Thu, 13 Jun 2024 19:55:37 +0000 (14:55 -0500)]
Merge pull request #16212 from FRRouting/mergify/bp/stable/10.0/pr-16210

lib: fix incorrect use of error checking macro (backport #16210)

10 months agolib: fix incorrect use of error checking macro 16212/head
Christian Hopps [Wed, 12 Jun 2024 22:48:02 +0000 (18:48 -0400)]
lib: fix incorrect use of error checking macro

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 07090ccf5a3c81f650faef914a646f0e31a26fc8)

10 months agolib: fix copy srte_color from zapi_nexthop structure 16203/head
Philippe Guibert [Sun, 17 Dec 2023 20:04:31 +0000 (21:04 +0100)]
lib: fix copy srte_color from zapi_nexthop structure

When switching from nexthop to zapi_nexthop, the srte color
is copied. Do the same in reverse.

Fixes: 31f937fb43f4 ("lib, zebra: Add SR-TE policy infrastructure to zebra")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
(cherry picked from commit 49bc1b6c21e8da0da82746373a7257aeb2c9fa4a)

10 months agoFRR Release 10.0.1 docker/10.0.1 frr-10.0.1
Jafar Al-Gharaibeh [Thu, 6 Jun 2024 05:01:52 +0000 (00:01 -0500)]
FRR Release 10.0.1

Changelog:

bgpd
    Fix route leaking from the default l3vrf
    Allow using optional table id for negative `no set table x` command
    Apply noop when doing negative commands for gr operations
    Drop newline in json output for `show bgp afi safi json detail`
    Fix `match peer` when switching between ipv4/ipv6/interface
    Fix `no set as-path prepend asnum...`
    Fix crash when deleting the srv6 locator
    Fix display when using `missing-as-worst`
    Fix dynamic peer graceful restart race condition
    Fix logging message when receiving a software version capability
    Fix show run of network route-distinguisher
    Fix srv6 memory leaks spotted by asan
    Fix the order of null check and zapi decode
    Ignore validating the attribute flags if path-attribute is configured
    Inherit `capability software-version` flag from the peer-group
    Inherit `enforce-first-as` flag from the peer-group
    Move srv6 cleanup functions
    Print old/new states of graceful restart fsm
    Revert "Fix pointer arithmetic in bgp snmp module"

debian, redhat, snapcraft
    Libyang min version is 2.1.128

isisd
    Fix heap-after-free with prefix sid
    Fix ip/ipv6 reachability tlvs

lib
    Check for not being a blackhole route
    Fix exit commands
    Remove nb/yang memory cleanup when daemonizing
    Replace deprecated ares_gethostbyname
    Replace deprecated ares_process()

nhrpd
    Fix race condition
    Fix core dump on shutdown
    Clean up shortcut cache entries on termination

ospf6d
    Accept cli `no` for point-to-multipoint
    Fix defun formatting wrecked by clang
    Fix loopback/ptp/ptmp conn. route checks
    Force recalculate on interface_up
    Prevent heap-buffer-overflow with unknown
    Ospfv3 route change comparision fixed for asbr-only change

ospfd
    Correct opaque lsa extended parser
    Fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer
    Protect call to get_edge() in ospf_te.c
    Solved crash in ri parsing with ospf te
    Revert "Fix some dicey pointer arith in snmp module"

pimd
    Fix crash unconfiguring rp keepalive timer
    Fix dr-priority range
    Fix null register before aging out reg-stop
    Fix order of operations for evaluating join
    Fix crash when mixing ssm/any-source joins

tests
    Check if ibgp session can drop invalid aigp attribute

tools
    Frr-reload strip interface vrf ctx line
    Handle seq num for bgp as-path in frr-reload.py

topotests
    Do not check table version

vtysh
    Check if bgpd is enabled before installing vtysh commands for rpki
    Fix `show route-map` command when calling via `do`
    Show `ip ospf network ...` even if it's not the same as the interface type

zebra
    Deny the routes if ip protocol cli refers to an undefined rmap
    Fix encoded dnssl length
    Fix evpn svd based remote nh neigh del
    Fix mpls command

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
10 months agoMerge pull request #16175 from FRRouting/mergify/bp/stable/10.0/pr-16170
Jafar Al-Gharaibeh [Thu, 6 Jun 2024 04:18:21 +0000 (23:18 -0500)]
Merge pull request #16175 from FRRouting/mergify/bp/stable/10.0/pr-16170

nhrpd: cleans up shortcut cache entries on termination (backport #16170)

10 months agonhrpd: cleans up shortcut cache entries on termination 16175/head
Dave LeRoy [Wed, 5 Jun 2024 17:22:57 +0000 (10:22 -0700)]
nhrpd: cleans up shortcut cache entries on termination

nhrp_shortcut_terminate() previously was just freeing the associated AFI shortcut
RIBs and not addressing existing shortcut cache entries. This cause a use after
free issue in vrf_terminate() later in the terminate sequence

NHRP: Received signal 7 at 1717516286 (si_addr 0x1955d, PC 0x7098786912c0); aborting...
NHRP: zlog_signal+0xf5                   709878ad1255     7fff3d992eb0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: core_handler+0xb5                  709878b0db85     7fff3d992ff0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: __sigaction+0x50                   709878642520     7fff3d993140 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP:     ---- signal ----
NHRP: __lll_lock_wait_private+0x90       7098786912c0     7fff3d9936d8 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: pthread_mutex_lock+0x112           709878698002     7fff3d9936e0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: _event_add_read_write+0x63         709878b1f423     7fff3d993700 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: zclient_send_message+0xd4          709878b37614     7fff3d993770 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: nhrp_route_announce+0x1ad          5ab34d63d39d     7fff3d993790 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: nhrp_shortcut_cache_notify+0xd8     5ab34d63e758     7fff3d99d4e0 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: nhrp_cache_free+0x165              5ab34d632f25     7fff3d99d510 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: hash_iterate+0x4d                  709878ab949d     7fff3d99d540 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: nhrp_cache_interface_del+0x37      5ab34d633eb7     7fff3d99d580 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: nhrp_if_delete_hook+0x26           5ab34d6350d6     7fff3d99d5a0 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: if_delete_retain+0x3d              709878abcd1d     7fff3d99d5c0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: if_delete+0x4c                     709878abd87c     7fff3d99d600 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: if_terminate+0x53                  709878abda83     7fff3d99d630 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: vrf_terminate_single+0x24          709878b23c74     7fff3d99d670 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: nhrp_request_stop+0x34             5ab34d636844     7fff3d99d690 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: frr_sigevent_process+0x53          709878b0df53     7fff3d99d6a0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: event_fetch+0x6c5                  709878b20405     7fff3d99d6c0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: frr_run+0xd3                       709878ac8163     7fff3d99d840 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: main+0x195                         5ab34d631915     7fff3d99d960 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: __libc_init_first+0x90             709878629d90     7fff3d99d980 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: __libc_start_main+0x80             709878629e40     7fff3d99da20 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: _start+0x25                        5ab34d631b65     7fff3d99da70 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)

Signed-off-by: Dave LeRoy <dleroy@labn.net>
(cherry picked from commit 2b7e357cf902190aad544b4f7d46e9f229454346)

10 months agoMerge pull request #16104 from FRRouting/mergify/bp/stable/10.0/pr-16098
Donatas Abraitis [Sun, 2 Jun 2024 18:12:26 +0000 (21:12 +0300)]
Merge pull request #16104 from FRRouting/mergify/bp/stable/10.0/pr-16098

ospf6d: OSPFv3 route change comparision fixed for ASBR-only change (backport #16098)

10 months agoospf6d: OSPFv3 route change comparision fixed for ASBR-only change 16104/head
Acee [Tue, 28 May 2024 14:02:27 +0000 (10:02 -0400)]
ospf6d: OSPFv3 route change comparision fixed for ASBR-only change

When a router route already exists in the area border routers table
as an ABR and it solely changes its ABR or ASBR status, the change
was missed and border route is not updated. This fixes the comparison
for the router_bits in the ospf6_path structure.

This fixes issue https://github.com/FRRouting/frr/issues/16053 although
the actual problem is not the computing router (r2) and not the OSPFv3
redistribution (r3).

Signed-off-by: Acee <aceelindem@gmail.com>
(cherry picked from commit 772688d2d3c03d8eeeb711c2fe3735c9e0885498)

10 months agoMerge pull request #16133 from FRRouting/mergify/bp/stable/10.0/pr-16115
Donald Sharp [Sat, 1 Jun 2024 14:03:32 +0000 (10:03 -0400)]
Merge pull request #16133 from FRRouting/mergify/bp/stable/10.0/pr-16115

pimd: fix crash when mixing ssm/any-source joins (backport #16115)

10 months agoMerge pull request #16134 from FRRouting/mergify/bp/stable/10.0/pr-16111
Donald Sharp [Sat, 1 Jun 2024 14:02:50 +0000 (10:02 -0400)]
Merge pull request #16134 from FRRouting/mergify/bp/stable/10.0/pr-16111

ospf6d: Prevent heap-buffer-overflow with unknown type (backport #16111)

10 months agoospf6d: Prevent heap-buffer-overflow with unknown type 16134/head
Iggy Frankovic [Thu, 30 May 2024 11:59:54 +0000 (07:59 -0400)]
ospf6d: Prevent heap-buffer-overflow with unknown type

When parsing a osf6 grace lsa field and we receive an
unknown tlv type, ospf6d was not incrementing the pointer
to get beyond the tlv.  Leaving a situation where ospf6d
would parse the packet incorrectly.

Signed-off-by: Iggy Frankovic <iggy07@gmail.com>
(cherry picked from commit 826f2510e67711045e52cf4b5e3ddef514ed556e)

10 months agopimd: fix crash when mixing ssm/any-source joins 16133/head
Jafar Al-Gharaibeh [Thu, 30 May 2024 17:46:47 +0000 (12:46 -0500)]
pimd: fix crash when mixing ssm/any-source joins

There is no reason to call `igmp_anysource_forward_stop()` inside a call to
`igmp_get_source_by_addr()`; not only it is not expected for a "get" function
to perform such an action, but also the decision to start/stop forwarding is
already handled correctly by pim outside `igmp_get_source_by_addr()`.
That call was left there from the days pim was initially imported into the sources.

The problem/crash was happening because `igmp_find_source_by_addr()` would fail to
find the group/source combo when mixing `(*, G)` and `(S, G)`. When having an existing
flow `(*, G)`, and a new `(S, G)` igmp is received, a new entry is correctly created.
`igmp_anysource_forward_stop(group)` always stops and eventually frees `(*, G)`, even
when the new igmp is `(S, G)`, leaving a bad state. I.e, the new entry for `(S, G)`
causes `(*, G)` to be deleted.

Tested the fix with multiple receivers on the same interface with several ssm and
any source senders and receivers with various combination of start/stop orders and
they all worked correctly.

Fixes: #15630
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
(cherry picked from commit a951960a15e8b6b5ed248abb0ecc9eb4e9a3427f)

10 months agoMerge pull request #16116 from FRRouting/mergify/bp/stable/10.0/pr-15879
Donald Sharp [Fri, 31 May 2024 14:55:21 +0000 (10:55 -0400)]
Merge pull request #16116 from FRRouting/mergify/bp/stable/10.0/pr-15879

nhrpd: fixes core dump on shutdown (backport #15879)

10 months agoMerge pull request #16122 from opensourcerouting/fix/add_missing_backports_10.0
Jafar Al-Gharaibeh [Fri, 31 May 2024 13:51:17 +0000 (08:51 -0500)]
Merge pull request #16122 from opensourcerouting/fix/add_missing_backports_10.0

tests: fix duplicates in bgp_vrf_route_leak_basic

10 months agotests: fix duplicates in bgp_vrf_route_leak_basic 16122/head
Louis Scalbert [Fri, 9 Feb 2024 14:55:47 +0000 (15:55 +0100)]
tests: fix duplicates in bgp_vrf_route_leak_basic

Test functions were duplicated by mistakes. They were identical.

Fixes: 8af61c8a34 ("topotests: test leak from the default vrf")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agotests: add a topotest to verify nhrp shortcuts in a redundant nhs topology 16116/head
dleroy [Mon, 29 Apr 2024 21:59:25 +0000 (14:59 -0700)]
tests: add a topotest to verify nhrp shortcuts in a redundant nhs topology

Contains 2 testcases. The first does a basic configuration/connectivity.
The second testcase initiates a shortcut through the primary NHS,
verifies shortcut routes are installed. Primary NHS interface brought
down and verify that the shortcut is not impacted. Finally verify that
after the shortcut expires, it is able to be re-established via a backup
NHS.

Signed-off-by: dleroy <dleroy@labn.net>
(cherry picked from commit a7037ab23407d5667385f9be096e347caa0c94ad)

10 months agonhrpd: fixes core dump on shutdown
dleroy [Mon, 29 Apr 2024 16:40:21 +0000 (09:40 -0700)]
nhrpd: fixes core dump on shutdown

When nhrpd is shutdown via nhrp_request_stop() the shutdown
sequence was not handling the case where there are active
shortcut routes installed. The zebra client and shortcut rib
were being cleaned up before vrf_terminate() had an opportunity
to delete the active routes.

Signed-off-by: dleroy <dleroy@labn.net>
(cherry picked from commit a4ee9762734332697ba186ae7223da1eb0445cb2)

11 months agoMerge pull request #16084 from FRRouting/mergify/bp/stable/10.0/pr-15674
Donald Sharp [Sat, 25 May 2024 14:51:17 +0000 (10:51 -0400)]
Merge pull request #16084 from FRRouting/mergify/bp/stable/10.0/pr-15674

ospfd: Solved crash in RI parsing with OSPF TE (backport #15674)

11 months agoospfd: protect call to get_edge() in ospf_te.c 16084/head
Olivier Dugeon [Tue, 16 Apr 2024 14:42:06 +0000 (16:42 +0200)]
ospfd: protect call to get_edge() in ospf_te.c

During fuzzing, Iggy Frankovic discovered that get_edge() function in ospf_te.c
could return null pointer, in particular when the link_id or advertised router
IP addresses are fuzzed. As the null pointer returned by get_edge() function is
not handlei by calling functions, this could cause ospfd crash.

This patch introduces new verification of returned pointer by get_edge()
function and stop the processing in case of null pointer. In addition, link ID
and advertiser router ID are validated before calling ls_find_edge_by_key() to
avoid the creation of a new edge with an invalid key.

CVE-2024-34088

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
(cherry picked from commit 8c177d69e32b91b45bda5fc5da6511fa03dc11ca)

11 months agoospfd: Correct Opaque LSA Extended parser
Olivier Dugeon [Fri, 5 Apr 2024 10:57:11 +0000 (12:57 +0200)]
ospfd: Correct Opaque LSA Extended parser

Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF
LSA packets. The crash occurs in ospf_te_parse_ext_link() function when
attemping to read Segment Routing Adjacency SID subTLVs. The original code
doesn't check if the size of the Extended Link TLVs and subTLVs have the correct
length. In presence of erronous LSA, this will cause a buffer overflow and ospfd
crashes.

This patch introduces new verification of the subTLVs size for Extended Link
TLVs and subTLVs. Similar check has been also introduced for the Extended
Prefix TLV.

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
(cherry picked from commit 5557a289acdaeec8cc63ffc97b5c2abf6dee7b3a)

11 months agoospfd: Solved crash in RI parsing with OSPF TE
Olivier Dugeon [Wed, 3 Apr 2024 14:28:23 +0000 (16:28 +0200)]
ospfd: Solved crash in RI parsing with OSPF TE

Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF
LSA packets. The crash occurs in ospf_te_parse_ri() function when attemping to
read Segment Routing subTLVs. The original code doesn't check if the size of
the SR subTLVs have the correct length. In presence of erronous LSA, this will
cause a buffer overflow and ospfd crash.

This patch introduces new verification of the subTLVs size for Router
Information TLV.

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
(cherry picked from commit f69d1313b19047d3d83fc2b36a518355b861dfc4)

11 months agoMerge pull request #16082 from FRRouting/mergify/bp/stable/10.0/pr-16044
Donald Sharp [Fri, 24 May 2024 14:29:30 +0000 (10:29 -0400)]
Merge pull request #16082 from FRRouting/mergify/bp/stable/10.0/pr-16044

bgpd: fix route leaking from the default l3vrf (backport #16044)

11 months agoMerge pull request #16077 from FRRouting/mergify/bp/stable/10.0/pr-16021
Donald Sharp [Fri, 24 May 2024 13:47:34 +0000 (09:47 -0400)]
Merge pull request #16077 from FRRouting/mergify/bp/stable/10.0/pr-16021

isisd: fix heap-after-free with prefix sid (backport #16021)

11 months agobgpd, tests: fix route leaking from the default l3vrf 16082/head
Louis Scalbert [Fri, 17 May 2024 15:57:46 +0000 (17:57 +0200)]
bgpd, tests: fix route leaking from the default l3vrf

Leaked route from the l3VRF are installed with the loopback as the
nexthop interface instead of the real interface.

> B>* 10.0.0.0/30 [20/0] is directly connected, lo (vrf default), weight 1, 00:21:01

Routing of packet from a L3VRF to the default L3VRF destined to a leak
prefix fails because of the default routing rules on Linux.

> 0:      from all lookup local
> 1000:   from all lookup [l3mdev-table]
> 32766:  from all lookup main
> 32767:  from all lookup default

When the packet is received in the loopback interface, the local rules
are checked without match, then the l3mdev-table says to route to the
loopback. A routing loop occurs (TTL is decreasing).

> 12:26:27.928748 ens37 In  IP (tos 0x0, ttl 64, id 26402, offset 0, flags [DF], proto ICMP (1), length 84)
>     10.0.0.2 > 10.0.1.2: ICMP echo request, id 47463, seq 1, length 64
> 12:26:27.928784 red   Out IP (tos 0x0, ttl 63, id 26402, offset 0, flags [DF], proto ICMP (1), length 84)
>     10.0.0.2 > 10.0.1.2: ICMP echo request, id 47463, seq 1, length 64
> 12:26:27.928797 ens38 Out IP (tos 0x0, ttl 63, id 26402, offset 0, flags [DF], proto ICMP (1), length 84)
>     10.0.0.2 > 10.0.1.2: ICMP echo request, id 47463, seq 1, length 64

Do not set the lo interface as a nexthop interface. Keep the real
interface where possible.

Fixes: db7cf73a33 ("bgpd: fix interface on leaks from redistribute connected")
Fixes: 067fbab4e4 ("bgpd: fix interface on leaks from network statement")
Fixes: 8a02d9fe1e ("bgpd: Set nh ifindex to VRF's interface, not the real")
Fixes: https://github.com/FRRouting/frr/issues/15909
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 31fc89b2301ca624a331539c0a077627bacddbe2)

11 months agoisisd: fix heap-after-free with prefix sid 16077/head
Louis Scalbert [Thu, 16 May 2024 14:44:03 +0000 (16:44 +0200)]
isisd: fix heap-after-free with prefix sid

> ==2334217==ERROR: AddressSanitizer: heap-use-after-free on address 0x61000001d0a0 at pc 0x563828c8de6f bp 0x7fffbdaee560 sp 0x7fffbdaee558
> READ of size 1 at 0x61000001d0a0 thread T0
>     #0 0x563828c8de6e in prefix_sid_cmp isisd/isis_spf.c:187
>     #1 0x7f84b8204f71 in hash_get lib/hash.c:142
>     #2 0x7f84b82055ec in hash_lookup lib/hash.c:184
>     #3 0x563828c8e185 in isis_spf_prefix_sid_lookup isisd/isis_spf.c:209
>     #4 0x563828c90642 in isis_spf_add2tent isisd/isis_spf.c:598
>     #5 0x563828c91cd0 in process_N isisd/isis_spf.c:824
>     #6 0x563828c93852 in isis_spf_process_lsp isisd/isis_spf.c:1041
>     #7 0x563828c98dde in isis_spf_loop isisd/isis_spf.c:1821
>     #8 0x563828c998de in isis_run_spf isisd/isis_spf.c:1983
>     #9 0x563828c99c7b in isis_run_spf_with_protection isisd/isis_spf.c:2009
>     #10 0x563828c9a60d in isis_run_spf_cb isisd/isis_spf.c:2090
>     #11 0x7f84b835c72d in event_call lib/event.c:2011
>     #12 0x7f84b8236d93 in frr_run lib/libfrr.c:1217
>     #13 0x563828c21918 in main isisd/isis_main.c:346
>     #14 0x7f84b7e4fd09 in __libc_start_main ../csu/libc-start.c:308
>     #15 0x563828c20df9 in _start (/usr/lib/frr/isisd+0xf5df9)
>
> 0x61000001d0a0 is located 96 bytes inside of 184-byte region [0x61000001d040,0x61000001d0f8)
> freed by thread T0 here:
>     #0 0x7f84b88a9b6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123
>     #1 0x7f84b8263bae in qfree lib/memory.c:130
>     #2 0x563828c8e433 in isis_vertex_del isisd/isis_spf.c:249
>     #3 0x563828c91c95 in process_N isisd/isis_spf.c:811
>     #4 0x563828c93852 in isis_spf_process_lsp isisd/isis_spf.c:1041
>     #5 0x563828c98dde in isis_spf_loop isisd/isis_spf.c:1821
>     #6 0x563828c998de in isis_run_spf isisd/isis_spf.c:1983
>     #7 0x563828c99c7b in isis_run_spf_with_protection isisd/isis_spf.c:2009
>     #8 0x563828c9a60d in isis_run_spf_cb isisd/isis_spf.c:2090
>     #9 0x7f84b835c72d in event_call lib/event.c:2011
>     #10 0x7f84b8236d93 in frr_run lib/libfrr.c:1217
>     #11 0x563828c21918 in main isisd/isis_main.c:346
>     #12 0x7f84b7e4fd09 in __libc_start_main ../csu/libc-start.c:308
>
> previously allocated by thread T0 here:
>     #0 0x7f84b88aa037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
>     #1 0x7f84b8263a6c in qcalloc lib/memory.c:105
>     #2 0x563828c8e262 in isis_vertex_new isisd/isis_spf.c:225
>     #3 0x563828c904db in isis_spf_add2tent isisd/isis_spf.c:588
>     #4 0x563828c91cd0 in process_N isisd/isis_spf.c:824
>     #5 0x563828c93852 in isis_spf_process_lsp isisd/isis_spf.c:1041
>     #6 0x563828c98dde in isis_spf_loop isisd/isis_spf.c:1821
>     #7 0x563828c998de in isis_run_spf isisd/isis_spf.c:1983
>     #8 0x563828c99c7b in isis_run_spf_with_protection isisd/isis_spf.c:2009
>     #9 0x563828c9a60d in isis_run_spf_cb isisd/isis_spf.c:2090
>     #10 0x7f84b835c72d in event_call lib/event.c:2011
>     #11 0x7f84b8236d93 in frr_run lib/libfrr.c:1217
>     #12 0x563828c21918 in main isisd/isis_main.c:346
>     #13 0x7f84b7e4fd09 in __libc_start_main ../csu/libc-start.c:308
>
> SUMMARY: AddressSanitizer: heap-use-after-free isisd/isis_spf.c:187 in prefix_sid_cmp
> Shadow bytes around the buggy address:
>   0x0c207fffb9c0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffb9d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffb9e0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffb9f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffba00: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
> =>0x0c207fffba10: fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fa
>   0x0c207fffba20: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffba30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffba40: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffba50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffba60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> Shadow byte legend (one shadow byte represents 8 application bytes):
>   Addressable:           00
>   Partially addressable: 01 02 03 04 05 06 07
>   Heap left redzone:       fa
>   Freed heap region:       fd
>   Stack left redzone:      f1
>   Stack mid redzone:       f2
>   Stack right redzone:     f3
>   Stack after return:      f5
>   Stack use after scope:   f8
>   Global redzone:          f9
>   Global init order:       f6
>   Poisoned by user:        f7
>   Container overflow:      fc
>   Array cookie:            ac
>   Intra object redzone:    bb
>   ASan internal:           fe
>   Left alloca redzone:     ca
>   Right alloca redzone:    cb
>   Shadow gap:              cc
> ==2334217==ABORTING

Fixes: 2f7cc7bcd3 ("isisd: detect Prefix-SID collisions and handle them appropriately")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit e697de58431474cdb06eff79bcbc70de4215e222)

11 months agoMerge pull request #16060 from FRRouting/mergify/bp/stable/10.0/pr-16032
Donald Sharp [Tue, 21 May 2024 18:45:08 +0000 (14:45 -0400)]
Merge pull request #16060 from FRRouting/mergify/bp/stable/10.0/pr-16032

zebra: Deny the routes if ip protocol CLI refers to an undefined rmap (backport #16032)

11 months agozebra: Deny the routes if ip protocol CLI refers to an undefined rmap 16060/head
Pooja Jagadeesh Doijode [Thu, 16 May 2024 23:36:18 +0000 (16:36 -0700)]
zebra: Deny the routes if ip protocol CLI refers to an undefined rmap

Currently zebra does not deny the routes if `ip protocol <proto> route-map
FOO`
commmand is configured with reference to an undefined route-map (FOO in
this case).
However, on FRR restart, in zebra_route_map_check() routes get denied
if route-map name is available but the route-map is not defined. This
change was introduced in fd303a4ba14c762550db972317e1e88528768005.

Fix:
When `ip protocol <proto> route-map FOO` CLI is configured with reference to an
undefined route-map FOO, let the processing in ip_protocol_rm_add() and
ip_protocol_rm_del() go through so that zebra can deny the routes instead
of simply returning. This will result in consistent behavior.

Testing Done:

Before fix:
```
spine-1# configure
spine-1(config)# ip protocol bgp route-map rmap7

root@spine-1:mgmt:/var/home/cumulus# vtysh -c "show run" | grep rmap7
ip protocol bgp route-map rmap7
root@spine-1:mgmt:/var/home/cumulus#

spine-1(config)# do show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, A - Babel, D - SHARP, F - PBR, f - OpenFabric,
       Z - FRR,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

C>* 27.0.0.1/32 is directly connected, lo, 02:27:45
B>* 27.0.0.3/32 [20/0] via fe80::202:ff:fe00:21, downlink_1, weight 1, 02:27:35
B>* 27.0.0.4/32 [20/0] via fe80::202:ff:fe00:29, downlink_2, weight 1, 02:27:40
B>* 27.0.0.5/32 [20/0] via fe80::202:ff:fe00:31, downlink_3, weight 1, 02:27:40
B>* 27.0.0.6/32 [20/0] via fe80::202:ff:fe00:39, downlink_4, weight 1, 02:27:40
```

After fix:
```
spine-1(config)# ip protocol bgp route-map route-map67
spine-1(config)# do show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, A - Babel, D - SHARP, F - PBR, f - OpenFabric,
       Z - FRR,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

C>* 27.0.0.1/32 is directly connected, lo, 00:35:03
B   27.0.0.3/32 [20/0] via fe80::202:ff:fe00:21, downlink_1 inactive, weight 1, 00:34:58
B   27.0.0.4/32 [20/0] via fe80::202:ff:fe00:29, downlink_2 inactive, weight 1, 00:34:57
B   27.0.0.5/32 [20/0] via fe80::202:ff:fe00:31, downlink_3 inactive, weight 1, 00:34:57
B   27.0.0.6/32 [20/0] via fe80::202:ff:fe00:39, downlink_4 inactive, weight 1, 00:34:58
spine-1(config)#

root@spine-1:mgmt:/var/home/cumulus# ip route show
root@spine-1:mgmt:/var/home/cumulus#
```

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
(cherry picked from commit 705e8ef78f84dea3af5943a74571f968ad076c8d)

11 months agoMerge pull request #16045 from FRRouting/mergify/bp/stable/10.0/pr-16033
Donald Sharp [Mon, 20 May 2024 19:21:12 +0000 (15:21 -0400)]
Merge pull request #16045 from FRRouting/mergify/bp/stable/10.0/pr-16033

bgpd: Fix logging message when receiving a software version capability (backport #16033)

11 months agoMerge pull request #16047 from FRRouting/mergify/bp/stable/10.0/pr-16022
Donald Sharp [Mon, 20 May 2024 19:20:12 +0000 (15:20 -0400)]
Merge pull request #16047 from FRRouting/mergify/bp/stable/10.0/pr-16022

bgpd: Fix `match peer` when switching between IPv4/IPv6/interface (backport #16022)

11 months agobgpd: Fix `match peer` when switching between IPv4/IPv6/interface 16047/head
Donatas Abraitis [Thu, 16 May 2024 17:49:56 +0000 (20:49 +0300)]
bgpd: Fix `match peer` when switching between IPv4/IPv6/interface

Without this patch we MUST follow this sequence:

```
no match peer 10.0.0.1
match peer 2a01::1
```

Otherwise, both IPv4/IPv6 values are set/compiled, thus when printing the
configuration in show running, we see the first one (IPv4).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit edfc03614f0c5e14cffde25afae111908cb3bf30)

11 months agobgpd: Fix logging message when receiving a software version capability 16045/head
Donatas Abraitis [Fri, 17 May 2024 19:04:40 +0000 (22:04 +0300)]
bgpd: Fix logging message when receiving a software version capability

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit d50730ba48e337c6424ed7daba241d762060415d)

11 months agoMerge pull request #16038 from FRRouting/mergify/bp/stable/10.0/pr-16019
Jafar Al-Gharaibeh [Mon, 20 May 2024 03:17:24 +0000 (22:17 -0500)]
Merge pull request #16038 from FRRouting/mergify/bp/stable/10.0/pr-16019

zebra: fix mpls command (backport #16019)

11 months agozebra: fix mpls command 16038/head
anlan_cs [Thu, 16 May 2024 08:44:45 +0000 (16:44 +0800)]
zebra: fix mpls command

Configured with "mpls label bind 1.1.1.1/32 explicit-null", the running
configuration is:
```
!
mpls label bind 1.1.1.1/32 IPv4 Explicit Null
!
```

After this commit, the running configuration is:
```
!
mpls label bind 1.1.1.1/32 explicit-null
!
```

And add the support for the "no" form:
```
anlan(config)# mpls label bind 1.1.1.1/32 explicit-null
anlan(config)# no mpls label bind 1.1.1.1/32 explicit-null
```

Signed-off-by: anlan_cs <anlan_cs@tom.com>
(cherry picked from commit 05ad3ccb034c174d2e853e88b826ca0db1e77f45)

11 months agoMerge pull request #16029 from FRRouting/mergify/bp/stable/10.0/pr-15566
Donatas Abraitis [Sat, 18 May 2024 13:10:43 +0000 (16:10 +0300)]
Merge pull request #16029 from FRRouting/mergify/bp/stable/10.0/pr-15566

lib: remove nb/yang memory cleanup when daemonizing (backport #15566)

11 months agoMerge pull request #16030 from FRRouting/mergify/bp/stable/10.0/pr-15711
Donald Sharp [Fri, 17 May 2024 15:49:00 +0000 (11:49 -0400)]
Merge pull request #16030 from FRRouting/mergify/bp/stable/10.0/pr-15711

topotests: do not check table version (backport #15711)

11 months agoMerge pull request #16025 from FRRouting/mergify/bp/stable/10.0/pr-16020
Donald Sharp [Fri, 17 May 2024 13:42:14 +0000 (09:42 -0400)]
Merge pull request #16025 from FRRouting/mergify/bp/stable/10.0/pr-16020

bgpd: fix dynamic peer graceful restart race condition (backport #16020)

11 months agotopotests: do not check table version 16030/head
Louis Scalbert [Tue, 9 Apr 2024 07:45:06 +0000 (09:45 +0200)]
topotests: do not check table version

BGP table version is variable. Don't check it.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 29f47f3debddbea7da5d39d46dbc4a659237acdc)

11 months agolib: remove nb/yang memory cleanup when daemonizing 16029/head
Igor Ryzhov [Sun, 17 Mar 2024 20:44:28 +0000 (22:44 +0200)]
lib: remove nb/yang memory cleanup when daemonizing

We're not calling any other termination functions to free allocated
memory when daemonizing except these two. There's no reason for such an
exception, and because of these calls we have the following libyang
warnings every time FRR is started:
```
MGMTD: libyang: String "15" not freed from the dictionary, refcount 2
MGMTD: libyang: String "200" not freed from the dictionary, refcount 2
MGMTD: libyang: String "mrib-then-urib" not freed from the dictionary, refcount 2
MGMTD: libyang: String "1000" not freed from the dictionary, refcount 2
MGMTD: libyang: String "10" not freed from the dictionary, refcount 2
MGMTD: libyang: String "5" not freed from the dictionary, refcount 2
```

Remove these calls to get rid of the unnecessary warnings.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit a564710c34bdae8a0f0630f50b5718f0757d8edc)

11 months agobgpd: fix dynamic peer graceful restart race condition 16025/head
Louis Scalbert [Thu, 16 May 2024 13:08:09 +0000 (15:08 +0200)]
bgpd: fix dynamic peer graceful restart race condition

bgp_llgr topotest sometimes fails at step 8:

> topo: STEP 8: 'Check if we can see 172.16.1.2/32 after R4 (dynamic peer) was killed'

R4 neighbor is deleted on R2 because it fails to re-connect:

> 14:33:40.128048 BGP: [HKWM3-ZC5QP] 192.168.3.1 fd -1 went from Established to Clearing
> 14:33:40.128154 BGP: [MJ1TJ-HEE3V] 192.168.3.1(r4) graceful restart timer expired
> 14:33:40.128158 BGP: [ZTA2J-YRKGY] 192.168.3.1(r4) graceful restart stalepath timer stopped
> 14:33:40.128162 BGP: [H917J-25EWN] 192.168.3.1(r4) Long-lived stale timer (IPv4 Unicast) started for 20 sec
> 14:33:40.128168 BGP: [H5X66-NXP9S] 192.168.3.1(r4) Long-lived set stale community (LLGR_STALE) for: 172.16.1.2/32
> 14:33:40.128220 BGP: [H5X66-NXP9S] 192.168.3.1(r4) Long-lived set stale community (LLGR_STALE) for: 192.168.3.0/24
> [...]
> 14:33:41.138869 BGP: [RGGAC-RJ6WG] 192.168.3.1 [Event] Connect failed 111(Connection refused)
> 14:33:41.138906 BGP: [ZWCSR-M7FG9] 192.168.3.1 [FSM] TCP_connection_open_failed (Connect->Active), fd 23
> 14:33:41.138912 BGP: [JA9RP-HSD1K] 192.168.3.1 (dynamic neighbor) deleted (bgp_connect_fail)
> 14:33:41.139126 BGP: [P98A2-2RDFE] 192.168.3.1(r4) graceful restart stalepath timer stopped

af8496af08 ("bgpd: Do not delete BGP dynamic peers if graceful restart
kicks in") forgot to modify bgp_connect_fail()

Do not delete the peer in bgp_connect_fail() if Non-Stop-Forwarding is
in progress.

Fixes: af8496af08 ("bgpd: Do not delete BGP dynamic peers if graceful restart kicks in")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit e446308d76b4ac8f26149db982bf5ed5ac93d5f5)

11 months agoMerge pull request #15998 from FRRouting/mergify/bp/stable/10.0/pr-15655
Donatas Abraitis [Mon, 13 May 2024 12:04:34 +0000 (15:04 +0300)]
Merge pull request #15998 from FRRouting/mergify/bp/stable/10.0/pr-15655

isisd: fix ip/ipv6 reachability tlvs (backport #15655)

11 months agoisisd: fix ip/ipv6 reachability tlvs 15998/head
Igor Ryzhov [Mon, 1 Apr 2024 21:56:17 +0000 (00:56 +0300)]
isisd: fix ip/ipv6 reachability tlvs

Don't allocate subtlvs container if there's nothing to add to it. If the
container is allocated, the "sub-TLVs presence" bit is set in the TLVs
even if there's no actual sub-TLVs, what violates the RFC.

Fixes #14514.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit c3d34b84f3e1b789b78b6ee93068f074eb884af1)

11 months agoMerge pull request #15985 from FRRouting/mergify/bp/stable/10.0/pr-15975
Donald Sharp [Thu, 9 May 2024 17:37:36 +0000 (13:37 -0400)]
Merge pull request #15985 from FRRouting/mergify/bp/stable/10.0/pr-15975

pimd: fixes split off from #15969 (backport #15975)

11 months agoMerge pull request #15978 from FRRouting/mergify/bp/stable/10.0/pr-15965
Donald Sharp [Thu, 9 May 2024 17:04:33 +0000 (13:04 -0400)]
Merge pull request #15978 from FRRouting/mergify/bp/stable/10.0/pr-15965

bgpd: Fix SRv6 memory leaks spotted by Address Sanitizer (backport #15965)

11 months agopimd: fix order of operations for evaluating join 15985/head
David Lamparter [Mon, 12 Dec 2022 16:50:59 +0000 (17:50 +0100)]
pimd: fix order of operations for evaluating join

join_desired looks at whether up->channel_oil is empty.  up->channel_oil
is updated from pim_forward_stop(), calling pim_channel_del_oif().  But
that was being called *after* updating join_desired, so join_desired saw
a non-empty OIL.  Pull up the pim_forward_stop() call to before updating
join_desired.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit fdb1a6fed5a8e42447b5b9633ad9df0f3042d0a9)

11 months agopimd: fix null register before aging out reg-stop
David Lamparter [Mon, 17 Apr 2023 09:47:08 +0000 (11:47 +0200)]
pimd: fix null register before aging out reg-stop

It looks like the code was trying to do this with the null_register
parameter on pim_upstream_start_register_stop_timer(), but that didn't
quite work right.  Restructure a bit to get it right.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit dce38da8061a7ac62c690dbb8a89cae7f9a758d6)

11 months agopimd: fix dr-priority range
David Lamparter [Fri, 14 Apr 2023 15:17:27 +0000 (17:17 +0200)]
pimd: fix dr-priority range

0 is a valid DR priority.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit b564c1d890aef75067db22df09e608faf72b99f5)

11 months agobgpd: Move SRv6 cleanup functions 15978/head
Carmine Scarpitta [Wed, 8 May 2024 07:48:55 +0000 (09:48 +0200)]
bgpd: Move SRv6 cleanup functions

Move SRv6 cleanup operations to `bgp_srv6_cleanup` function.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
(cherry picked from commit 165caaeea8b04b6ac59c9016f1d5240238200a27)

11 months agobgpd: Fix SRv6 memory leaks spotted by ASAN
Carmine Scarpitta [Wed, 8 May 2024 07:45:56 +0000 (09:45 +0200)]
bgpd: Fix SRv6 memory leaks spotted by ASAN

Fix a couple of memory leaks spotted by Address Sanitizer:

```

=================================================================
==970960==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 592 byte(s) in 2 object(s) allocated from:
    #0 0xfeb98b28a4b4 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0xfeb98ae572f8 in qcalloc lib/memory.c:105
    #2 0xfeb98ae76138 in srv6_locator_chunk_alloc lib/srv6.c:138
    #3 0xb7f3c8508fa0 in ensure_vrf_tovpn_sid_per_vrf bgpd/bgp_mplsvpn.c:831
    #4 0xb7f3c8509494 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:866
    #5 0xb7f3c85028a8 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:289
    #6 0xb7f3c851a7c0 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3769
    #7 0xb7f3c86f6ef0 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3378
    #8 0xfeb98afa6e14 in zclient_read lib/zclient.c:4608
    #9 0xfeb98af3d684 in event_call lib/event.c:2011
    #10 0xfeb98ae2788c in frr_run lib/libfrr.c:1217
    #11 0xb7f3c83cbf0c in main bgpd/bgp_main.c:545
    #12 0xfeb98a8973f8 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #13 0xfeb98a8974c8 in __libc_start_main_impl ../csu/libc-start.c:392
    #14 0xb7f3c83c832c in _start (/usr/lib/frr/bgpd+0x2d832c)

Direct leak of 32 byte(s) in 2 object(s) allocated from:
    #0 0xfeb98b28a4b4 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0xfeb98ae572f8 in qcalloc lib/memory.c:105
    #2 0xb7f3c8508fd8 in ensure_vrf_tovpn_sid_per_vrf bgpd/bgp_mplsvpn.c:832
    #3 0xb7f3c8509494 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:866
    #4 0xb7f3c85028a8 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:289
    #5 0xb7f3c851a7c0 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3769
    #6 0xb7f3c86f6ef0 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3378
    #7 0xfeb98afa6e14 in zclient_read lib/zclient.c:4608
    #8 0xfeb98af3d684 in event_call lib/event.c:2011
    #9 0xfeb98ae2788c in frr_run lib/libfrr.c:1217
    #10 0xb7f3c83cbf0c in main bgpd/bgp_main.c:545
    #11 0xfeb98a8973f8 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #12 0xfeb98a8974c8 in __libc_start_main_impl ../csu/libc-start.c:392
    #13 0xb7f3c83c832c in _start (/usr/lib/frr/bgpd+0x2d832c)

Direct leak of 32 byte(s) in 2 object(s) allocated from:
    #0 0xfeb98b28a4b4 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0xfeb98ae572f8 in qcalloc lib/memory.c:105
    #2 0xb7f3c8506520 in vpn_leak_zebra_vrf_sid_update_per_vrf bgpd/bgp_mplsvpn.c:439
    #3 0xb7f3c85068d8 in vpn_leak_zebra_vrf_sid_update bgpd/bgp_mplsvpn.c:459
    #4 0xb7f3c86f6aec in bgp_ifp_create bgpd/bgp_zebra.c:3345
    #5 0xfeb98adfd3f8 in hook_call_if_real lib/if.c:48
    #6 0xfeb98adfe750 in if_new_via_zapi lib/if.c:181
    #7 0xfeb98af98084 in zclient_interface_add lib/zclient.c:2592
    #8 0xfeb98afa6d24 in zclient_read lib/zclient.c:4606
    #9 0xfeb98af3d684 in event_call lib/event.c:2011
    #10 0xfeb98ae2788c in frr_run lib/libfrr.c:1217
    #11 0xb7f3c83cbf0c in main bgpd/bgp_main.c:545
    #12 0xfeb98a8973f8 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #13 0xfeb98a8974c8 in __libc_start_main_impl ../csu/libc-start.c:392
    #14 0xb7f3c83c832c in _start (/usr/lib/frr/bgpd+0x2d832c)

SUMMARY: AddressSanitizer: 656 byte(s) leaked in 6 allocation(s).

```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
(cherry picked from commit 65e01119be288922deeca09f53a410ecfee1e6c2)

11 months agoMerge pull request #15970 from FRRouting/mergify/bp/stable/10.0/pr-15920
Donald Sharp [Thu, 9 May 2024 11:10:36 +0000 (07:10 -0400)]
Merge pull request #15970 from FRRouting/mergify/bp/stable/10.0/pr-15920

zebra: fix EVPN svd based remote nh neigh del (backport #15920)

11 months agozebra: fix EVPN svd based remote nh neigh del 15970/head
Chirag Shah [Fri, 3 May 2024 03:58:50 +0000 (20:58 -0700)]
zebra: fix EVPN svd based remote nh neigh del

In the context of SVD (Single VxLAN Device) for L3VNI,
the remote VTEP's nexthop is programmed neighbor entry against
SVD along with neighbor entry against SVI.

However, when L3VNI is removed or the VRF is disabled, all SVI
based remote nexthop neighbors are uninstalled and deleted.
The SVD based neigh entries remains in Zebra and the Kernel.
Subsequently, when reconfiguring L3VNI and relearning the same nexthop,
the neighbor entry is not programmed is because it is not removed
from Zebra SVD neighbor hash table, leading to the failure to
reprogram the entry.

With this fix, the SVD nexthop neigh entry is uninstalled
and deleted from Zebra and Kernel.

Ticket: #3729045

Testing:

borderleaf:# ip neigh show 2.2.2.2
2.2.2.2 dev vlan2560_l3 lladdr 00:01:00:00:1d:09 extern_learn NOARP proto zebra
2.2.2.2 dev vxlan99 lladdr 00:01:00:00:1d:09 extern_learn NOARP proto zebra

With the fix:

Zebra log shows both enties SVD (vxlan99) and SVI (vlan2560_l3)
neighbor entries are deleted.

2024/05/03 18:41:33.527125 ZEBRA: [NH6N7-54CD1] Tx RTM_DELNEIGH family
ipv4 IF vxlan99(16) Neigh 2.2.2.2 MAC  null flags 0x10 state 0x0
ext_flags 0x0
2024/05/03 18:41:33.527128 ZEBRA: [NH6N7-54CD1] Tx RTM_DELNEIGH family
ipv4 IF vlan2560_l3(18) Neigh 2.2.2.2 MAC  null flags 0x10 state 0x0
ext_flags 0x0

borderleaf:# ip neigh show 2.2.2.2
borderleaf:#

Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit fde6dd7bb9161cf58fdd8ca066cce77bad159c9d)

11 months agoMerge pull request #15956 from FRRouting/mergify/bp/stable/10.0/pr-15895
Donald Sharp [Wed, 8 May 2024 13:57:28 +0000 (09:57 -0400)]
Merge pull request #15956 from FRRouting/mergify/bp/stable/10.0/pr-15895

bgpd: Ignore validating the attribute flags if path-attribute is configured (backport #15895)

11 months agoMerge pull request #15958 from FRRouting/mergify/bp/stable/10.0/pr-15913
Donald Sharp [Wed, 8 May 2024 13:56:49 +0000 (09:56 -0400)]
Merge pull request #15958 from FRRouting/mergify/bp/stable/10.0/pr-15913

bgpd: Fix `no set as-path prepend ASNUM...` (backport #15913)

11 months agoMerge pull request #15952 from FRRouting/mergify/bp/stable/10.0/pr-15846
Donatas Abraitis [Wed, 8 May 2024 11:47:26 +0000 (14:47 +0300)]
Merge pull request #15952 from FRRouting/mergify/bp/stable/10.0/pr-15846

ospfd: fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer (backport #15846)

11 months agoMerge pull request #15951 from FRRouting/mergify/bp/stable/10.0/pr-15883
Donatas Abraitis [Wed, 8 May 2024 03:56:24 +0000 (06:56 +0300)]
Merge pull request #15951 from FRRouting/mergify/bp/stable/10.0/pr-15883

bgpd: Apply NOOP when doing negative commands for GR operations (backport #15883)

11 months agobgpd: Allow using optional table id for negative `no set table X` command 15958/head
Donatas Abraitis [Fri, 3 May 2024 05:58:21 +0000 (08:58 +0300)]
bgpd: Allow using optional table id for negative `no set table X` command

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit e411988a86f1b719fb16ec4c30499bfc650b4ea7)

11 months agobgpd: Fix `no set as-path prepend ASNUM...`
Donatas Abraitis [Thu, 2 May 2024 20:07:19 +0000 (23:07 +0300)]
bgpd: Fix `no set as-path prepend ASNUM...`

If entering `no set as-path prepend 1 2 3`, it's warned as unknown command.

Now fixed, and the following combinations work fine:

```
no set as-path prepend
no set as-path prepend last-as
no set as-path prepend last-as 1
no set as-path prepend 1
no set as-path prepend 1 2
```

Fixes: https://github.com/FRRouting/frr/issues/15912
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit e069a1c8d52bb6e7808303df488d7ce912e4f652)

11 months agotests: Check if iBGP session can drop invalid AIGP attribute 15956/head
Donatas Abraitis [Wed, 1 May 2024 13:33:52 +0000 (16:33 +0300)]
tests: Check if iBGP session can drop invalid AIGP attribute

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit f58227c91e4aaf3b54929634b310de86c0202a6e)

11 months agobgpd: Ignore validating the attribute flags if path-attribute is configured
Donatas Abraitis [Wed, 1 May 2024 13:01:38 +0000 (16:01 +0300)]
bgpd: Ignore validating the attribute flags if path-attribute is configured

E.g. Cisco sends AIGP attribute as transitive, but it's wrong. Hence, the session
is teared down, because of this bgp_attr_flag_invalid() test.

Relax this check if we have `neighbor X path-attribute <discard|treat-as-withdraw>`
configured.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 714e5be9a0804c0da2c9429bead274bbaefc9939)

11 months agoMerge pull request #15870 from opensourcerouting/fix/1ce626aea6f1f274da92478a8e487c22...
Russ White [Tue, 7 May 2024 14:42:11 +0000 (10:42 -0400)]
Merge pull request #15870 from opensourcerouting/fix/1ce626aea6f1f274da92478a8e487c229b08f9ce_10.0

vtysh: Show `ip ospf network ...` even if it's not the same as the interface type

11 months agoospfd:fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset... 15952/head
Bing Shui [Thu, 25 Apr 2024 16:02:26 +0000 (16:02 +0000)]
ospfd:fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer

Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
(cherry picked from commit d733fe2c048cd75948d9f30ced77ed828e92ee18)

11 months agobgpd: Apply NOOP when doing negative commands for GR operations 15951/head
Donatas Abraitis [Tue, 30 Apr 2024 10:40:08 +0000 (13:40 +0300)]
bgpd: Apply NOOP when doing negative commands for GR operations

E.g.:

```
% The Graceful Restart command used is not valid at this moment.
zsh: exit 1     vtysh -c configure -c 'router bgp' -c 'no neighbor 127.0.0.1 graceful-restart
1
```

This does not make sense frr-reload to fail.

Instead, just ignore such requests if they are just NOOP.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 9ebdb8e80d83a9087deaffee93df4bc90ab6e7ee)

11 months agobgpd: Print old/new states of graceful restart FSM
Donatas Abraitis [Tue, 30 Apr 2024 10:38:54 +0000 (13:38 +0300)]
bgpd: Print old/new states of graceful restart FSM

To better debug what's going on before/after.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 7b5595b61dfbd27ba05b8f5416882514a1e2f94f)

11 months agoMerge pull request #15935 from FRRouting/mergify/bp/stable/10.0/pr-15921
Donald Sharp [Mon, 6 May 2024 14:24:02 +0000 (10:24 -0400)]
Merge pull request #15935 from FRRouting/mergify/bp/stable/10.0/pr-15921

bgpd: Fix crash when deleting the SRv6 locator (backport #15921)

11 months agobgpd: Fix the order of NULL check and ZAPI decode 15935/head
Carmine Scarpitta [Sun, 5 May 2024 05:25:57 +0000 (07:25 +0200)]
bgpd: Fix the order of NULL check and ZAPI decode

When BGP receives an SRV6_LOCATOR_ADD message from zebra, it calls the
`bgp_zebra_process_srv6_locator_add()` function to process the message.
`bgp_zebra_process_srv6_locator_add()` decodes the message first, and
then if the pointer to the default BGP instance is NULL (i.e. the
default BGP instance is not configured yet), it returns early without
doing anything and without using the decoded message information.

This commit fixes the order of the operations executed by
`bgp_zebra_process_srv6_locator_add()`. We first ensure that the default
BGP instance is ready and we return early if it is not. Then, we decode
the message and do something with the information contained in it.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
(cherry picked from commit bdc2c7bc5473b5582419702211c22e5d29bf0631)