summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_pbr.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2018-03-24 14:55:06 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2018-04-16 14:40:43 +0200
commited78b7c8251277bebbd5780e32d5bff3fb072751 (patch)
treee78c52e036a67e12852361644398f11067295ea8 /zebra/zebra_pbr.c
parentzebra: add IPTABLE_ADD and IPTABLE_DEL commands in zapi (diff)
downloadfrr-ed78b7c8251277bebbd5780e32d5bff3fb072751.tar.xz
frr-ed78b7c8251277bebbd5780e32d5bff3fb072751.zip
zebra: add a helper structure to look zebra_pbr_ipset per ipsetname
Add an intermediate helper structure that is used to walk the list of ipset entries, and look for associated name. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to '')
-rw-r--r--zebra/zebra_pbr.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index 42b3f37da..eb686bf5a 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -335,20 +335,6 @@ static void *pbr_ipset_alloc_intern(void *arg)
return new;
}
-static struct zebra_pbr_ipset *zpi_found;
-
-static int zebra_pbr_ipset_pername_walkcb(struct hash_backet *backet, void *arg)
-{
- struct zebra_pbr_ipset *zpi = (struct zebra_pbr_ipset *)backet->data;
- char *ipset_name = (char *)arg;
-
- if (!strncmp(ipset_name, zpi->ipset_name, ZEBRA_IPSET_NAME_SIZE)) {
- zpi_found = zpi;
- return HASHWALK_ABORT;
- }
- return HASHWALK_CONTINUE;
-}
-
void zebra_pbr_create_ipset(struct zebra_ns *zns,
struct zebra_pbr_ipset *ipset)
{
@@ -375,14 +361,38 @@ void zebra_pbr_destroy_ipset(struct zebra_ns *zns,
__PRETTY_FUNCTION__);
}
+struct pbr_ipset_name_lookup {
+ struct zebra_pbr_ipset *ipset;
+ char ipset_name[ZEBRA_IPSET_NAME_SIZE];
+};
+
+static int zebra_pbr_ipset_pername_walkcb(struct hash_backet *backet, void *arg)
+{
+ struct pbr_ipset_name_lookup *pinl =
+ (struct pbr_ipset_name_lookup *)arg;
+ struct zebra_pbr_ipset *zpi = (struct zebra_pbr_ipset *)backet->data;
+
+ if (!strncmp(pinl->ipset_name, zpi->ipset_name,
+ ZEBRA_IPSET_NAME_SIZE)) {
+ pinl->ipset = zpi;
+ return HASHWALK_ABORT;
+ }
+ return HASHWALK_CONTINUE;
+}
+
struct zebra_pbr_ipset *zebra_pbr_lookup_ipset_pername(struct zebra_ns *zns,
char *ipsetname)
{
+ struct pbr_ipset_name_lookup pinl;
+ struct pbr_ipset_name_lookup *ptr = &pinl;
+
if (!ipsetname)
return NULL;
- zpi_found = NULL;
- hash_walk(zns->ipset_hash, zebra_pbr_ipset_pername_walkcb, ipsetname);
- return zpi_found;
+ memset(ptr, 0, sizeof(struct pbr_ipset_name_lookup));
+ snprintf((char *)ptr->ipset_name, ZEBRA_IPSET_NAME_SIZE, "%s",
+ ipsetname);
+ hash_walk(zns->ipset_hash, zebra_pbr_ipset_pername_walkcb, ptr);
+ return ptr->ipset;
}
static void *pbr_ipset_entry_alloc_intern(void *arg)