]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
13 months agobgpd: Convert the bgp_advertise_attr->adv to a fifo 15622/head
Donald Sharp [Fri, 6 Oct 2023 16:48:38 +0000 (12:48 -0400)]
bgpd: Convert the bgp_advertise_attr->adv to a fifo

BGP is storing outgoing updates in a couple of different
fifo's.  This is to ensure proper packet packing of
all bgp_dests that happen to use the same attribute.

How it's all put together currently:  On initial update
BGP walks through all the bgp_dest's in a table.  For each
path being sent a bgp_advertise is created.  This bgp_advertise
is placed in fifo order on the bgp_synchronize->update queue.
The bgp_advertise has a pointer to the bgp_advertise_attr which
is associated iwth the actual attribute that is being sent to
it's peer.  In turn this bgp_advertise is placed in a fifo off
of the bgp_advertise_attr structure.  As such as we have paths
that share an attribute, the path/dest is placed on the
bgp_syncrhonize->update fifo as well as being placed on the fifo
associated with the advertised attribute.

On actual creation of a packet.  The first item in the
bgp_synchronize->update fifo is popped.  The bgp_advertise_attr
pointer is grabbed, we fill out the nlri part of the bgp packet
and then walk the bgp_advertise_attr fifo to place paths/dests in
the packet.  As each path/dest is placed in the packet it is removed
from both the bgp_synchronize->update fifo and the bgp_advertise_attr
fifo.

The whole point of this change is to switch the *next, *prev
pointers in the bgp_advertise structure with a typesafe data
structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit b2e0c12d723a6464f67491ceb912225f35c9427a)

# Conflicts:
# bgpd/bgp_advertise.c

13 months agoMerge pull request #15600 from FRRouting/mergify/bp/stable/9.0/pr-15010
Donatas Abraitis [Mon, 25 Mar 2024 06:23:20 +0000 (08:23 +0200)]
Merge pull request #15600 from FRRouting/mergify/bp/stable/9.0/pr-15010

