enum zapi_rule_notify_owner note;
struct bgp_pbr_action *bgp_pbra;
struct bgp_pbr_rule *bgp_pbr = NULL;
- ifindex_t ifi;
+ char ifname[INTERFACE_NAMSIZ + 1];
if (!zapi_rule_notify_decode(zclient->ibuf, &seqno, &priority, &unique,
- &ifi, ¬e))
+ ifname, ¬e))
return -1;
bgp_pbra = bgp_pbr_action_rule_lookup(vrf_id, unique);
uint32_t unique;
struct pbr_filter filter;
struct pbr_action action;
- ifindex_t ifindex;
+
+ char ifname[INTERFACE_NAMSIZ + 1];
};
/* TCP flags value shared
stream_putw(s, zrule->filter.fwmark); /* fwmark */
stream_putl(s, zrule->action.table);
- stream_putl(s, zrule->ifindex);
+ stream_put(s, zrule->ifname, INTERFACE_NAMSIZ);
/* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s));
}
bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
- uint32_t *priority, uint32_t *unique,
- ifindex_t *ifindex,
+ uint32_t *priority, uint32_t *unique, char *ifname,
enum zapi_rule_notify_owner *note)
{
uint32_t prio, seq, uni;
- ifindex_t ifi;
STREAM_GET(note, s, sizeof(*note));
STREAM_GETL(s, seq);
STREAM_GETL(s, prio);
STREAM_GETL(s, uni);
- STREAM_GETL(s, ifi);
+ STREAM_GET(ifname, s, INTERFACE_NAMSIZ);
if (zclient_debug)
- zlog_debug("%s: %u %u %u %u", __func__, seq, prio, uni, ifi);
+ zlog_debug("%s: %u %u %u %s", __func__, seq, prio, uni, ifname);
*seqno = seq;
*priority = prio;
*unique = uni;
- *ifindex = ifi;
return true;
uint32_t *tableid,
enum zapi_route_notify_owner *note);
bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
- uint32_t *priority, uint32_t *unique,
- ifindex_t *ifindex,
+ uint32_t *priority, uint32_t *unique, char *ifname,
enum zapi_rule_notify_owner *note);
bool zapi_ipset_notify_decode(struct stream *s,
uint32_t *unique,
pbr_map_delete_common(pbrms);
}
-struct pbr_map_sequence *pbrms_lookup_unique(uint32_t unique, ifindex_t ifindex,
+struct pbr_map_sequence *pbrms_lookup_unique(uint32_t unique, char *ifname,
struct pbr_map_interface **ppmi)
{
struct pbr_map_sequence *pbrms;
RB_FOREACH (pbrm, pbr_map_entry_head, &pbr_maps) {
for (ALL_LIST_ELEMENTS_RO(pbrm->incoming, inode, pmi)) {
- if (pmi->ifp->ifindex != ifindex)
+ if (strncmp(pmi->ifp->name, ifname, INTERFACE_NAMSIZ)
+ != 0)
continue;
if (ppmi)
extern struct pbr_map_sequence *pbrms_get(const char *name, uint32_t seqno);
extern struct pbr_map_sequence *
-pbrms_lookup_unique(uint32_t unique, ifindex_t ifindex,
+pbrms_lookup_unique(uint32_t unique, char *ifname,
struct pbr_map_interface **ppmi);
extern struct pbr_map *pbrm_find(const char *name);
enum zapi_rule_notify_owner note;
struct pbr_map_sequence *pbrms;
struct pbr_map_interface *pmi;
- ifindex_t ifi;
+ char ifname[INTERFACE_NAMSIZ + 1];
uint64_t installed;
if (!zapi_rule_notify_decode(zclient->ibuf, &seqno, &priority, &unique,
- &ifi, ¬e))
+ ifname, ¬e))
return -1;
pmi = NULL;
- pbrms = pbrms_lookup_unique(unique, ifi, &pmi);
+ pbrms = pbrms_lookup_unique(unique, ifname, &pmi);
if (!pbrms) {
DEBUGD(&pbr_dbg_zebra,
"%s: Failure to lookup pbrms based upon %u", __func__,
stream_putl(s, pbr_nht_get_table(pbrms->nhgrp_name));
else if (pbrms->nhg)
stream_putl(s, pbr_nht_get_table(pbrms->internal_nhg_name));
- stream_putl(s, ifp->ifindex);
+ stream_put(s, ifp->name, INTERFACE_NAMSIZ);
}
void pbr_send_pbr_map(struct pbr_map_sequence *pbrms,
char buf[];
} *req = buf;
- const char *ifname = dplane_ctx_get_ifname(ctx);
+ const char *ifname = dplane_ctx_rule_get_ifname(ctx);
char buf1[PREFIX_STRLEN];
char buf2[PREFIX_STRLEN];
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
- "Tx %s family %s IF %s(%u) Pref %u Fwmark %u Src %s Dst %s Table %u",
+ "Tx %s family %s IF %s Pref %u Fwmark %u Src %s Dst %s Table %u",
nl_msg_type_to_str(cmd), nl_family_to_str(family),
- ifname, dplane_ctx_get_ifindex(ctx), priority, fwmark,
+ ifname, priority, fwmark,
prefix2str(src_ip, buf1, sizeof(buf1)),
prefix2str(dst_ip, buf2, sizeof(buf2)), table);
ret = dplane_pbr_rule_delete(&rule);
zlog_debug(
- "%s: %s leftover rule: family %s IF %s(%u) Pref %u Src %s Dst %s Table %u",
+ "%s: %s leftover rule: family %s IF %s Pref %u Src %s Dst %s Table %u",
__func__,
((ret == ZEBRA_DPLANE_REQUEST_FAILURE)
? "Failed to remove"
: "Removed"),
nl_family_to_str(frh->family), rule.ifname,
- rule.rule.ifindex, rule.rule.priority,
+ rule.rule.priority,
prefix2str(&rule.rule.filter.src_ip, buf1,
sizeof(buf1)),
prefix2str(&rule.rule.filter.dst_ip, buf2,
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
- "Rx %s family %s IF %s(%u) Pref %u Src %s Dst %s Table %u",
+ "Rx %s family %s IF %s Pref %u Src %s Dst %s Table %u",
nl_msg_type_to_str(h->nlmsg_type),
nl_family_to_str(frh->family), rule.ifname,
- rule.rule.ifindex, rule.rule.priority,
+ rule.rule.priority,
prefix2str(&rule.rule.filter.src_ip, buf1,
sizeof(buf1)),
prefix2str(&rule.rule.filter.dst_ip, buf2,
stream_putl(s, dplane_ctx_rule_get_seq(ctx));
stream_putl(s, dplane_ctx_rule_get_priority(ctx));
stream_putl(s, dplane_ctx_rule_get_unique(ctx));
- stream_putl(s, dplane_ctx_get_ifindex(ctx));
+ stream_put(s, dplane_ctx_rule_get_ifname(ctx), INTERFACE_NAMSIZ);
stream_putw_at(s, 0, stream_get_endp(s));
struct zebra_pbr_rule zpr;
struct stream *s;
uint32_t total, i;
+ char ifname[INTERFACE_NAMSIZ + 1] = {};
s = msg;
STREAM_GETL(s, total);
STREAM_GETC(s, zpr.rule.filter.dsfield);
STREAM_GETL(s, zpr.rule.filter.fwmark);
STREAM_GETL(s, zpr.rule.action.table);
- STREAM_GETL(s, zpr.rule.ifindex);
+ STREAM_GET(ifname, s, INTERFACE_NAMSIZ);
- if (zpr.rule.ifindex) {
- struct interface *ifp;
-
- ifp = if_lookup_by_index_per_ns(zvrf->zns,
- zpr.rule.ifindex);
- if (!ifp) {
- zlog_debug("Failed to lookup ifindex: %u",
- zpr.rule.ifindex);
- return;
- }
-
- strlcpy(zpr.ifname, ifp->name, sizeof(zpr.ifname));
- }
+ strlcpy(zpr.ifname, ifname, sizeof(zpr.ifname));
+ strlcpy(zpr.rule.ifname, ifname, sizeof(zpr.rule.ifname));
if (!is_default_prefix(&zpr.rule.filter.src_ip))
zpr.rule.filter.filter_bm |= PBR_FILTER_SRC_IP;
uint8_t dsfield;
struct prefix src_ip;
struct prefix dst_ip;
+ char ifname[INTERFACE_NAMSIZ + 1];
};
struct dplane_rule_info {
return ctx->u.rule.sock;
}
+const char *dplane_ctx_rule_get_ifname(const struct zebra_dplane_ctx *ctx)
+{
+ DPLANE_CTX_VALID(ctx);
+
+ return ctx->u.rule.new.ifname;
+}
+
int dplane_ctx_rule_get_unique(const struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);
dplane_rule->dsfield = rule->rule.filter.dsfield;
prefix_copy(&(dplane_rule->dst_ip), &rule->rule.filter.dst_ip);
prefix_copy(&(dplane_rule->src_ip), &rule->rule.filter.src_ip);
+ strlcpy(dplane_rule->ifname, rule->ifname, INTERFACE_NAMSIZ);
}
/**
char buf2[PREFIX_STRLEN];
zlog_debug(
- "init dplane ctx %s: IF %s(%u) Prio %u Fwmark %u Src %s Dst %s Table %u",
+ "init dplane ctx %s: IF %s Prio %u Fwmark %u Src %s Dst %s Table %u",
dplane_op2str(op), new_rule->ifname,
- new_rule->rule.ifindex, new_rule->rule.priority,
- new_rule->rule.filter.fwmark,
+ new_rule->rule.priority, new_rule->rule.filter.fwmark,
prefix2str(&new_rule->rule.filter.src_ip, buf1,
sizeof(buf1)),
prefix2str(&new_rule->rule.filter.dst_ip, buf2,
ctx->zd_vrf_id = new_rule->vrf_id;
memcpy(ctx->zd_ifname, new_rule->ifname, sizeof(new_rule->ifname));
- ctx->zd_ifindex = new_rule->rule.ifindex;
ctx->u.rule.sock = new_rule->sock;
ctx->u.rule.unique = new_rule->rule.unique;
int dplane_ctx_rule_get_sock(const struct zebra_dplane_ctx *ctx);
int dplane_ctx_rule_get_unique(const struct zebra_dplane_ctx *ctx);
int dplane_ctx_rule_get_seq(const struct zebra_dplane_ctx *ctx);
+const char *dplane_ctx_rule_get_ifname(const struct zebra_dplane_ctx *ctx);
uint32_t dplane_ctx_rule_get_priority(const struct zebra_dplane_ctx *ctx);
uint32_t dplane_ctx_rule_get_old_priority(const struct zebra_dplane_ctx *ctx);
uint32_t dplane_ctx_rule_get_table(const struct zebra_dplane_ctx *ctx);
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,
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)
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;
};
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;
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);