summaryrefslogtreecommitdiff
path: root/zebra/zapi_msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zapi_msg.c')
-rw-r--r--zebra/zapi_msg.c85
1 files changed, 38 insertions, 47 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index fbed99dc59..e436e5a288 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -815,7 +815,7 @@ void zsend_rule_notify_owner(const struct zebra_dplane_ctx *ctx,
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));
@@ -1349,6 +1349,20 @@ static void zread_interface_add(ZAPI_HANDLER_ARGS)
struct vrf *vrf;
struct interface *ifp;
+ vrf_id_t vrf_id = zvrf_id(zvrf);
+ if (vrf_id != VRF_DEFAULT && vrf_id != VRF_UNKNOWN) {
+ FOR_ALL_INTERFACES (zvrf->vrf, ifp) {
+ /* Skip pseudo interface. */
+ if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE))
+ continue;
+
+ zsend_interface_add(client, ifp);
+ zsend_interface_link_params(client, ifp);
+ zsend_interface_addresses(client, ifp);
+ }
+ return;
+ }
+
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
FOR_ALL_INTERFACES (vrf, ifp) {
/* Skip pseudo interface. */
@@ -1588,16 +1602,17 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
return;
}
+ vrf_id = zvrf_id(zvrf);
+
if (IS_ZEBRA_DEBUG_RECV) {
char buf_prefix[PREFIX_STRLEN];
prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: p=%s, msg flags=0x%x, flags=0x%x",
- __func__, buf_prefix, (int)api.message, api.flags);
+ zlog_debug("%s: p=(%u:%u)%s, msg flags=0x%x, flags=0x%x",
+ __func__, vrf_id, api.tableid, buf_prefix, (int)api.message, api.flags);
}
/* Allocate new route. */
- vrf_id = zvrf_id(zvrf);
re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
re->type = api.type;
re->instance = api.instance;
@@ -1878,9 +1893,18 @@ static void zread_route_del(ZAPI_HANDLER_ARGS)
else
table_id = zvrf->table_id;
+ if (IS_ZEBRA_DEBUG_RECV) {
+ char buf_prefix[PREFIX_STRLEN];
+
+ prefix2str(&api.prefix, buf_prefix, sizeof(buf_prefix));
+ zlog_debug("%s: p=(%u:%u)%s, msg flags=0x%x, flags=0x%x",
+ __func__, zvrf_id(zvrf), table_id, buf_prefix,
+ (int)api.message, api.flags);
+ }
+
rib_delete(afi, api.safi, zvrf_id(zvrf), api.type, api.instance,
api.flags, &api.prefix, src_p, NULL, 0, table_id, api.metric,
- api.distance, false);
+ api.distance, false, false);
/* Stats */
switch (api.prefix.family) {
@@ -2727,6 +2751,7 @@ static inline void zread_rule(ZAPI_HANDLER_ARGS)
struct zebra_pbr_rule zpr;
struct stream *s;
uint32_t total, i;
+ char ifname[INTERFACE_NAMSIZ + 1] = {};
s = msg;
STREAM_GETL(s, total);
@@ -2752,21 +2777,10 @@ static inline void zread_rule(ZAPI_HANDLER_ARGS)
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;
@@ -2831,6 +2845,7 @@ static inline void zread_ipset(ZAPI_HANDLER_ARGS)
zpi.vrf_id = zvrf->vrf->vrf_id;
STREAM_GETL(s, zpi.unique);
STREAM_GETL(s, zpi.type);
+ STREAM_GETC(s, zpi.family);
STREAM_GET(&zpi.ipset_name, s, ZEBRA_IPSET_NAME_SIZE);
if (hdr->command == ZEBRA_IPSET_CREATE)
@@ -2941,6 +2956,7 @@ static inline void zread_iptable(ZAPI_HANDLER_ARGS)
STREAM_GETL(s, zpi->action);
STREAM_GETL(s, zpi->fwmark);
STREAM_GET(&zpi->ipset_name, s, ZEBRA_IPSET_NAME_SIZE);
+ STREAM_GETC(s, zpi->family);
STREAM_GETW(s, zpi->pkt_len_min);
STREAM_GETW(s, zpi->pkt_len_max);
STREAM_GETW(s, zpi->tcp_flags);
@@ -2948,6 +2964,7 @@ static inline void zread_iptable(ZAPI_HANDLER_ARGS)
STREAM_GETC(s, zpi->dscp_value);
STREAM_GETC(s, zpi->fragment);
STREAM_GETC(s, zpi->protocol);
+ STREAM_GETW(s, zpi->flow_label);
STREAM_GETL(s, zpi->nb_interface);
zebra_pbr_iptable_update_interfacelist(s, zpi);
@@ -3103,29 +3120,6 @@ void (*const zserv_handlers[])(ZAPI_HANDLER_ARGS) = {
[ZEBRA_CLIENT_CAPABILITIES] = zread_client_capabilities,
[ZEBRA_NEIGH_DISCOVER] = zread_neigh_discover};
-#if defined(HANDLE_ZAPI_FUZZING)
-extern struct zebra_privs_t zserv_privs;
-
-static void zserv_write_incoming(struct stream *orig, uint16_t command)
-{
- char fname[MAXPATHLEN];
- struct stream *copy;
- int fd = -1;
-
- copy = stream_dup(orig);
- stream_set_getp(copy, 0);
-
- snprintf(fname, MAXPATHLEN, "%s/%u", frr_vtydir, command);
-
- frr_with_privs(&zserv_privs) {
- fd = open(fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
- }
- stream_flush(copy, fd);
- close(fd);
- stream_free(copy);
-}
-#endif
-
/*
* Process a batch of zapi messages.
*/
@@ -3152,13 +3146,10 @@ void zserv_handle_commands(struct zserv *client, struct stream_fifo *fifo)
zapi_parse_header(msg, &hdr);
- if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
+ if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV
+ && IS_ZEBRA_DEBUG_DETAIL)
zserv_log_message(NULL, msg, &hdr);
-#if defined(HANDLE_ZAPI_FUZZING)
- zserv_write_incoming(msg, hdr.command);
-#endif
-
hdr.length -= ZEBRA_HEADER_SIZE;
/* Before checking for a handler function, check for