XFREE(MTYPE_TMP, rule);
}
-uint32_t zebra_pbr_rules_hash_key(void *arg)
+uint32_t zebra_pbr_rules_hash_key(const void *arg)
{
- struct zebra_pbr_rule *rule;
+ const struct zebra_pbr_rule *rule;
uint32_t key;
- rule = (struct zebra_pbr_rule *)arg;
+ rule = arg;
key = jhash_3words(rule->rule.seq, rule->rule.priority,
rule->rule.action.table,
prefix_hash_key(&rule->rule.filter.src_ip));
- if (rule->ifp)
- key = jhash_1word(rule->ifp->ifindex, key);
- else
- key = jhash_1word(0, key);
if (rule->rule.filter.fwmark)
- key = jhash_1word(rule->rule.filter.fwmark, key);
+ key = jhash_3words(rule->rule.filter.fwmark, rule->vrf_id,
+ rule->rule.ifindex, key);
else
- key = jhash_1word(0, key);
-
- key = jhash_1word(rule->vrf_id, key);
+ key = jhash_2words(rule->vrf_id, rule->rule.ifindex, key);
return jhash_3words(rule->rule.filter.src_port,
rule->rule.filter.dst_port,
if (!prefix_same(&r1->rule.filter.dst_ip, &r2->rule.filter.dst_ip))
return false;
- if (r1->ifp != r2->ifp)
+ if (r1->rule.ifindex != r2->rule.ifindex)
return false;
if (r1->vrf_id != r2->vrf_id)
struct pbr_rule_unique_lookup {
struct zebra_pbr_rule *rule;
uint32_t unique;
- struct interface *ifp;
+ ifindex_t ifindex;
vrf_id_t vrf_id;
};
-static int pbr_rule_lookup_unique_walker(struct hash_backet *b, void *data)
+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
- && pul->ifp == rule->ifp
+ && pul->ifindex == rule->rule.ifindex
&& pul->vrf_id == rule->vrf_id) {
pul->rule = rule;
return HASHWALK_ABORT;
struct pbr_rule_unique_lookup pul;
pul.unique = zrule->rule.unique;
- pul.ifp = zrule->ifp;
+ pul.ifindex = zrule->rule.ifindex;
pul.rule = NULL;
pul.vrf_id = zrule->vrf_id;
hash_walk(zrouter.rules_hash, &pbr_rule_lookup_unique_walker, &pul);
XFREE(MTYPE_TMP, ipset);
}
-uint32_t zebra_pbr_ipset_hash_key(void *arg)
+uint32_t zebra_pbr_ipset_hash_key(const void *arg)
{
- struct zebra_pbr_ipset *ipset = (struct zebra_pbr_ipset *)arg;
+ const struct zebra_pbr_ipset *ipset = arg;
uint32_t *pnt = (uint32_t *)&ipset->ipset_name;
uint32_t key = jhash_1word(ipset->vrf_id, 0x63ab42de);
XFREE(MTYPE_TMP, ipset);
}
-uint32_t zebra_pbr_ipset_entry_hash_key(void *arg)
+uint32_t zebra_pbr_ipset_entry_hash_key(const void *arg)
{
- struct zebra_pbr_ipset_entry *ipset;
+ const struct zebra_pbr_ipset_entry *ipset;
uint32_t key;
- ipset = (struct zebra_pbr_ipset_entry *)arg;
+ ipset = arg;
key = prefix_hash_key(&ipset->src);
key = jhash_1word(ipset->unique, key);
key = jhash_1word(prefix_hash_key(&ipset->dst), key);
iptable = (struct zebra_pbr_iptable *)arg;
hook_call(zebra_pbr_iptable_update, 0, iptable);
- for (ALL_LIST_ELEMENTS(iptable->interface_name_list,
- node, nnode, name)) {
- XFREE(MTYPE_PBR_IPTABLE_IFNAME, name);
- list_delete_node(iptable->interface_name_list,
- node);
+ if (iptable->interface_name_list) {
+ for (ALL_LIST_ELEMENTS(iptable->interface_name_list, node,
+ nnode, name)) {
+ XFREE(MTYPE_PBR_IPTABLE_IFNAME, name);
+ list_delete_node(iptable->interface_name_list, node);
+ }
+ list_delete(&iptable->interface_name_list);
}
XFREE(MTYPE_TMP, iptable);
}
-uint32_t zebra_pbr_iptable_hash_key(void *arg)
+uint32_t zebra_pbr_iptable_hash_key(const void *arg)
{
- struct zebra_pbr_iptable *iptable = (struct zebra_pbr_iptable *)arg;
+ const struct zebra_pbr_iptable *iptable = arg;
uint32_t *pnt = (uint32_t *)&(iptable->ipset_name);
uint32_t key;
key = jhash_1word(iptable->tcp_flags, key);
key = jhash_1word(iptable->tcp_mask_flags, key);
key = jhash_1word(iptable->dscp_value, key);
+ key = jhash_1word(iptable->protocol, key);
key = jhash_1word(iptable->fragment, key);
key = jhash_1word(iptable->vrf_id, key);
r2 = (const struct zebra_pbr_iptable *)arg2;
if (r1->vrf_id != r2->vrf_id)
- return 0;
+ return false;
if (r1->type != r2->type)
return false;
if (r1->unique != r2->unique)
return false;
if (r1->fragment != r2->fragment)
return false;
+ if (r1->protocol != r2->protocol)
+ return false;
return true;
}
__PRETTY_FUNCTION__);
}
-static void zebra_pbr_cleanup_rules(struct hash_backet *b, void *data)
+static void zebra_pbr_cleanup_rules(struct hash_bucket *b, void *data)
{
struct zebra_pbr_rule *rule = b->data;
int *sock = data;
if (rule->sock == *sock) {
(void)kernel_del_pbr_rule(rule);
- hash_release(zrouter.rules_hash, rule);
- XFREE(MTYPE_TMP, rule);
+ if (hash_release(zrouter.rules_hash, rule))
+ XFREE(MTYPE_TMP, rule);
+ else
+ zlog_debug(
+ "%s: Rule seq: %u is being cleaned but we can't find it in our tables",
+ __func__, rule->rule.seq);
}
}
-static void zebra_pbr_cleanup_ipset(struct hash_backet *b, void *data)
+static void zebra_pbr_cleanup_ipset(struct hash_bucket *b, void *data)
{
struct zebra_pbr_ipset *ipset = b->data;
int *sock = data;
}
}
-static void zebra_pbr_cleanup_ipset_entry(struct hash_backet *b, void *data)
+static void zebra_pbr_cleanup_ipset_entry(struct hash_bucket *b, void *data)
{
struct zebra_pbr_ipset_entry *ipset = b->data;
int *sock = data;
}
}
-static void zebra_pbr_cleanup_iptable(struct hash_backet *b, void *data)
+static void zebra_pbr_cleanup_iptable(struct hash_bucket *b, void *data)
{
struct zebra_pbr_iptable *iptable = b->data;
int *sock = data;
"Unrecognized IPset Type");
}
-static int zebra_pbr_ipset_pername_walkcb(struct hash_backet *backet, void *arg)
+static int zebra_pbr_ipset_pername_walkcb(struct hash_bucket *bucket, 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;
+ struct zebra_pbr_ipset *zpi = (struct zebra_pbr_ipset *)bucket->data;
if (!strncmp(pinl->ipset_name, zpi->ipset_name,
ZEBRA_IPSET_NAME_SIZE)) {
list_delete_node(iptable->interface_name_list,
node);
}
+ list_delete(&iptable->interface_name_list);
XFREE(MTYPE_TMP, lookup);
} else
zlog_debug("%s: IPTable being deleted we know nothing about",
}
}
-static int zebra_pbr_show_ipset_entry_walkcb(struct hash_backet *backet,
+static int zebra_pbr_show_ipset_entry_walkcb(struct hash_bucket *bucket,
void *arg)
{
struct zebra_pbr_ipset_entry_unique_display *unique =
struct zebra_pbr_ipset *zpi = unique->zpi;
struct vty *vty = unique->vty;
struct zebra_pbr_ipset_entry *zpie =
- (struct zebra_pbr_ipset_entry *)backet->data;
+ (struct zebra_pbr_ipset_entry *)bucket->data;
uint64_t pkts = 0, bytes = 0;
int ret = 0;
return HASHWALK_CONTINUE;
}
-static int zebra_pbr_show_ipset_walkcb(struct hash_backet *backet, void *arg)
+static int zebra_pbr_show_ipset_walkcb(struct hash_bucket *bucket, void *arg)
{
struct zebra_pbr_env_display *uniqueipset =
(struct zebra_pbr_env_display *)arg;
- struct zebra_pbr_ipset *zpi = (struct zebra_pbr_ipset *)backet->data;
+ struct zebra_pbr_ipset *zpi = (struct zebra_pbr_ipset *)bucket->data;
struct zebra_pbr_ipset_entry_unique_display unique;
struct vty *vty = uniqueipset->vty;
struct zebra_ns *zns = uniqueipset->zns;
uint32_t fwmark;
};
-static int zebra_pbr_rule_lookup_fwmark_walkcb(struct hash_backet *backet,
+static int zebra_pbr_rule_lookup_fwmark_walkcb(struct hash_bucket *bucket,
void *arg)
{
struct pbr_rule_fwmark_lookup *iprule =
(struct pbr_rule_fwmark_lookup *)arg;
- struct zebra_pbr_rule *zpr = (struct zebra_pbr_rule *)backet->data;
+ struct zebra_pbr_rule *zpr = (struct zebra_pbr_rule *)bucket->data;
if (iprule->fwmark == zpr->rule.filter.fwmark) {
iprule->ptr = zpr;
" not" : "", lookup_msg(fragment_value_str,
iptable->fragment, val_str));
}
+ if (iptable->protocol) {
+ vty_out(vty, "\t protocol %d\n",
+ iptable->protocol);
+ }
ret = hook_call(zebra_pbr_iptable_get_stat, iptable, &pkts,
&bytes);
if (ret && pkts > 0)
}
}
-static int zebra_pbr_show_iptable_walkcb(struct hash_backet *backet, void *arg)
+static int zebra_pbr_show_iptable_walkcb(struct hash_bucket *bucket, void *arg)
{
struct zebra_pbr_iptable *iptable =
- (struct zebra_pbr_iptable *)backet->data;
+ (struct zebra_pbr_iptable *)bucket->data;
struct zebra_pbr_env_display *env = (struct zebra_pbr_env_display *)arg;
struct vty *vty = env->vty;
struct zebra_ns *zns = env->zns;