From aa903d1e4805dd30012fcac0cb30f05e6f5f04bc Mon Sep 17 00:00:00 2001 From: Corey Siltala Date: Tue, 26 Nov 2024 08:35:42 -0600 Subject: [PATCH] pimd: Convert boundary_oil_plist to struct prefix_list Rather than storing the prefix-list name and looking it up every time we use it, store a pointer to the prefix-list itself. Signed-off-by: Corey Siltala --- pimd/pim_iface.c | 1 - pimd/pim_iface.h | 2 +- pimd/pim_igmpv3.c | 7 +++++-- pimd/pim_nb_config.c | 18 ++++++++---------- pimd/pim_util.c | 11 +++++------ pimd/pim_vty.c | 3 ++- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index e79d75fa2f0f..d0345eced43b 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -216,7 +216,6 @@ void pim_if_delete(struct interface *ifp) if (pim_ifp->bfd_config.profile) XFREE(MTYPE_TMP, pim_ifp->bfd_config.profile); - XFREE(MTYPE_PIM_INTERFACE, pim_ifp->boundary_oil_plist); XFREE(MTYPE_PIM_INTERFACE, pim_ifp); ifp->info = NULL; diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index 18e88ffbd5dc..90a81a21d026 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -134,7 +134,7 @@ struct pim_interface { int pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */ /* boundary prefix-list (group) */ - char *boundary_oil_plist; + struct prefix_list *boundary_oil_plist; /* boundary access-list (source and group) */ struct access_list *boundary_acl; diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index d0ba79378b31..7348d8130f2c 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -9,6 +9,8 @@ #include "memory.h" #include "if.h" #include "lib_errors.h" +#include "plist.h" +#include "plist_int.h" #include "pimd.h" #include "pim_instance.h" @@ -1815,9 +1817,10 @@ static bool igmp_pkt_grp_addr_ok(struct interface *ifp, const char *from_str, if (PIM_DEBUG_GM_PACKETS) { zlog_debug("Filtering IGMPv3 group record %pI4 from %s on %s per prefix-list %s or access-list %s", &grp.s_addr, from_str, ifp->name, - (pim_ifp->boundary_oil_plist ? pim_ifp->boundary_oil_plist + (pim_ifp->boundary_oil_plist ? pim_ifp->boundary_oil_plist->name : "(not found)"), - (pim_ifp->boundary_acl ? pim_ifp->boundary_acl->name : "(not found)")); + (pim_ifp->boundary_acl ? pim_ifp->boundary_acl->name + : "(not found)")); } return false; } diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index e78d3e98f87c..8a3c5205de57 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -2363,7 +2363,6 @@ int lib_interface_pim_address_family_multicast_boundary_oil_modify( { struct interface *ifp; struct pim_interface *pim_ifp; - const char *plist; const struct lyd_node *if_dnode; switch (args->event) { @@ -2371,7 +2370,12 @@ int lib_interface_pim_address_family_multicast_boundary_oil_modify( if_dnode = yang_dnode_get_parent(args->dnode, "interface"); if (!is_pim_interface(if_dnode)) { snprintf(args->errmsg, args->errmsg_len, - "Pim not enabled on this interface"); + "%% Enable PIM and/or IGMP on this interface first"); + return NB_ERR_VALIDATION; + } + if (!prefix_list_lookup(AFI_IP, yang_dnode_get_string(args->dnode, NULL))) { + snprintf(args->errmsg, args->errmsg_len, + "%% Specified prefix-list not found"); return NB_ERR_VALIDATION; } break; @@ -2381,13 +2385,8 @@ int lib_interface_pim_address_family_multicast_boundary_oil_modify( case NB_EV_APPLY: ifp = nb_running_get_entry(args->dnode, NULL, true); pim_ifp = ifp->info; - plist = yang_dnode_get_string(args->dnode, NULL); - - if (pim_ifp->boundary_oil_plist) - XFREE(MTYPE_PIM_INTERFACE, pim_ifp->boundary_oil_plist); - pim_ifp->boundary_oil_plist = - XSTRDUP(MTYPE_PIM_INTERFACE, plist); + prefix_list_lookup(AFI_IP, yang_dnode_get_string(args->dnode, NULL)); break; } @@ -2417,8 +2416,7 @@ int lib_interface_pim_address_family_multicast_boundary_oil_destroy( case NB_EV_APPLY: ifp = nb_running_get_entry(args->dnode, NULL, true); pim_ifp = ifp->info; - if (pim_ifp->boundary_oil_plist) - XFREE(MTYPE_PIM_INTERFACE, pim_ifp->boundary_oil_plist); + pim_ifp->boundary_oil_plist = NULL; break; } diff --git a/pimd/pim_util.c b/pimd/pim_util.c index b6f3be52fc74..40404714e7fb 100644 --- a/pimd/pim_util.c +++ b/pimd/pim_util.c @@ -9,6 +9,7 @@ #include "log.h" #include "prefix.h" #include "plist.h" +#include "plist_int.h" #include "pimd.h" #include "pim_instance.h" @@ -174,7 +175,6 @@ bool pim_is_group_filtered(struct pim_interface *pim_ifp, pim_addr *grp, pim_add bool is_filtered = false; #if PIM_IPV == 4 struct prefix grp_pfx = {}; - struct prefix_list *pl = NULL; pim_addr any_src = PIMADDR_ANY; if (!pim_ifp->boundary_oil_plist && !pim_ifp->boundary_acl) @@ -182,14 +182,13 @@ bool pim_is_group_filtered(struct pim_interface *pim_ifp, pim_addr *grp, pim_add pim_addr_to_prefix(&grp_pfx, *grp); - pl = prefix_list_lookup(PIM_AFI, pim_ifp->boundary_oil_plist); - /* Filter if either group or (S,G) are denied */ - if (pl) { - is_filtered = prefix_list_apply_ext(pl, NULL, &grp_pfx, true) == PREFIX_DENY; + if (pim_ifp->boundary_oil_plist) { + is_filtered = prefix_list_apply_ext(pim_ifp->boundary_oil_plist, NULL, &grp_pfx, + true) == PREFIX_DENY; if (is_filtered && PIM_DEBUG_EVENTS) { zlog_debug("Filtering group %pI4 per prefix-list %s", grp, - pim_ifp->boundary_oil_plist); + pim_ifp->boundary_oil_plist->name); } } if (!is_filtered && pim_ifp->boundary_acl) { diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index bf511c64f652..24605f1fc450 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -12,6 +12,7 @@ #include "vty.h" #include "vrf.h" #include "plist.h" +#include "plist_int.h" #include "filter.h" #include "pimd.h" @@ -487,7 +488,7 @@ int pim_config_write(struct vty *vty, int writes, struct interface *ifp, /* boundary */ if (pim_ifp->boundary_oil_plist) { vty_out(vty, " " PIM_AF_NAME " multicast boundary oil %s\n", - pim_ifp->boundary_oil_plist); + pim_ifp->boundary_oil_plist->name); ++writes; }