diff options
Diffstat (limited to 'zebra')
61 files changed, 203 insertions, 298 deletions
diff --git a/zebra/connected.c b/zebra/connected.c index dd8fab5e4e..6f405ca1bb 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -29,7 +29,6 @@ #include "table.h" #include "log.h" #include "memory.h" -#include "zebra_memory.h" #include "vty.h" #include "zebra/debug.h" diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c index 79a5d148a6..9abed77fa6 100644 --- a/zebra/dplane_fpm_nl.c +++ b/zebra/dplane_fpm_nl.c @@ -1517,4 +1517,4 @@ FRR_MODULE_SETUP( .version = "0.0.1", .description = "Data plane plugin for FPM using netlink.", .init = fpm_nl_init, - ) +); diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 8bec256355..14d8ac442e 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -29,7 +29,6 @@ #include "ioctl.h" #include "connected.h" #include "memory.h" -#include "zebra_memory.h" #include "log.h" #include "vrf.h" #include "vty.h" diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 98bde4b3c0..af2c251607 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -44,7 +44,6 @@ #include "connected.h" #include "table.h" #include "memory.h" -#include "zebra_memory.h" #include "rib.h" #include "thread.h" #include "privs.h" diff --git a/zebra/if_sysctl.c b/zebra/if_sysctl.c index 695cef1995..38729c8d38 100644 --- a/zebra/if_sysctl.c +++ b/zebra/if_sysctl.c @@ -28,7 +28,6 @@ #include "prefix.h" #include "connected.h" #include "memory.h" -#include "zebra_memory.h" #include "ioctl.h" #include "log.h" #include "interface.h" diff --git a/zebra/interface.c b/zebra/interface.c index 6373b4b200..3eeed9ac90 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -28,7 +28,6 @@ #include "prefix.h" #include "command.h" #include "memory.h" -#include "zebra_memory.h" #include "ioctl.h" #include "connected.h" #include "log.h" @@ -53,14 +52,14 @@ #include "zebra/zebra_errors.h" #include "zebra/zebra_evpn_mh.h" -DEFINE_MTYPE_STATIC(ZEBRA, ZINFO, "Zebra Interface Information") +DEFINE_MTYPE_STATIC(ZEBRA, ZINFO, "Zebra Interface Information"); #define ZEBRA_PTM_SUPPORT DEFINE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp), - (vty, ifp)) + (vty, ifp)); DEFINE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp), - (vty, ifp)) + (vty, ifp)); static void if_down_del_nbr_connected(struct interface *ifp); diff --git a/zebra/interface.h b/zebra/interface.h index 64569742b4..67eb1176b9 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -417,9 +417,9 @@ struct zebra_if { }; DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp), - (vty, ifp)) + (vty, ifp)); DECLARE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp), - (vty, ifp)) + (vty, ifp)); #define IS_ZEBRA_IF_VRF(ifp) \ (((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_VRF) diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 5352c6214d..28db2ad87d 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -34,7 +34,6 @@ #include "prefix.h" #include "command.h" #include "memory.h" -#include "zebra_memory.h" #include "stream.h" #include "ioctl.h" #include "connected.h" @@ -57,7 +56,7 @@ extern int irdp_sock; -DEFINE_MTYPE_STATIC(ZEBRA, IRDP_IF, "IRDP interface data") +DEFINE_MTYPE_STATIC(ZEBRA, IRDP_IF, "IRDP interface data"); #define IRDP_CONFIGED \ do { \ diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index 936206641f..600fc3f2fc 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -42,7 +42,6 @@ #include "prefix.h" #include "command.h" #include "memory.h" -#include "zebra_memory.h" #include "stream.h" #include "ioctl.h" #include "connected.h" @@ -349,4 +348,5 @@ static int irdp_module_init(void) } FRR_MODULE_SETUP(.name = "zebra_irdp", .version = FRR_VERSION, - .description = "zebra IRDP module", .init = irdp_module_init, ) + .description = "zebra IRDP module", .init = irdp_module_init, +); diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c index 6134df9c41..7d67c42a79 100644 --- a/zebra/irdp_packet.c +++ b/zebra/irdp_packet.c @@ -54,7 +54,6 @@ #include "zclient.h" #include "lib_errors.h" -#include "zebra_memory.h" #include "zebra/interface.h" #include "zebra/rtadv.h" #include "zebra/rib.h" diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index aa19b18089..e71e662458 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -29,7 +29,6 @@ #include "connected.h" #include "table.h" #include "memory.h" -#include "zebra_memory.h" #include "rib.h" #include "thread.h" #include "privs.h" @@ -159,7 +158,7 @@ extern uint32_t nl_rcvbufsize; extern struct zebra_privs_t zserv_privs; -DEFINE_MTYPE_STATIC(ZEBRA, NL_BUF, "Zebra Netlink buffers") +DEFINE_MTYPE_STATIC(ZEBRA, NL_BUF, "Zebra Netlink buffers"); size_t nl_batch_tx_bufsize; char *nl_batch_tx_buf; diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index adbdf54c1f..03884a9168 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -32,7 +32,6 @@ #include "sockunion.h" #include "connected.h" #include "memory.h" -#include "zebra_memory.h" #include "ioctl.h" #include "log.h" #include "table.h" diff --git a/zebra/main.c b/zebra/main.c index 55fd3244cb..09350f72c1 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -26,7 +26,6 @@ #include "thread.h" #include "filter.h" #include "memory.h" -#include "zebra_memory.h" #include "prefix.h" #include "log.h" #include "plist.h" @@ -274,7 +273,8 @@ FRR_DAEMON_INFO( .privs = &zserv_privs, .yang_modules = zebra_yang_modules, - .n_yang_modules = array_size(zebra_yang_modules), ) + .n_yang_modules = array_size(zebra_yang_modules), +); /* Main startup routine. */ int main(int argc, char **argv) diff --git a/zebra/redistribute.c b/zebra/redistribute.c index ac60d09ecc..9e675011ee 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -41,7 +41,6 @@ #include "zebra/debug.h" #include "zebra/router-id.h" #include "zebra/zapi_msg.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_vxlan.h" #include "zebra/zebra_errors.h" diff --git a/zebra/rib.h b/zebra/rib.h index 86766b8175..e7676a1324 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -23,6 +23,7 @@ #define _ZEBRA_RIB_H #include "zebra.h" +#include "memory.h" #include "hook.h" #include "typesafe.h" #include "linklist.h" @@ -41,9 +42,13 @@ extern "C" { #endif +DECLARE_MGROUP(ZEBRA); + +DECLARE_MTYPE(RE); + enum rnh_type { RNH_NEXTHOP_TYPE, RNH_IMPORT_CHECK_TYPE }; -PREDECL_LIST(rnh_list) +PREDECL_LIST(rnh_list); /* Nexthop structure. */ struct rnh { @@ -82,7 +87,7 @@ struct rnh { #define DISTANCE_INFINITY 255 #define ZEBRA_KERNEL_TABLE_MAX 252 /* support for no more than this rt tables */ -PREDECL_LIST(re_list) +PREDECL_LIST(re_list); struct opaque { uint16_t length; @@ -541,7 +546,7 @@ static inline void rib_tables_iter_cleanup(rib_tables_iter_t *iter) } DECLARE_HOOK(rib_update, (struct route_node * rn, const char *reason), - (rn, reason)) + (rn, reason)); /* * Access installed/fib nexthops, which may be a subset of the diff --git a/zebra/router-id.c b/zebra/router-id.c index ac21978ee8..3b556c92b5 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -29,7 +29,6 @@ #include "stream.h" #include "command.h" #include "memory.h" -#include "zebra_memory.h" #include "ioctl.h" #include "connected.h" #include "network.h" diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index fdeef2c88c..55e0775a8c 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -41,7 +41,6 @@ #include "connected.h" #include "table.h" #include "memory.h" -#include "zebra_memory.h" #include "rib.h" #include "thread.h" #include "privs.h" diff --git a/zebra/rtadv.c b/zebra/rtadv.c index c3add16c56..8ffb3870fa 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -23,7 +23,6 @@ #include <zebra.h> #include "memory.h" -#include "zebra_memory.h" #include "sockopt.h" #include "thread.h" #include "if.h" @@ -54,7 +53,7 @@ extern struct zebra_privs_t zserv_privs; #include "zebra/rtadv_clippy.c" #endif -DEFINE_MTYPE_STATIC(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix") +DEFINE_MTYPE_STATIC(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix"); #ifdef OPEN_BSD #include <netinet/icmp6.h> @@ -71,8 +70,8 @@ DEFINE_MTYPE_STATIC(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix") #define ALLNODE "ff02::1" #define ALLROUTER "ff02::2" -DEFINE_MTYPE_STATIC(ZEBRA, RTADV_RDNSS, "Router Advertisement RDNSS") -DEFINE_MTYPE_STATIC(ZEBRA, RTADV_DNSSL, "Router Advertisement DNSSL") +DEFINE_MTYPE_STATIC(ZEBRA, RTADV_RDNSS, "Router Advertisement RDNSS"); +DEFINE_MTYPE_STATIC(ZEBRA, RTADV_DNSSL, "Router Advertisement DNSSL"); /* Order is intentional. Matches RFC4191. This array is also used for command matching, so only modify with care. */ diff --git a/zebra/rtread_sysctl.c b/zebra/rtread_sysctl.c index 01a97db8b3..74c6825ba1 100644 --- a/zebra/rtread_sysctl.c +++ b/zebra/rtread_sysctl.c @@ -24,7 +24,6 @@ #if !defined(GNU_LINUX) #include "memory.h" -#include "zebra_memory.h" #include "log.h" #include "vrf.h" diff --git a/zebra/sample_plugin.c b/zebra/sample_plugin.c index 464205f2f3..e54186bc18 100644 --- a/zebra/sample_plugin.c +++ b/zebra/sample_plugin.c @@ -130,4 +130,4 @@ FRR_MODULE_SETUP( .version = "0.0.1", .description = "Dataplane Sample Plugin", .init = module_init, - ) +); diff --git a/zebra/subdir.am b/zebra/subdir.am index f842a8c0f3..b5c26d720f 100644 --- a/zebra/subdir.am +++ b/zebra/subdir.am @@ -88,7 +88,6 @@ zebra_zebra_SOURCES = \ zebra/zebra_evpn_neigh.c \ zebra/zebra_mlag.c \ zebra/zebra_mlag_vty.c \ - zebra/zebra_memory.c \ zebra/zebra_mpls.c \ zebra/zebra_mpls_netlink.c \ zebra/zebra_mpls_openbsd.c \ @@ -158,7 +157,6 @@ noinst_HEADERS += \ zebra/zebra_evpn_vxlan.h \ zebra/zebra_fpm_private.h \ zebra/zebra_l2.h \ - zebra/zebra_memory.h \ zebra/zebra_mlag.h \ zebra/zebra_mlag_vty.h \ zebra/zebra_mpls.h \ @@ -193,7 +191,7 @@ zebra_zebra_irdp_la_SOURCES = \ zebra_zebra_irdp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic zebra_zebra_snmp_la_SOURCES = zebra/zebra_snmp.c -zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 +zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu11 zebra_zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic zebra_zebra_snmp_la_LIBADD = lib/libfrrsnmp.la diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 9f5adfa409..63ba6cd8d9 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -38,7 +38,6 @@ #include "zebra/zebra_router.h" #include "zebra/rib.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_ns.h" #include "zebra/zebra_vrf.h" #include "zebra/router-id.h" @@ -62,6 +61,8 @@ #include "zebra/zebra_opaque.h" #include "zebra/zebra_srte.h" +DEFINE_MTYPE_STATIC(ZEBRA, OPAQUE, "Opaque Data"); + static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg); /* Encoding helpers -------------------------------------------------------- */ @@ -2076,6 +2077,11 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) } } +void zapi_opaque_free(struct opaque *opaque) +{ + XFREE(MTYPE_OPAQUE, opaque); +} + static void zread_route_del(ZAPI_HANDLER_ARGS) { struct stream *s; diff --git a/zebra/zapi_msg.h b/zebra/zapi_msg.h index 023b9f74a8..ca471f8d98 100644 --- a/zebra/zapi_msg.h +++ b/zebra/zapi_msg.h @@ -111,6 +111,8 @@ extern int zsend_client_close_notify(struct zserv *client, int zsend_nhg_notify(uint16_t type, uint16_t instance, uint32_t session_id, uint32_t id, enum zapi_nhg_notify_owner note); +extern void zapi_opaque_free(struct opaque *opaque); + #ifdef __cplusplus } #endif diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 4e63d08aca..18fe0a7e85 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -28,7 +28,6 @@ #include "lib/memory.h" #include "lib/queue.h" #include "lib/zebra.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_router.h" #include "zebra/zebra_dplane.h" #include "zebra/zebra_vxlan_private.h" @@ -39,10 +38,10 @@ #include "printfrr.h" /* Memory type for context blocks */ -DEFINE_MTYPE_STATIC(ZEBRA, DP_CTX, "Zebra DPlane Ctx") -DEFINE_MTYPE_STATIC(ZEBRA, DP_INTF, "Zebra DPlane Intf") -DEFINE_MTYPE_STATIC(ZEBRA, DP_PROV, "Zebra DPlane Provider") -DEFINE_MTYPE_STATIC(ZEBRA, DP_NETFILTER, "Zebra Netfilter Internal Object") +DEFINE_MTYPE_STATIC(ZEBRA, DP_CTX, "Zebra DPlane Ctx"); +DEFINE_MTYPE_STATIC(ZEBRA, DP_INTF, "Zebra DPlane Intf"); +DEFINE_MTYPE_STATIC(ZEBRA, DP_PROV, "Zebra DPlane Provider"); +DEFINE_MTYPE_STATIC(ZEBRA, DP_NETFILTER, "Zebra Netfilter Internal Object"); #ifndef AOK # define AOK 0 diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index 27a5a07e48..80e06d913d 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -44,7 +44,6 @@ #include "zebra/rt_netlink.h" #include "zebra/zebra_errors.h" #include "zebra/zebra_l2.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_ns.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_vxlan.h" diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index b36e8034b7..7bbe092d8c 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -34,7 +34,6 @@ #include "zebra/zserv.h" #include "zebra/debug.h" #include "zebra/zebra_router.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_errors.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_evpn.h" diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c index 5a28ee10c6..1c258a04f7 100644 --- a/zebra/zebra_evpn_mh.c +++ b/zebra/zebra_evpn_mh.c @@ -41,7 +41,6 @@ #include "zebra/if_netlink.h" #include "zebra/zebra_errors.h" #include "zebra/zebra_l2.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_ns.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_vxlan.h" diff --git a/zebra/zebra_evpn_neigh.c b/zebra/zebra_evpn_neigh.c index 0e31617c4f..d1b93dbe8a 100644 --- a/zebra/zebra_evpn_neigh.c +++ b/zebra/zebra_evpn_neigh.c @@ -34,7 +34,6 @@ #include "zebra/debug.h" #include "zebra/zebra_router.h" #include "zebra/rt.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_errors.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_evpn.h" diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 099ac1434b..5fe8934a82 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -37,7 +37,6 @@ #include "zebra/zebra_ns.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_errors.h" -#include "zebra/zebra_memory.h" #include "fpm/fpm.h" #include "zebra_fpm_private.h" @@ -2046,4 +2045,5 @@ static int zebra_fpm_module_init(void) FRR_MODULE_SETUP(.name = "zebra_fpm", .version = FRR_VERSION, .description = "zebra FPM (Forwarding Plane Manager) module", - .init = zebra_fpm_module_init, ) + .init = zebra_fpm_module_init, +); diff --git a/zebra/zebra_l2.c b/zebra/zebra_l2.c index 3583c5fbf4..c3fbff2723 100644 --- a/zebra/zebra_l2.c +++ b/zebra/zebra_l2.c @@ -38,7 +38,6 @@ #include "zebra/zserv.h" #include "zebra/debug.h" #include "zebra/interface.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_vrf.h" #include "zebra/rt_netlink.h" #include "zebra/interface.h" diff --git a/zebra/zebra_memory.c b/zebra/zebra_memory.c deleted file mode 100644 index 17b52a2bcb..0000000000 --- a/zebra/zebra_memory.c +++ /dev/null @@ -1,33 +0,0 @@ -/* zebra memory type definitions - * - * Copyright (C) 2015 David Lamparter - * - * This file is part of Quagga. - * - * Quagga is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * Quagga is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; see the file COPYING; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "zebra_memory.h" - -DEFINE_MGROUP(ZEBRA, "zebra") -DEFINE_MTYPE(ZEBRA, RE, "Route Entry") -DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination") -DEFINE_MTYPE(ZEBRA, ZVLAN, "VLAN") -DEFINE_MTYPE(ZEBRA, ZVLAN_BITMAP, "VLAN bitmap") -DEFINE_MTYPE(ZEBRA, OPAQUE, "Opaque Data") diff --git a/zebra/zebra_memory.h b/zebra/zebra_memory.h deleted file mode 100644 index 71901b765f..0000000000 --- a/zebra/zebra_memory.h +++ /dev/null @@ -1,41 +0,0 @@ -/* zebra memory type declarations - * - * Copyright (C) 2015 David Lamparter - * - * This file is part of Quagga. - * - * Quagga is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * Quagga is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; see the file COPYING; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _QUAGGA_ZEBRA_MEMORY_H -#define _QUAGGA_ZEBRA_MEMORY_H - -#include "memory.h" - -#ifdef __cplusplus -extern "C" { -#endif - -DECLARE_MGROUP(ZEBRA) -DECLARE_MTYPE(ZEBRA_NS) -DECLARE_MTYPE(RE) -DECLARE_MTYPE(RIB_DEST) -DECLARE_MTYPE(OPAQUE) - -#ifdef __cplusplus -} -#endif - -#endif /* _QUAGGA_ZEBRA_MEMORY_H */ diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c index d8ed9b2a3a..3b0c75151b 100644 --- a/zebra/zebra_mlag.c +++ b/zebra/zebra_mlag.c @@ -29,7 +29,6 @@ #include "zebra/zebra_mlag.h" #include "zebra/zebra_mlag_vty.h" #include "zebra/zebra_router.h" -#include "zebra/zebra_memory.h" #include "zebra/zapi_msg.h" #include "zebra/debug.h" @@ -38,11 +37,11 @@ #endif DEFINE_HOOK(zebra_mlag_private_write_data, - (uint8_t *data, uint32_t len), (data, len)) -DEFINE_HOOK(zebra_mlag_private_monitor_state, (), ()) -DEFINE_HOOK(zebra_mlag_private_open_channel, (), ()) -DEFINE_HOOK(zebra_mlag_private_close_channel, (), ()) -DEFINE_HOOK(zebra_mlag_private_cleanup_data, (), ()) + (uint8_t *data, uint32_t len), (data, len)); +DEFINE_HOOK(zebra_mlag_private_monitor_state, (), ()); +DEFINE_HOOK(zebra_mlag_private_open_channel, (), ()); +DEFINE_HOOK(zebra_mlag_private_close_channel, (), ()); +DEFINE_HOOK(zebra_mlag_private_cleanup_data, (), ()); #define ZEBRA_MLAG_METADATA_LEN 4 #define ZEBRA_MLAG_MSG_BCAST 0xFFFFFFFF @@ -659,7 +658,7 @@ void zebra_mlag_terminate(void) #ifdef HAVE_PROTOBUF_VERSION_3 -DEFINE_MTYPE_STATIC(ZEBRA, MLAG_PBUF, "ZEBRA MLAG PROTOBUF") +DEFINE_MTYPE_STATIC(ZEBRA, MLAG_PBUF, "ZEBRA MLAG PROTOBUF"); int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) { diff --git a/zebra/zebra_mlag.h b/zebra/zebra_mlag.h index b195c75ea3..eb96a57d30 100644 --- a/zebra/zebra_mlag.h +++ b/zebra/zebra_mlag.h @@ -34,11 +34,11 @@ extern "C" { #define ZEBRA_MLAG_LEN_SIZE 4 DECLARE_HOOK(zebra_mlag_private_write_data, - (uint8_t *data, uint32_t len), (data, len)) -DECLARE_HOOK(zebra_mlag_private_monitor_state, (), ()) -DECLARE_HOOK(zebra_mlag_private_open_channel, (), ()) -DECLARE_HOOK(zebra_mlag_private_close_channel, (), ()) -DECLARE_HOOK(zebra_mlag_private_cleanup_data, (), ()) + (uint8_t *data, uint32_t len), (data, len)); +DECLARE_HOOK(zebra_mlag_private_monitor_state, (), ()); +DECLARE_HOOK(zebra_mlag_private_open_channel, (), ()); +DECLARE_HOOK(zebra_mlag_private_close_channel, (), ()); +DECLARE_HOOK(zebra_mlag_private_cleanup_data, (), ()); extern uint8_t mlag_wr_buffer[ZEBRA_MLAG_BUF_LIMIT]; extern uint8_t mlag_rd_buffer[ZEBRA_MLAG_BUF_LIMIT]; diff --git a/zebra/zebra_mlag_private.c b/zebra/zebra_mlag_private.c index 8a66d6de72..aaf93b4dc1 100644 --- a/zebra/zebra_mlag_private.c +++ b/zebra/zebra_mlag_private.c @@ -297,4 +297,4 @@ FRR_MODULE_SETUP( .version = FRR_VERSION, .description = "zebra Cumulus MLAG interface", .init = zebra_mlag_module_init, -) +); diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index dc49695019..c0c064cbc7 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -44,15 +44,14 @@ #include "zebra/zebra_router.h" #include "zebra/redistribute.h" #include "zebra/debug.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_mpls.h" #include "zebra/zebra_srte.h" #include "zebra/zebra_errors.h" -DEFINE_MTYPE_STATIC(ZEBRA, LSP, "MPLS LSP object") -DEFINE_MTYPE_STATIC(ZEBRA, FEC, "MPLS FEC object") -DEFINE_MTYPE_STATIC(ZEBRA, NHLFE, "MPLS nexthop object") +DEFINE_MTYPE_STATIC(ZEBRA, LSP, "MPLS LSP object"); +DEFINE_MTYPE_STATIC(ZEBRA, FEC, "MPLS FEC object"); +DEFINE_MTYPE_STATIC(ZEBRA, NHLFE, "MPLS nexthop object"); int mpls_enabled; diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 1fc1faff67..bdeb84486d 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -401,14 +401,24 @@ const struct frr_yang_module_info frr_zebra_info = { { .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib", .cbs = { - .create = lib_vrf_zebra_ribs_rib_create, - .destroy = lib_vrf_zebra_ribs_rib_destroy, .get_next = lib_vrf_zebra_ribs_rib_get_next, .get_keys = lib_vrf_zebra_ribs_rib_get_keys, .lookup_entry = lib_vrf_zebra_ribs_rib_lookup_entry, } }, { + .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/afi-safi-name", + .cbs = { + .get_elem = lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem, + } + }, + { + .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/table-id", + .cbs = { + .get_elem = lib_vrf_zebra_ribs_rib_table_id_get_elem, + } + }, + { .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route", .cbs = { .get_next = lib_vrf_zebra_ribs_rib_route_get_next, diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index e68b819767..79632dc83e 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -149,12 +149,14 @@ struct yang_data *lib_interface_zebra_state_remote_vtep_get_elem( struct nb_cb_get_elem_args *args); struct yang_data *lib_interface_zebra_state_mcast_group_get_elem( struct nb_cb_get_elem_args *args); -int lib_vrf_zebra_ribs_rib_create(struct nb_cb_create_args *args); -int lib_vrf_zebra_ribs_rib_destroy(struct nb_cb_destroy_args *args); const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args); int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args); const void * lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args); +struct yang_data * +lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem(struct nb_cb_get_elem_args *args); +struct yang_data * +lib_vrf_zebra_ribs_rib_table_id_get_elem(struct nb_cb_get_elem_args *args); const void * lib_vrf_zebra_ribs_rib_route_get_next(struct nb_cb_get_next_args *args); int lib_vrf_zebra_ribs_rib_route_get_keys(struct nb_cb_get_keys_args *args); @@ -201,19 +203,6 @@ lib_vrf_zebra_ribs_rib_route_nexthop_group_frr_nexthops_nexthop_get_next( struct nb_cb_get_next_args *args); int lib_vrf_zebra_ribs_rib_route_nexthop_group_frr_nexthops_nexthop_get_keys( struct nb_cb_get_keys_args *args); -int lib_vrf_zebra_ribs_rib_create(struct nb_cb_create_args *args); -int lib_vrf_zebra_ribs_rib_destroy(struct nb_cb_destroy_args *args); -const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args); -int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args); -const void * -lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args); -const void * -lib_vrf_zebra_ribs_rib_route_get_next(struct nb_cb_get_next_args *args); -int lib_vrf_zebra_ribs_rib_route_get_keys(struct nb_cb_get_keys_args *args); -const void * -lib_vrf_zebra_ribs_rib_route_lookup_entry(struct nb_cb_lookup_entry_args *args); -struct yang_data * -lib_vrf_zebra_ribs_rib_route_prefix_get_elem(struct nb_cb_get_elem_args *args); const void *lib_vrf_zebra_ribs_rib_route_route_entry_get_next( struct nb_cb_get_next_args *args); int lib_vrf_zebra_ribs_rib_route_route_entry_get_keys( diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index ea2e20ed3b..ba9f96b7de 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -841,7 +841,6 @@ int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args *args) struct interface *ifp; struct prefix prefix; - ifp = nb_running_get_entry(args->dnode, NULL, true); // addr_family = yang_dnode_get_enum(dnode, "./address-family"); yang_dnode_get_prefix(&prefix, args->dnode, "./ip-prefix"); apply_mask(&prefix); @@ -864,6 +863,7 @@ int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args *args) case NB_EV_ABORT: break; case NB_EV_APPLY: + ifp = nb_running_get_entry(args->dnode, NULL, true); if (prefix.family == AF_INET) if_ip_address_install(ifp, &prefix, NULL, NULL); else if (prefix.family == AF_INET6) @@ -881,12 +881,15 @@ int lib_interface_zebra_ip_addrs_destroy(struct nb_cb_destroy_args *args) struct prefix prefix; struct connected *ifc; - ifp = nb_running_get_entry(args->dnode, NULL, true); yang_dnode_get_prefix(&prefix, args->dnode, "./ip-prefix"); apply_mask(&prefix); switch (args->event) { case NB_EV_VALIDATE: + ifp = nb_running_get_entry(args->dnode, NULL, false); + if (!ifp) + return NB_OK; + if (prefix.family == AF_INET) { /* Check current interface address. */ ifc = connected_check_ptp(ifp, &prefix, NULL); @@ -927,6 +930,7 @@ int lib_interface_zebra_ip_addrs_destroy(struct nb_cb_destroy_args *args) case NB_EV_ABORT: break; case NB_EV_APPLY: + ifp = nb_running_get_entry(args->dnode, NULL, true); if_ip_address_uinstall(ifp, &prefix); break; } @@ -1068,6 +1072,9 @@ int lib_interface_zebra_link_detect_destroy(struct nb_cb_destroy_args *args) */ int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args *args) { + if (args->event != NB_EV_APPLY) + return NB_OK; + struct interface *ifp; ifp = nb_running_get_entry(args->dnode, NULL, true); @@ -1079,6 +1086,9 @@ int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args *args) int lib_interface_zebra_shutdown_destroy(struct nb_cb_destroy_args *args) { + if (args->event != NB_EV_APPLY) + return NB_OK; + struct interface *ifp; ifp = nb_running_get_entry(args->dnode, NULL, true); @@ -1130,61 +1140,6 @@ int lib_interface_zebra_bandwidth_destroy(struct nb_cb_destroy_args *args) } /* - * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib - */ -int lib_vrf_zebra_ribs_rib_create(struct nb_cb_create_args *args) -{ - struct vrf *vrf; - afi_t afi; - safi_t safi; - struct zebra_vrf *zvrf; - struct zebra_router_table *zrt; - uint32_t table_id; - const char *afi_safi_name; - - vrf = nb_running_get_entry(args->dnode, NULL, false); - zvrf = vrf_info_lookup(vrf->vrf_id); - table_id = yang_dnode_get_uint32(args->dnode, "./table-id"); - if (!table_id) - table_id = zvrf->table_id; - - afi_safi_name = yang_dnode_get_string(args->dnode, "./afi-safi-name"); - yang_afi_safi_identity2value(afi_safi_name, &afi, &safi); - - zrt = zebra_router_find_zrt(zvrf, table_id, afi, safi); - - switch (args->event) { - case NB_EV_VALIDATE: - if (!zrt) { - snprintf(args->errmsg, args->errmsg_len, - "vrf %s table is not found.", vrf->name); - return NB_ERR_VALIDATION; - } - break; - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_APPLY: - - nb_running_set_entry(args->dnode, zrt); - - break; - } - - return NB_OK; -} - -int lib_vrf_zebra_ribs_rib_destroy(struct nb_cb_destroy_args *args) -{ - if (args->event != NB_EV_APPLY) - return NB_OK; - - nb_running_unset_entry(args->dnode); - - return NB_OK; -} - -/* * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id */ int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args) diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index 21c89f64ed..a9cb096aee 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -214,6 +214,29 @@ lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args) } /* + * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/afi-safi-name + */ +struct yang_data * +lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem(struct nb_cb_get_elem_args *args) +{ + const struct zebra_router_table *zrt = args->list_entry; + + return yang_data_new_string(args->xpath, + yang_afi_safi_value2identity(zrt->afi, zrt->safi)); +} + +/* + * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/table-id + */ +struct yang_data * +lib_vrf_zebra_ribs_rib_table_id_get_elem(struct nb_cb_get_elem_args *args) +{ + const struct zebra_router_table *zrt = args->list_entry; + + return yang_data_new_uint32(args->xpath, zrt->tableid); +} + +/* * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route */ const void * diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index ee2dc7a0ed..3e89df68fd 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -37,7 +37,6 @@ #include "lib_errors.h" #include "zebra_router.h" -#include "zebra_memory.h" #endif /* defined(HAVE_NETLINK) */ #include "zebra_netns_notify.h" @@ -53,7 +52,7 @@ #define ZEBRA_NS_POLLING_INTERVAL_MSEC 1000 #define ZEBRA_NS_POLLING_MAX_RETRIES 200 -DEFINE_MTYPE_STATIC(ZEBRA, NETNS_MISC, "ZebraNetNSInfo") +DEFINE_MTYPE_STATIC(ZEBRA, NETNS_MISC, "ZebraNetNSInfo"); static struct thread *zebra_netns_notify_current; struct zebra_netns_info { diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 9246283fdf..12ed024a66 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -36,7 +36,6 @@ #include "zebra/zebra_nhg_private.h" #include "zebra/zebra_rnh.h" #include "zebra/zebra_routemap.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_srte.h" #include "zebra/zserv.h" #include "zebra/rt.h" diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c index e9ff3fcc08..27b8a3ea47 100644 --- a/zebra/zebra_ns.c +++ b/zebra/zebra_ns.c @@ -28,7 +28,6 @@ #include "zebra_ns.h" #include "zebra_vrf.h" -#include "zebra_memory.h" #include "rt.h" #include "zebra_vxlan.h" #include "debug.h" @@ -41,7 +40,7 @@ extern struct zebra_privs_t zserv_privs; -DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") +DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_NS, "Zebra Name Space"); static struct zebra_ns *dzns; diff --git a/zebra/zebra_opaque.c b/zebra/zebra_opaque.c index 1d59e0ab34..244f16302b 100644 --- a/zebra/zebra_opaque.c +++ b/zebra/zebra_opaque.c @@ -24,7 +24,6 @@ #include "lib/stream.h" #include "zebra/debug.h" #include "zebra/zserv.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_opaque.h" /* Mem type */ diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 92a7a0ba3a..c4004842e6 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -30,12 +30,11 @@ #include "zebra/zebra_pbr.h" #include "zebra/rt.h" #include "zebra/zapi_msg.h" -#include "zebra/zebra_memory.h" #include "zebra/zserv.h" #include "zebra/debug.h" /* definitions */ -DEFINE_MTYPE_STATIC(ZEBRA, PBR_IPTABLE_IFNAME, "PBR interface list") +DEFINE_MTYPE_STATIC(ZEBRA, PBR_IPTABLE_IFNAME, "PBR interface list"); /* definitions */ static const struct message ipset_type_msg[] = { @@ -128,12 +127,12 @@ static const struct message fragment_value_str[] = { DEFINE_HOOK(zebra_pbr_ipset_entry_get_stat, (struct zebra_pbr_ipset_entry *ipset, uint64_t *pkts, uint64_t *bytes), - (ipset, pkts, bytes)) + (ipset, pkts, bytes)); DEFINE_HOOK(zebra_pbr_iptable_get_stat, (struct zebra_pbr_iptable *iptable, uint64_t *pkts, uint64_t *bytes), - (iptable, pkts, bytes)) + (iptable, pkts, bytes)); DEFINE_HOOK(zebra_pbr_iptable_update, (int cmd, struct zebra_pbr_iptable *iptable), (cmd, iptable)); diff --git a/zebra/zebra_pbr.h b/zebra/zebra_pbr.h index ef93033661..2e9658e7e5 100644 --- a/zebra/zebra_pbr.h +++ b/zebra/zebra_pbr.h @@ -249,11 +249,11 @@ size_t zebra_pbr_tcpflags_snprintf(char *buffer, size_t len, DECLARE_HOOK(zebra_pbr_ipset_entry_get_stat, (struct zebra_pbr_ipset_entry *ipset, uint64_t *pkts, uint64_t *bytes), - (ipset, pkts, bytes)) + (ipset, pkts, bytes)); DECLARE_HOOK(zebra_pbr_iptable_get_stat, (struct zebra_pbr_iptable *iptable, uint64_t *pkts, uint64_t *bytes), - (iptable, pkts, bytes)) + (iptable, pkts, bytes)); DECLARE_HOOK(zebra_pbr_iptable_update, (int cmd, struct zebra_pbr_iptable *iptable), (cmd, iptable)); diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 1e7b38086b..bea855d1af 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -1167,8 +1167,6 @@ void zebra_ptm_if_write(struct vty *vty, struct zebra_if *zebra_ifp) #else /* HAVE_BFDD */ -#include "zebra/zebra_memory.h" - /* * Data structures. */ diff --git a/zebra/zebra_ptm_redistribute.c b/zebra/zebra_ptm_redistribute.c index eabc2e005e..537d69fbca 100644 --- a/zebra/zebra_ptm_redistribute.c +++ b/zebra/zebra_ptm_redistribute.c @@ -26,7 +26,6 @@ #include "zebra/zapi_msg.h" #include "zebra/zebra_ptm.h" #include "zebra/zebra_ptm_redistribute.h" -#include "zebra/zebra_memory.h" static int zsend_interface_bfd_update(int cmd, struct zserv *client, struct interface *ifp, struct prefix *dp, diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index ecae021dba..5afb3e5926 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -35,12 +35,12 @@ #include "zebra/zebra_vrf.h" #include "zebra/zebra_pw.h" -DEFINE_MTYPE_STATIC(LIB, PW, "Pseudowire") +DEFINE_MTYPE_STATIC(LIB, PW, "Pseudowire"); -DEFINE_QOBJ_TYPE(zebra_pw) +DEFINE_QOBJ_TYPE(zebra_pw); -DEFINE_HOOK(pw_install, (struct zebra_pw * pw), (pw)) -DEFINE_HOOK(pw_uninstall, (struct zebra_pw * pw), (pw)) +DEFINE_HOOK(pw_install, (struct zebra_pw * pw), (pw)); +DEFINE_HOOK(pw_uninstall, (struct zebra_pw * pw), (pw)); #define MPLS_NO_LABEL MPLS_INVALID_LABEL diff --git a/zebra/zebra_pw.h b/zebra/zebra_pw.h index 7b13c7e16b..0da8203802 100644 --- a/zebra/zebra_pw.h +++ b/zebra/zebra_pw.h @@ -53,9 +53,9 @@ struct zebra_pw { struct zserv *client; struct rnh *rnh; struct thread *install_retry_timer; - QOBJ_FIELDS + QOBJ_FIELDS; }; -DECLARE_QOBJ_TYPE(zebra_pw) +DECLARE_QOBJ_TYPE(zebra_pw); RB_HEAD(zebra_pw_head, zebra_pw); RB_PROTOTYPE(zebra_pw_head, zebra_pw, pw_entry, zebra_pw_compare); @@ -63,8 +63,8 @@ RB_PROTOTYPE(zebra_pw_head, zebra_pw, pw_entry, zebra_pw_compare); RB_HEAD(zebra_static_pw_head, zebra_pw); RB_PROTOTYPE(zebra_static_pw_head, zebra_pw, static_pw_entry, zebra_pw_compare); -DECLARE_HOOK(pw_install, (struct zebra_pw * pw), (pw)) -DECLARE_HOOK(pw_uninstall, (struct zebra_pw * pw), (pw)) +DECLARE_HOOK(pw_install, (struct zebra_pw * pw), (pw)); +DECLARE_HOOK(pw_uninstall, (struct zebra_pw * pw), (pw)); struct zebra_pw *zebra_pw_add(struct zebra_vrf *zvrf, const char *ifname, uint8_t protocol, struct zserv *client); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index bc3c68638d..ffe4be8557 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -49,7 +49,6 @@ #include "zebra/rt.h" #include "zebra/zapi_msg.h" #include "zebra/zebra_errors.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_ns.h" #include "zebra/zebra_rnh.h" #include "zebra/zebra_routemap.h" @@ -58,6 +57,10 @@ #include "zebra/zapi_msg.h" #include "zebra/zebra_dplane.h" +DEFINE_MGROUP(ZEBRA, "zebra"); + +DEFINE_MTYPE(ZEBRA, RE, "Route Entry"); +DEFINE_MTYPE_STATIC(ZEBRA, RIB_DEST, "RIB destination"); DEFINE_MTYPE_STATIC(ZEBRA, RIB_UPDATE_CTX, "Rib update context object"); /* @@ -68,7 +71,7 @@ static struct thread *t_dplane; static struct dplane_ctx_q rib_dplane_q; DEFINE_HOOK(rib_update, (struct route_node * rn, const char *reason), - (rn, reason)) + (rn, reason)); /* Should we allow non Quagga processes to delete our routes */ extern int allow_delete; @@ -800,6 +803,23 @@ int rib_gc_dest(struct route_node *rn) return 1; } +void zebra_rtable_node_cleanup(struct route_table *table, + struct route_node *node) +{ + struct route_entry *re, *next; + + RNODE_FOREACH_RE_SAFE (node, re, next) { + rib_unlink(node, re); + } + + if (node->info) { + rib_dest_t *dest = node->info; + + rnh_list_fini(&dest->nht); + XFREE(MTYPE_RIB_DEST, node->info); + } +} + static void rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *new) { @@ -2698,7 +2718,7 @@ void rib_unlink(struct route_node *rn, struct route_entry *re) nexthops_free(re->fib_ng.nexthop); - XFREE(MTYPE_OPAQUE, re->opaque); + zapi_opaque_free(re->opaque); XFREE(MTYPE_RE, re); } diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 48e2bafe44..3b0ef71987 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -48,10 +48,9 @@ #include "zebra/zebra_routemap.h" #include "zebra/zebra_srte.h" #include "zebra/interface.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_errors.h" -DEFINE_MTYPE_STATIC(ZEBRA, RNH, "Nexthop tracking object") +DEFINE_MTYPE_STATIC(ZEBRA, RNH, "Nexthop tracking object"); static void free_state(vrf_id_t vrf_id, struct route_entry *re, struct route_node *rn); diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 17a9bf97f9..c9660c7309 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -21,7 +21,6 @@ #include <zebra.h> #include "memory.h" -#include "zebra_memory.h" #include "prefix.h" #include "rib.h" #include "vty.h" diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 249ec38a69..5a00f3155d 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -25,14 +25,14 @@ #include "lib/frratomic.h" #include "zebra_router.h" -#include "zebra_memory.h" #include "zebra_pbr.h" #include "zebra_vxlan.h" #include "zebra_mlag.h" #include "zebra_nhg.h" #include "debug.h" -DEFINE_MTYPE_STATIC(ZEBRA, RIB_TABLE_INFO, "RIB table info") +DEFINE_MTYPE_STATIC(ZEBRA, RIB_TABLE_INFO, "RIB table info"); +DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_RT_TABLE, "Zebra VRF table"); struct zebra_router zrouter = { .multipath_num = MULTIPATH_NUM, @@ -121,7 +121,7 @@ struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf, if (zrt) return zrt->table; - zrt = XCALLOC(MTYPE_ZEBRA_NS, sizeof(*zrt)); + zrt = XCALLOC(MTYPE_ZEBRA_RT_TABLE, sizeof(*zrt)); zrt->tableid = tableid; zrt->afi = afi; zrt->safi = safi; @@ -185,7 +185,7 @@ static void zebra_router_free_table(struct zebra_router_table *zrt) RB_REMOVE(zebra_router_table_head, &zrouter.tables, zrt); XFREE(MTYPE_RIB_TABLE_INFO, table_info); - XFREE(MTYPE_ZEBRA_NS, zrt); + XFREE(MTYPE_ZEBRA_RT_TABLE, zrt); } void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid, diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 89b8238c29..3e08d83724 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -566,4 +566,5 @@ static int zebra_snmp_module_init(void) FRR_MODULE_SETUP(.name = "zebra_snmp", .version = FRR_VERSION, .description = "zebra AgentX SNMP module", - .init = zebra_snmp_module_init, ) + .init = zebra_snmp_module_init, +); diff --git a/zebra/zebra_srte.c b/zebra/zebra_srte.c index d6043534e3..98158ecc12 100644 --- a/zebra/zebra_srte.c +++ b/zebra/zebra_srte.c @@ -24,12 +24,11 @@ #include "lib/lib_errors.h" #include "zebra/zebra_srte.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_mpls.h" #include "zebra/zebra_rnh.h" #include "zebra/zapi_msg.h" -DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_SR_POLICY, "SR Policy") +DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_SR_POLICY, "SR Policy"); static void zebra_sr_policy_deactivate(struct zebra_sr_policy *policy); diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index be4fb29aae..b42923640f 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -36,7 +36,6 @@ #include "zebra/zebra_vrf.h" #include "zebra/zebra_rnh.h" #include "zebra/router-id.h" -#include "zebra/zebra_memory.h" #include "zebra/interface.h" #include "zebra/zebra_mpls.h" #include "zebra/zebra_vxlan.h" @@ -48,8 +47,8 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi, static void zebra_rnhtable_node_cleanup(struct route_table *table, struct route_node *node); -DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_VRF, "ZEBRA VRF") -DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table") +DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_VRF, "ZEBRA VRF"); +DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table"); /* VRF information update. */ static void zebra_vrf_add_update(struct zebra_vrf *zvrf) @@ -413,23 +412,6 @@ done: return table; } -void zebra_rtable_node_cleanup(struct route_table *table, - struct route_node *node) -{ - struct route_entry *re, *next; - - RNODE_FOREACH_RE_SAFE (node, re, next) { - rib_unlink(node, re); - } - - if (node->info) { - rib_dest_t *dest = node->info; - - rnh_list_fini(&dest->nht); - XFREE(MTYPE_RIB_DEST, node->info); - } -} - static void zebra_rnhtable_node_cleanup(struct route_table *table, struct route_node *node) { diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index 910d192317..ed6376b01f 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -238,7 +238,7 @@ zvrf_other_table_compare_func(const struct other_route_table *a, } DECLARE_RBTREE_UNIQ(otable, struct other_route_table, next, - zvrf_other_table_compare_func) + zvrf_other_table_compare_func); extern struct route_table * zebra_vrf_lookup_table_with_table_id(afi_t afi, safi_t safi, vrf_id_t vrf_id, diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 3349c18204..283a3e52d6 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -21,7 +21,6 @@ #include <zebra.h> #include "memory.h" -#include "zebra_memory.h" #include "if.h" #include "prefix.h" #include "command.h" @@ -2565,10 +2564,8 @@ DEFUN (default_vrf_vni_mapping, "VNI-ID\n" "Prefix routes only \n") { - int ret = 0; - char err[ERR_STR_SZ]; + char xpath[XPATH_MAXLEN]; struct zebra_vrf *zvrf = NULL; - vni_t vni = strtoul(argv[1]->arg, NULL, 10); int filter = 0; zvrf = vrf_info_lookup(VRF_DEFAULT); @@ -2578,25 +2575,35 @@ DEFUN (default_vrf_vni_mapping, if (argc == 3) filter = 1; - ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, - filter, 1); - if (ret != 0) { - vty_out(vty, "%s\n", err); - return CMD_WARNING; + snprintf(xpath, sizeof(xpath), FRR_VRF_KEY_XPATH "/frr-zebra:zebra", + VRF_DEFAULT_NAME); + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); + + snprintf(xpath, sizeof(xpath), + FRR_VRF_KEY_XPATH "/frr-zebra:zebra/l3vni-id", + VRF_DEFAULT_NAME); + nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, argv[1]->arg); + + if (filter) { + snprintf(xpath, sizeof(xpath), + FRR_VRF_KEY_XPATH "/frr-zebra:zebra/prefix-only", + VRF_DEFAULT_NAME); + nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, "true"); } - return CMD_SUCCESS; + return nb_cli_apply_changes(vty, NULL); } DEFUN (no_default_vrf_vni_mapping, no_default_vrf_vni_mapping_cmd, - "no vni " CMD_VNI_RANGE, + "no vni " CMD_VNI_RANGE "[prefix-routes-only]", NO_STR "VNI corresponding to DEFAULT VRF\n" - "VNI-ID") + "VNI-ID\n" + "Prefix routes only \n") { - int ret = 0; - char err[ERR_STR_SZ]; + char xpath[XPATH_MAXLEN]; + int filter = 0; vni_t vni = strtoul(argv[2]->arg, NULL, 10); struct zebra_vrf *zvrf = NULL; @@ -2604,13 +2611,32 @@ DEFUN (no_default_vrf_vni_mapping, if (!zvrf) return CMD_WARNING; - ret = zebra_vxlan_process_vrf_vni_cmd(zvrf, vni, err, ERR_STR_SZ, 0, 0); - if (ret != 0) { - vty_out(vty, "%s\n", err); + if (argc == 4) + filter = 1; + + if (zvrf->l3vni != vni) { + vty_out(vty, "VNI %d doesn't exist in VRF: %s \n", vni, + zvrf->vrf->name); return CMD_WARNING; } - return CMD_SUCCESS; + snprintf(xpath, sizeof(xpath), + FRR_VRF_KEY_XPATH "/frr-zebra:zebra/l3vni-id", + VRF_DEFAULT_NAME); + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, argv[2]->arg); + + if (filter) { + snprintf(xpath, sizeof(xpath), + FRR_VRF_KEY_XPATH "/frr-zebra:zebra/prefix-only", + VRF_DEFAULT_NAME); + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, "true"); + } + + snprintf(xpath, sizeof(xpath), FRR_VRF_KEY_XPATH "/frr-zebra:zebra", + VRF_DEFAULT_NAME); + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + + return nb_cli_apply_changes(vty, NULL); } DEFUN (vrf_vni_mapping, @@ -2638,9 +2664,7 @@ DEFUN (vrf_vni_mapping, nb_cli_enqueue_change(vty, "./frr-zebra:zebra/prefix-only", NB_OP_MODIFY, "true"); - nb_cli_apply_changes(vty, NULL); - - return CMD_SUCCESS; + return nb_cli_apply_changes(vty, NULL); } DEFUN (no_vrf_vni_mapping, @@ -2677,9 +2701,7 @@ DEFUN (no_vrf_vni_mapping, nb_cli_enqueue_change(vty, "./frr-zebra:zebra", NB_OP_DESTROY, NULL); - nb_cli_apply_changes(vty, NULL); - - return CMD_SUCCESS; + return nb_cli_apply_changes(vty, NULL); } /* show vrf */ diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index e5efbe0d4a..bc2eac7a0b 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -46,7 +46,6 @@ #include "zebra/rt_netlink.h" #include "zebra/zebra_errors.h" #include "zebra/zebra_l2.h" -#include "zebra/zebra_memory.h" #include "zebra/zebra_ns.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_vxlan.h" @@ -65,7 +64,7 @@ DEFINE_MTYPE_STATIC(ZEBRA, L3NEIGH, "EVPN Neighbor"); DEFINE_MTYPE_STATIC(ZEBRA, ZVXLAN_SG, "zebra VxLAN multicast group"); DEFINE_HOOK(zebra_rmac_update, (zebra_mac_t *rmac, zebra_l3vni_t *zl3vni, - bool delete, const char *reason), (rmac, zl3vni, delete, reason)) + bool delete, const char *reason), (rmac, zl3vni, delete, reason)); /* static function declarations */ static void zevpn_print_neigh_hash_all_evpn(struct hash_bucket *bucket, diff --git a/zebra/zebra_vxlan_private.h b/zebra/zebra_vxlan_private.h index 4ec55542a7..0556c4adce 100644 --- a/zebra/zebra_vxlan_private.h +++ b/zebra/zebra_vxlan_private.h @@ -226,7 +226,7 @@ extern struct interface *zl3vni_map_to_mac_vlan_if(zebra_l3vni_t *zl3vni); extern zebra_l3vni_t *zl3vni_lookup(vni_t vni); DECLARE_HOOK(zebra_rmac_update, (zebra_mac_t *rmac, zebra_l3vni_t *zl3vni, - bool delete, const char *reason), (rmac, zl3vni, delete, reason)) + bool delete, const char *reason), (rmac, zl3vni, delete, reason)); #ifdef __cplusplus |
