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 <csiltala@atcorp.com>
This commit is contained in:
Corey Siltala 2024-11-26 08:35:42 -06:00
parent ff5309ca2d
commit 8465ba1dde
6 changed files with 21 additions and 21 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -2390,7 +2390,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) {
@ -2398,7 +2397,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;
@ -2408,13 +2412,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;
}
@ -2444,8 +2443,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;
}

View File

@ -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) {

View File

@ -12,6 +12,7 @@
#include "vty.h"
#include "vrf.h"
#include "plist.h"
#include "plist_int.h"
#include "filter.h"
#include "pimd.h"
@ -493,7 +494,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;
}