diff options
author | Donald Sharp <sharpd@nvidia.com> | 2020-09-10 17:31:39 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2020-09-12 02:04:45 +0200 |
commit | 58a1d249249840694e04f7b31a45c35ef6d067c8 (patch) | |
tree | 663ac92256f90326dabc7d099d5eb3b8ba4124c9 /zebra/zebra_pbr.c | |
parent | Merge pull request #6974 from liron-ze/high-cpu-usage (diff) | |
download | frr-58a1d249249840694e04f7b31a45c35ef6d067c8.tar.xz frr-58a1d249249840694e04f7b31a45c35ef6d067c8.zip |
bgpd, lib, pbrd, zebra: Pass by ifname
When installing rules pass by the interface name across
zapi.
This is being changed because we have a situation where
if you quickly create/destroy ephermeal interfaces under
linux the upper level protocol may be trying to add
a rule for a interface that does not quite exist
at the moment. Since ip rules actually want the
interface name ( to handle just this sort of situation )
convert over to passing the interface name and storing
it and using it in zebra.
Ticket: CM-31042
Signed-off-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra/zebra_pbr.c')
-rw-r--r-- | zebra/zebra_pbr.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 95d241c59..c244d2a95 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -167,10 +167,11 @@ uint32_t zebra_pbr_rules_hash_key(const void *arg) prefix_hash_key(&rule->rule.filter.src_ip)); if (rule->rule.filter.fwmark) - key = jhash_3words(rule->rule.filter.fwmark, rule->vrf_id, - rule->rule.ifindex, key); + key = jhash_2words(rule->rule.filter.fwmark, rule->vrf_id, key); else - key = jhash_2words(rule->vrf_id, rule->rule.ifindex, key); + key = jhash_1word(rule->vrf_id, key); + + key = jhash(rule->ifname, strlen(rule->ifname), key); return jhash_3words(rule->rule.filter.src_port, rule->rule.filter.dst_port, @@ -212,7 +213,7 @@ bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2) if (!prefix_same(&r1->rule.filter.dst_ip, &r2->rule.filter.dst_ip)) return false; - if (r1->rule.ifindex != r2->rule.ifindex) + if (strcmp(r1->rule.ifname, r2->rule.ifname) != 0) return false; if (r1->vrf_id != r2->vrf_id) @@ -224,7 +225,7 @@ bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2) struct pbr_rule_unique_lookup { struct zebra_pbr_rule *rule; uint32_t unique; - ifindex_t ifindex; + char ifname[INTERFACE_NAMSIZ + 1]; vrf_id_t vrf_id; }; @@ -234,7 +235,7 @@ static int pbr_rule_lookup_unique_walker(struct hash_bucket *b, void *data) struct zebra_pbr_rule *rule = b->data; if (pul->unique == rule->rule.unique - && pul->ifindex == rule->rule.ifindex + && strncmp(pul->ifname, rule->rule.ifname, INTERFACE_NAMSIZ) == 0 && pul->vrf_id == rule->vrf_id) { pul->rule = rule; return HASHWALK_ABORT; @@ -249,7 +250,7 @@ pbr_rule_lookup_unique(struct zebra_pbr_rule *zrule) struct pbr_rule_unique_lookup pul; pul.unique = zrule->rule.unique; - pul.ifindex = zrule->rule.ifindex; + strlcpy(pul.ifname, zrule->rule.ifname, INTERFACE_NAMSIZ); pul.rule = NULL; pul.vrf_id = zrule->vrf_id; hash_walk(zrouter.rules_hash, &pbr_rule_lookup_unique_walker, &pul); |