2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-08-27 16:43:37 +02:00
|
|
|
/* Zebra Router Code.
|
|
|
|
* Copyright (C) 2018 Cumulus Networks, Inc.
|
|
|
|
* Donald Sharp
|
|
|
|
*/
|
|
|
|
#include "zebra.h"
|
|
|
|
|
2019-01-22 13:39:14 +01:00
|
|
|
#include <pthread.h>
|
|
|
|
#include "lib/frratomic.h"
|
|
|
|
|
2018-08-27 16:43:37 +02:00
|
|
|
#include "zebra_router.h"
|
2018-08-27 20:36:46 +02:00
|
|
|
#include "zebra_pbr.h"
|
2018-12-06 09:03:12 +01:00
|
|
|
#include "zebra_vxlan.h"
|
2018-12-18 13:44:23 +01:00
|
|
|
#include "zebra_mlag.h"
|
2019-11-22 21:30:53 +01:00
|
|
|
#include "zebra_nhg.h"
|
2021-12-18 20:28:49 +01:00
|
|
|
#include "zebra_neigh.h"
|
2022-09-06 09:10:11 +02:00
|
|
|
#include "zebra/zebra_tc.h"
|
2019-02-15 15:06:58 +01:00
|
|
|
#include "debug.h"
|
2021-10-27 13:57:43 +02:00
|
|
|
#include "zebra_script.h"
|
zebra: Bring up 514 BGP neighbor sessions
Issue:
When 514 inerfaces/neighbors are configured, it creates socket error,
"Cannot allocate memory", when back to back V6 RA messages are tried
to be sent over the socket. This prevents interface, to know its peer's
link local address. Socket error comes when 1) try to join ICMPv6 all
router multicast group, back to back for all interfaces 2)send back to
back RA for all interfaces
Fix:
1)For ICMPv6 join case, we check if the interface has already joined
all router group, if not try to join. On failure, retry joining after
random amount of time determined 1 ms to ICMPV6_JOIN_TIMER_EXP_MS(100 ms)
2) For RA issue case, batch sending of RA mesages using wheel timer
Testing:
Monitor BGP session running sh bgp summary command
Before fix:
r1# sh bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth1 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth2 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth3 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth4 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth5 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
…..<snip>...
r1-eth252 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth253 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth254 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth255 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth256 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth257 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth258 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth259 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth260 4 0 0 0 0 0 0 never Idle 0 N/A
……..<snip>…..
r1-eth511 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth512 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth513 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth514 4 0 0 0 0 0 0 never Idle 0 N/A
After fix:
r1# show bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth1 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth2 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth3 4 1002 64 67 0 0 0 00:05:09 0 0 N/A
r1-eth4 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth5 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth6 4 1002 67 70 0 0 0 00:05:22 0 0 N/A
r1-eth7 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth8 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
....
r1-eth499 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth500 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth501 4 1002 19 22 0 0 0 00:01:21 0 0 N/A
r1-eth502 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth503 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth504 4 1002 20 23 0 0 0 00:01:30 0 0 N/A
r1-eth505 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth506 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth507 4 1002 22 25 0 0 0 00:01:39 0 0 N/A
r1-eth508 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth509 4 1002 17 20 0 0 0 00:01:13 0 0 N/A
r1-eth510 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth511 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth512 4 1002 19 22 0 0 0 00:01:22 0 0 N/A
r1-eth513 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth514 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
Signed-off-by: Soumya Roy <souroy@nvidia.com>
2025-02-15 03:13:37 +01:00
|
|
|
#include "wheel.h"
|
2018-08-27 16:43:37 +02:00
|
|
|
|
2019-06-21 08:10:39 +02:00
|
|
|
DEFINE_MTYPE_STATIC(ZEBRA, RIB_TABLE_INFO, "RIB table info");
|
2021-03-22 20:02:17 +01:00
|
|
|
DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_RT_TABLE, "Zebra VRF table");
|
2019-06-21 08:10:39 +02:00
|
|
|
|
2019-02-13 20:58:29 +01:00
|
|
|
struct zebra_router zrouter = {
|
|
|
|
.multipath_num = MULTIPATH_NUM,
|
|
|
|
};
|
2018-08-27 16:43:37 +02:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
zebra_router_table_entry_compare(const struct zebra_router_table *e1,
|
|
|
|
const struct zebra_router_table *e2);
|
|
|
|
|
|
|
|
RB_GENERATE(zebra_router_table_head, zebra_router_table,
|
|
|
|
zebra_router_table_entry, zebra_router_table_entry_compare);
|
|
|
|
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
zebra_router_table_entry_compare(const struct zebra_router_table *e1,
|
|
|
|
const struct zebra_router_table *e2)
|
|
|
|
{
|
|
|
|
if (e1->tableid < e2->tableid)
|
|
|
|
return -1;
|
|
|
|
if (e1->tableid > e2->tableid)
|
|
|
|
return 1;
|
|
|
|
if (e1->ns_id < e2->ns_id)
|
|
|
|
return -1;
|
|
|
|
if (e1->ns_id > e2->ns_id)
|
|
|
|
return 1;
|
|
|
|
if (e1->afi < e2->afi)
|
|
|
|
return -1;
|
|
|
|
if (e1->afi > e2->afi)
|
|
|
|
return 1;
|
|
|
|
return (e1->safi - e2->safi);
|
|
|
|
}
|
|
|
|
|
2020-02-28 03:38:24 +01:00
|
|
|
struct zebra_router_table *zebra_router_find_zrt(struct zebra_vrf *zvrf,
|
|
|
|
uint32_t tableid, afi_t afi,
|
|
|
|
safi_t safi)
|
|
|
|
{
|
|
|
|
struct zebra_router_table finder;
|
|
|
|
struct zebra_router_table *zrt;
|
|
|
|
|
|
|
|
memset(&finder, 0, sizeof(finder));
|
|
|
|
finder.afi = afi;
|
|
|
|
finder.safi = safi;
|
|
|
|
finder.tableid = tableid;
|
|
|
|
finder.ns_id = zvrf->zns->ns_id;
|
|
|
|
zrt = RB_FIND(zebra_router_table_head, &zrouter.tables, &finder);
|
2023-10-20 10:53:05 +02:00
|
|
|
|
|
|
|
return zrt;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct zebra_router_table *zebra_router_find_next_zrt(struct zebra_vrf *zvrf,
|
|
|
|
uint32_t tableid,
|
|
|
|
afi_t afi, safi_t safi)
|
|
|
|
{
|
|
|
|
struct zebra_router_table finder;
|
|
|
|
struct zebra_router_table *zrt;
|
|
|
|
|
|
|
|
memset(&finder, 0, sizeof(finder));
|
|
|
|
finder.afi = afi;
|
|
|
|
finder.safi = safi;
|
|
|
|
finder.tableid = tableid;
|
|
|
|
finder.ns_id = zvrf->zns->ns_id;
|
|
|
|
zrt = RB_NFIND(zebra_router_table_head, &zrouter.tables, &finder);
|
|
|
|
if (zrt->afi == afi && zrt->safi == safi && zrt->tableid == tableid &&
|
|
|
|
zrt->ns_id == finder.ns_id)
|
|
|
|
zrt = RB_NEXT(zebra_router_table_head, zrt);
|
2020-02-28 03:38:24 +01:00
|
|
|
|
|
|
|
return zrt;
|
|
|
|
}
|
2018-08-27 16:43:37 +02:00
|
|
|
|
|
|
|
struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
|
|
|
|
uint32_t tableid, afi_t afi,
|
|
|
|
safi_t safi)
|
|
|
|
{
|
|
|
|
struct zebra_router_table finder;
|
|
|
|
struct zebra_router_table *zrt;
|
|
|
|
|
|
|
|
memset(&finder, 0, sizeof(finder));
|
|
|
|
finder.afi = afi;
|
|
|
|
finder.safi = safi;
|
|
|
|
finder.tableid = tableid;
|
|
|
|
finder.ns_id = zvrf->zns->ns_id;
|
|
|
|
zrt = RB_FIND(zebra_router_table_head, &zrouter.tables, &finder);
|
|
|
|
|
|
|
|
if (zrt)
|
|
|
|
return zrt->table;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf,
|
|
|
|
uint32_t tableid, afi_t afi,
|
|
|
|
safi_t safi)
|
|
|
|
{
|
|
|
|
struct zebra_router_table finder;
|
|
|
|
struct zebra_router_table *zrt;
|
2020-05-07 14:59:27 +02:00
|
|
|
struct rib_table_info *info;
|
2018-08-27 16:43:37 +02:00
|
|
|
|
|
|
|
memset(&finder, 0, sizeof(finder));
|
|
|
|
finder.afi = afi;
|
|
|
|
finder.safi = safi;
|
|
|
|
finder.tableid = tableid;
|
|
|
|
finder.ns_id = zvrf->zns->ns_id;
|
|
|
|
zrt = RB_FIND(zebra_router_table_head, &zrouter.tables, &finder);
|
|
|
|
|
|
|
|
if (zrt)
|
|
|
|
return zrt->table;
|
|
|
|
|
2021-03-22 20:02:17 +01:00
|
|
|
zrt = XCALLOC(MTYPE_ZEBRA_RT_TABLE, sizeof(*zrt));
|
2018-08-27 16:43:37 +02:00
|
|
|
zrt->tableid = tableid;
|
|
|
|
zrt->afi = afi;
|
2018-10-28 11:54:52 +01:00
|
|
|
zrt->safi = safi;
|
2018-08-27 16:43:37 +02:00
|
|
|
zrt->ns_id = zvrf->zns->ns_id;
|
|
|
|
zrt->table =
|
|
|
|
(afi == AFI_IP6) ? srcdest_table_init() : route_table_init();
|
|
|
|
|
|
|
|
info = XCALLOC(MTYPE_RIB_TABLE_INFO, sizeof(*info));
|
|
|
|
info->zvrf = zvrf;
|
|
|
|
info->afi = afi;
|
2019-01-04 14:36:02 +01:00
|
|
|
info->safi = safi;
|
2018-11-13 16:26:21 +01:00
|
|
|
info->table_id = tableid;
|
2018-08-27 16:43:37 +02:00
|
|
|
route_table_set_info(zrt->table, info);
|
|
|
|
zrt->table->cleanup = zebra_rtable_node_cleanup;
|
|
|
|
|
|
|
|
RB_INSERT(zebra_router_table_head, &zrouter.tables, zrt);
|
|
|
|
return zrt->table;
|
|
|
|
}
|
|
|
|
|
2019-01-04 15:41:09 +01:00
|
|
|
void zebra_router_show_table_summary(struct vty *vty)
|
|
|
|
{
|
|
|
|
struct zebra_router_table *zrt;
|
|
|
|
|
|
|
|
vty_out(vty,
|
|
|
|
"VRF NS ID VRF ID AFI SAFI Table Count\n");
|
|
|
|
vty_out(vty,
|
|
|
|
"---------------------------------------------------------------------------\n");
|
|
|
|
RB_FOREACH (zrt, zebra_router_table_head, &zrouter.tables) {
|
2020-05-07 14:59:27 +02:00
|
|
|
struct rib_table_info *info = route_table_get_info(zrt->table);
|
2019-01-04 15:41:09 +01:00
|
|
|
|
|
|
|
vty_out(vty, "%-16s%5d %9d %7s %15s %8d %10lu\n", info->zvrf->vrf->name,
|
|
|
|
zrt->ns_id, info->zvrf->vrf->vrf_id,
|
|
|
|
afi2str(zrt->afi), safi2str(zrt->safi),
|
|
|
|
zrt->tableid,
|
|
|
|
zrt->table->count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-27 16:43:37 +02:00
|
|
|
void zebra_router_sweep_route(void)
|
|
|
|
{
|
|
|
|
struct zebra_router_table *zrt;
|
|
|
|
|
|
|
|
RB_FOREACH (zrt, zebra_router_table_head, &zrouter.tables) {
|
|
|
|
if (zrt->ns_id != NS_DEFAULT)
|
|
|
|
continue;
|
|
|
|
rib_sweep_table(zrt->table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 20:07:04 +02:00
|
|
|
void zebra_router_sweep_nhgs(void)
|
|
|
|
{
|
|
|
|
zebra_nhg_sweep_table(zrouter.nhgs_id);
|
|
|
|
}
|
|
|
|
|
2018-08-27 16:43:37 +02:00
|
|
|
static void zebra_router_free_table(struct zebra_router_table *zrt)
|
|
|
|
{
|
|
|
|
void *table_info;
|
|
|
|
|
|
|
|
table_info = route_table_get_info(zrt->table);
|
|
|
|
route_table_finish(zrt->table);
|
2019-02-28 15:11:41 +01:00
|
|
|
RB_REMOVE(zebra_router_table_head, &zrouter.tables, zrt);
|
|
|
|
|
2018-08-27 16:43:37 +02:00
|
|
|
XFREE(MTYPE_RIB_TABLE_INFO, table_info);
|
2021-03-22 20:02:17 +01:00
|
|
|
XFREE(MTYPE_ZEBRA_RT_TABLE, zrt);
|
2018-08-27 16:43:37 +02:00
|
|
|
}
|
|
|
|
|
2019-02-28 15:11:41 +01:00
|
|
|
void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid,
|
|
|
|
afi_t afi, safi_t safi)
|
|
|
|
{
|
|
|
|
struct zebra_router_table finder;
|
|
|
|
struct zebra_router_table *zrt;
|
|
|
|
|
|
|
|
memset(&finder, 0, sizeof(finder));
|
|
|
|
finder.afi = afi;
|
|
|
|
finder.safi = safi;
|
|
|
|
finder.tableid = tableid;
|
|
|
|
finder.ns_id = zvrf->zns->ns_id;
|
|
|
|
zrt = RB_FIND(zebra_router_table_head, &zrouter.tables, &finder);
|
|
|
|
|
|
|
|
if (!zrt)
|
|
|
|
return;
|
|
|
|
|
|
|
|
zebra_router_free_table(zrt);
|
|
|
|
}
|
|
|
|
|
2019-01-22 13:39:14 +01:00
|
|
|
uint32_t zebra_router_get_next_sequence(void)
|
|
|
|
{
|
|
|
|
return 1
|
|
|
|
+ atomic_fetch_add_explicit(&zrouter.sequence_num, 1,
|
|
|
|
memory_order_relaxed);
|
|
|
|
}
|
|
|
|
|
zebra: Bring up 514 BGP neighbor sessions
Issue:
When 514 inerfaces/neighbors are configured, it creates socket error,
"Cannot allocate memory", when back to back V6 RA messages are tried
to be sent over the socket. This prevents interface, to know its peer's
link local address. Socket error comes when 1) try to join ICMPv6 all
router multicast group, back to back for all interfaces 2)send back to
back RA for all interfaces
Fix:
1)For ICMPv6 join case, we check if the interface has already joined
all router group, if not try to join. On failure, retry joining after
random amount of time determined 1 ms to ICMPV6_JOIN_TIMER_EXP_MS(100 ms)
2) For RA issue case, batch sending of RA mesages using wheel timer
Testing:
Monitor BGP session running sh bgp summary command
Before fix:
r1# sh bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth1 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth2 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth3 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth4 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth5 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
…..<snip>...
r1-eth252 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth253 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth254 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth255 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth256 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth257 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth258 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth259 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth260 4 0 0 0 0 0 0 never Idle 0 N/A
……..<snip>…..
r1-eth511 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth512 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth513 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth514 4 0 0 0 0 0 0 never Idle 0 N/A
After fix:
r1# show bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth1 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth2 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth3 4 1002 64 67 0 0 0 00:05:09 0 0 N/A
r1-eth4 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth5 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth6 4 1002 67 70 0 0 0 00:05:22 0 0 N/A
r1-eth7 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth8 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
....
r1-eth499 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth500 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth501 4 1002 19 22 0 0 0 00:01:21 0 0 N/A
r1-eth502 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth503 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth504 4 1002 20 23 0 0 0 00:01:30 0 0 N/A
r1-eth505 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth506 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth507 4 1002 22 25 0 0 0 00:01:39 0 0 N/A
r1-eth508 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth509 4 1002 17 20 0 0 0 00:01:13 0 0 N/A
r1-eth510 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth511 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth512 4 1002 19 22 0 0 0 00:01:22 0 0 N/A
r1-eth513 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth514 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
Signed-off-by: Soumya Roy <souroy@nvidia.com>
2025-02-15 03:13:37 +01:00
|
|
|
static inline unsigned int interface_hash_key(const void *arg)
|
|
|
|
{
|
|
|
|
const struct interface *ifp = arg;
|
|
|
|
|
|
|
|
return ifp->ifindex;
|
|
|
|
}
|
|
|
|
|
2018-08-27 16:43:37 +02:00
|
|
|
void zebra_router_terminate(void)
|
|
|
|
{
|
|
|
|
struct zebra_router_table *zrt, *tmp;
|
|
|
|
|
zebra: Bring up 514 BGP neighbor sessions
Issue:
When 514 inerfaces/neighbors are configured, it creates socket error,
"Cannot allocate memory", when back to back V6 RA messages are tried
to be sent over the socket. This prevents interface, to know its peer's
link local address. Socket error comes when 1) try to join ICMPv6 all
router multicast group, back to back for all interfaces 2)send back to
back RA for all interfaces
Fix:
1)For ICMPv6 join case, we check if the interface has already joined
all router group, if not try to join. On failure, retry joining after
random amount of time determined 1 ms to ICMPV6_JOIN_TIMER_EXP_MS(100 ms)
2) For RA issue case, batch sending of RA mesages using wheel timer
Testing:
Monitor BGP session running sh bgp summary command
Before fix:
r1# sh bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth1 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth2 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth3 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth4 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth5 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
…..<snip>...
r1-eth252 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth253 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth254 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth255 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth256 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth257 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth258 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth259 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth260 4 0 0 0 0 0 0 never Idle 0 N/A
……..<snip>…..
r1-eth511 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth512 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth513 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth514 4 0 0 0 0 0 0 never Idle 0 N/A
After fix:
r1# show bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth1 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth2 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth3 4 1002 64 67 0 0 0 00:05:09 0 0 N/A
r1-eth4 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth5 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth6 4 1002 67 70 0 0 0 00:05:22 0 0 N/A
r1-eth7 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth8 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
....
r1-eth499 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth500 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth501 4 1002 19 22 0 0 0 00:01:21 0 0 N/A
r1-eth502 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth503 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth504 4 1002 20 23 0 0 0 00:01:30 0 0 N/A
r1-eth505 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth506 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth507 4 1002 22 25 0 0 0 00:01:39 0 0 N/A
r1-eth508 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth509 4 1002 17 20 0 0 0 00:01:13 0 0 N/A
r1-eth510 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth511 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth512 4 1002 19 22 0 0 0 00:01:22 0 0 N/A
r1-eth513 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth514 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
Signed-off-by: Soumya Roy <souroy@nvidia.com>
2025-02-15 03:13:37 +01:00
|
|
|
if (zrouter.ra_wheel) {
|
|
|
|
wheel_delete(zrouter.ra_wheel);
|
|
|
|
zrouter.ra_wheel = NULL;
|
|
|
|
}
|
|
|
|
|
2024-06-27 00:49:45 +02:00
|
|
|
EVENT_OFF(zrouter.t_rib_sweep);
|
2021-11-29 21:51:45 +01:00
|
|
|
|
2019-04-09 21:30:15 +02:00
|
|
|
RB_FOREACH_SAFE (zrt, zebra_router_table_head, &zrouter.tables, tmp)
|
2018-08-27 16:43:37 +02:00
|
|
|
zebra_router_free_table(zrt);
|
2018-08-27 20:36:46 +02:00
|
|
|
|
2019-01-11 21:11:38 +01:00
|
|
|
work_queue_free_and_null(&zrouter.ribq);
|
2022-08-09 19:09:16 +02:00
|
|
|
meta_queue_free(zrouter.mq, NULL);
|
2019-01-11 21:11:38 +01:00
|
|
|
|
2018-12-06 09:03:12 +01:00
|
|
|
zebra_vxlan_disable();
|
2018-12-18 13:44:23 +01:00
|
|
|
zebra_mlag_terminate();
|
2021-12-18 20:28:49 +01:00
|
|
|
zebra_neigh_terminate();
|
2018-12-18 13:44:23 +01:00
|
|
|
|
zebra: free unhashable (dup) NHEs via ID table cleanup
Free unhashable (duplicate NHEs from the kernel) via ID table
cleanup. Since the NHE ID hash table contains extra entries,
that's the one we need to be calling zebra_nhg_hash_free()
on, otherwise we will never free the unhashable NHEs.
This was found via a memleak:
==1478713== HEAP SUMMARY:
==1478713== in use at exit: 10,267 bytes in 46 blocks
==1478713== total heap usage: 76,810 allocs, 76,764 frees, 3,901,237 bytes allocated
==1478713==
==1478713== 208 (88 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 35 of 41
==1478713== at 0x483BB1A: calloc (vg_replace_malloc.c:762)
==1478713== by 0x48E35E8: qcalloc (memory.c:110)
==1478713== by 0x451CCB: zebra_nhg_alloc (zebra_nhg.c:369)
==1478713== by 0x453DE3: zebra_nhg_copy (zebra_nhg.c:379)
==1478713== by 0x452670: nhg_ctx_process_new (zebra_nhg.c:1143)
==1478713== by 0x4523A8: nhg_ctx_process (zebra_nhg.c:1234)
==1478713== by 0x452A2D: zebra_nhg_kernel_find (zebra_nhg.c:1294)
==1478713== by 0x4326E0: netlink_nexthop_change (rt_netlink.c:2433)
==1478713== by 0x427320: netlink_parse_info (kernel_netlink.c:945)
==1478713== by 0x432DAD: netlink_nexthop_read (rt_netlink.c:2488)
==1478713== by 0x41B600: interface_list (if_netlink.c:1486)
==1478713== by 0x457275: zebra_ns_enable (zebra_ns.c:127)
Repro with:
ip next add id 1 blackhole
ip next add id 2 blackhole
valgrind /usr/lib/frr/zebra
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-04-01 21:31:40 +02:00
|
|
|
/* Free NHE in ID table only since it has unhashable entries as well */
|
2022-08-04 13:05:46 +02:00
|
|
|
hash_iterate(zrouter.nhgs_id, zebra_nhg_hash_free_zero_id, NULL);
|
2023-03-21 13:54:21 +01:00
|
|
|
hash_clean_and_free(&zrouter.nhgs_id, zebra_nhg_hash_free);
|
|
|
|
hash_clean_and_free(&zrouter.nhgs, NULL);
|
|
|
|
|
|
|
|
hash_clean_and_free(&zrouter.rules_hash, zebra_pbr_rules_free);
|
|
|
|
|
|
|
|
hash_clean_and_free(&zrouter.ipset_entry_hash,
|
|
|
|
zebra_pbr_ipset_entry_free);
|
|
|
|
hash_clean_and_free(&zrouter.ipset_hash, zebra_pbr_ipset_free);
|
|
|
|
hash_clean_and_free(&zrouter.iptable_hash, zebra_pbr_iptable_free);
|
2023-11-29 13:33:54 +01:00
|
|
|
hash_clean_and_free(&zrouter.filter_hash, (void (*)(void *)) zebra_tc_filter_free);
|
|
|
|
hash_clean_and_free(&zrouter.qdisc_hash, (void (*)(void *)) zebra_tc_qdisc_free);
|
|
|
|
hash_clean_and_free(&zrouter.class_hash, (void (*)(void *)) zebra_tc_class_free);
|
2021-10-18 20:40:58 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_SCRIPTING
|
|
|
|
zebra_script_destroy();
|
|
|
|
#endif
|
2022-02-10 19:29:59 +01:00
|
|
|
|
2023-11-20 19:57:59 +01:00
|
|
|
zebra_vxlan_terminate();
|
2022-02-10 19:29:59 +01:00
|
|
|
/* OS-specific deinit */
|
|
|
|
kernel_router_terminate();
|
2018-08-27 16:43:37 +02:00
|
|
|
}
|
|
|
|
|
2020-09-28 21:22:52 +02:00
|
|
|
bool zebra_router_notify_on_ack(void)
|
|
|
|
{
|
|
|
|
return !zrouter.asic_offloaded || zrouter.notify_on_ack;
|
|
|
|
}
|
|
|
|
|
2023-07-24 17:16:53 +02:00
|
|
|
void zebra_router_init(bool asic_offload, bool notify_on_ack,
|
|
|
|
bool v6_with_v4_nexthop)
|
2018-08-27 16:43:37 +02:00
|
|
|
{
|
2019-01-22 13:39:14 +01:00
|
|
|
zrouter.sequence_num = 0;
|
|
|
|
|
2023-04-27 13:37:58 +02:00
|
|
|
zrouter.protodown_r_bit = FRR_PROTODOWN_REASON_DEFAULT_BIT;
|
|
|
|
|
2022-06-30 17:59:39 +02:00
|
|
|
zrouter.allow_delete = false;
|
|
|
|
|
2019-01-11 21:35:45 +01:00
|
|
|
zrouter.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS;
|
2019-01-11 20:59:36 +01:00
|
|
|
|
2022-06-16 01:54:29 +02:00
|
|
|
zrouter.nhg_keep = ZEBRA_DEFAULT_NHG_KEEP_TIMER;
|
|
|
|
|
zebra: Bring up 514 BGP neighbor sessions
Issue:
When 514 inerfaces/neighbors are configured, it creates socket error,
"Cannot allocate memory", when back to back V6 RA messages are tried
to be sent over the socket. This prevents interface, to know its peer's
link local address. Socket error comes when 1) try to join ICMPv6 all
router multicast group, back to back for all interfaces 2)send back to
back RA for all interfaces
Fix:
1)For ICMPv6 join case, we check if the interface has already joined
all router group, if not try to join. On failure, retry joining after
random amount of time determined 1 ms to ICMPV6_JOIN_TIMER_EXP_MS(100 ms)
2) For RA issue case, batch sending of RA mesages using wheel timer
Testing:
Monitor BGP session running sh bgp summary command
Before fix:
r1# sh bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth1 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth2 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth3 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth4 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
r1-eth5 4 1002 89 90 0 0 0 00:07:10 0 0 N/A
…..<snip>...
r1-eth252 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth253 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth254 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth255 4 1002 31 29 0 0 0 00:02:08 0 0 N/A
r1-eth256 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth257 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth258 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth259 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth260 4 0 0 0 0 0 0 never Idle 0 N/A
……..<snip>…..
r1-eth511 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth512 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth513 4 0 0 0 0 0 0 never Idle 0 N/A
r1-eth514 4 0 0 0 0 0 0 never Idle 0 N/A
After fix:
r1# show bgp summary
IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
r1-eth0 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth1 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth2 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth3 4 1002 64 67 0 0 0 00:05:09 0 0 N/A
r1-eth4 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth5 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth6 4 1002 67 70 0 0 0 00:05:22 0 0 N/A
r1-eth7 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
r1-eth8 4 1002 87 87 0 0 0 00:07:04 0 0 N/A
....
r1-eth499 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth500 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth501 4 1002 19 22 0 0 0 00:01:21 0 0 N/A
r1-eth502 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth503 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth504 4 1002 20 23 0 0 0 00:01:30 0 0 N/A
r1-eth505 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth506 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth507 4 1002 22 25 0 0 0 00:01:39 0 0 N/A
r1-eth508 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth509 4 1002 17 20 0 0 0 00:01:13 0 0 N/A
r1-eth510 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth511 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth512 4 1002 19 22 0 0 0 00:01:22 0 0 N/A
r1-eth513 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
r1-eth514 4 1002 43 43 0 0 0 00:03:22 0 0 N/A
Signed-off-by: Soumya Roy <souroy@nvidia.com>
2025-02-15 03:13:37 +01:00
|
|
|
/*Init V6 RA batching stuffs*/
|
|
|
|
zrouter.ra_wheel = wheel_init(zrouter.master, RTADV_TIMER_WHEEL_PERIOD_MS,
|
|
|
|
RTADV_TIMER_WHEEL_SLOTS_NO, interface_hash_key, process_rtadv,
|
|
|
|
NULL);
|
|
|
|
|
2018-12-06 09:03:12 +01:00
|
|
|
zebra_vxlan_init();
|
2018-12-18 13:44:23 +01:00
|
|
|
zebra_mlag_init();
|
2021-12-18 20:28:49 +01:00
|
|
|
zebra_neigh_init();
|
2018-12-18 13:44:23 +01:00
|
|
|
|
2018-08-27 20:36:46 +02:00
|
|
|
zrouter.rules_hash = hash_create_size(8, zebra_pbr_rules_hash_key,
|
|
|
|
zebra_pbr_rules_hash_equal,
|
|
|
|
"Rules Hash");
|
2018-08-27 21:24:02 +02:00
|
|
|
|
|
|
|
zrouter.ipset_hash =
|
|
|
|
hash_create_size(8, zebra_pbr_ipset_hash_key,
|
|
|
|
zebra_pbr_ipset_hash_equal, "IPset Hash");
|
|
|
|
|
|
|
|
zrouter.ipset_entry_hash = hash_create_size(
|
|
|
|
8, zebra_pbr_ipset_entry_hash_key,
|
|
|
|
zebra_pbr_ipset_entry_hash_equal, "IPset Hash Entry");
|
|
|
|
|
|
|
|
zrouter.iptable_hash = hash_create_size(8, zebra_pbr_iptable_hash_key,
|
|
|
|
zebra_pbr_iptable_hash_equal,
|
|
|
|
"IPtable Hash Entry");
|
2019-01-24 14:06:34 +01:00
|
|
|
|
|
|
|
zrouter.nhgs =
|
|
|
|
hash_create_size(8, zebra_nhg_hash_key, zebra_nhg_hash_equal,
|
|
|
|
"Zebra Router Nexthop Groups");
|
2019-02-15 19:18:48 +01:00
|
|
|
zrouter.nhgs_id =
|
2019-02-26 00:18:07 +01:00
|
|
|
hash_create_size(8, zebra_nhg_id_key, zebra_nhg_hash_id_equal,
|
2019-02-15 19:18:48 +01:00
|
|
|
"Zebra Router Nexthop Groups ID index");
|
2020-09-18 21:41:19 +02:00
|
|
|
|
2022-09-06 09:10:11 +02:00
|
|
|
zrouter.qdisc_hash =
|
|
|
|
hash_create_size(8, zebra_tc_qdisc_hash_key,
|
|
|
|
zebra_tc_qdisc_hash_equal, "TC (qdisc) Hash");
|
|
|
|
zrouter.class_hash = hash_create_size(8, zebra_tc_class_hash_key,
|
|
|
|
zebra_tc_class_hash_equal,
|
|
|
|
"TC (classes) Hash");
|
|
|
|
zrouter.filter_hash = hash_create_size(8, zebra_tc_filter_hash_key,
|
|
|
|
zebra_tc_filter_hash_equal,
|
|
|
|
"TC (filter) Hash");
|
|
|
|
|
2020-09-28 21:22:52 +02:00
|
|
|
zrouter.asic_offloaded = asic_offload;
|
|
|
|
zrouter.notify_on_ack = notify_on_ack;
|
2023-07-24 17:16:53 +02:00
|
|
|
zrouter.v6_with_v4_nexthop = v6_with_v4_nexthop;
|
2022-10-05 16:04:11 +02:00
|
|
|
/*
|
|
|
|
* If you start using asic_notification_nexthop_control
|
|
|
|
* come talk to the FRR community about what you are doing
|
|
|
|
* We would like to know.
|
|
|
|
*/
|
|
|
|
#if CONFDATE > 20251231
|
|
|
|
CPP_NOTICE(
|
|
|
|
"Remove zrouter.asic_notification_nexthop_control as that it's not being maintained or used");
|
|
|
|
#endif
|
|
|
|
zrouter.asic_notification_nexthop_control = false;
|
|
|
|
|
2024-02-22 22:20:37 +01:00
|
|
|
zrouter.nexthop_weight_scale_value = 254;
|
2023-09-28 18:44:31 +02:00
|
|
|
|
2021-10-18 20:40:58 +02:00
|
|
|
#ifdef HAVE_SCRIPTING
|
|
|
|
zebra_script_init();
|
|
|
|
#endif
|
2022-02-10 19:29:59 +01:00
|
|
|
|
|
|
|
/* OS-specific init */
|
|
|
|
kernel_router_init();
|
2018-08-27 16:43:37 +02:00
|
|
|
}
|