diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2021-06-04 14:18:56 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2021-07-08 11:12:47 -0400 |
| commit | b94683f0db071775ce2d9e92c711f8f7f9acd1b3 (patch) | |
| tree | 200ee1cf4dcc1fcdf1624505c324a757c5bdbae1 | |
| parent | 8ccbc778cffa1ecac10d261ca0f034ffa999136c (diff) | |
lib, zebra: add ip_proto to the filter data structure
Add ip_proto to the filter data structure and also account
for it in the hash when stored.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
| -rw-r--r-- | lib/pbr.h | 3 | ||||
| -rw-r--r-- | zebra/zebra_pbr.c | 9 |
2 files changed, 8 insertions, 4 deletions
@@ -68,6 +68,9 @@ struct pbr_filter { /* Filter with fwmark */ uint32_t fwmark; + + /* Filter with the ip protocol */ + uint8_t ip_proto; }; /* diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 7bcd097371..3607110aa2 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -166,10 +166,8 @@ uint32_t zebra_pbr_rules_hash_key(const void *arg) rule->rule.action.table, prefix_hash_key(&rule->rule.filter.src_ip)); - if (rule->rule.filter.fwmark) - key = jhash_2words(rule->rule.filter.fwmark, rule->vrf_id, key); - else - key = jhash_1word(rule->vrf_id, key); + key = jhash_3words(rule->rule.filter.fwmark, rule->vrf_id, + rule->rule.filter.ip_proto, key); key = jhash(rule->ifname, strlen(rule->ifname), key); @@ -207,6 +205,9 @@ bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2) if (r1->rule.filter.fwmark != r2->rule.filter.fwmark) return false; + if (r1->rule.filter.ip_proto != r2->rule.filter.ip_proto) + return false; + if (!prefix_same(&r1->rule.filter.src_ip, &r2->rule.filter.src_ip)) return false; |