zebra: Fix crash on macvlan link down/up (backport #15010)

13 months agozebra: Fix crash on macvlan link down/up 15600/head
Tomi Salminen [Wed, 13 Dec 2023 09:37:21 +0000 (11:37 +0200)]
zebra: Fix crash on macvlan link down/up

Whenever a link up change was detected on a macvlan device where
the linked device wasn't visible in the namespace zebra was
running in, the linked zebra interface was NULL. This was already
handled in the event of a link down, but was ommitted from the
upside. Added the same null check to the up-side.

Signed-off-by: Tomi Salminen <tlsalmin@gmail.com>
(cherry picked from commit bdf6a9ba810b58146371e8a0000397d2ae9ea956)

13 months agoMerge pull request #15578 from FRRouting/mergify/bp/stable/9.0/pr-15558
Russ White [Tue, 19 Mar 2024 15:07:41 +0000 (11:07 -0400)]
Merge pull request #15578 from FRRouting/mergify/bp/stable/9.0/pr-15558

bgpd: Update default-originate route-map actual map structure (backport #15558)

13 months agoMerge pull request #15567 from opensourcerouting/fix/backport_bgp_filter_fun_9.0
Russ White [Tue, 19 Mar 2024 14:37:02 +0000 (10:37 -0400)]
Merge pull request #15567 from opensourcerouting/fix/backport_bgp_filter_fun_9.0

BGP memory backports

13 months agobgpd: Update default-originate route-map actual map structure 15578/head
Donatas Abraitis [Fri, 15 Mar 2024 11:49:06 +0000 (13:49 +0200)]
bgpd: Update default-originate route-map actual map structure

If using with `bgp listen range ... peer-group x`, default_rmap[afi][safi] is not
updated, and after the hard-reset in other side, this is flushed and never updated
again without restarting the sender BGP daemon.

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

13 months agobgpd: Ensure community data is freed in some cases. 15567/head
Donald Sharp [Sat, 2 Mar 2024 14:50:38 +0000 (09:50 -0500)]
bgpd: Ensure community data is freed in some cases.

Customer has this valgrind trace:

Direct leak of 2829120 byte(s) in 70728 object(s) allocated from:
  0 in community_new ../bgpd/bgp_community.c:39
  1 in community_uniq_sort ../bgpd/bgp_community.c:170
  2 in route_set_community ../bgpd/bgp_routemap.c:2342
  3 in route_map_apply_ext ../lib/routemap.c:2673
  4 in subgroup_announce_check ../bgpd/bgp_route.c:2367
  5 in subgroup_process_announce_selected ../bgpd/bgp_route.c:2914
  6 in group_announce_route_walkcb ../bgpd/bgp_updgrp_adv.c:199
  7 in hash_walk ../lib/hash.c:285
  8 in update_group_af_walk ../bgpd/bgp_updgrp.c:2061
  9 in group_announce_route ../bgpd/bgp_updgrp_adv.c:1059
 10 in bgp_process_main_one ../bgpd/bgp_route.c:3221
 11 in bgp_process_wq ../bgpd/bgp_route.c:3221
 12 in work_queue_run ../lib/workqueue.c:282

The above leak detected by valgrind was from a screenshot so I copied it
by hand.  Any mistakes in line numbers are purely from my transcription.
Additionally this is against a slightly modified 8.5.1 version of FRR.
Code inspection of 8.5.1 -vs- latest master shows the same problem
exists.  Code should be able to be followed from there to here.

What is happening:

There is a route-map being applied that modifes the outgoing community
to a peer.  This is saved in the attr copy created in
subgroup_process_announce_selected.  This community pointer is not
interned.  So the community->refcount is still 0.  Normally when
a prefix is announced, the attr and the prefix are placed on a
adjency out structure where the attribute is interned.  This will
cause the community to be saved in the community hash list as well.
In a non-normal operation when the decision to send is aborted after
the route-map application, the attribute is just dropped and the
pointer to the community is just dropped too, leading to situations
where the memory is leaked.  The usage of bgp suppress-fib would
would be a case where the community is caused to be leaked.
Additionally the previous commit where an unsuppress-map is used
to modify the outgoing attribute but since unsuppress-map was
not considered part of outgoing policy the attribute would be dropped as
well.  This pointer drop also extends to any dynamically allocated
memory saved by the attribute pointer that was not interned yet as well.

So let's modify the return case where the decision is made to
not send the prefix to the peer to always just flush the attribute
to ensure memory is not leaked.

Fixes: #15459
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
13 months agobgpd: Include unsuppress-map as a valid outgoing policy
Donald Sharp [Sat, 2 Mar 2024 14:42:30 +0000 (09:42 -0500)]
bgpd: Include unsuppress-map as a valid outgoing policy

If unsuppress-map is setup for outgoing peers, consider that
policy is being applied as for RFC 8212.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
13 months agobgpd: Ensure that the correct aspath is free'd
Donald Sharp [Wed, 13 Mar 2024 14:26:58 +0000 (10:26 -0400)]
bgpd: Ensure that the correct aspath is free'd

Currently in subgroup_default_originate the attr.aspath
is set in bgp_attr_default_set, which hashs the aspath
and creates a refcount for it.  If this is a withdraw
the subgroup_announce_check and bgp_adj_out_set_subgroup
is called which will intern the attribute.  This will
cause the the attr.aspath to be set to a new value
finally at the bottom of the function it intentionally
uninterns the aspath which is not the one that was
created for this function.  This reduces the other
aspath's refcount by 1 and if a clear bgp * is issued
fast enough the aspath for that will be removed
and the system will crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
14 months agoMerge pull request #15444 from FRRouting/mergify/bp/stable/9.0/pr-15399
Russ White [Tue, 27 Feb 2024 19:16:47 +0000 (14:16 -0500)]
Merge pull request #15444 from FRRouting/mergify/bp/stable/9.0/pr-15399

zebra: fix crash when macvlan link-interface is in another netns (backport #15399)

14 months agoMerge pull request #15441 from FRRouting/mergify/bp/stable/9.0/pr-15431
Russ White [Tue, 27 Feb 2024 19:16:28 +0000 (14:16 -0500)]
Merge pull request #15441 from FRRouting/mergify/bp/stable/9.0/pr-15431

ospfd: Solved crash in OSPF TE parsing (backport #15431)

14 months agozebra: fix crash if macvlan link in another netns 15444/head
Louis Scalbert [Tue, 20 Feb 2024 16:49:01 +0000 (17:49 +0100)]
zebra: fix crash if macvlan link in another netns

A macvlan interface can have its underlying link-interface in another
namespace (aka. netns). However, by default, zebra does not know the
interface from the other namespaces. It results in a crash the pointer
to the link interface is NULL.

> 6  0x0000559d77a329d3 in zebra_vxlan_macvlan_up (ifp=0x559d798b8e00) at /root/frr/zebra/zebra_vxlan.c:4676
> 4676 link_zif = link_ifp->info;
> (gdb) list
> 4671 struct interface *link_ifp, *link_if;
> 4672
> 4673 zif = ifp->info;
> 4674 assert(zif);
> 4675 link_ifp = zif->link;
> 4676 link_zif = link_ifp->info;
> 4677 assert(link_zif);
> 4678
> (gdb) p zif->link
> $2 = (struct interface *) 0x0
> (gdb) p zif->link_ifindex
> $3 = 15

Fix the crash by returning when the macvlan link-interface is in another
namespace. No need to go further because any vxlan under the macvlan
interface would not be accessible by zebra.

Link: https://github.com/FRRouting/frr/issues/15370
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 44e6e3868d7a1488447f2be446dbd7cb5a5559ce)

14 months agoMerge pull request #15417 from opensourcerouting/fix/backport_ee1c3c5518b1fb5b3989b80...
Russ White [Tue, 27 Feb 2024 15:43:35 +0000 (10:43 -0500)]
Merge pull request #15417 from opensourcerouting/fix/backport_ee1c3c5518b1fb5b3989b80f8bd71ad2c2bc049a_9.0

lib: Do not convert EVPN prefixes into IPv4/IPv6 if not needed

14 months agoospfd: Solved crash in OSPF TE parsing 15441/head
Olivier Dugeon [Mon, 26 Feb 2024 09:40:34 +0000 (10:40 +0100)]
ospfd: Solved crash in OSPF TE parsing

Iggy Frankovic discovered an ospfd crash when perfomring fuzzing of OSPF LSA
packets. The crash occurs in ospf_te_parse_te() function when attemping to
create corresponding egde from TE Link parameters. If there is no local
address, an edge is created but without any attributes. During parsing, the
function try to access to this attribute fields which has not been created
causing an ospfd crash.

The patch simply check if the te parser has found a valid local address. If not
found, we stop the parser which avoid the crash.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
(cherry picked from commit a73e66d07329d721f26f3f336f7735de420b0183)

14 months agolib: Do not convert EVPN prefixes into IPv4/IPv6 if not needed 15417/head
Donatas Abraitis [Thu, 15 Feb 2024 10:07:43 +0000 (12:07 +0200)]
lib: Do not convert EVPN prefixes into IPv4/IPv6 if not needed

Convert only when this is really needed, e.g. `match ip address prefix-list ...`.

Otherwise, we can't have mixed match clauses, like:

```
match ip address prefix-list p1
match evpn route-type prefix
```

This won't work, because the prefix is already converted, and we can't extract
route type, vni, etc. from the original EVPN prefix.

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

14 months agoMerge pull request #15363 from FRRouting/mergify/bp/stable/9.0/pr-14080
Donatas Abraitis [Tue, 13 Feb 2024 15:10:37 +0000 (17:10 +0200)]
Merge pull request #15363 from FRRouting/mergify/bp/stable/9.0/pr-14080

zebra: fix nhg out of sync between zebra and kernel (backport #14080)

14 months agozebra: fix nhg out of sync between zebra and kernel 15363/head
anlan_cs [Mon, 24 Jul 2023 06:40:22 +0000 (14:40 +0800)]
zebra: fix nhg out of sync between zebra and kernel

PR#13413 introduces reinstall mechanism, but there is problem with the route
leak scenario.

With route leak configuration: ( `x1` and `x2` are binded to `vrf1` )
```
vrf vrf2
 ip route 75.75.75.75/32 77.75.1.75 nexthop-vrf vrf1
 ip route 75.75.75.75/32 77.75.2.75 nexthop-vrf vrf1
exit-vrf
```

Firstly, all are ok.  But after `x1` is set down and up ( The interval
between the down and up operations should be less than 180 seconds. ) ,
`x1` is lost from the nexthop group:
```
anlan# ip nexthop
id 121 group 122/123 proto zebra
id 122 via 77.75.1.75 dev x1 scope link proto zebra
id 123 via 77.75.2.75 dev x2 scope link proto zebra
anlan# ip route show table 2
75.75.75.75 nhid 121 proto 196 metric 20
        nexthop via 77.75.1.75 dev x1 weight 1
        nexthop via 77.75.2.75 dev x2 weight 1
anlan# ip link set dev x1 down
anlan# ip link set dev x1 up
anlan# ip route show table 2 <- Wrong, one nexthop lost from group
75.75.75.75 nhid 121 via 77.75.2.75 dev x2 proto 196 metric 20
anlan# ip nexthop
id 121 group 123 proto zebra
id 122 via 77.75.1.75 dev x1 scope link proto zebra
id 123 via 77.75.2.75 dev x2 scope link proto zebra
anlan# show ip route vrf vrf2 <- Still ok
VRF vrf2:
S>* 75.75.75.75/32 [1/0] via 77.75.1.75, x1 (vrf vrf1), weight 1, 00:00:05
  *                      via 77.75.2.75, x2 (vrf vrf1), weight 1, 00:00:05
```

From the impact on kernel:
The `nh->type` of `id 122` is *always* `NEXTHOP_TYPE_IPV4` in the route leak
case.  Then, `nexthop_is_ifindex_type()` introduced by commit `5bb877` always
returns `false`, so its dependents can't be reinstalled.  After `x1` is down,
there is only `id 123` in the group of `id 121`.  So, Finally `id 121` remains
unchanged after `x1` is up, i.e., `id 122` is not added to the group even it is
reinstalled itself.

From the impact on zebra:
The `show ip route vrf vrf2` is still ok because the `id`s are reused/reinstalled
successfully within 180 seconds after `x1` is down and up.  The group of `id 121`
is with old `NEXTHOP_GROUP_INSTALLED` flag, and it is still the group of `id 122`
and `id 123` as before.

In this way, kernel and zebra have become out of sync.

The `nh->type` of `id 122` should be adjusted to `NEXTHOP_TYPE_IPV4_IFINDEX`
after nexthop resolved.  This commit is for doing this to make that reinstall
mechanism work.

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

14 months agoMerge pull request #15344 from FRRouting/mergify/bp/stable/9.0/pr-15327
Donald Sharp [Mon, 12 Feb 2024 02:34:16 +0000 (21:34 -0500)]
Merge pull request #15344 from FRRouting/mergify/bp/stable/9.0/pr-15327

pimd: re-evaluated S,G OILs upon RP changes and empty SG upstream oils (backport #15327)

14 months agoMerge pull request #15341 from FRRouting/mergify/bp/stable/9.0/pr-15336
Donatas Abraitis [Sat, 10 Feb 2024 14:56:02 +0000 (16:56 +0200)]
Merge pull request #15341 from FRRouting/mergify/bp/stable/9.0/pr-15336

ospfd: add support for "no router-info [<area|as>] command" (backport #15336)

14 months agoMerge pull request #15349 from FRRouting/mergify/bp/stable/9.0/pr-15316
Donatas Abraitis [Sat, 10 Feb 2024 12:54:00 +0000 (14:54 +0200)]
Merge pull request #15349 from FRRouting/mergify/bp/stable/9.0/pr-15316

nhrp: fix race condition in  null lladdr from zebra (backport #15316)

14 months agonhrp: fix race condition 15349/head
Lou Berger [Tue, 6 Feb 2024 23:14:07 +0000 (23:14 +0000)]
nhrp: fix race condition

where null lladdr recieved from zebra before nhrp next hop
is installed.

Signed-off-by: Lou Berger <lberger@labn.net>
(cherry picked from commit 5d9ebe61815814804fac39597578c57e6420a69c)

14 months agopimd: re-evaluated S,G OILs upon RP changes and for empty SG upstream oils 15344/head
Rajesh Varatharaj [Thu, 8 Feb 2024 02:58:39 +0000 (18:58 -0800)]
pimd: re-evaluated S,G OILs upon RP changes and for empty SG upstream oils

Topology:

TOR11 (FHR) --- LEAF-11---SPINE1 (RP)MSDP SPINE-2(RP)MSDP --- LEAF-12 -- TOR12 (LHR)
        |         |                    | |       |
|         -----------------------------------------------------(ECMP)   |
|         |                                 |               |
 -----------------------------------------------------------------------(ECMP)
Issue:
In some triggers, S,G upstream is preserved even with the PP timer expiry, resulting
in S,G with NULL OILS. This could be because we create a dummy S,G upstream and
dummy channel_oif for *,G, where RPF is UNKNOWN. As a result, PIM+VXLAN traffic is never
forwarded downstream to LHR.

Fix:
when the S,G stream is running, Determine if a reevaluation of the outgoing interface
 list (OIL) is required. S,G upstream should then inherit the OIL from *,G.

Testing:
- Evpn pim tests - TestEvpnPimSingleVtepOneMdt.test_02_broadcast_traffic_spt_zero
- pim-smoke

Ticket: #
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
(cherry picked from commit 071d43a052e04de52771b2f03461c407f0ced36f)

14 months agoMerge pull request #15338 from FRRouting/mergify/bp/stable/9.0/pr-15333
Donald Sharp [Fri, 9 Feb 2024 14:53:12 +0000 (09:53 -0500)]
Merge pull request #15338 from FRRouting/mergify/bp/stable/9.0/pr-15333

ospfd: can not delete "segment-routing node-msd" when SR if off (backport #15333)

14 months agoospfd: add support for "no router-info [<area|as>] command" 15341/head
Christian Breunig [Thu, 8 Feb 2024 21:39:04 +0000 (22:39 +0100)]
ospfd: add support for "no router-info [<area|as>] command"

frr-reload.py will walk through all config contexts and prepend no to the CLI
command. This requires that the vtysh shell code accepts a full command.

To Reproduce

vtysh -c "conf t" -c "router ospf" -c "router-info area"
vtysh -c "conf t" -c "router ospf" -c "no router-info area"
% Unknown command: no router-info area
vtysh -c "conf t" -c "router ospf" -c "no router-info"

Signed-off-by: Christian Breunig <christian@breunig.cc>
(cherry picked from commit e744db5098dcdca1bce32169aaa0703a21ab6b0c)

14 months agoospfd: can not delete "segment-routing node-msd" when SR if off 15338/head
Christian Breunig [Thu, 8 Feb 2024 20:53:35 +0000 (21:53 +0100)]
ospfd: can not delete "segment-routing node-msd" when SR if off

This fixes the initial implementation of commit 7743f2f8c00 ("OSPFd: Update
Segment Routing PR following review") where it wsa not possible to remove
the "segment-routing node-msd" CLI nodes via vtysh once segment-routing got
disabled.

Closes #14910

Signed-off-by: Christian Breunig <christian@breunig.cc>
(cherry picked from commit ba45aa62e7bcc4ea7b02773614f03efb6f7c595b)

14 months agoMerge pull request #15323 from c-po/stable-9.0
Donald Sharp [Thu, 8 Feb 2024 15:36:16 +0000 (10:36 -0500)]
Merge pull request #15323 from c-po/stable-9.0

frr-reload: backport fixes from master for stable/9.0

14 months agotools: Use error log level when failing to execute commands via frr-reload.py 15323/head
Donatas Abraitis [Thu, 14 Dec 2023 07:05:02 +0000 (09:05 +0200)]
tools: Use error log level when failing to execute commands via frr-reload.py

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

14 months agotools: fix frr-reload multiple no description cmds
Chirag Shah [Wed, 13 Dec 2023 01:31:40 +0000 (17:31 -0800)]
tools: fix frr-reload multiple no description cmds

Ensure to change description for index 0 from the list.

Ticket: #3628756
Testing Done:

After fix:
start with three interfaces description delete in lines_to_del:
(Pdb) lines_to_del
[(('interface swp1',), "description swp1 -> sp1's swp1"),
(('interface swp2',), "description swp2 -> sp2's swp
1"), (('interface swp3',), "description swp3 -> sp3's swp1")]

After first iteration swp1:
(Pdb) index
0
(Pdb) lines_to_del
[(('interface swp1',), 'description'), (('interface swp2',),
"description swp2 -> sp2's swp1"), (('interface swp
1s2',), "description swp3 -> sp3's swp1")]

After second iteration swp2:
(Pdb) lines_to_del
[(('interface swp1',), 'description'), (('interface swp2',),
'description'), (('interface swp3',), "description
swp3 -> sp3's swp1")]

After third iteration swp3 fix
(Pdb) lines_to_del
[(('interface swp1',), 'description'), (('interface swp2',),
'description'), (('interface swp3',), 'description'
)]

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

14 months agotools: Apply black formatting for tools/frr-reload.py
Donatas Abraitis [Thu, 2 Nov 2023 11:39:53 +0000 (13:39 +0200)]
tools: Apply black formatting for tools/frr-reload.py

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

14 months agotools: fix key chain reload removal
Rafael Zalamena [Thu, 27 Jul 2023 13:47:23 +0000 (10:47 -0300)]
tools: fix key chain reload removal

When deleting a key chain with frr-reload track if the whole root node
is being removed or not.

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

14 months agotools: fix ospf area stub summary in frr-reload
Chirag Shah [Sat, 8 Jul 2023 20:17:12 +0000 (13:17 -0700)]
tools: fix ospf area stub summary in frr-reload

OSPFv2 no area x stub no-summary only resets
'no-summary' config. From frr-reload if the config
line 'area x stub no-summary' is removed then
it needs to remove completely. Before this change
it took two frr-roload to remove the config which is
inconsistent behavior.
Fix is to frr-reload to add extra line to delete
'no area x stub'.

Ticket:#3514775
Testing Done:

Running config:

router ospf
 ospf router-id 6.6.6.6
 area 0.0.0.1 stub no-summary
 area 0.0.0.2 stub
exit
!
router ospf vrf sym_1
 area 0.0.1.1 range 24.1.1.0/24
 area 0.0.1.2 stub no-summary
exit

changed frr.conf:
router ospf
 ospf router-id 6.6.6.6
 area 0.0.0.2 stub
exit
!
router ospf vrf sym_1
 area 0.0.1.1 range 24.1.1.0/24
exit

Lines To Delete
===============
router ospf
 no area 0.0.0.1 stub  <<<< newly added
router ospf vrf sym_1
 no area 0.0.1.2 stub  <<<< newly added
router ospf
 no area 0.0.0.1 stub no-summary
router ospf vrf sym_1
 no area 0.0.1.2 stub no-summary

After fix new running-config post reload:
i
router ospf
 ospf router-id 6.6.6.6
 area 0.0.0.2 stub
exit
!
router ospf vrf sym_1
 area 0.0.1.1 range 24.1.1.0/24
exit

Before fix running-config post 1st reload:

router ospf
 ospf router-id 6.6.6.6
 area 0.0.0.1 stub
 area 0.0.0.2 stub
exit
!
router ospf vrf sym_1
 area 0.0.1.1 range 24.1.1.0/24
 area 0.0.1.2 stub
exit

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

14 months agotools: fix pim interface config deletion
Chirag Shah [Thu, 29 Jun 2023 16:55:12 +0000 (09:55 -0700)]
tools: fix pim interface config deletion

When no ip pim is performed subsequent pim related
configs under the interface also implicitly deleted.

When doing this via frr-reload requires to remove any
explicit no ip pim <blah> lines so delete list.

Testing Done:

running-config:
interface lo
 ip pim
 ip pim use-source 6.0.0.1
exit

frr.conf:
remove two pim config lines.
interface lo
exit

Before fix:
2023-06-29 23:44:26,062  INFO: Failed to execute interface lo  no ip pim use-source 6.0.0.1
2023-06-29 23:44:26,142  INFO: Failed to execute interface lo  no ip pim use-source
2023-06-29 23:44:26,221  INFO: Executed "interface lo  no ip pim"

After fix:
Only no ip pim executed and rest of the other lines removed from delete
list.

2023-06-30 01:07:32,618  INFO: Executed "interface lo  no ip pim"

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

14 months agotools: always append "exit" in frr-reload.py
Igor Ryzhov [Sun, 28 Nov 2021 21:36:35 +0000 (00:36 +0300)]
tools: always append "exit" in frr-reload.py

When reloading the following config:
```
router ospf6
 area 0 range 2001:db8::/32 advertise
exit
!
interface eth0
 ipv6 ospf6 area 0
exit
```
frr-reload.py doesn't execute "exit" commands. Because of that, it tries
to execute "interface eth0" inside the "router ospf6" context and fails.

To always execute all commands from the correct context, frr-reload.py
should properly exit from every entered node.

Fixes #10132.

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

15 months agoMerge pull request #15229 from FRRouting/mergify/bp/stable/9.0/pr-15206
Donald Sharp [Thu, 25 Jan 2024 14:35:00 +0000 (09:35 -0500)]
Merge pull request #15229 from FRRouting/mergify/bp/stable/9.0/pr-15206

pbrd: Fix PBR handling for last rule deletion (backport #15206)

15 months agoMerge pull request #15218 from FRRouting/mergify/bp/stable/9.0/pr-15210
Donald Sharp [Thu, 25 Jan 2024 12:49:53 +0000 (07:49 -0500)]
Merge pull request #15218 from FRRouting/mergify/bp/stable/9.0/pr-15210

bgpd: Fix format overflow for graceful-restart debug logs (backport #15210)

15 months agopbrd: Fix PBR handling for last rule deletion 15229/head
Rajesh Varatharaj [Tue, 23 Jan 2024 06:24:33 +0000 (22:24 -0800)]
pbrd: Fix PBR handling for last rule deletion

Issue:
Previously, the PBR common was updated for every rule update or deletion

example:
let say we have three rule 11, 12, 13 and if we are removing rule 12. in the current code
we are making the entire map "valid" to false.

pbr-map MAP1 seq 11
match src-ip 90.1.1.2/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 12
match src-ip 90.1.1.3/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 13
match src-ip 90.1.1.4/32
set nexthop 20.1.1.2 swp1

no pbr-map MAP1 seq 12 ==> turns whole map valid to false.

r1(config)# end
r1# show pbr map
  pbr-map MAP1 valid: no
    Seq: 11 rule: 310
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.2/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10002
    Seq: 13 rule: 312
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.4/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10004

Fix:
Now, the PBR common will only be updated when the last rule is being deleted.
This change ensures that we only send a delete request to Zebra once, and only
set the valid and installed flags to false when the last rule is deleted.
This optimizes the handling of PBR rules and reduces unnecessary interactions with Zebra

Testing: UT in MR notes

Ticket: #
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
(cherry picked from commit aa12c72c2a9cc1ea22145db28636e716bbd52ace)

15 months agobgpd: Fix format overflow for graceful-restart debug logs 15218/head
Donatas Abraitis [Wed, 24 Jan 2024 06:57:56 +0000 (08:57 +0200)]
bgpd: Fix format overflow for graceful-restart debug logs

Use enum instead of int, and make the compiler happy when using -format-overflow.

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

15 months agoMerge pull request #15207 from FRRouting/mergify/bp/stable/9.0/pr-15197
Donatas Abraitis [Wed, 24 Jan 2024 08:09:12 +0000 (10:09 +0200)]
Merge pull request #15207 from FRRouting/mergify/bp/stable/9.0/pr-15197

pimd: fix crash when configuring ssmpingd (backport #15197)

15 months agoMerge pull request #15187 from opensourcerouting/fix/revert_noprefixroute_9.0
Donald Sharp [Tue, 23 Jan 2024 18:57:50 +0000 (13:57 -0500)]
Merge pull request #15187 from opensourcerouting/fix/revert_noprefixroute_9.0

Revert `noprefixroute` stuff

15 months agopimd: fix crash when configuring ssmpingd 15207/head
Igor Ryzhov [Tue, 23 Jan 2024 00:32:22 +0000 (02:32 +0200)]
pimd: fix crash when configuring ssmpingd

Command: `ip ssmpingd 1.1.1.1`

Backtrace:
```
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
0x00007fd1d3b02859 in __GI_abort () at abort.c:79
0x00007fd1d3e323e1 in yang_dnode_xpath_get_canon (dnode=<optimized out>, xpath_fmt=<optimized out>, ap=<optimized out>) at lib/yang_wrappers.c:61
0x00007fd1d3e34f41 in yang_dnode_get_ipv4 (addr=addr@entry=0x7ffc368554d4, dnode=<optimized out>, xpath_fmt=xpath_fmt@entry=0x5556af8680d4 "./source-addr") at lib/yang_wrappers.c:826
0x00005556af8216d3 in routing_control_plane_protocols_control_plane_protocol_pim_address_family_ssm_pingd_source_ip_create (args=0x7ffc36855530) at pimd/pim_nb_config.c:925
0x00007fd1d3dec13f in nb_callback_create (nb_node=0x5556b197ea40, nb_node=0x5556b197ea40, errmsg_len=8192, errmsg=0x7ffc36855a90 "", resource=0x5556b18fa6f8, dnode=0x5556b1ad7a10, event=NB_EV_APPLY, context=0x5556b1ad75c0) at lib/northbound.c:1260
nb_callback_configuration (context=0x5556b1ad75c0, event=NB_EV_APPLY, change=<optimized out>, errmsg=0x7ffc36855a90 "", errmsg_len=8192) at lib/northbound.c:1648
0x00007fd1d3deca6c in nb_transaction_process (event=event@entry=NB_EV_APPLY, transaction=transaction@entry=0x5556b1ad75c0, errmsg=errmsg@entry=0x7ffc36855a90 "", errmsg_len=errmsg_len@entry=8192) at lib/northbound.c:1779
0x00007fd1d3decdd6 in nb_candidate_commit_apply (transaction=0x5556b1ad75c0, save_transaction=save_transaction@entry=true, transaction_id=transaction_id@entry=0x0, errmsg=errmsg@entry=0x7ffc36855a90 "", errmsg_len=errmsg_len@entry=8192) at lib/northbound.c:1129
0x00007fd1d3decf15 in nb_candidate_commit (context=..., candidate=<optimized out>, save_transaction=save_transaction@entry=true, comment=comment@entry=0x0, transaction_id=transaction_id@entry=0x0, errmsg=0x7ffc36855a90 "", errmsg_len=8192) at lib/northbound.c:1162
0x00007fd1d3ded4af in nb_cli_classic_commit (vty=vty@entry=0x5556b1ada2a0) at lib/northbound_cli.c:50
0x00007fd1d3df025f in nb_cli_apply_changes_internal (vty=vty@entry=0x5556b1ada2a0, xpath_base=xpath_base@entry=0x7ffc36859b50 ".", clear_pending=clear_pending@entry=false) at lib/northbound_cli.c:177
0x00007fd1d3df06ad in nb_cli_apply_changes (vty=vty@entry=0x5556b1ada2a0, xpath_base_fmt=xpath_base_fmt@entry=0x0) at lib/northbound_cli.c:233
0x00005556af80fdd5 in pim_process_ssmpingd_cmd (vty=0x5556b1ada2a0, operation=NB_OP_CREATE, src_str=0x5556b1ad9630 "1.1.1.1") at pimd/pim_cmd_common.c:3423
0x00007fd1d3da7b0e in cmd_execute_command_real (vline=vline@entry=0x5556b1ac9520, vty=vty@entry=0x5556b1ada2a0, cmd=cmd@entry=0x0, up_level=up_level@entry=0) at lib/command.c:982
0x00007fd1d3da7cb1 in cmd_execute_command (vline=vline@entry=0x5556b1ac9520, vty=vty@entry=0x5556b1ada2a0, cmd=0x0, vtysh=vtysh@entry=0) at lib/command.c:1040
0x00007fd1d3da7e50 in cmd_execute (vty=vty@entry=0x5556b1ada2a0, cmd=cmd@entry=0x5556b1ae0a30 "ip ssmpingd 1.1.1.1", matched=matched@entry=0x0, vtysh=vtysh@entry=0) at lib/command.c:1207
0x00007fd1d3e278be in vty_command (vty=vty@entry=0x5556b1ada2a0, buf=<optimized out>) at lib/vty.c:591
0x00007fd1d3e27afd in vty_execute (vty=0x5556b1ada2a0) at lib/vty.c:1354
0x00007fd1d3e2bb23 in vtysh_read (thread=<optimized out>) at lib/vty.c:2362
0x00007fd1d3e22254 in event_call (thread=thread@entry=0x7ffc3685cd80) at lib/event.c:2003
0x00007fd1d3dce9e8 in frr_run (master=0x5556b183c830) at lib/libfrr.c:1218
0x00005556af803653 in main (argc=6, argv=<optimized out>, envp=<optimized out>) at pimd/pim_main.c:162
```

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

15 months agoMerge pull request #15199 from FRRouting/mergify/bp/stable/9.0/pr-15193
Donald Sharp [Tue, 23 Jan 2024 15:36:58 +0000 (10:36 -0500)]
Merge pull request #15199 from FRRouting/mergify/bp/stable/9.0/pr-15193

bgpd: fix route-map match probability deconfiguration callback (backport #15193)

15 months agobgpd: fix route-map match probability deconfiguration callback 15199/head
Igor Ryzhov [Mon, 22 Jan 2024 20:31:21 +0000 (22:31 +0200)]
bgpd: fix route-map match probability deconfiguration callback

Add missing break. Currently, lib_route_map_entry_match_destroy is
called on every commit stage, but it should run only on APPLY.

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

15 months agoRevert "zebra: Add ability to note that a address is NOPREFIXROUTE" 15187/head
Donatas Abraitis [Sun, 21 Jan 2024 21:11:49 +0000 (23:11 +0200)]
Revert "zebra: Add ability to note that a address is NOPREFIXROUTE"

This reverts commit ebf9a394e30bf35c48612831ecebdb533232d729.

15 months agoRevert "zebra: Add connected with noprefixroute"
Donatas Abraitis [Sun, 21 Jan 2024 21:11:43 +0000 (23:11 +0200)]
Revert "zebra: Add connected with noprefixroute"

This reverts commit 6e207024fed2144e569629598b830d11955774ec.

15 months agoRevert "tests: Add a noprefixroute test"
Donatas Abraitis [Sun, 21 Jan 2024 21:11:38 +0000 (23:11 +0200)]
Revert "tests: Add a noprefixroute test"

This reverts commit 95df4c997add76988c38ede9da45699e74b51d25.

15 months agoMerge pull request #15158 from opensourcerouting/fix/backport_68573c34d40c7503f0b78f1...
Russ White [Tue, 16 Jan 2024 16:13:02 +0000 (11:13 -0500)]
Merge pull request #15158 from opensourcerouting/fix/backport_68573c34d40c7503f0b78f1f7188b3ad3e28ae5a_9.0

bgpd: Set correct TTL for the dynamic neighbor peers

15 months agobgpd: Set correct TTL for the dynamic neighbor peers 15158/head
Rajesh Varatharaj [Fri, 29 Dec 2023 19:26:43 +0000 (11:26 -0800)]
bgpd: Set correct TTL for the dynamic neighbor peers

In an EBGP multihop configuration with dynamic neighbors, the TTL configured is not being updated for the socket.

Issue:
Assume the following topology:
Host (Dynamic peer to spine - 192.168.1.100) - Leaf - Spine (192.168.1.1)

When the host establishes a BGP multihop session to the spine,
the connection uses the MAXTTL value instead of the configured TTL (in this case, 2).
This issue is only observed with dynamic peers.

Logs: look at the TTL is still MAXTTL, instead of “2” configured.

18:13:18.872395 48:b0:2d:0c:58:0b > 48:b0:2d:66:64:6b, ethertype IPv4 (0x0800), length 85: (tos 0xc0, ttl 255, id 32078, offset 0, flags [DF], proto TCP (6), length 71)
192.168.1.100.179 > 192.168.1.1.40967: Flags [P.], cksum 0xfe89 (correct), seq 28406:28425, ack 28424, win 255, options [nop,nop,TS val 4192664793 ecr 2814447051], length 19: BGP
Keepalive Message (4), length: 19

Fix:
Whenever a dynamic peer is created, the socket TTL should be updated with the configured TTL, in this case 2.

19:13:24.894890 48:b0:2d:0c:58:0b > 48:b0:2d:66:64:6b, ethertype IPv4 (0x0800), length 85: (tos 0xc0, ttl 2, id 1131, offset 0, flags [DF], proto TCP (6), length 71)
    192.168.1.100.179 > 192.168.1.1.41937: Flags [P.], cksum 0x7a67 (correct), seq 2046150759:2046150778, ack 4286110599, win 255, options [nop,nop,TS val 4196270815 ecr 2818051226], length 19: BGP
        Keepalive Message (4), length: 19

Testing: UT

UT logs:
2023-12-29T19:13:21.892205+00:00 host bgpd[1591425]: [WWPV7-YSZB5] Dynamic Neighbor 192.168.1.1/32 matches group test listen range 192.168.1.0/30
2023-12-29T19:13:21.892654+00:00 host bgpd[1591425]: [GBPAR-M31QF] 192.168.1.1 Dynamic Neighbor added, group test count 1
2023-12-29T19:13:21.892993+00:00 host bgpd[1591425]: [GPE2H-K9QRE] bgp_set_socket_ttl:  set TxTTL on peer (rtrid 0.0.0.0) socket, err = 2, peer ttl 2

 Conflicts:
bgpd/bgp_network.c

Ticket: #
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
16 months agoMerge pull request #15040 from FRRouting/mergify/bp/stable/9.0/pr-15032
Donald Sharp [Mon, 18 Dec 2023 20:00:23 +0000 (15:00 -0500)]
Merge pull request #15040 from FRRouting/mergify/bp/stable/9.0/pr-15032

bgpd: "default-originate" shouldn't withdraw non-default routes (backport #15032)

16 months agotests: Check for 0.0.0.0/1 in bgp_default_route 15040/head
Xiao Liang [Mon, 18 Dec 2023 06:57:22 +0000 (14:57 +0800)]
tests: Check for 0.0.0.0/1 in bgp_default_route

Ensure that 0.0.0.0/1 route can be advertised along with
default-originate.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
(cherry picked from commit 4538247c995e551aed0c08c4bb20b187ce95f5f2)

16 months agobgpd: "default-originate" shouldn't withdraw non-default routes
Xiao Liang [Fri, 15 Dec 2023 10:27:39 +0000 (18:27 +0800)]
bgpd: "default-originate" shouldn't withdraw non-default routes

Prevent "default-originate" from withdrawing non-default routes like
0.0.0.0/1 by checking prefix length.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
(cherry picked from commit 4d74ba929daa6e6b2fe15f9df6e61d5e4808b64c)

16 months agoMerge pull request #15008 from opensourcerouting/fix/8a5c6e4389a8f56c1a25941977a1f6ac...
Donald Sharp [Mon, 18 Dec 2023 13:57:48 +0000 (08:57 -0500)]
Merge pull request #15008 from opensourcerouting/fix/8a5c6e4389a8f56c1a25941977a1f6acaf92f53e_9.0

tools: fix frr-reload multiple no description cmds

16 months agoMerge pull request #15029 from FRRouting/mergify/bp/stable/9.0/pr-15026
Donald Sharp [Fri, 15 Dec 2023 01:23:40 +0000 (20:23 -0500)]
Merge pull request #15029 from FRRouting/mergify/bp/stable/9.0/pr-15026

ospfd: Correct LSA parser which fulfill the TED (backport #15026)

16 months agotests: Update OSPF TE topotests 15029/head
Olivier Dugeon [Thu, 14 Dec 2023 17:34:38 +0000 (18:34 +0100)]
tests: Update OSPF TE topotests

The OSPF TE topotest is using switches to interconnect router. During the test,
interfaces are shutdown on some routers to simulate link failure and check that
the TED is correctly updated. However, the switche between router avoid the
detection by the neighbor router that the interface is down i.e. the interface
line remains up as it is conneted to the switch and not to the router.

This patch update the tested topology by removing the switch and connect
directly the router excepted the inter AS link on R3. Interface are also
renamed accordingly.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
(cherry picked from commit 55ad78575351fa90a2485b99b3665adb74712c65)

16 months agoospfd: Correct LSA parser which fulfill the TED
Olivier Dugeon [Thu, 14 Dec 2023 17:22:32 +0000 (18:22 +0100)]
ospfd: Correct LSA parser which fulfill the TED

Traffic Engineering Database (TED) is fulfill from the various LSA advertised
and received by the router. To remove information on the TED, 2 mechanisms are
used: i) parse TE Opaque LSA when there are flushed and ii) compare the list of
prefixes advertised in the Router LSA with the list of corresponding edges and
subnets contained in the TED. However, this second mechanism assumes that the
Router LSA is unique and contains all prefixes of the advertised router.
But, this is wrong. Prefixes could be advertised with several Router LSA.
This conduct to remove edge and subnet in the TED while it should be maintained.
The result is a faulty test with ospf_sr_te_topo1 topotest when server is heavy
loaded.

This simple patch removed deletion of edges and subnets when parsing the Router
LSA and only removed them when the corresponding TE Opaque LSA is flushed. In
addition, TE Opaque LSA are not flushed when OSPF ajacency goes down. This
patch also correct this second problem.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
(cherry picked from commit a3230323f74204f88e44e579c3ec7e8b9142bad1)

16 months agoMerge pull request #15020 from FRRouting/mergify/bp/stable/9.0/pr-15014
Donald Sharp [Thu, 14 Dec 2023 15:38:26 +0000 (10:38 -0500)]
Merge pull request #15020 from FRRouting/mergify/bp/stable/9.0/pr-15014

ospfd: fix some ospf cmds' param range (backport #15014)

16 months agodoc: add param range for graceful-restart helper supported-grace-time 15020/head
Bing Shui [Wed, 13 Dec 2023 14:25:43 +0000 (22:25 +0800)]
doc: add param range for graceful-restart helper supported-grace-time

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

16 months agoospfd: fix ospf dead-interval minimal hello-multiplier param range
Bing Shui [Wed, 13 Dec 2023 14:23:58 +0000 (22:23 +0800)]
ospfd: fix ospf dead-interval minimal hello-multiplier param range

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

16 months agoMerge pull request #15013 from opensourcerouting/fix/bdb5ae8bce94432eb5e581f04f48dc4a...
Mark Stapp [Wed, 13 Dec 2023 21:19:46 +0000 (16:19 -0500)]
Merge pull request #15013 from opensourcerouting/fix/bdb5ae8bce94432eb5e581f04f48dc4aa5db7ca4_9.0

bgpd: Make suppress-fib-pending clear peering

16 months agobgpd: Make `suppress-fib-pending` clear peering 15013/head
Donald Sharp [Mon, 11 Dec 2023 15:46:53 +0000 (10:46 -0500)]
bgpd: Make `suppress-fib-pending` clear peering

When a peer has come up and already started installing
routes into the rib and `suppress-fib-pending` is either
turned on or off.  BGP is left with some routes that
may need to be withdrawn from peers and routes that
it does not know the status of.  Clear the BGP peers
for the interesting parties and let's let us come
up to speed as needed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
16 months agoRevert "bgpd: Make `suppress-fib-pending` clear peering"
Donatas Abraitis [Wed, 13 Dec 2023 09:48:06 +0000 (11:48 +0200)]
Revert "bgpd: Make `suppress-fib-pending` clear peering"

This reverts commit 758e14a3ea55d79932d14aa6d447d90d83642481.

16 months agotools: fix frr-reload multiple no description cmds 15008/head
Chirag Shah [Wed, 13 Dec 2023 01:31:40 +0000 (17:31 -0800)]
tools: fix frr-reload multiple no description cmds

Ensure to change description for index 0 from the list.

Ticket: #3628756
Testing Done:

After fix:
start with three interfaces description delete in lines_to_del:
(Pdb) lines_to_del
[(('interface swp1',), "description swp1 -> sp1's swp1"),
(('interface swp2',), "description swp2 -> sp2's swp
1"), (('interface swp3',), "description swp3 -> sp3's swp1")]

After first iteration swp1:
(Pdb) index
0
(Pdb) lines_to_del
[(('interface swp1',), 'description'), (('interface swp2',),
"description swp2 -> sp2's swp1"), (('interface swp
1s2',), "description swp3 -> sp3's swp1")]

After second iteration swp2:
(Pdb) lines_to_del
[(('interface swp1',), 'description'), (('interface swp2',),
'description'), (('interface swp3',), "description
swp3 -> sp3's swp1")]

After third iteration swp3 fix
(Pdb) lines_to_del
[(('interface swp1',), 'description'), (('interface swp2',),
'description'), (('interface swp3',), 'description'
)]

Signed-off-by: Chirag Shah <chirag@nvidia.com>
16 months agoMerge pull request #14998 from FRRouting/mergify/bp/stable/9.0/pr-14982
Donald Sharp [Tue, 12 Dec 2023 23:21:50 +0000 (18:21 -0500)]
Merge pull request #14998 from FRRouting/mergify/bp/stable/9.0/pr-14982

bgpd: Make `suppress-fib-pending` clear peering (backport #14982)

16 months agobgpd: Make `suppress-fib-pending` clear peering 14998/head
Donald Sharp [Mon, 11 Dec 2023 15:46:53 +0000 (10:46 -0500)]
bgpd: Make `suppress-fib-pending` clear peering

When a peer has come up and already started installing
routes into the rib and `suppress-fib-pending` is either
turned on or off.  BGP is left with some routes that
may need to be withdrawn from peers and routes that
it does not know the status of.  Clear the BGP peers
for the interesting parties and let's let us come
up to speed as needed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit bdb5ae8bce94432eb5e581f04f48dc4aa5db7ca4)

16 months agoMerge pull request #14989 from FRRouting/mergify/bp/stable/9.0/pr-14983
Donatas Abraitis [Tue, 12 Dec 2023 12:19:41 +0000 (14:19 +0200)]
Merge pull request #14989 from FRRouting/mergify/bp/stable/9.0/pr-14983

zebra: The dplane_fpm_nl return path leaks memory (backport #14983)

16 months agozebra: The dplane_fpm_nl return path leaks memory 14989/head
Donald Sharp [Mon, 11 Dec 2023 18:41:36 +0000 (13:41 -0500)]
zebra: The dplane_fpm_nl return path leaks memory

The route entry created when using a ctx to pass route
entry data backup to the master pthread in zebra is
being leaked.  Prevent this from happening.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 7f9c5c7fa2d927033549a806fd9025a9459f22bc)

16 months agoMerge pull request #14980 from FRRouting/mergify/bp/stable/9.0/pr-14962
Donald Sharp [Mon, 11 Dec 2023 12:35:23 +0000 (07:35 -0500)]
Merge pull request #14980 from FRRouting/mergify/bp/stable/9.0/pr-14962

ospfd: Correct SID check size (backport #14962)

16 months agoospfd: Correct SID check size 14980/head
Olivier Dugeon [Thu, 7 Dec 2023 13:53:16 +0000 (14:53 +0100)]
ospfd: Correct SID check size

Segment Router Identifier (SID) could be an index (4 bytes) within a range
(SRGB or SRLB) or an MPLS label (3 bytes). Thus, before calling check_size
macro to verify SID TLVs size, it is mandatory to determine the SID type to
avoid wrong assert.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
(cherry picked from commit 397dbbcae6083a00f30ad8310160650ec7ac7a87)

16 months agoMerge pull request #14978 from FRRouting/mergify/bp/stable/9.0/pr-14968
Donatas Abraitis [Mon, 11 Dec 2023 05:13:53 +0000 (07:13 +0200)]
Merge pull request #14978 from FRRouting/mergify/bp/stable/9.0/pr-14968

zebra: Add missing whitespace when printing route entry status (backport #14968)

16 months agozebra: Add missing whitespace when printing route entry status 14978/head
Donatas Abraitis [Fri, 8 Dec 2023 11:57:56 +0000 (13:57 +0200)]
zebra: Add missing whitespace when printing route entry status

Before:

```
status: Removed ReplacingInstalled
```

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

16 months agoMerge pull request #14961 from FRRouting/mergify/bp/stable/9.0/pr-14957
Donald Sharp [Thu, 7 Dec 2023 16:11:24 +0000 (11:11 -0500)]
Merge pull request #14961 from FRRouting/mergify/bp/stable/9.0/pr-14957

Add ability to handle `noprefixroute` to zebra (backport #14957)

16 months agotests: Add a noprefixroute test 14961/head
Donald Sharp [Wed, 6 Dec 2023 14:27:09 +0000 (09:27 -0500)]
tests: Add a noprefixroute test

Add a simple test case to ensure that the noprefixroute
code stays working in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 0d5c5472c96c91516ae99c87c7a711237f6b45b2)

16 months agozebra: Add connected with noprefixroute
Donald Sharp [Wed, 6 Dec 2023 13:33:31 +0000 (08:33 -0500)]
zebra: Add connected with noprefixroute

Add ability for the connected routes to know
if they are a prefix route or not.

sharpd@eva:/work/home/sharpd/frr1$ ip addr show dev dummy1
13: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether aa:93:ce:ce:3f:62 brd ff:ff:ff:ff:ff:ff
    inet 192.168.55.1/24 scope global noprefixroute dummy1
       valid_lft forever preferred_lft forever
    inet 192.168.56.1/24 scope global dummy1
       valid_lft forever preferred_lft forever
    inet6 fe80::a893:ceff:fece:3f62/64 scope link
       valid_lft forever preferred_lft forever

sharpd@eva:/work/home/sharpd/frr1$ sudo vtysh -c "show int dummy1"
Interface dummy1 is up, line protocol is up
  Link ups:       0    last: (never)
  Link downs:     0    last: (never)
  vrf: default
  index 13 metric 0 mtu 1500 speed 0 txqlen 1000
  flags: <UP,BROADCAST,RUNNING,NOARP>
  Type: Ethernet
  HWaddr: aa:93:ce:ce:3f:62
  inet 192.168.55.1/24 noprefixroute
  inet 192.168.56.1/24
  inet6 fe80::a893:ceff:fece:3f62/64
  Interface Type Other
  Interface Slave Type None
  protodown: off

sharpd@eva:/work/home/sharpd/frr1$ sudo vtysh -c "show ip route"
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp13s0, 00:00:08
K>* 169.254.0.0/16 [0/1000] is directly connected, virbr2 linkdown, 00:00:08
L>* 192.168.44.1/32 is directly connected, dummy2, 00:00:08
L>* 192.168.55.1/32 is directly connected, dummy1, 00:00:08
C>* 192.168.56.0/24 is directly connected, dummy1, 00:00:08
L>* 192.168.56.1/32 is directly connected, dummy1, 00:00:08
L>* 192.168.119.205/32 is directly connected, enp13s0, 00:00:08

sharpd@eva:/work/home/sharpd/frr1$ ip route show
default via 192.168.119.1 dev enp13s0 proto dhcp metric 100
169.254.0.0/16 dev virbr2 scope link metric 1000 linkdown
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.45.0/24 dev virbr2 proto kernel scope link src 192.168.45.1 linkdown
192.168.56.0/24 dev dummy1 proto kernel scope link src 192.168.56.1
192.168.119.0/24 dev enp13s0 proto kernel scope link src 192.168.119.205 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

sharpd@eva:/work/home/sharpd/frr1$ ip route show table 255
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
local 172.17.0.1 dev docker0 proto kernel scope host src 172.17.0.1
broadcast 172.17.255.255 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
local 192.168.44.1 dev dummy2 proto kernel scope host src 192.168.44.1
broadcast 192.168.44.255 dev dummy2 proto kernel scope link src 192.168.44.1
local 192.168.45.1 dev virbr2 proto kernel scope host src 192.168.45.1
broadcast 192.168.45.255 dev virbr2 proto kernel scope link src 192.168.45.1 linkdown
local 192.168.55.1 dev dummy1 proto kernel scope host src 192.168.55.1
broadcast 192.168.55.255 dev dummy1 proto kernel scope link src 192.168.55.1
local 192.168.56.1 dev dummy1 proto kernel scope host src 192.168.56.1
broadcast 192.168.56.255 dev dummy1 proto kernel scope link src 192.168.56.1
local 192.168.119.205 dev enp13s0 proto kernel scope host src 192.168.119.205
broadcast 192.168.119.255 dev enp13s0 proto kernel scope link src 192.168.119.205
local 192.168.122.1 dev virbr0 proto kernel scope host src 192.168.122.1
broadcast 192.168.122.255 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

Fixes: #14952
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 8a574840a4e29d2529fb03cdeeb6a09a11b0bdf5)

16 months agozebra: Add ability to note that a address is NOPREFIXROUTE
Donald Sharp [Wed, 6 Dec 2023 13:24:01 +0000 (08:24 -0500)]
zebra: Add ability to note that a address is NOPREFIXROUTE

The linux kernel can send up a flag that tells us that the
connected address is not a PREFIXROUTE.  Add the ability
to note this and pass it up from the data plane.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 466ad88ce12af8d613600717def6a17dc6283ee8)

16 months agoMerge pull request #14956 from FRRouting/mergify/bp/stable/9.0/pr-14922
Donald Sharp [Thu, 7 Dec 2023 13:04:17 +0000 (08:04 -0500)]
Merge pull request #14956 from FRRouting/mergify/bp/stable/9.0/pr-14922

staticd: fix changing to source auto in bfd monitor  (backport #14922)

16 months agotopotests: test wrong bfd source in bfd_topo3 14956/head
Louis Scalbert [Thu, 30 Nov 2023 15:07:40 +0000 (16:07 +0100)]
topotests: test wrong bfd source in bfd_topo3

Test setting a wrong bfd source and restore the source auto parameter.

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

16 months agotopotests: redispatch tests in bfd_topo3
Louis Scalbert [Thu, 30 Nov 2023 15:01:09 +0000 (16:01 +0100)]
topotests: redispatch tests in bfd_topo3

Redispatch tests in bfd_topo3 in order to prepare next commit.
Cosmetic change.

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

16 months agostaticd: fix changing to source auto in bfd monitor
Louis Scalbert [Thu, 30 Nov 2023 16:29:20 +0000 (17:29 +0100)]
staticd: fix changing to source auto in bfd monitor

When monitoring a static route with BFD multi-hop, the source IP can be
either configured or retrieved from NextHop-Tracking (NHT). After
removing a configured source, the source is supposed to be retrieved
from NHT but it remains to the previous value. This is problematic if
the user desires to fix the configuration of a incorrect source IP.

For example, theses two commands results in the incorrect state:

> ip route 10.0.0.0/24 10.1.0.1 bfd multi-hop source 10.2.2.2
> ip route 10.0.0.0/24 10.1.0.1 bfd multi-hop

When removing the source, BFD is unable to find the source from NHT via
bfd_nht_update() were called.

Force zebra to resend the information to BFD by unregistering and
registering again NHT. The (...)/frr-nexthops/nexthop northbound
apply_finish function will trigger a call to static_install_nexthop()
that does a call to static_zebra_nht_register(nh, true);

Fixes: b7ca809d1c ("lib: BFD automatic source selection")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 580c605194b3893a1d61a997a7b9d62e2d877427)

16 months agoMerge pull request #14951 from FRRouting/mergify/bp/stable/9.0/pr-14913
Donatas Abraitis [Wed, 6 Dec 2023 08:45:04 +0000 (10:45 +0200)]
Merge pull request #14951 from FRRouting/mergify/bp/stable/9.0/pr-14913

pbrd: fix map seq installed flag in json (backport #14913)

16 months agopbrd: fix map seq installed flag in json 14951/head
Chirag Shah [Fri, 20 Oct 2023 05:07:15 +0000 (22:07 -0700)]
pbrd: fix map seq installed flag in json

Ticket:#3638598
Testing:

Post fix:
tor-2# show pbr map json
[
  {
    "name":"global-vrf-PBR-map",
    "valid":true,
    "policies":[
      {
        "id":1,
        "sequenceNumber":10,
        "ruleNumber":309,
        "vrfUnchanged":false,
        "installed":true,   <<<< now display correct value
        "installedReason":"Valid",
        "vrfName":"sym_1",
        "matchSrc":"10.1.200.0\/24",
        "matchDst":"10.6.200.0\/24"
      }
    ]
  }

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

16 months agoMerge pull request #14943 from FRRouting/mergify/bp/stable/9.0/pr-14939
Donatas Abraitis [Tue, 5 Dec 2023 14:26:25 +0000 (16:26 +0200)]
Merge pull request #14943 from FRRouting/mergify/bp/stable/9.0/pr-14939

isisd: Fix dislaying LSP ID (backport #14939)

16 months agoisisd: Fix dislaying LSP ID 14943/head
lynnemorrison [Tue, 5 Dec 2023 00:41:28 +0000 (19:41 -0500)]
isisd: Fix dislaying LSP ID

If "no hostname dynamic" command is used this fix correctly
displays the LSP ID.

Signed-off-by: Lynne Morrison <lynne.morrison@ibm.com>
(cherry picked from commit 1f201c6f034de88c875b5127af82574f1beba969)

16 months agoFRR Release 9.0.2 docker/9.0.2 frr-9.0.2
Donatas Abraitis [Fri, 1 Dec 2023 08:02:21 +0000 (10:02 +0200)]
FRR Release 9.0.2

bgpd
    Fix aggregate-address summary-only suppressed export to EVPN
    Allow using attribute number 255 for path attr discard/withdraw cmds
    Check mandatory attributes more carefully for the UPDATE message
    Do not suppress conditional advertisement updates if triggered
    Fix Extended community memory leak
    Fix the no set as-path prepend command
    Fix heap-use-after-free for bgp_best_selection()
    Fix crash in SNMP BGP4V2-MIB bgpv2PeerErrorsTable()
    Fix clear bgp ipv6 unicast ... command
    Flush attributes only if we don't have to announce a conditional route (avoid use-after-free)
    Free memory for SRv6 functions and locator chunks
    Handle MP_UNREACH_NLRI malformed packets with session reset
    Ignore handling NLRIs if we received the MP_UNREACH_NLRI attribute
    Initialise timebuf arrays to zeros for dampening reuse timer
    Initialise buffer in bgp_notify_admin_message() before using it
    LTTng add EVPN route trace events
    Make sure dampening is enabled for the specified AFI/SAFI
    Use proper AFI when dumping information for dampening stuff
    Treat the AS4-PATH attribute as withdrawn if malformed
    Treat PMSI tunnel attribute as withdrawn if malformed
    Treat EOR as withdrawn to avoid unwanted handling of malformed attrs

eigrpd
    Use the correct memory pool on interface deletion

mgmtd
    Change mgmtd_vty_port to 2623
    Fix crash on show mgmtd datastore-contents

ospf6d
    Fix setting of the forwarding address in as-external LSAs
    Set loopback interface cost to 0

ospfd
    Fixing infinite loop when listing OSPF interfaces

pathd
    Add no msd command
    Add no pcep command

pbrd
    Fix show pbr map detail json command
    Free memory in pbr_map_delete()

pim6d
    Fix valgrind issues

pimd
    Fix missing pimreg interface

tools
    Fix the frr-reload interface description command
    Fix the frr-reload route-map description command
    Make --quiet actually suppress output

vtysh
    Fix entering configuration node in file-lock mode
    Fix configure terminal argument descriptions
    Fix working in file-lock mode
    Fix show route map json output

zebra
    Add encap type when building packet for FPM
    Display ptmStatus order in interface JSON
    Fix connected route deletion when multiple entry exists
    Fix FPM multipath encap addition
    Fix link update for veth interfaces
    Fix zebra crash when replacing nhe during shutdown
    Prevent null pointer dereference

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
16 months agoMerge pull request #14919 from opensourcerouting/fix/ac30911160c6dd5556dd42133760a0c6...
Donald Sharp [Thu, 30 Nov 2023 14:44:48 +0000 (09:44 -0500)]
Merge pull request #14919 from opensourcerouting/fix/ac30911160c6dd5556dd42133760a0c60b897569_9.0

bgpd: aggr summary-only suppressed export to evpn

16 months agoMerge pull request #14916 from FRRouting/mergify/bp/stable/9.0/pr-14907
Donatas Abraitis [Thu, 30 Nov 2023 11:50:07 +0000 (13:50 +0200)]
Merge pull request #14916 from FRRouting/mergify/bp/stable/9.0/pr-14907

bgpd: Free Memory for SRv6 Functions and Locator Chunks (backport #14907)

16 months agobgpd: aggr summary-only suppressed export to evpn 14919/head
Chirag Shah [Sat, 23 Sep 2023 00:19:09 +0000 (17:19 -0700)]
bgpd: aggr summary-only suppressed export to evpn

When exporting bgp vrf instance unicast route into
EVPN as type-5, check for suppressed ones and do not
export them.

Ticket:#3534718
Testing Done:

Config:

router bgp 660000 vrf vrf1
 bgp router-id 144.1.1.2
 no bgp network import-check
 neighbor 144.1.1.1 remote-as external
 !
 address-family ipv4 unicast
  aggregate-address 50.1.0.0/16 summary-only
  redistribute connected
 exit-address-family
 !
 address-family l2vpn evpn
  advertise ipv4 unicast
 exit-address-family
exit

v4 suppressed route: (5 suppressed routes not exported to evpn)

tor1# vtysh -c "show bgp vrf vrf1 ipv4 unicast" | grep "50.1"
*> 50.1.0.0/16      0.0.0.0(bordertor-11)
s> 50.1.1.212/32    6.0.0.30(leaf-11)<
s> 50.1.1.222/32    6.0.0.31(leaf-11)<
s> 50.1.110.0/24    0.0.0.0(bordertor-11)
s> 50.1.210.214/32  6.0.0.30(leaf-11)<
s> 50.1.220.224/32  6.0.0.31(leaf-11)<

tor1# vtysh -c "show bgp l2vpn evpn route" | grep -A3 "*> \[5\].*\[50.1"
*> [5]:[0]:[16]:[50.1.0.0] RD 144.1.1.2:7
                    6.0.0.1 (bordertor-11)
                                             0         32768 ?
                    ET:8 RT:4640:104001 Rmac:00:02:00:00:00:04

Signed-off-by: Chirag Shah <chirag@nvidia.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
16 months agobgpd: lttng tp add evpn route events
Chirag Shah [Thu, 7 Sep 2023 22:51:32 +0000 (15:51 -0700)]
bgpd: lttng tp add evpn route events

Ticket:#3597393
Testing Done:

2023-09-08T22:53:03.532 frr_bgp:evpn_withdraw_type5 {'vrf_id': 42, 'ip':
'53.1.1.0'}
2023-09-08T22:53:06.207 frr_bgp:evpn_advertise_type5 {'vrf_id': 42,
'ip': '53.1.1.0', 'rmac': '00:02:00:00:00:38', 'vtep': '27.0.0.15'}

2023-09-08T21:51:15.637 frr_bgp:evpn_mh_local_ead_es_evi_route_upd
{'esi': '03:44:38:39:ff:ff:01:00:00:03', 'vni': 1000, 'route_type': 1,
'vtep': '27.0.0.15'}

2023-09-08T20:45:17.059 frr_bgp:evpn_mh_local_ead_es_evi_route_del
{'esi': '03:44:38:39:ff:ff:01:00:00:01', 'vni': 0, 'route_type': 4,
'vtep': '27.0.0.15'}

2023-09-08T21:51:18.363 frr_bgp:evpn_mh_es_evi_vtep_add {'esi':
'03:44:38:39:ff:ff:01:00:00:02', 'vni': 1000, 'vtep': '27.0.0.16',
'ead_es': 1}

2023-09-08T20:43:50.206 frr_bgp:evpn_mh_es_evi_vtep_del {'esi':
'03:44:38:39:ff:ff:01:00:00:01', 'vni': 1002, 'vtep': '27.0.0.16',
'ead_es': 0}

Signed-off-by: Chirag Shah <chirag@nvidia.com>
16 months agobgpd: Free Memory for SRv6 Functions and Locator Chunks 14916/head
Keelan10 [Wed, 29 Nov 2023 11:49:58 +0000 (15:49 +0400)]
bgpd: Free Memory for SRv6 Functions and Locator Chunks

Implement proper memory cleanup for SRv6 functions and locator chunks to prevent potential memory leaks.
The list callback deletion functions have been set.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.asan.bgpd.4180

=================================================================
==4180==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 544 byte(s) in 2 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x55d5dba6ee75 in sid_register bgpd/bgp_mplsvpn.c:591
    #3 0x55d5dba6ee75 in alloc_new_sid bgpd/bgp_mplsvpn.c:712
    #4 0x55d5dba6f3ce in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:758
    #5 0x55d5dba6fb94 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:849
    #6 0x55d5dba7f975 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:299
    #7 0x55d5dba7f975 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3704
    #8 0x55d5dbbb6c66 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3164
    #9 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #10 0x7f8d1713f034 in event_call lib/event.c:1974
    #11 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #12 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #13 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 296 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x7f8d170b1d5f in srv6_locator_chunk_alloc lib/srv6.c:135
    #3 0x55d5dbbb6a19 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3144
    #4 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #5 0x7f8d1713f034 in event_call lib/event.c:1974
    #6 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #7 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #8 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
***********************************************************************************

```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
(cherry picked from commit 8e7044ba3b806d286ed964746f4e88004035be09)

17 months agoMerge pull request #14904 from opensourcerouting/fix/9561f9671dbfb77ec7d319cd19c88e4b...
Donald Sharp [Wed, 29 Nov 2023 18:50:12 +0000 (13:50 -0500)]
Merge pull request #14904 from opensourcerouting/fix/9561f9671dbfb77ec7d319cd19c88e4be506004b_9.0

bgpd: fix bgp_best_selection heap-use-after-free

17 months agoMerge pull request #14900 from FRRouting/mergify/bp/stable/9.0/pr-14897
Donatas Abraitis [Wed, 29 Nov 2023 12:49:51 +0000 (14:49 +0200)]
Merge pull request #14900 from FRRouting/mergify/bp/stable/9.0/pr-14897

tools: fix frr-reload interface desc cmd (backport #14897)

17 months agobgpd: fix bgp_best_selection heap-use-after-free 14904/head
Louis Scalbert [Tue, 28 Nov 2023 13:54:46 +0000 (14:54 +0100)]
bgpd: fix bgp_best_selection heap-use-after-free

Fix bgp_best_selection heap-use-after-free

> ==2521540==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d000032810 at pc 0x000000716f45 bp 0x7ffedc6229d0 sp 0x7ffedc6229c8
> READ of size 8 at 0x60d000032810 thread T0
>     #0 0x716f44 in bgp_best_selection /home/lscalber/git/frr/bgpd/bgp_route.c:2834:5
>     #1 0x71a05e in bgp_process_main_one /home/lscalber/git/frr/bgpd/bgp_route.c:3344:2
>     #2 0x71c265 in bgp_process_wq /home/lscalber/git/frr/bgpd/bgp_route.c:3622:3
>     #3 0x7fe630a6669c in work_queue_run /home/lscalber/git/frr/lib/workqueue.c:282:10
>     #4 0x7fe630a294e2 in event_call /home/lscalber/git/frr/lib/event.c:1974:2
>     #5 0x7fe630898f3f in frr_run /home/lscalber/git/frr/lib/libfrr.c:1214:3
>     #6 0x4f4ace in main /home/lscalber/git/frr/bgpd/bgp_main.c:510:2
>     #7 0x7fe63018bd09 in __libc_start_main csu/../csu/libc-start.c:308:16
>     #8 0x449629 in _start (/usr/lib/frr/bgpd+0x449629)
>
> 0x60d000032810 is located 48 bytes inside of 144-byte region [0x60d0000327e0,0x60d000032870)
> freed by thread T0 here:
>     #0 0x4c341d in free (/usr/lib/frr/bgpd+0x4c341d)
>     #1 0x7fe6308d7420 in qfree /home/lscalber/git/frr/lib/memory.c:130:2
>     #2 0x702632 in bgp_path_info_free_with_caller /home/lscalber/git/frr/bgpd/bgp_route.c:300:2
>     #3 0x702023 in bgp_path_info_unlock /home/lscalber/git/frr/bgpd/bgp_route.c:315:3
>     #4 0x703bc6 in bgp_path_info_reap /home/lscalber/git/frr/bgpd/bgp_route.c:461:2
>     #5 0x716e5d in bgp_best_selection /home/lscalber/git/frr/bgpd/bgp_route.c:2829:12
>     #6 0x71a05e in bgp_process_main_one /home/lscalber/git/frr/bgpd/bgp_route.c:3344:2
>     #7 0x71c265 in bgp_process_wq /home/lscalber/git/frr/bgpd/bgp_route.c:3622:3
>     #8 0x7fe630a6669c in work_queue_run /home/lscalber/git/frr/lib/workqueue.c:282:10
>     #9 0x7fe630a294e2 in event_call /home/lscalber/git/frr/lib/event.c:1974:2
>     #10 0x7fe630898f3f in frr_run /home/lscalber/git/frr/lib/libfrr.c:1214:3
>     #11 0x4f4ace in main /home/lscalber/git/frr/bgpd/bgp_main.c:510:2
>     #12 0x7fe63018bd09 in __libc_start_main csu/../csu/libc-start.c:308:16
>
> previously allocated by thread T0 here:
>     #0 0x4c3812 in calloc (/usr/lib/frr/bgpd+0x4c3812)
>     #1 0x7fe6308d7178 in qcalloc /home/lscalber/git/frr/lib/memory.c:105:27
>     #2 0x71f5b4 in info_make /home/lscalber/git/frr/bgpd/bgp_route.c:3985:8
>     #3 0x725293 in bgp_update /home/lscalber/git/frr/bgpd/bgp_route.c:4881:8
>     #4 0x73083d in bgp_nlri_parse_ip /home/lscalber/git/frr/bgpd/bgp_route.c:6230:4
>     #5 0x6ba980 in bgp_nlri_parse /home/lscalber/git/frr/bgpd/bgp_packet.c:341:10
>     #6 0x6cca2a in bgp_update_receive /home/lscalber/git/frr/bgpd/bgp_packet.c:2412:15
>     #7 0x6c6788 in bgp_process_packet /home/lscalber/git/frr/bgpd/bgp_packet.c:3887:11
>     #8 0x7fe630a294e2 in event_call /home/lscalber/git/frr/lib/event.c:1974:2
>     #9 0x7fe630898f3f in frr_run /home/lscalber/git/frr/lib/libfrr.c:1214:3
>     #10 0x4f4ace in main /home/lscalber/git/frr/bgpd/bgp_main.c:510:2
>     #11 0x7fe63018bd09 in __libc_start_main csu/../csu/libc-start.c:308:16

Fixes: ddb5b4880b ("bgpd: vpn-vrf route leaking")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
17 months agotools: fix frr-reload interface desc cmd 14900/head
Chirag Shah [Wed, 29 Nov 2023 02:54:14 +0000 (18:54 -0800)]
tools: fix frr-reload interface desc cmd

Fix frr-reload script to only render 'no description'
rather than 'no description blah'

Ticket:#3628756
Testing Done:

Before:
2023-11-29 02:38:55,758  INFO: Failed to execute interface hostbond_1
no description hostbond_1_to_host exit
2023-11-29 02:38:55,758 ERROR: "interface hostbond_1 --  no description
hostbond_1_to_host -- exit" we failed to remove this command
2023-11-29 02:38:55,758 ERROR: % Unknown command:  no description
hostbond_1_to_host

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

17 months agoMerge pull request #14892 from FRRouting/mergify/bp/stable/9.0/pr-14856
Donald Sharp [Tue, 28 Nov 2023 14:17:48 +0000 (09:17 -0500)]
Merge pull request #14892 from FRRouting/mergify/bp/stable/9.0/pr-14856

lib: fix show route map JSON display (backport #14856)

17 months agodoc: remove duplicated show route-map 14892/head
Rafael Zalamena [Tue, 21 Nov 2023 18:02:44 +0000 (15:02 -0300)]
doc: remove duplicated show route-map

Remove zebra duplicated command documentation without description.

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

17 months agolib,vtysh: fix show route map JSON output
Rafael Zalamena [Mon, 20 Nov 2023 20:32:19 +0000 (17:32 -0300)]
lib,vtysh: fix show route map JSON output

Move the command from 'lib' to 'vtysh' so we can properly format the
JSON output in a correct manner.

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

17 months agoMerge pull request #14872 from FRRouting/mergify/bp/stable/9.0/pr-14862
Donald Sharp [Fri, 24 Nov 2023 19:32:45 +0000 (14:32 -0500)]
Merge pull request #14872 from FRRouting/mergify/bp/stable/9.0/pr-14862

zebra: fix dplane_ctx_iptable use-after-free (backport #14862)

17 months agozebra: fix dplane_ctx_iptable use-after-free 14872/head
Louis Scalbert [Wed, 22 Nov 2023 17:21:25 +0000 (18:21 +0100)]
zebra: fix dplane_ctx_iptable use-after-free

Fix a crash because a use-after-free.

> =================================================================
> ==1249835==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000074210 at pc 0x7fa1b42a652c bp 0x7ffc477a2aa0 sp 0x7ffc477a2a98
> READ of size 8 at 0x604000074210 thread T0
>     #0 0x7fa1b42a652b in list_delete_all_node git/frr/lib/linklist.c:299:20
>     #1 0x7fa1b42a683f in list_delete git/frr/lib/linklist.c:312:2
>     #2 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4
>     #3 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2
>     #4 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2
>     #5 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4
>     #6 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2
>     #7 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3
>     #8 0x556808 in main git/frr/zebra/main.c:488:2
>     #9 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16
>     #10 0x4453e9 in _start (/usr/lib/frr/zebra+0x4453e9)
>
> 0x604000074210 is located 0 bytes inside of 40-byte region [0x604000074210,0x604000074238)
> freed by thread T0 here:
>     #0 0x4bf1dd in free (/usr/lib/frr/zebra+0x4bf1dd)
>     #1 0x7fa1b42df0c0 in qfree git/frr/lib/memory.c:130:2
>     #2 0x7fa1b42a68ce in list_free_internal git/frr/lib/linklist.c:24:2
>     #3 0x7fa1b42a6870 in list_delete git/frr/lib/linklist.c:313:2
>     #4 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4
>     #5 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2
>     #6 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2
>     #7 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4
>     #8 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2
>     #9 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3
>     #10 0x556808 in main git/frr/zebra/main.c:488:2
>     #11 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16
>
> previously allocated by thread T0 here:
>     #0 0x4bf5d2 in calloc (/usr/lib/frr/zebra+0x4bf5d2)
>     #1 0x7fa1b42dee18 in qcalloc git/frr/lib/memory.c:105:27
>     #2 0x7fa1b42a3784 in list_new git/frr/lib/linklist.c:18:9
>     #3 0x6d165f in pbr_iptable_alloc_intern git/frr/zebra/zebra_pbr.c:1015:29
>     #4 0x7fa1b426ad1f in hash_get git/frr/lib/hash.c:147:13
>     #5 0x6d15f2 in zebra_pbr_add_iptable git/frr/zebra/zebra_pbr.c:1030:13
>     #6 0x5db2a3 in zread_iptable git/frr/zebra/zapi_msg.c:3759:3
>     #7 0x5e365d in zserv_handle_commands git/frr/zebra/zapi_msg.c:4039:3
>     #8 0x7e09fc in zserv_process_messages git/frr/zebra/zserv.c:520:3
>     #9 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2
>     #10 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3
>     #11 0x556808 in main git/frr/zebra/main.c:488:2
>     #12 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16

Fixes: 1cc380679e ("zebra: Actually free all memory associated ctx->u.iptable.interface_name_list")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 45140bb9e1efd2e603377809e349b35087d24f7d)

17 months agoMerge pull request #14861 from FRRouting/mergify/bp/stable/9.0/pr-14716
Donatas Abraitis [Thu, 23 Nov 2023 14:00:32 +0000 (16:00 +0200)]
Merge pull request #14861 from FRRouting/mergify/bp/stable/9.0/pr-14716

bgpd: A couple more bgpd crash fixes for malformed packets  (backport #14716)

17 months agobgpd: Ignore handling NLRIs if we received MP_UNREACH_NLRI 14861/head
Donatas Abraitis [Sun, 29 Oct 2023 20:44:45 +0000 (22:44 +0200)]
bgpd: Ignore handling NLRIs if we received MP_UNREACH_NLRI

If we receive MP_UNREACH_NLRI, we should stop handling remaining NLRIs if
no mandatory path attributes received.

In other words, if MP_UNREACH_NLRI received, the remaining NLRIs should be handled
as a new data, but without mandatory attributes, it's a malformed packet.

In normal case, this MUST not happen at all, but to avoid crashing bgpd, we MUST
handle that.

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

17 months agobgpd: Treat EOR as withdrawn to avoid unwanted handling of malformed attrs
Donatas Abraitis [Fri, 27 Oct 2023 08:56:45 +0000 (11:56 +0300)]
bgpd: Treat EOR as withdrawn to avoid unwanted handling of malformed attrs

Treat-as-withdraw, otherwise if we just ignore it, we will pass it to be
processed as a normal UPDATE without mandatory attributes, that could lead
to harmful behavior. In this case, a crash for route-maps with the configuration
such as:

```
router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 127.0.0.1 remote-as external
 neighbor 127.0.0.1 passive
 neighbor 127.0.0.1 ebgp-multihop
 neighbor 127.0.0.1 disable-connected-check
 neighbor 127.0.0.1 update-source 127.0.0.2
 neighbor 127.0.0.1 timers 3 90
 neighbor 127.0.0.1 timers connect 1
 !
 address-family ipv4 unicast
  neighbor 127.0.0.1 addpath-tx-all-paths
  neighbor 127.0.0.1 default-originate
  neighbor 127.0.0.1 route-map RM_IN in
 exit-address-family
exit
!
route-map RM_IN permit 10
 set as-path prepend 200
exit
```

Send a malformed optional transitive attribute:

```
import socket
import time

OPEN = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\x00\x62\x01\x04\xfd\xea\x00\x5a\x0a\x00\x00\x01\x45\x02"
b"\x06\x01\x04\x00\x01\x00\x01\x02\x02\x02\x00\x02\x02\x46\x00\x02"
b"\x06\x41\x04\x00\x00\xfd\xea\x02\x02\x06\x00\x02\x06\x45\x04\x00"
b"\x01\x01\x03\x02\x0e\x49\x0c\x0a\x64\x6f\x6e\x61\x74\x61\x73\x2d"
b"\x70\x63\x00\x02\x04\x40\x02\x00\x78\x02\x09\x47\x07\x00\x01\x01"
b"\x80\x00\x00\x00")

KEEPALIVE = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\xff\xff\xff\xff\x00\x13\x04")

UPDATE = bytearray.fromhex("ffffffffffffffffffffffffffffffff002b0200000003c0ff00010100eb00ac100b0b001ad908ac100b0b")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.2', 179))
s.send(OPEN)
data = s.recv(1024)
s.send(KEEPALIVE)
data = s.recv(1024)
s.send(UPDATE)
data = s.recv(1024)
time.sleep(100)
s.close()
```

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

17 months agoMerge pull request #14854 from FRRouting/mergify/bp/stable/9.0/pr-14845
Donatas Abraitis [Wed, 22 Nov 2023 05:50:12 +0000 (07:50 +0200)]
Merge pull request #14854 from FRRouting/mergify/bp/stable/9.0/pr-14845

bgpd: Prevent USE case for conditional advertisements with `set` actions (backport #14845)