Skip to content

Commit

Permalink
pimd: Convert boundary_oil_plist to struct prefix_list
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Corey Siltala committed Dec 5, 2024
1 parent f369a27 commit 4f726c1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
1 change: 0 additions & 1 deletion pimd/pim_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 5 additions & 2 deletions pimd/pim_igmpv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
18 changes: 8 additions & 10 deletions pimd/pim_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2390,15 +2390,19 @@ 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) {
case NB_EV_VALIDATE:
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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
11 changes: 5 additions & 6 deletions pimd/pim_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "log.h"
#include "prefix.h"
#include "plist.h"
#include "plist_int.h"

#include "pimd.h"
#include "pim_instance.h"
Expand Down Expand Up @@ -174,22 +175,20 @@ 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)
return false;

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) {
Expand Down
3 changes: 2 additions & 1 deletion pimd/pim_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "vty.h"
#include "vrf.h"
#include "plist.h"
#include "plist_int.h"
#include "filter.h"

#include "pimd.h"
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 4f726c1

Please sign in to comment.