summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
Diffstat (limited to 'zebra')
-rw-r--r--zebra/interface.c38
-rw-r--r--zebra/kernel_netlink.c13
-rw-r--r--zebra/rt_netlink.c13
-rw-r--r--zebra/rtadv.c2
-rw-r--r--zebra/zebra_dplane.c8
-rw-r--r--zebra/zebra_fpm.c426
-rw-r--r--zebra/zebra_fpm_netlink.c63
-rw-r--r--zebra/zebra_fpm_private.h31
-rw-r--r--zebra/zebra_memory.c6
-rw-r--r--zebra/zebra_memory.h8
-rw-r--r--zebra/zebra_rib.c10
-rw-r--r--zebra/zebra_rnh.c29
-rw-r--r--zebra/zebra_rnh.h12
-rw-r--r--zebra/zebra_routemap.c76
-rw-r--r--zebra/zebra_router.c2
-rw-r--r--zebra/zebra_vrf.c3
-rw-r--r--zebra/zebra_vty.c15
-rw-r--r--zebra/zebra_vxlan.c39
-rw-r--r--zebra/zebra_vxlan_private.h6
-rw-r--r--zebra/zserv.c2
20 files changed, 703 insertions, 99 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 6e16ae819..34bdd54b8 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1520,7 +1520,6 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
#endif /* HAVE_PROC_NET_DEV */
#ifdef HAVE_NET_RT_IFLIST
-#if defined(__bsdi__) || defined(__NetBSD__)
/* Statistics print out using sysctl (). */
vty_out(vty,
" input packets %llu, bytes %llu, dropped %llu,"
@@ -1545,25 +1544,6 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
vty_out(vty, " collisions %llu\n",
(unsigned long long)ifp->stats.ifi_collisions);
-#else
- /* Statistics print out using sysctl (). */
- vty_out(vty,
- " input packets %lu, bytes %lu, dropped %lu,"
- " multicast packets %lu\n",
- ifp->stats.ifi_ipackets, ifp->stats.ifi_ibytes,
- ifp->stats.ifi_iqdrops, ifp->stats.ifi_imcasts);
-
- vty_out(vty, " input errors %lu\n", ifp->stats.ifi_ierrors);
-
- vty_out(vty,
- " output packets %lu, bytes %lu, multicast packets %lu\n",
- ifp->stats.ifi_opackets, ifp->stats.ifi_obytes,
- ifp->stats.ifi_omcasts);
-
- vty_out(vty, " output errors %lu\n", ifp->stats.ifi_oerrors);
-
- vty_out(vty, " collisions %lu\n", ifp->stats.ifi_collisions);
-#endif /* __bsdi__ || __NetBSD__ */
#endif /* HAVE_NET_RT_IFLIST */
}
@@ -1614,12 +1594,13 @@ DEFPY(show_interface, show_interface_cmd,
/* Show all interfaces to vty. */
-DEFUN (show_interface_vrf_all,
+DEFPY (show_interface_vrf_all,
show_interface_vrf_all_cmd,
- "show interface vrf all",
+ "show interface vrf all [brief$brief]",
SHOW_STR
"Interface status and configuration\n"
- VRF_ALL_CMD_HELP_STR)
+ VRF_ALL_CMD_HELP_STR
+ "Interface status and configuration summary\n")
{
struct vrf *vrf;
struct interface *ifp;
@@ -1627,9 +1608,14 @@ DEFUN (show_interface_vrf_all,
interface_update_stats();
/* All interface print. */
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- FOR_ALL_INTERFACES (vrf, ifp)
- if_dump_vty(vty, ifp);
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
+ if (brief) {
+ ifs_dump_brief_vty(vty, vrf);
+ } else {
+ FOR_ALL_INTERFACES (vrf, ifp)
+ if_dump_vty(vty, ifp);
+ }
+ }
return CMD_SUCCESS;
}
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 387a3531b..2c306434a 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -23,6 +23,7 @@
#if defined(HANDLE_NETLINK_FUZZING)
#include <stdio.h>
#include <string.h>
+#include "libfrr.h"
#endif /* HANDLE_NETLINK_FUZZING */
#ifdef HAVE_NETLINK
@@ -128,8 +129,18 @@ static const struct message family_str[] = {{AF_INET, "ipv4"},
{RTNL_FAMILY_IP6MR, "ipv6MR"},
{0}};
-static const struct message rttype_str[] = {{RTN_UNICAST, "unicast"},
+static const struct message rttype_str[] = {{RTN_UNSPEC, "none"},
+ {RTN_UNICAST, "unicast"},
+ {RTN_LOCAL, "local"},
+ {RTN_BROADCAST, "broadcast"},
+ {RTN_ANYCAST, "anycast"},
{RTN_MULTICAST, "multicast"},
+ {RTN_BLACKHOLE, "blackhole"},
+ {RTN_UNREACHABLE, "unreachable"},
+ {RTN_PROHIBIT, "prohibited"},
+ {RTN_THROW, "throw"},
+ {RTN_NAT, "nat"},
+ {RTN_XRESOLVE, "resolver"},
{0}};
extern struct thread_master *master;
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 1624eea39..c4654510b 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -330,6 +330,10 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
bh_type = BLACKHOLE_ADMINPROHIB;
break;
default:
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug("Route rtm_type: %s(%d) intentionally ignoring",
+ nl_rttype_to_str(rtm->rtm_type),
+ rtm->rtm_type);
return 0;
}
@@ -2413,8 +2417,13 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
}
/* if kernel marks our rfc5549 neighbor entry invalid, re-install it */
- if (h->nlmsg_type == RTM_NEWNEIGH && !(ndm->ndm_state & NUD_VALID))
- netlink_handle_5549(ndm, zif, ifp, &ip);
+ if (h->nlmsg_type == RTM_NEWNEIGH && !(ndm->ndm_state & NUD_VALID)) {
+ if (!(ndm->ndm_state & NUD_FAILED))
+ netlink_handle_5549(ndm, zif, ifp, &ip);
+ else
+ zlog_info("Neighbor Entry for %s has entered a failed state, not reinstalling",
+ ifp->name);
+ }
/* The neighbor is present on an SVI. From this, we locate the
* underlying
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index d591e230c..33d0022a9 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -50,6 +50,8 @@ extern struct zebra_privs_t zserv_privs;
#if defined(HAVE_RTADV)
+DEFINE_MTYPE_STATIC(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix")
+
#ifdef OPEN_BSD
#include <netinet/icmp6.h>
#endif
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 3d64c201f..e2128b1c8 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -17,6 +17,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "lib/libfrr.h"
#include "lib/debug.h"
#include "lib/frratomic.h"
@@ -32,8 +36,8 @@
#include "zebra/debug.h"
/* Memory type for context blocks */
-DEFINE_MTYPE(ZEBRA, DP_CTX, "Zebra DPlane Ctx")
-DEFINE_MTYPE(ZEBRA, DP_PROV, "Zebra DPlane Provider")
+DEFINE_MTYPE_STATIC(ZEBRA, DP_CTX, "Zebra DPlane Ctx")
+DEFINE_MTYPE_STATIC(ZEBRA, DP_PROV, "Zebra DPlane Provider")
#ifndef AOK
# define AOK 0
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c
index 35a5d69ee..32b9763c5 100644
--- a/zebra/zebra_fpm.c
+++ b/zebra/zebra_fpm.c
@@ -30,15 +30,21 @@
#include "network.h"
#include "command.h"
#include "version.h"
+#include "jhash.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_errors.h"
+#include "zebra/zebra_memory.h"
#include "fpm/fpm.h"
#include "zebra_fpm_private.h"
+#include "zebra/zebra_router.h"
+#include "zebra_vxlan_private.h"
+
+DEFINE_MTYPE_STATIC(ZEBRA, FPM_MAC_INFO, "FPM_MAC_INFO");
/*
* Interval at which we attempt to connect to the FPM.
@@ -62,6 +68,9 @@
* Interval over which we collect statistics.
*/
#define ZFPM_STATS_IVL_SECS 10
+#define FPM_MAX_MAC_MSG_LEN 512
+
+static void zfpm_iterate_rmac_table(struct hash_backet *backet, void *args);
/*
* Structure that holds state for iterating over all route_node
@@ -179,6 +188,25 @@ typedef struct zfpm_glob_t_ {
TAILQ_HEAD(zfpm_dest_q, rib_dest_t_) dest_q;
/*
+ * List of fpm_mac_info structures to be processed
+ */
+ TAILQ_HEAD(zfpm_mac_q, fpm_mac_info_t) mac_q;
+
+ /*
+ * Hash table of fpm_mac_info_t entries
+ *
+ * While adding fpm_mac_info_t for a MAC to the mac_q,
+ * it is possible that another fpm_mac_info_t node for the this MAC
+ * is already present in the queue.
+ * This is possible in the case of consecutive add->delete operations.
+ * To avoid such duplicate insertions in the mac_q,
+ * define a hash table for fpm_mac_info_t which can be looked up
+ * to see if an fpm_mac_info_t node for a MAC is already present
+ * in the mac_q.
+ */
+ struct hash *fpm_mac_info_table;
+
+ /*
* Stream socket to the FPM.
*/
int sock;
@@ -259,6 +287,7 @@ static int zfpm_write_cb(struct thread *thread);
static void zfpm_set_state(zfpm_state_t state, const char *reason);
static void zfpm_start_connect_timer(const char *reason);
static void zfpm_start_stats_timer(void);
+static void zfpm_mac_info_del(struct fpm_mac_info_t *fpm_mac);
/*
* zfpm_thread_should_yield
@@ -492,6 +521,9 @@ static int zfpm_conn_up_thread_cb(struct thread *thread)
goto done;
}
+ /* Enqueue FPM updates for all the RMAC entries */
+ hash_iterate(zrouter.l3vni_table, zfpm_iterate_rmac_table, NULL);
+
while ((rnode = zfpm_rnodes_iter_next(iter))) {
dest = rib_dest_from_rnode(rnode);
@@ -591,9 +623,17 @@ static int zfpm_conn_down_thread_cb(struct thread *thread)
struct route_node *rnode;
zfpm_rnodes_iter_t *iter;
rib_dest_t *dest;
+ struct fpm_mac_info_t *mac = NULL;
assert(zfpm_g->state == ZFPM_STATE_IDLE);
+ /*
+ * Delink and free all fpm_mac_info_t nodes
+ * in the mac_q and fpm_mac_info_hash
+ */
+ while ((mac = TAILQ_FIRST(&zfpm_g->mac_q)) != NULL)
+ zfpm_mac_info_del(mac);
+
zfpm_g->t_conn_down = NULL;
iter = &zfpm_g->t_conn_down_state.iter;
@@ -778,6 +818,14 @@ done:
return 0;
}
+static bool zfpm_updates_pending(void)
+{
+ if (!(TAILQ_EMPTY(&zfpm_g->dest_q)) || !(TAILQ_EMPTY(&zfpm_g->mac_q)))
+ return true;
+
+ return false;
+}
+
/*
* zfpm_writes_pending
*
@@ -794,9 +842,9 @@ static int zfpm_writes_pending(void)
return 1;
/*
- * Check if there are any prefixes on the outbound queue.
+ * Check if there are any updates scheduled on the outbound queues.
*/
- if (!TAILQ_EMPTY(&zfpm_g->dest_q))
+ if (zfpm_updates_pending())
return 1;
return 0;
@@ -861,12 +909,29 @@ struct route_entry *zfpm_route_for_update(rib_dest_t *dest)
}
/*
- * zfpm_build_updates
+ * Define an enum for return codes for queue processing functions
*
- * Process the outgoing queue and write messages to the outbound
- * buffer.
+ * FPM_WRITE_STOP: This return code indicates that the write buffer is full.
+ * Stop processing all the queues and empty the buffer by writing its content
+ * to the socket.
+ *
+ * FPM_GOTO_NEXT_Q: This return code indicates that either this queue is
+ * empty or we have processed enough updates from this queue.
+ * So, move on to the next queue.
*/
-static void zfpm_build_updates(void)
+enum {
+ FPM_WRITE_STOP = 0,
+ FPM_GOTO_NEXT_Q = 1
+};
+
+#define FPM_QUEUE_PROCESS_LIMIT 10000
+
+/*
+ * zfpm_build_route_updates
+ *
+ * Process the dest_q queue and write FPM messages to the outbound buffer.
+ */
+static int zfpm_build_route_updates(void)
{
struct stream *s;
rib_dest_t *dest;
@@ -877,25 +942,27 @@ static void zfpm_build_updates(void)
struct route_entry *re;
int is_add, write_msg;
fpm_msg_type_e msg_type;
+ uint16_t q_limit;
- s = zfpm_g->obuf;
+ if (TAILQ_EMPTY(&zfpm_g->dest_q))
+ return FPM_GOTO_NEXT_Q;
- assert(stream_empty(s));
-
- do {
+ s = zfpm_g->obuf;
+ q_limit = FPM_QUEUE_PROCESS_LIMIT;
+ do {
/*
* Make sure there is enough space to write another message.
*/
if (STREAM_WRITEABLE(s) < FPM_MAX_MSG_LEN)
- break;
+ return FPM_WRITE_STOP;
buf = STREAM_DATA(s) + stream_get_endp(s);
buf_end = buf + STREAM_WRITEABLE(s);
dest = TAILQ_FIRST(&zfpm_g->dest_q);
if (!dest)
- break;
+ return FPM_GOTO_NEXT_Q;
assert(CHECK_FLAG(dest->flags, RIB_DEST_UPDATE_FPM));
@@ -955,10 +1022,136 @@ static void zfpm_build_updates(void)
if (rib_gc_dest(dest->rnode))
zfpm_g->stats.dests_del_after_update++;
+ q_limit--;
+ if (q_limit == 0) {
+ /*
+ * We have processed enough updates in this queue.
+ * Now yield for other queues.
+ */
+ return FPM_GOTO_NEXT_Q;
+ }
+ } while (true);
+}
+
+/*
+ * zfpm_encode_mac
+ *
+ * Encode a message to FPM with information about the given MAC.
+ *
+ * Returns the number of bytes written to the buffer.
+ */
+static inline int zfpm_encode_mac(struct fpm_mac_info_t *mac, char *in_buf,
+ size_t in_buf_len, fpm_msg_type_e *msg_type)
+{
+ size_t len = 0;
+
+ *msg_type = FPM_MSG_TYPE_NONE;
+
+ switch (zfpm_g->message_format) {
+
+ case ZFPM_MSG_FORMAT_NONE:
+ break;
+ case ZFPM_MSG_FORMAT_NETLINK:
+#ifdef HAVE_NETLINK
+ len = zfpm_netlink_encode_mac(mac, in_buf, in_buf_len);
+ assert(fpm_msg_align(len) == len);
+ *msg_type = FPM_MSG_TYPE_NETLINK;
+#endif /* HAVE_NETLINK */
+ break;
+ case ZFPM_MSG_FORMAT_PROTOBUF:
+ break;
+ }
+ return len;
+}
+
+static int zfpm_build_mac_updates(void)
+{
+ struct stream *s;
+ struct fpm_mac_info_t *mac;
+ unsigned char *buf, *data, *buf_end;
+ fpm_msg_hdr_t *hdr;
+ size_t data_len, msg_len;
+ fpm_msg_type_e msg_type;
+ uint16_t q_limit;
+
+ if (TAILQ_EMPTY(&zfpm_g->mac_q))
+ return FPM_GOTO_NEXT_Q;
+
+ s = zfpm_g->obuf;
+ q_limit = FPM_QUEUE_PROCESS_LIMIT;
+
+ do {
+ /* Make sure there is enough space to write another message. */
+ if (STREAM_WRITEABLE(s) < FPM_MAX_MAC_MSG_LEN)
+ return FPM_WRITE_STOP;
+
+ buf = STREAM_DATA(s) + stream_get_endp(s);
+ buf_end = buf + STREAM_WRITEABLE(s);
+
+ mac = TAILQ_FIRST(&zfpm_g->mac_q);
+ if (!mac)
+ return FPM_GOTO_NEXT_Q;
+
+ /* Check for no-op */
+ if (!CHECK_FLAG(mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM)) {
+ zfpm_g->stats.nop_deletes_skipped++;
+ zfpm_mac_info_del(mac);
+ continue;
+ }
+
+ hdr = (fpm_msg_hdr_t *)buf;
+ hdr->version = FPM_PROTO_VERSION;
+
+ data = fpm_msg_data(hdr);
+ data_len = zfpm_encode_mac(mac, (char *)data, buf_end - data,
+ &msg_type);
+ assert(data_len);
+
+ hdr->msg_type = msg_type;
+ msg_len = fpm_data_len_to_msg_len(data_len);
+ hdr->msg_len = htons(msg_len);
+ stream_forward_endp(s, msg_len);
+
+ /* Remove the MAC from the queue, and delete it. */
+ zfpm_mac_info_del(mac);
+
+ q_limit--;
+ if (q_limit == 0) {
+ /*
+ * We have processed enough updates in this queue.
+ * Now yield for other queues.
+ */
+ return FPM_GOTO_NEXT_Q;
+ }
} while (1);
}
/*
+ * zfpm_build_updates
+ *
+ * Process the outgoing queues and write messages to the outbound
+ * buffer.
+ */
+static void zfpm_build_updates(void)
+{
+ struct stream *s;
+
+ s = zfpm_g->obuf;
+ assert(stream_empty(s));
+
+ do {
+ /*
+ * Stop processing the queues if zfpm_g->obuf is full
+ * or we do not have more updates to process
+ */
+ if (zfpm_build_mac_updates() == FPM_WRITE_STOP)
+ break;
+ if (zfpm_build_route_updates() == FPM_WRITE_STOP)
+ break;
+ } while (zfpm_updates_pending());
+}
+
+/*
* zfpm_write_cb
*/
static int zfpm_write_cb(struct thread *thread)
@@ -1277,6 +1470,207 @@ static int zfpm_trigger_update(struct route_node *rn, const char *reason)
}
/*
+ * Generate Key for FPM MAC info hash entry
+ * Key is generated using MAC address and VNI id which should be sufficient
+ * to provide uniqueness
+ */
+static unsigned int zfpm_mac_info_hash_keymake(const void *p)
+{
+ struct fpm_mac_info_t *fpm_mac = (struct fpm_mac_info_t *)p;
+ uint32_t mac_key;
+
+ mac_key = jhash(fpm_mac->macaddr.octet, ETH_ALEN, 0xa5a5a55a);
+
+ return jhash_2words(mac_key, fpm_mac->vni, 0);
+}
+
+/*
+ * Compare function for FPM MAC info hash lookup
+ */
+static bool zfpm_mac_info_cmp(const void *p1, const void *p2)
+{
+ const struct fpm_mac_info_t *fpm_mac1 = p1;
+ const struct fpm_mac_info_t *fpm_mac2 = p2;
+
+ if (memcmp(fpm_mac1->macaddr.octet, fpm_mac2->macaddr.octet, ETH_ALEN)
+ != 0)
+ return false;
+ if (fpm_mac1->r_vtep_ip.s_addr != fpm_mac2->r_vtep_ip.s_addr)
+ return false;
+ if (fpm_mac1->vni != fpm_mac2->vni)
+ return false;
+
+ return true;
+}
+
+/*
+ * Lookup FPM MAC info hash entry.
+ */
+static struct fpm_mac_info_t *zfpm_mac_info_lookup(struct fpm_mac_info_t *key)
+{
+ return hash_lookup(zfpm_g->fpm_mac_info_table, key);
+}
+
+/*
+ * Callback to allocate fpm_mac_info_t structure.
+ */
+static void *zfpm_mac_info_alloc(void *p)
+{
+ const struct fpm_mac_info_t *key = p;
+ struct fpm_mac_info_t *fpm_mac;
+
+ fpm_mac = XCALLOC(MTYPE_FPM_MAC_INFO, sizeof(struct fpm_mac_info_t));
+
+ memcpy(&fpm_mac->macaddr, &key->macaddr, ETH_ALEN);
+ memcpy(&fpm_mac->r_vtep_ip, &key->r_vtep_ip, sizeof(struct in_addr));
+ fpm_mac->vni = key->vni;
+
+ return (void *)fpm_mac;
+}
+
+/*
+ * Delink and free fpm_mac_info_t.
+ */
+static void zfpm_mac_info_del(struct fpm_mac_info_t *fpm_mac)
+{
+ hash_release(zfpm_g->fpm_mac_info_table, fpm_mac);
+ TAILQ_REMOVE(&zfpm_g->mac_q, fpm_mac, fpm_mac_q_entries);
+ XFREE(MTYPE_FPM_MAC_INFO, fpm_mac);
+}
+
+/*
+ * zfpm_trigger_rmac_update
+ *
+ * Zebra code invokes this function to indicate that we should
+ * send an update to FPM for given MAC entry.
+ *
+ * This function checks if we already have enqueued an update for this RMAC,
+ * If yes, update the same fpm_mac_info_t. Else, create and enqueue an update.
+ */
+static int zfpm_trigger_rmac_update(zebra_mac_t *rmac, zebra_l3vni_t *zl3vni,
+ bool delete, const char *reason)
+{
+ char buf[ETHER_ADDR_STRLEN];
+ struct fpm_mac_info_t *fpm_mac, key;
+ struct interface *vxlan_if, *svi_if;
+
+ /*
+ * Ignore if the connection is down. We will update the FPM about
+ * all destinations once the connection comes up.
+ */
+ if (!zfpm_conn_is_up())
+ return 0;
+
+ if (reason) {
+ zfpm_debug("triggering update to FPM - Reason: %s - %s",
+ reason,
+ prefix_mac2str(&rmac->macaddr, buf, sizeof(buf)));
+ }
+
+ vxlan_if = zl3vni_map_to_vxlan_if(zl3vni);
+ svi_if = zl3vni_map_to_svi_if(zl3vni);
+
+ memset(&key, 0, sizeof(struct fpm_mac_info_t));
+
+ memcpy(&key.macaddr, &rmac->macaddr, ETH_ALEN);
+ key.r_vtep_ip.s_addr = rmac->fwd_info.r_vtep_ip.s_addr;
+ key.vni = zl3vni->vni;
+
+ /* Check if this MAC is already present in the queue. */
+ fpm_mac = zfpm_mac_info_lookup(&key);
+
+ if (fpm_mac) {
+ if (!!CHECK_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_DELETE_FPM)
+ == delete) {
+ /*
+ * MAC is already present in the queue
+ * with the same op as this one. Do nothing
+ */
+ zfpm_g->stats.redundant_triggers++;
+ return 0;
+ }
+
+ /*
+ * A new op for an already existing fpm_mac_info_t node.
+ * Update the existing node for the new op.
+ */
+ if (!delete) {
+ /*
+ * New op is "add". Previous op is "delete".
+ * Update the fpm_mac_info_t for the new add.
+ */
+ fpm_mac->zebra_flags = rmac->flags;
+
+ fpm_mac->vxlan_if = vxlan_if ? vxlan_if->ifindex : 0;
+ fpm_mac->svi_if = svi_if ? svi_if->ifindex : 0;
+
+ UNSET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_DELETE_FPM);
+ SET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM);
+ } else {
+ /*
+ * New op is "delete". Previous op is "add".
+ * Thus, no-op. Unset ZEBRA_MAC_UPDATE_FPM flag.
+ */
+ SET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_DELETE_FPM);
+ UNSET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM);
+ }
+
+ return 0;
+ }
+
+ fpm_mac = hash_get(zfpm_g->fpm_mac_info_table, &key,
+ zfpm_mac_info_alloc);
+ if (!fpm_mac)
+ return 0;
+
+ fpm_mac->zebra_flags = rmac->flags;
+ fpm_mac->vxlan_if = vxlan_if ? vxlan_if->ifindex : 0;
+ fpm_mac->svi_if = svi_if ? svi_if->ifindex : 0;
+
+ SET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM);
+ if (delete)
+ SET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_DELETE_FPM);
+
+ TAILQ_INSERT_TAIL(&zfpm_g->mac_q, fpm_mac, fpm_mac_q_entries);
+
+ zfpm_g->stats.updates_triggered++;
+
+ /* If writes are already enabled, return. */
+ if (zfpm_g->t_write)
+ return 0;
+
+ zfpm_write_on();
+ return 0;
+}
+
+/*
+ * This function is called when the FPM connections is established.
+ * Iterate over all the RMAC entries for the given L3VNI
+ * and enqueue the RMAC for FPM processing.
+ */
+static void zfpm_trigger_rmac_update_wrapper(struct hash_backet *backet,
+ void *args)
+{
+ zebra_mac_t *zrmac = (zebra_mac_t *)backet->data;
+ zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)args;
+
+ zfpm_trigger_rmac_update(zrmac, zl3vni, false, "RMAC added");
+}
+
+/*
+ * This function is called when the FPM connections is established.
+ * This function iterates over all the L3VNIs to trigger
+ * FPM updates for RMACs currently available.
+ */
+static void zfpm_iterate_rmac_table(struct hash_backet *backet, void *args)
+{
+ zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)backet->data;
+
+ hash_iterate(zl3vni->rmac_table, zfpm_trigger_rmac_update_wrapper,
+ (void *)zl3vni);
+}
+
+/*
* zfpm_stats_timer_cb
*/
static int zfpm_stats_timer_cb(struct thread *t)
@@ -1589,6 +1983,13 @@ static int zfpm_init(struct thread_master *master)
memset(zfpm_g, 0, sizeof(*zfpm_g));
zfpm_g->master = master;
TAILQ_INIT(&zfpm_g->dest_q);
+ TAILQ_INIT(&zfpm_g->mac_q);
+
+ /* Create hash table for fpm_mac_info_t enties */
+ zfpm_g->fpm_mac_info_table = hash_create(zfpm_mac_info_hash_keymake,
+ zfpm_mac_info_cmp,
+ "FPM MAC info hash table");
+
zfpm_g->sock = -1;
zfpm_g->state = ZFPM_STATE_IDLE;
@@ -1631,6 +2032,7 @@ static int zfpm_init(struct thread_master *master)
static int zebra_fpm_module_init(void)
{
hook_register(rib_update, zfpm_trigger_update);
+ hook_register(zebra_rmac_update, zfpm_trigger_rmac_update);
hook_register(frr_late_init, zfpm_init);
return 0;
}
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
index 2ac79b100..d5479bc62 100644
--- a/zebra/zebra_fpm_netlink.c
+++ b/zebra/zebra_fpm_netlink.c
@@ -580,4 +580,67 @@ int zfpm_netlink_encode_route(int cmd, rib_dest_t *dest, struct route_entry *re,
return netlink_route_info_encode(ri, in_buf, in_buf_len);
}
+/*
+ * zfpm_netlink_encode_mac
+ *
+ * Create a netlink message corresponding to the given MAC.
+ *
+ * Returns the number of bytes written to the buffer. 0 or a negative
+ * value indicates an error.
+ */
+int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf,
+ size_t in_buf_len)
+{
+ char buf1[ETHER_ADDR_STRLEN];
+ size_t buf_offset;
+
+ struct macmsg {
+ struct nlmsghdr hdr;
+ struct ndmsg ndm;
+ char buf[0];
+ } *req;
+ req = (void *)in_buf;
+
+ buf_offset = offsetof(struct macmsg, buf);
+ if (in_buf_len < buf_offset)
+ return 0;
+ memset(req, 0, buf_offset);
+
+ /* Construct nlmsg header */
+ req->hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg));
+ req->hdr.nlmsg_type = CHECK_FLAG(mac->fpm_flags, ZEBRA_MAC_DELETE_FPM) ?
+ RTM_DELNEIGH : RTM_NEWNEIGH;
+ req->hdr.nlmsg_flags = NLM_F_REQUEST;
+ if (req->hdr.nlmsg_type == RTM_NEWNEIGH)
+ req->hdr.nlmsg_flags |= (NLM_F_CREATE | NLM_F_REPLACE);
+
+ /* Construct ndmsg */
+ req->ndm.ndm_family = AF_BRIDGE;
+ req->ndm.ndm_ifindex = mac->vxlan_if;
+
+ req->ndm.ndm_state = NUD_REACHABLE;
+ req->ndm.ndm_flags |= NTF_SELF | NTF_MASTER;
+ if (CHECK_FLAG(mac->zebra_flags,
+ (ZEBRA_MAC_STICKY | ZEBRA_MAC_REMOTE_DEF_GW)))
+ req->ndm.ndm_state |= NUD_NOARP;
+ else
+ req->ndm.ndm_flags |= NTF_EXT_LEARNED;
+
+ /* Add attributes */
+ addattr_l(&req->hdr, in_buf_len, NDA_LLADDR, &mac->macaddr, 6);
+ addattr_l(&req->hdr, in_buf_len, NDA_DST, &mac->r_vtep_ip, 4);
+ addattr32(&req->hdr, in_buf_len, NDA_MASTER, mac->svi_if);
+ addattr32(&req->hdr, in_buf_len, NDA_VNI, mac->vni);
+
+ assert(req->hdr.nlmsg_len < in_buf_len);
+
+ zfpm_debug("Tx %s family %s ifindex %u MAC %s DEST %s",
+ nl_msg_type_to_str(req->hdr.nlmsg_type),
+ nl_family_to_str(req->ndm.ndm_family), req->ndm.ndm_ifindex,
+ prefix_mac2str(&mac->macaddr, buf1, sizeof(buf1)),
+ inet_ntoa(mac->r_vtep_ip));
+
+ return req->hdr.nlmsg_len;
+}
+
#endif /* HAVE_NETLINK */
diff --git a/zebra/zebra_fpm_private.h b/zebra/zebra_fpm_private.h
index 943aad986..c169ee8c2 100644
--- a/zebra/zebra_fpm_private.h
+++ b/zebra/zebra_fpm_private.h
@@ -53,6 +53,34 @@ static inline void zfpm_debug(const char *format, ...)
}
#endif
+/* This structure contains the MAC addresses enqueued for FPM processing. */
+struct fpm_mac_info_t {
+ struct ethaddr macaddr;
+ uint32_t zebra_flags; /* Could be used to build FPM messages */
+ vni_t vni;
+ ifindex_t vxlan_if;
+ ifindex_t svi_if; /* L2 or L3 Bridge interface */
+ struct in_addr r_vtep_ip; /* Remote VTEP IP */
+
+ /* Linkage to put MAC on the FPM processing queue. */
+ TAILQ_ENTRY(fpm_mac_info_t) fpm_mac_q_entries;
+
+ uint8_t fpm_flags;
+
+#define ZEBRA_MAC_UPDATE_FPM 0x1 /* This flag indicates if we want to upadte
+ * data plane for this MAC. If a MAC is added
+ * and then deleted immediately, we do not want
+ * to update data plane for such operation.
+ * Unset the ZEBRA_MAC_UPDATE_FPM flag in this
+ * case. FPM thread while processing the queue
+ * node will check this flag and dequeue the
+ * node silently without sending any update to
+ * the data plane.
+ */
+#define ZEBRA_MAC_DELETE_FPM 0x2 /* This flag is set if it is a delete operation
+ * for the MAC.
+ */
+};
/*
* Externs
@@ -64,6 +92,9 @@ extern int zfpm_netlink_encode_route(int cmd, rib_dest_t *dest,
extern int zfpm_protobuf_encode_route(rib_dest_t *dest, struct route_entry *re,
uint8_t *in_buf, size_t in_buf_len);
+extern int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf,
+ size_t in_buf_len);
+
extern struct route_entry *zfpm_route_for_update(rib_dest_t *dest);
#ifdef __cplusplus
diff --git a/zebra/zebra_memory.c b/zebra/zebra_memory.c
index ee041b1c3..a9c2c5fe5 100644
--- a/zebra/zebra_memory.c
+++ b/zebra/zebra_memory.c
@@ -26,11 +26,5 @@
#include "zebra_memory.h"
DEFINE_MGROUP(ZEBRA, "zebra")
-DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix")
-DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
DEFINE_MTYPE(ZEBRA, RE, "Route Entry")
-DEFINE_MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue")
-DEFINE_MTYPE(ZEBRA, STATIC_ROUTE, "Static route")
DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination")
-DEFINE_MTYPE(ZEBRA, RIB_TABLE_INFO, "RIB table info")
-DEFINE_MTYPE(ZEBRA, RNH, "Nexthop tracking object")
diff --git a/zebra/zebra_memory.h b/zebra/zebra_memory.h
index 667c73b22..e15f97249 100644
--- a/zebra/zebra_memory.h
+++ b/zebra/zebra_memory.h
@@ -29,17 +29,9 @@ extern "C" {
#endif
DECLARE_MGROUP(ZEBRA)
-DECLARE_MTYPE(RTADV_PREFIX)
DECLARE_MTYPE(ZEBRA_NS)
-DECLARE_MTYPE(ZEBRA_VRF)
DECLARE_MTYPE(RE)
-DECLARE_MTYPE(RIB_QUEUE)
-DECLARE_MTYPE(STATIC_ROUTE)
DECLARE_MTYPE(RIB_DEST)
-DECLARE_MTYPE(RIB_TABLE_INFO)
-DECLARE_MTYPE(RNH)
-DECLARE_MTYPE(DP_CTX)
-DECLARE_MTYPE(DP_PROV)
#ifdef __cplusplus
}
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index cc614abac..555bec959 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -744,9 +744,10 @@ void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq)
if (IS_ZEBRA_DEBUG_NHT_DETAILED) {
char buf[PREFIX_STRLEN];
- zlog_debug("%s: %s Being examined for Nexthop Tracking",
+ zlog_debug("%s: %s Being examined for Nexthop Tracking Count: %zd",
__PRETTY_FUNCTION__,
- srcdest_rnode2str(rn, buf, sizeof(buf)));
+ srcdest_rnode2str(rn, buf, sizeof(buf)),
+ dest ? rnh_list_count(&dest->nht) : 0);
}
if (!dest) {
rn = rn->parent;
@@ -760,7 +761,7 @@ void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq)
* nht resolution and as such we need to call the
* nexthop tracking evaluation code
*/
- frr_each (rnh_list, &dest->nht, rnh) {
+ frr_each_safe(rnh_list, &dest->nht, rnh) {
struct zebra_vrf *zvrf =
zebra_vrf_lookup_by_id(rnh->vrf_id);
struct prefix *p = &rnh->node->p;
@@ -769,11 +770,12 @@ void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq)
char buf1[PREFIX_STRLEN];
char buf2[PREFIX_STRLEN];
- zlog_debug("%u:%s has Nexthop(%s) depending on it, evaluating %u:%u",
+ zlog_debug("%u:%s has Nexthop(%s) Type: %s depending on it, evaluating %u:%u",
zvrf->vrf->vrf_id,
srcdest_rnode2str(rn, buf1,
sizeof(buf1)),
prefix2str(p, buf2, sizeof(buf2)),
+ rnh_type2str(rnh->type),
seq, rnh->seqno);
}
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 1024f3a05..5f397eb8c 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -50,6 +50,8 @@
#include "zebra/zebra_memory.h"
#include "zebra/zebra_errors.h"
+DEFINE_MTYPE_STATIC(ZEBRA, RNH, "Nexthop tracking object")
+
static void free_state(vrf_id_t vrf_id, struct route_entry *re,
struct route_node *rn);
static void copy_state(struct rnh *rnh, struct route_entry *re,
@@ -160,14 +162,15 @@ struct rnh *zebra_add_rnh(struct prefix *p, vrf_id_t vrfid, rnh_type_t type,
if (IS_ZEBRA_DEBUG_NHT) {
prefix2str(p, buf, sizeof(buf));
- zlog_debug("%u: Add RNH %s type %d", vrfid, buf, type);
+ zlog_debug("%u: Add RNH %s type %s", vrfid, buf,
+ rnh_type2str(type));
}
table = get_rnh_table(vrfid, afi, type);
if (!table) {
prefix2str(p, buf, sizeof(buf));
flog_warn(EC_ZEBRA_RNH_NO_TABLE,
- "%u: Add RNH %s type %d - table not found", vrfid,
- buf, type);
+ "%u: Add RNH %s type %s - table not found", vrfid,
+ buf, rnh_type2str(type));
exists = false;
return NULL;
}
@@ -271,8 +274,8 @@ static void zebra_delete_rnh(struct rnh *rnh, rnh_type_t type)
if (IS_ZEBRA_DEBUG_NHT) {
char buf[PREFIX2STR_BUFFER];
- zlog_debug("%u: Del RNH %s type %d", rnh->vrf_id,
- rnh_str(rnh, buf, sizeof(buf)), type);
+ zlog_debug("%u: Del RNH %s type %s", rnh->vrf_id,
+ rnh_str(rnh, buf, sizeof(buf)), rnh_type2str(type));
}
zebra_free_rnh(rnh);
@@ -293,9 +296,9 @@ void zebra_add_rnh_client(struct rnh *rnh, struct zserv *client,
{
if (IS_ZEBRA_DEBUG_NHT) {
char buf[PREFIX2STR_BUFFER];
- zlog_debug("%u: Client %s registers for RNH %s type %d", vrf_id,
+ zlog_debug("%u: Client %s registers for RNH %s type %s", vrf_id,
zebra_route_string(client->proto),
- rnh_str(rnh, buf, sizeof(buf)), type);
+ rnh_str(rnh, buf, sizeof(buf)), rnh_type2str(type));
}
if (!listnode_lookup(rnh->client_list, client))
listnode_add(rnh->client_list, client);
@@ -312,9 +315,9 @@ void zebra_remove_rnh_client(struct rnh *rnh, struct zserv *client,
{
if (IS_ZEBRA_DEBUG_NHT) {
char buf[PREFIX2STR_BUFFER];
- zlog_debug("Client %s unregisters for RNH %s type %d",
+ zlog_debug("Client %s unregisters for RNH %s type %s",
zebra_route_string(client->proto),
- rnh_str(rnh, buf, sizeof(buf)), type);
+ rnh_str(rnh, buf, sizeof(buf)), rnh_type2str(type));
}
listnode_delete(rnh->client_list, client);
zebra_delete_rnh(rnh, type);
@@ -803,8 +806,8 @@ static void zebra_rnh_evaluate_entry(struct zebra_vrf *zvrf, afi_t afi,
if (IS_ZEBRA_DEBUG_NHT) {
prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN);
- zlog_debug("%u:%s: Evaluate RNH, type %d %s", zvrf->vrf->vrf_id,
- bufn, type, force ? "(force)" : "");
+ zlog_debug("%u:%s: Evaluate RNH, type %s %s", zvrf->vrf->vrf_id,
+ bufn, rnh_type2str(type), force ? "(force)" : "");
}
rnh = nrn->info;
@@ -1156,9 +1159,9 @@ static int zebra_cleanup_rnh_client(vrf_id_t vrf_id, afi_t afi,
struct rnh *rnh;
if (IS_ZEBRA_DEBUG_NHT)
- zlog_debug("%u: Client %s RNH cleanup for family %s type %d",
+ zlog_debug("%u: Client %s RNH cleanup for family %s type %s",
vrf_id, zebra_route_string(client->proto),
- afi2str(afi), type);
+ afi2str(afi), rnh_type2str(type));
ntable = get_rnh_table(vrf_id, afi, type);
if (!ntable) {
diff --git a/zebra/zebra_rnh.h b/zebra/zebra_rnh.h
index 95a394118..c7d2c0d29 100644
--- a/zebra/zebra_rnh.h
+++ b/zebra/zebra_rnh.h
@@ -43,6 +43,18 @@ static inline int rnh_resolve_via_default(int family)
return 0;
}
+static inline const char *rnh_type2str(rnh_type_t type)
+{
+ switch (type) {
+ case RNH_NEXTHOP_TYPE:
+ return "Nexthop";
+ case RNH_IMPORT_CHECK_TYPE:
+ return "Import";
+ }
+
+ return "ERROR";
+}
+
extern struct rnh *zebra_add_rnh(struct prefix *p, vrf_id_t vrfid,
rnh_type_t type, bool *exists);
extern struct rnh *zebra_lookup_rnh(struct prefix *p, vrf_id_t vrfid,
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index dbfe695a0..2f7d50541 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -1254,6 +1254,40 @@ static struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = {
route_match_address_prefix_list_compile,
route_match_address_prefix_list_free};
+/* `match ipv6 next-hop type <TYPE>' */
+
+static route_map_result_t
+route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ struct nh_rmap_obj *nh_data;
+
+ if (type == RMAP_ZEBRA && prefix->family == AF_INET6) {
+ nh_data = (struct nh_rmap_obj *)object;
+ if (!nh_data)
+ return RMAP_DENYMATCH;
+
+ if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
+ return RMAP_MATCH;
+ }
+ return RMAP_NOMATCH;
+}
+
+static void *route_match_ipv6_next_hop_type_compile(const char *arg)
+{
+ return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+}
+
+static void route_match_ipv6_next_hop_type_free(void *rule)
+{
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+struct route_map_rule_cmd route_match_ipv6_next_hop_type_cmd = {
+ "ipv6 next-hop type", route_match_ipv6_next_hop_type,
+ route_match_ipv6_next_hop_type_compile,
+ route_match_ipv6_next_hop_type_free};
+
/* `match ip address prefix-len PREFIXLEN' */
static route_map_result_t
@@ -1345,6 +1379,40 @@ static struct route_map_rule_cmd route_match_ip_nexthop_prefix_len_cmd = {
route_match_address_prefix_len_free /* reuse */
};
+/* `match ip next-hop type <blackhole>' */
+
+static route_map_result_t
+route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ struct nh_rmap_obj *nh_data;
+
+ if (type == RMAP_ZEBRA && prefix->family == AF_INET) {
+ nh_data = (struct nh_rmap_obj *)object;
+ if (!nh_data)
+ return RMAP_DENYMATCH;
+
+ if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
+ return RMAP_MATCH;
+ }
+ return RMAP_NOMATCH;
+}
+
+static void *route_match_ip_next_hop_type_compile(const char *arg)
+{
+ return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+}
+
+static void route_match_ip_next_hop_type_free(void *rule)
+{
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+static struct route_map_rule_cmd route_match_ip_next_hop_type_cmd = {
+ "ip next-hop type", route_match_ip_next_hop_type,
+ route_match_ip_next_hop_type_compile,
+ route_match_ip_next_hop_type_free};
+
/* `match source-protocol PROTOCOL' */
static route_map_result_t route_match_source_protocol(void *rule,
@@ -1927,6 +1995,9 @@ void zebra_route_map_init(void)
route_map_match_ip_next_hop_prefix_list_hook(generic_match_add);
route_map_no_match_ip_next_hop_prefix_list_hook(generic_match_delete);
+ route_map_match_ip_next_hop_type_hook(generic_match_add);
+ route_map_no_match_ip_next_hop_type_hook(generic_match_delete);
+
route_map_match_tag_hook(generic_match_add);
route_map_no_match_tag_hook(generic_match_delete);
@@ -1936,6 +2007,9 @@ void zebra_route_map_init(void)
route_map_match_ipv6_address_prefix_list_hook(generic_match_add);
route_map_no_match_ipv6_address_prefix_list_hook(generic_match_delete);
+ route_map_match_ipv6_next_hop_type_hook(generic_match_add);
+ route_map_no_match_ipv6_next_hop_type_hook(generic_match_delete);
+
route_map_install_match(&route_match_tag_cmd);
route_map_install_match(&route_match_interface_cmd);
route_map_install_match(&route_match_ip_next_hop_cmd);
@@ -1947,6 +2021,8 @@ void zebra_route_map_init(void)
route_map_install_match(&route_match_ip_address_prefix_len_cmd);
route_map_install_match(&route_match_ipv6_address_prefix_len_cmd);
route_map_install_match(&route_match_ip_nexthop_prefix_len_cmd);
+ route_map_install_match(&route_match_ip_next_hop_type_cmd);
+ route_map_install_match(&route_match_ipv6_next_hop_type_cmd);
route_map_install_match(&route_match_source_protocol_cmd);
route_map_install_match(&route_match_source_instance_cmd);
diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c
index 4352d688a..1e9f9e4ec 100644
--- a/zebra/zebra_router.c
+++ b/zebra/zebra_router.c
@@ -32,6 +32,8 @@
#include "zebra_nhg.h"
#include "debug.h"
+DEFINE_MTYPE_STATIC(ZEBRA, RIB_TABLE_INFO, "RIB table info")
+
struct zebra_router zrouter = {
.multipath_num = MULTIPATH_NUM,
.ipv4_multicast_mode = MCAST_NO_CONFIG,
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index fdf0cbc69..fcc94a7be 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -48,7 +48,8 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
static void zebra_rnhtable_node_cleanup(struct route_table *table,
struct route_node *node);
-DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table");
+DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
+DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table")
/* VRF information update. */
static void zebra_vrf_add_update(struct zebra_vrf *zvrf)
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 71d61e4c1..a38d060bd 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -2171,7 +2171,7 @@ DEFPY (show_evpn_mac_vni_all_dad,
DEFPY (show_evpn_mac_vni_dad,
show_evpn_mac_vni_dad_cmd,
- "show evpn mac vni " CMD_VNI_RANGE " duplicate" "[json]",
+ "show evpn mac vni " CMD_VNI_RANGE " duplicate [json]",
SHOW_STR
"EVPN\n"
"MAC addresses\n"
@@ -2181,10 +2181,8 @@ DEFPY (show_evpn_mac_vni_dad,
JSON_STR)
{
struct zebra_vrf *zvrf;
- vni_t vni;
bool uj = use_json(argc, argv);
- vni = strtoul(argv[4]->arg, NULL, 10);
zvrf = zebra_vrf_get_evpn();
zebra_vxlan_print_macs_vni_dad(vty, zvrf, vni, uj);
@@ -2194,7 +2192,7 @@ DEFPY (show_evpn_mac_vni_dad,
DEFPY (show_evpn_neigh_vni_dad,
show_evpn_neigh_vni_dad_cmd,
- "show evpn arp-cache vni " CMD_VNI_RANGE "duplicate" "[json]",
+ "show evpn arp-cache vni " CMD_VNI_RANGE "duplicate [json]",
SHOW_STR
"EVPN\n"
"ARP and ND cache\n"
@@ -2204,10 +2202,8 @@ DEFPY (show_evpn_neigh_vni_dad,
JSON_STR)
{
struct zebra_vrf *zvrf;
- vni_t vni;
bool uj = use_json(argc, argv);
- vni = strtoul(argv[4]->arg, NULL, 10);
zvrf = zebra_vrf_get_evpn();
zebra_vxlan_print_neigh_vni_dad(vty, zvrf, vni, uj);
return CMD_SUCCESS;
@@ -2386,7 +2382,7 @@ DEFUN (show_pbr_iptable,
DEFPY (clear_evpn_dup_addr,
clear_evpn_dup_addr_cmd,
- "clear evpn dup-addr vni <all$vni_all |" CMD_VNI_RANGE"$vni_val [mac M:A:C$mac_val | ip <A.B.C.D|X:X::X:X>]>",
+ "clear evpn dup-addr vni <all$vni_all |" CMD_VNI_RANGE"$vni [mac M:A:C$mac_val | ip <A.B.C.D|X:X::X:X>]>",
CLEAR_STR
"EVPN\n"
"Duplicate address \n"
@@ -2400,15 +2396,12 @@ DEFPY (clear_evpn_dup_addr,
"IPv6 address\n")
{
struct zebra_vrf *zvrf;
- vni_t vni = 0;
struct ipaddr host_ip = {.ipa_type = IPADDR_NONE };
struct ethaddr mac_addr;
int ret = CMD_SUCCESS;
zvrf = zebra_vrf_get_evpn();
- if (vni_val) {
- vni = strtoul(vni_val, NULL, 10);
-
+ if (vni_str) {
if (mac_val) {
prefix_str2mac(mac_val, &mac_addr);
ret = zebra_vxlan_clear_dup_detect_vni_mac(vty, zvrf,
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 99e2f9b17..c058fdce6 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -60,6 +60,9 @@ DEFINE_MTYPE_STATIC(ZEBRA, MAC, "VNI MAC");
DEFINE_MTYPE_STATIC(ZEBRA, NEIGH, "VNI Neighbor");
DEFINE_MTYPE_STATIC(ZEBRA, ZVXLAN_SG, "zebra VxLAN multicast group");
+DEFINE_HOOK(zebra_rmac_update, (zebra_mac_t *rmac, zebra_l3vni_t *zl3vni,
+ bool delete, const char *reason), (rmac, zl3vni, delete, reason))
+
/* definitions */
/* PMSI strings. */
#define VXLAN_FLOOD_STR_NO_INFO "-"
@@ -143,8 +146,6 @@ static zebra_l3vni_t *zl3vni_lookup(vni_t vni);
static void *zl3vni_alloc(void *p);
static zebra_l3vni_t *zl3vni_add(vni_t vni, vrf_id_t vrf_id);
static int zl3vni_del(zebra_l3vni_t *zl3vni);
-static struct interface *zl3vni_map_to_svi_if(zebra_l3vni_t *zl3vni);
-static struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni);
static void zebra_vxlan_process_l3vni_oper_up(zebra_l3vni_t *zl3vni);
static void zebra_vxlan_process_l3vni_oper_down(zebra_l3vni_t *zl3vni);
@@ -1386,7 +1387,9 @@ static void zvni_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
vty_out(vty, " %-5u", vid);
else
json_object_int_add(json_mac, "vlan", vid);
- }
+ } else /* No vid? fill out the space */
+ vty_out(vty, " %-5s", "");
+ vty_out(vty, " %u/%u", mac->loc_seq, mac->rem_seq);
if (json_mac_hdr == NULL) {
vty_out(vty, "\n");
} else {
@@ -1418,11 +1421,13 @@ static void zvni_print_mac_hash(struct hash_bucket *bucket, void *ctxt)
if ((wctx->flags & SHOW_REMOTE_MAC_FROM_VTEP) &&
(wctx->count == 0)) {
vty_out(vty, "\nVNI %u\n\n", wctx->zvni->vni);
- vty_out(vty, "%-17s %-6s %-21s %-5s\n", "MAC",
- "Type", "Intf/Remote VTEP", "VLAN");
+ vty_out(vty, "%-17s %-6s %-21s %-5s %s\n",
+ "MAC", "Type", "Intf/Remote VTEP",
+ "VLAN", "Seq #'s");
}
- vty_out(vty, "%-17s %-6s %-21s\n", buf1, "remote",
- inet_ntoa(mac->fwd_info.r_vtep_ip));
+ vty_out(vty, "%-17s %-6s %-21s %-5s %u/%u\n", buf1,
+ "remote", inet_ntoa(mac->fwd_info.r_vtep_ip),
+ "", mac->loc_seq, mac->rem_seq);
} else {
json_object_string_add(json_mac, "type", "remote");
json_object_string_add(json_mac, "remoteVtep",
@@ -1536,8 +1541,8 @@ static void zvni_print_mac_hash_all_vni(struct hash_bucket *bucket, void *ctxt)
if (json == NULL) {
vty_out(vty, "\nVNI %u #MACs (local and remote) %u\n\n",
zvni->vni, num_macs);
- vty_out(vty, "%-17s %-6s %-21s %-5s\n", "MAC", "Type",
- "Intf/Remote VTEP", "VLAN");
+ vty_out(vty, "%-17s %-6s %-21s %-5s %s\n", "MAC",
+ "Type", "Intf/Remote VTEP", "VLAN", "Seq #'s");
} else
json_object_int_add(json_vni, "numMacs", num_macs);
}
@@ -4460,6 +4465,10 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,
memset(&zrmac->fwd_info, 0, sizeof(zrmac->fwd_info));
zrmac->fwd_info.r_vtep_ip = vtep_ip->ipaddr_v4;
+ /* Send RMAC for FPM processing */
+ hook_call(zebra_rmac_update, zrmac, zl3vni, false,
+ "new RMAC added");
+
/* install rmac in kernel */
zl3vni_rmac_install(zl3vni, zrmac);
}
@@ -4480,6 +4489,10 @@ static void zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac,
/* uninstall from kernel */
zl3vni_rmac_uninstall(zl3vni, zrmac);
+ /* Send RMAC for FPM processing */
+ hook_call(zebra_rmac_update, zrmac, zl3vni, true,
+ "RMAC deleted");
+
/* del the rmac entry */
zl3vni_rmac_del(zl3vni, zrmac);
}
@@ -4791,7 +4804,7 @@ static int zl3vni_del(zebra_l3vni_t *zl3vni)
return 0;
}
-static struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni)
+struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni)
{
struct zebra_ns *zns = NULL;
struct route_node *rn = NULL;
@@ -4822,7 +4835,7 @@ static struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni)
return NULL;
}
-static struct interface *zl3vni_map_to_svi_if(zebra_l3vni_t *zl3vni)
+struct interface *zl3vni_map_to_svi_if(zebra_l3vni_t *zl3vni)
{
struct zebra_if *zif = NULL; /* zebra_if for vxlan_if */
struct zebra_l2info_vxlan *vxl = NULL; /* l2 info for vxlan_if */
@@ -5090,6 +5103,10 @@ static void zl3vni_del_rmac_hash_entry(struct hash_bucket *bucket, void *ctx)
zrmac = (zebra_mac_t *)bucket->data;
zl3vni = (zebra_l3vni_t *)ctx;
zl3vni_rmac_uninstall(zl3vni, zrmac);
+
+ /* Send RMAC for FPM processing */
+ hook_call(zebra_rmac_update, zrmac, zl3vni, true, "RMAC deleted");
+
zl3vni_rmac_del(zl3vni, zrmac);
}
diff --git a/zebra/zebra_vxlan_private.h b/zebra/zebra_vxlan_private.h
index 1dd42b708..8e7804264 100644
--- a/zebra/zebra_vxlan_private.h
+++ b/zebra/zebra_vxlan_private.h
@@ -431,6 +431,12 @@ struct nh_walk_ctx {
};
extern zebra_l3vni_t *zl3vni_from_vrf(vrf_id_t vrf_id);
+extern struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni);
+extern struct interface *zl3vni_map_to_svi_if(zebra_l3vni_t *zl3vni);
+
+DECLARE_HOOK(zebra_rmac_update, (zebra_mac_t *rmac, zebra_l3vni_t *zl3vni,
+ bool delete, const char *reason), (rmac, zl3vni, delete, reason))
+
#ifdef __cplusplus
}
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 49fb302ba..cb9ca6578 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -1067,10 +1067,8 @@ DEFUN (show_zebra_client_summary,
void zserv_read_file(char *input)
{
int fd;
- struct thread t;
fd = open(input, O_RDONLY | O_NONBLOCK);
- t.u.fd = fd;
zserv_client_create(fd);
}