summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorMark Stapp <mjs@labn.net>2023-10-06 18:26:38 +0200
committerMark Stapp <mjs@labn.net>2023-10-06 18:26:38 +0200
commita09cb688a09ec36ca4be0d477b03de133c602f1d (patch)
tree81565a066525ecc22d0d2ffc23daa402b11bfdb6 /zebra
parentMerge pull request #14510 from opensourcerouting/fix/coccinelle_issues (diff)
downloadfrr-a09cb688a09ec36ca4be0d477b03de133c602f1d.tar.xz
frr-a09cb688a09ec36ca4be0d477b03de133c602f1d.zip
zebra: add zclient to iprules key
Include a zclient value in the hash and tree key computations for iprules in zebra: clients may collide without this. Signed-off-by: Mark Stapp <mjs@labn.net>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/zebra_pbr.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index 5124768a7..c04c5f558 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -172,10 +172,13 @@ uint32_t zebra_pbr_rules_hash_key(const void *arg)
key = jhash_3words(rule->rule.filter.pcp, rule->rule.filter.vlan_id,
rule->rule.filter.vlan_flags, key);
- return jhash_3words(rule->rule.filter.src_port,
- rule->rule.filter.dst_port,
- prefix_hash_key(&rule->rule.filter.dst_ip),
- jhash_1word(rule->rule.unique, key));
+ key = jhash_3words(rule->rule.filter.src_port,
+ rule->rule.filter.dst_port,
+ prefix_hash_key(&rule->rule.filter.dst_ip), key);
+
+ key = jhash_2words(rule->rule.unique, rule->sock, key);
+
+ return key;
}
bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
@@ -191,6 +194,9 @@ bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
if (r1->rule.priority != r2->rule.priority)
return false;
+ if (r1->sock != r2->sock)
+ return false;
+
if (r1->rule.unique != r2->rule.unique)
return false;
@@ -226,6 +232,7 @@ bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
struct pbr_rule_unique_lookup {
struct zebra_pbr_rule *rule;
+ int sock;
uint32_t unique;
char ifname[INTERFACE_NAMSIZ + 1];
vrf_id_t vrf_id;
@@ -236,9 +243,9 @@ static int pbr_rule_lookup_unique_walker(struct hash_bucket *b, void *data)
struct pbr_rule_unique_lookup *pul = data;
struct zebra_pbr_rule *rule = b->data;
- if (pul->unique == rule->rule.unique
- && strncmp(pul->ifname, rule->rule.ifname, INTERFACE_NAMSIZ) == 0
- && pul->vrf_id == rule->vrf_id) {
+ if (pul->sock == rule->sock && pul->unique == rule->rule.unique &&
+ strmatch(pul->ifname, rule->rule.ifname) &&
+ pul->vrf_id == rule->vrf_id) {
pul->rule = rule;
return HASHWALK_ABORT;
}
@@ -255,6 +262,7 @@ pbr_rule_lookup_unique(struct zebra_pbr_rule *zrule)
strlcpy(pul.ifname, zrule->rule.ifname, INTERFACE_NAMSIZ);
pul.rule = NULL;
pul.vrf_id = zrule->vrf_id;
+ pul.sock = zrule->sock;
hash_walk(zrouter.rules_hash, &pbr_rule_lookup_unique_walker, &pul);
return pul.rule;