summaryrefslogtreecommitdiff
path: root/zebra/zebra_vxlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vxlan.c')
-rw-r--r--zebra/zebra_vxlan.c849
1 files changed, 376 insertions, 473 deletions
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 20b9e94288..256fa9e4b7 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -58,9 +58,8 @@ DEFINE_MTYPE_STATIC(ZEBRA, NEIGH, "VNI Neighbor");
/* static function declarations */
-static int ip_prefix_send_to_client(vrf_id_t vrf_id,
- struct prefix *p,
- uint16_t cmd);
+static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p,
+ uint16_t cmd);
static void zvni_print_neigh(zebra_neigh_t *n, void *ctxt, json_object *json);
static void zvni_print_neigh_hash(struct hash_backet *backet, void *ctxt);
static void zvni_print_neigh_hash_all_vni(struct hash_backet *backet,
@@ -75,8 +74,7 @@ static void zvni_print_mac_hash_all_vni(struct hash_backet *backet, void *ctxt);
static void zvni_print(zebra_vni_t *zvni, void **ctxt);
static void zvni_print_hash(struct hash_backet *backet, void *ctxt[]);
-static int zvni_macip_send_msg_to_client(vni_t vni,
- struct ethaddr *macaddr,
+static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,
struct ipaddr *ip, u_char flags,
u_int16_t cmd);
static unsigned int neigh_hash_keymake(void *p);
@@ -88,21 +86,18 @@ static int zvni_neigh_del(zebra_vni_t *zvni, zebra_neigh_t *n);
static int zvni_neigh_del_hash_entry(struct hash_backet *backet, void *arg);
static void zvni_neigh_del_from_vtep(zebra_vni_t *zvni, int uninstall,
struct in_addr *r_vtep_ip);
-static void zvni_neigh_del_all(zebra_vni_t *zvni,
- int uninstall, int upd_client, u_int32_t flags);
+static void zvni_neigh_del_all(zebra_vni_t *zvni, int uninstall, int upd_client,
+ u_int32_t flags);
static zebra_neigh_t *zvni_neigh_lookup(zebra_vni_t *zvni, struct ipaddr *ip);
-static int zvni_neigh_send_add_to_client(vni_t vni,
- struct ipaddr *ip,
+static int zvni_neigh_send_add_to_client(vni_t vni, struct ipaddr *ip,
struct ethaddr *macaddr, u_char flags);
-static int zvni_neigh_send_del_to_client(vni_t vni,
- struct ipaddr *ip,
+static int zvni_neigh_send_del_to_client(vni_t vni, struct ipaddr *ip,
struct ethaddr *macaddr, u_char flags);
static int zvni_neigh_install(zebra_vni_t *zvni, zebra_neigh_t *n);
static int zvni_neigh_uninstall(zebra_vni_t *zvni, zebra_neigh_t *n);
static zebra_vni_t *zvni_from_svi(struct interface *ifp,
- struct interface *br_if);
-static struct interface *zvni_map_to_svi(vlanid_t vid,
- struct interface *br_if);
+ struct interface *br_if);
+static struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);
/* l3-vni next-hop neigh related APIs */
static zebra_neigh_t *zl3vni_nh_lookup(zebra_l3vni_t *zl3vni,
@@ -124,8 +119,7 @@ static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni,
struct ethaddr *rmac);
static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac);
static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac);
-static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni,
- zebra_mac_t *zrmac);
+static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac);
/* l3-vni related APIs*/
static zebra_l3vni_t *zl3vni_lookup(vni_t vni);
@@ -146,13 +140,13 @@ static int zvni_mac_del(zebra_vni_t *zvni, zebra_mac_t *mac);
static int zvni_mac_del_hash_entry(struct hash_backet *backet, void *arg);
static void zvni_mac_del_from_vtep(zebra_vni_t *zvni, int uninstall,
struct in_addr *r_vtep_ip);
-static void zvni_mac_del_all(zebra_vni_t *zvni,
- int uninstall, int upd_client, u_int32_t flags);
+static void zvni_mac_del_all(zebra_vni_t *zvni, int uninstall, int upd_client,
+ u_int32_t flags);
static zebra_mac_t *zvni_mac_lookup(zebra_vni_t *zvni, struct ethaddr *macaddr);
-static int zvni_mac_send_add_to_client(vni_t vni,
- struct ethaddr *macaddr, u_char flags);
-static int zvni_mac_send_del_to_client(vni_t vni,
- struct ethaddr *macaddr, u_char flags);
+static int zvni_mac_send_add_to_client(vni_t vni, struct ethaddr *macaddr,
+ u_char flags);
+static int zvni_mac_send_del_to_client(vni_t vni, struct ethaddr *macaddr,
+ u_char flags);
static zebra_vni_t *zvni_map_vlan(struct interface *ifp,
struct interface *br_if, vlanid_t vid);
static int zvni_mac_install(zebra_vni_t *zvni, zebra_mac_t *mac);
@@ -434,8 +428,7 @@ static void zvni_print_neigh_hash_all_vni(struct hash_backet *backet,
}
/* print a specific next hop for an l3vni */
-static void zl3vni_print_nh(zebra_neigh_t *n,
- struct vty *vty,
+static void zl3vni_print_nh(zebra_neigh_t *n, struct vty *vty,
json_object *json)
{
char buf1[ETHER_ADDR_STRLEN];
@@ -448,7 +441,7 @@ static void zl3vni_print_nh(zebra_neigh_t *n,
vty_out(vty, "Ip: %s\n",
ipaddr2str(&n->ip, buf2, sizeof(buf2)));
vty_out(vty, " RMAC: %s\n",
- prefix_mac2str(&n->emac, buf1, sizeof(buf1)));
+ prefix_mac2str(&n->emac, buf1, sizeof(buf1)));
vty_out(vty, " Refcount: %d\n", listcount(n->host_list));
vty_out(vty, " Prefixes:\n");
for (ALL_LIST_ELEMENTS_RO(n->host_list, node, p))
@@ -456,25 +449,22 @@ static void zl3vni_print_nh(zebra_neigh_t *n,
prefix2str(p, buf2, sizeof(buf2)));
} else {
json_hosts = json_object_new_array();
- json_object_string_add(json, "ip",
- ipaddr2str(&(n->ip), buf2,
- sizeof(buf2)));
- json_object_string_add(json, "routerMac",
- prefix_mac2str(&n->emac, buf2,
- sizeof(buf2)));
+ json_object_string_add(
+ json, "ip", ipaddr2str(&(n->ip), buf2, sizeof(buf2)));
+ json_object_string_add(
+ json, "routerMac",
+ prefix_mac2str(&n->emac, buf2, sizeof(buf2)));
json_object_int_add(json, "refCount", listcount(n->host_list));
for (ALL_LIST_ELEMENTS_RO(n->host_list, node, p))
json_object_array_add(json_hosts,
- json_object_new_string(
- prefix2str(p, buf2,
- sizeof(buf2))));
+ json_object_new_string(prefix2str(
+ p, buf2, sizeof(buf2))));
json_object_object_add(json, "prefixList", json_hosts);
}
}
/* Print a specific RMAC entry */
-static void zl3vni_print_rmac(zebra_mac_t *zrmac,
- struct vty *vty,
+static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,
json_object *json)
{
char buf1[ETHER_ADDR_STRLEN];
@@ -495,19 +485,17 @@ static void zl3vni_print_rmac(zebra_mac_t *zrmac,
prefix2str(p, buf2, sizeof(buf2)));
} else {
json_hosts = json_object_new_array();
- json_object_string_add(json, "routerMac",
- prefix_mac2str(&zrmac->macaddr,
- buf1,
- sizeof(buf1)));
+ json_object_string_add(
+ json, "routerMac",
+ prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));
json_object_string_add(json, "vtepIp",
inet_ntoa(zrmac->fwd_info.r_vtep_ip));
json_object_int_add(json, "refCount",
listcount(zrmac->host_list));
for (ALL_LIST_ELEMENTS_RO(zrmac->host_list, node, p))
json_object_array_add(json_hosts,
- json_object_new_string(
- prefix2str(p, buf2,
- sizeof(buf2))));
+ json_object_new_string(prefix2str(
+ p, buf2, sizeof(buf2))));
json_object_object_add(json, "prefixList", json_hosts);
}
}
@@ -736,8 +724,7 @@ static void zvni_print_mac_hash_all_vni(struct hash_backet *backet, void *ctxt)
}
}
-static void zl3vni_print_nh_hash(struct hash_backet *backet,
- void *ctx)
+static void zl3vni_print_nh_hash(struct hash_backet *backet, void *ctx)
{
struct nh_walk_ctx *wctx = NULL;
struct vty *vty = NULL;
@@ -763,9 +750,9 @@ static void zl3vni_print_nh_hash(struct hash_backet *backet,
} else {
json_object_string_add(json_nh, "nexthopIp",
ipaddr2str(&n->ip, buf2, sizeof(buf2)));
- json_object_string_add(json_nh, "routerMac",
- prefix_mac2str(&n->emac, buf1,
- sizeof(buf1)));
+ json_object_string_add(
+ json_nh, "routerMac",
+ prefix_mac2str(&n->emac, buf1, sizeof(buf1)));
json_object_object_add(json_vni,
ipaddr2str(&(n->ip), buf2, sizeof(buf2)),
json_nh);
@@ -803,8 +790,7 @@ static void zl3vni_print_nh_hash_all_vni(struct hash_backet *backet,
}
if (json == NULL) {
- vty_out(vty, "\nVNI %u #Next-Hops %u\n\n",
- zl3vni->vni, num_nh);
+ vty_out(vty, "\nVNI %u #Next-Hops %u\n\n", zl3vni->vni, num_nh);
vty_out(vty, "%-15s %-17s\n", "IP", "RMAC");
} else
json_object_int_add(json_vni, "numNextHops", num_nh);
@@ -848,8 +834,7 @@ static void zl3vni_print_rmac_hash_all_vni(struct hash_backet *backet,
}
if (json == NULL) {
- vty_out(vty, "\nVNI %u #RMACs %u\n\n",
- zl3vni->vni, num_rmacs);
+ vty_out(vty, "\nVNI %u #RMACs %u\n\n", zl3vni->vni, num_rmacs);
vty_out(vty, "%-17s %-21s\n", "RMAC", "Remote VTEP");
} else
json_object_int_add(json_vni, "numRmacs", num_rmacs);
@@ -866,8 +851,7 @@ static void zl3vni_print_rmac_hash_all_vni(struct hash_backet *backet,
json_object_object_add(json, vni_str, json_vni);
}
-static void zl3vni_print_rmac_hash(struct hash_backet *backet,
- void *ctx)
+static void zl3vni_print_rmac_hash(struct hash_backet *backet, void *ctx)
{
zebra_mac_t *zrmac = NULL;
struct rmac_walk_ctx *wctx = NULL;
@@ -888,17 +872,16 @@ static void zl3vni_print_rmac_hash(struct hash_backet *backet,
if (!json) {
vty_out(vty, "%-17s %-21s\n",
prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
- inet_ntoa(zrmac->fwd_info.r_vtep_ip));
+ inet_ntoa(zrmac->fwd_info.r_vtep_ip));
} else {
- json_object_string_add(json_rmac, "routerMac",
- prefix_mac2str(&zrmac->macaddr, buf,
- sizeof(buf)));
+ json_object_string_add(
+ json_rmac, "routerMac",
+ prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)));
json_object_string_add(json_rmac, "vtepIp",
inet_ntoa(zrmac->fwd_info.r_vtep_ip));
- json_object_object_add(json,
- prefix_mac2str(&zrmac->macaddr, buf,
- sizeof(buf)),
- json_rmac);
+ json_object_object_add(
+ json, prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
+ json_rmac);
}
}
@@ -918,19 +901,17 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx)
if (!json) {
vty_out(vty, "VNI: %u\n", zl3vni->vni);
vty_out(vty, " Type: %s\n", "L3");
- vty_out(vty, " Tenant VRF: %s\n",
- zl3vni_vrf_name(zl3vni));
+ vty_out(vty, " Tenant VRF: %s\n", zl3vni_vrf_name(zl3vni));
vty_out(vty, " Local Vtep Ip: %s\n",
inet_ntoa(zl3vni->local_vtep_ip));
vty_out(vty, " Vxlan-Intf: %s\n",
zl3vni_vxlan_if_name(zl3vni));
- vty_out(vty, " SVI-If: %s\n",
- zl3vni_svi_if_name(zl3vni));
- vty_out(vty, " State: %s\n",
- zl3vni_state2str(zl3vni));
+ vty_out(vty, " SVI-If: %s\n", zl3vni_svi_if_name(zl3vni));
+ vty_out(vty, " State: %s\n", zl3vni_state2str(zl3vni));
vty_out(vty, " VNI Filter: %s\n",
- CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) ?
- "prefix-routes-only" : "none");
+ CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY)
+ ? "prefix-routes-only"
+ : "none");
vty_out(vty, " Router MAC: %s\n",
zl3vni_rmac2str(zl3vni, buf, sizeof(buf)));
vty_out(vty, " L2 VNIs: ");
@@ -947,17 +928,16 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx)
zl3vni_vxlan_if_name(zl3vni));
json_object_string_add(json, "sviIntf",
zl3vni_svi_if_name(zl3vni));
- json_object_string_add(json, "state",
- zl3vni_state2str(zl3vni));
- json_object_string_add(json, "vrf",
- zl3vni_vrf_name(zl3vni));
- json_object_string_add(json, "routerMac",
- zl3vni_rmac2str(zl3vni, buf,
- sizeof(buf)));
- json_object_string_add(json, "vniFilter",
- CHECK_FLAG(zl3vni->filter,
- PREFIX_ROUTES_ONLY) ?
- "prefix-routes-only" : "none");
+ json_object_string_add(json, "state", zl3vni_state2str(zl3vni));
+ json_object_string_add(json, "vrf", zl3vni_vrf_name(zl3vni));
+ json_object_string_add(
+ json, "routerMac",
+ zl3vni_rmac2str(zl3vni, buf, sizeof(buf)));
+ json_object_string_add(
+ json, "vniFilter",
+ CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY)
+ ? "prefix-routes-only"
+ : "none");
for (ALL_LIST_ELEMENTS(zl3vni->l2vnis, node, nnode, zvni)) {
json_object_array_add(json_vni_list,
json_object_new_int(zvni->vni));
@@ -1001,10 +981,9 @@ static void zvni_print(zebra_vni_t *zvni, void **ctxt)
num_macs = num_valid_macs(zvni);
num_neigh = hashcount(zvni->neigh_table);
if (json == NULL) {
- vty_out(vty, " VxLAN interface: %s\n",
- zvni->vxlan_if->name);
+ vty_out(vty, " VxLAN interface: %s\n", zvni->vxlan_if->name);
vty_out(vty, " VxLAN ifIndex: %u\n", zvni->vxlan_if->ifindex);
- vty_out(vty," Local VTEP IP: %s\n",
+ vty_out(vty, " Local VTEP IP: %s\n",
inet_ntoa(zvni->local_vtep_ip));
} else {
json_object_string_add(json, "vxlanInterface",
@@ -1054,8 +1033,7 @@ static void zvni_print(zebra_vni_t *zvni, void **ctxt)
}
/* print a L3 VNI hash entry */
-static void zl3vni_print_hash(struct hash_backet *backet,
- void *ctx[])
+static void zl3vni_print_hash(struct hash_backet *backet, void *ctx[])
{
struct vty *vty = NULL;
json_object *json = NULL;
@@ -1070,13 +1048,10 @@ static void zl3vni_print_hash(struct hash_backet *backet,
return;
if (!json) {
- vty_out(vty,
- "%-10u %-4s %-21s %-8lu %-8lu %-15s %-37s\n",
- zl3vni->vni, "L3",
- zl3vni_vxlan_if_name(zl3vni),
+ vty_out(vty, "%-10u %-4s %-21s %-8lu %-8lu %-15s %-37s\n",
+ zl3vni->vni, "L3", zl3vni_vxlan_if_name(zl3vni),
hashcount(zl3vni->rmac_table),
- hashcount(zl3vni->nh_table),
- "n/a",
+ hashcount(zl3vni->nh_table), "n/a",
zl3vni_vrf_name(zl3vni));
} else {
char vni_str[VNI_STR_LEN];
@@ -1096,7 +1071,6 @@ static void zl3vni_print_hash(struct hash_backet *backet,
zl3vni_vrf_name(zl3vni));
json_object_object_add(json, vni_str, json_vni);
}
-
}
/*
@@ -1131,8 +1105,7 @@ static void zvni_print_hash(struct hash_backet *backet, void *ctxt[])
num_macs = num_valid_macs(zvni);
num_neigh = hashcount(zvni->neigh_table);
if (json == NULL)
- vty_out(vty,
- "%-10u %-4s %-21s %-8u %-8u %-15u %-37s\n",
+ vty_out(vty, "%-10u %-4s %-21s %-8u %-8u %-15u %-37s\n",
zvni->vni, "L2",
zvni->vxlan_if ? zvni->vxlan_if->name : "unknown",
num_macs, num_neigh, num_vteps,
@@ -1169,8 +1142,7 @@ static void zvni_print_hash(struct hash_backet *backet, void *ctxt[])
/*
* Inform BGP about local MACIP.
*/
-static int zvni_macip_send_msg_to_client(vni_t vni,
- struct ethaddr *macaddr,
+static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,
struct ipaddr *ip, u_char flags,
u_int16_t cmd)
{
@@ -1185,8 +1157,7 @@ static int zvni_macip_send_msg_to_client(vni_t vni,
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, cmd, VRF_DEFAULT);
stream_putl(s, vni);
@@ -1213,8 +1184,8 @@ static int zvni_macip_send_msg_to_client(vni_t vni,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"Send MACIP %s flags 0x%x MAC %s IP %s L2-VNI %u to %s",
- (cmd == ZEBRA_MACIP_ADD) ? "Add" : "Del",
- flags, prefix_mac2str(macaddr, buf, sizeof(buf)),
+ (cmd == ZEBRA_MACIP_ADD) ? "Add" : "Del", flags,
+ prefix_mac2str(macaddr, buf, sizeof(buf)),
ipaddr2str(ip, buf2, sizeof(buf2)), vni,
zebra_route_string(client->proto));
@@ -1223,7 +1194,7 @@ static int zvni_macip_send_msg_to_client(vni_t vni,
else
client->macipdel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -1371,8 +1342,8 @@ static void zvni_neigh_del_from_vtep(zebra_vni_t *zvni, int uninstall,
/*
* Delete all neighbor entries for this VNI.
*/
-static void zvni_neigh_del_all(zebra_vni_t *zvni,
- int uninstall, int upd_client, u_int32_t flags)
+static void zvni_neigh_del_all(zebra_vni_t *zvni, int uninstall, int upd_client,
+ u_int32_t flags)
{
struct neigh_walk_ctx wctx;
@@ -1470,8 +1441,8 @@ static void zvni_process_neigh_on_local_mac_del(zebra_vni_t *zvni,
zvni->vni);
ZEBRA_NEIGH_SET_INACTIVE(n);
- zvni_neigh_send_del_to_client(
- zvni->vni, &n->ip, &n->emac, 0);
+ zvni_neigh_send_del_to_client(zvni->vni, &n->ip,
+ &n->emac, 0);
}
} else if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) {
if (IS_ZEBRA_DEBUG_VXLAN)
@@ -1507,8 +1478,8 @@ static void zvni_process_neigh_on_remote_mac_add(zebra_vni_t *zvni,
zvni->vni);
ZEBRA_NEIGH_SET_INACTIVE(n);
- zvni_neigh_send_del_to_client(
- zvni->vni, &n->ip, &n->emac, 0);
+ zvni_neigh_send_del_to_client(zvni->vni, &n->ip,
+ &n->emac, 0);
}
}
}
@@ -1539,12 +1510,11 @@ static void zvni_process_neigh_on_remote_mac_del(zebra_vni_t *zvni,
/*
* Inform BGP about local neighbor addition.
*/
-static int zvni_neigh_send_add_to_client(vni_t vni,
- struct ipaddr *ip,
+static int zvni_neigh_send_add_to_client(vni_t vni, struct ipaddr *ip,
struct ethaddr *macaddr,
u_char neigh_flags)
{
- u_char flags = 0;
+ u_char flags = 0;
if (CHECK_FLAG(neigh_flags, ZEBRA_NEIGH_DEF_GW))
SET_FLAG(flags, ZEBRA_MACIP_TYPE_GW);
@@ -1556,8 +1526,7 @@ static int zvni_neigh_send_add_to_client(vni_t vni,
/*
* Inform BGP about local neighbor deletion.
*/
-static int zvni_neigh_send_del_to_client(vni_t vni,
- struct ipaddr *ip,
+static int zvni_neigh_send_del_to_client(vni_t vni, struct ipaddr *ip,
struct ethaddr *macaddr, u_char flags)
{
return zvni_macip_send_msg_to_client(vni, macaddr, ip, flags,
@@ -1724,8 +1693,7 @@ static int zvni_add_macip_for_intf(struct interface *ifp, zebra_vni_t *zvni)
}
-static int zvni_advertise_subnet(zebra_vni_t *zvni,
- struct interface *ifp,
+static int zvni_advertise_subnet(zebra_vni_t *zvni, struct interface *ifp,
int advertise)
{
struct listnode *cnode = NULL, *cnnode = NULL;
@@ -1746,7 +1714,7 @@ static int zvni_advertise_subnet(zebra_vni_t *zvni,
apply_mask(&p);
if (advertise)
ip_prefix_send_to_client(ifp->vrf_id, &p,
- ZEBRA_IP_PREFIX_ROUTE_ADD);
+ ZEBRA_IP_PREFIX_ROUTE_ADD);
else
ip_prefix_send_to_client(ifp->vrf_id, &p,
ZEBRA_IP_PREFIX_ROUTE_DEL);
@@ -1822,8 +1790,7 @@ static int zvni_gw_macip_add(struct interface *ifp, zebra_vni_t *zvni,
prefix_mac2str(macaddr, buf, sizeof(buf)),
ipaddr2str(ip, buf2, sizeof(buf2)));
- zvni_neigh_send_add_to_client(zvni->vni, ip, macaddr,
- n->flags);
+ zvni_neigh_send_add_to_client(zvni->vni, ip, macaddr, n->flags);
return 0;
}
@@ -1858,20 +1825,16 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,
return -1;
/* only need to delete the entry from bgp if we sent it before */
- if (advertise_gw_macip_enabled(zvni)) {
- if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s del to BGP",
- ifp->vrf_id, ifp->name,
- ifp->ifindex, zvni->vni,
- prefix_mac2str(&(n->emac),
- NULL,
- ETHER_ADDR_STRLEN),
- ipaddr2str(ip, buf2, sizeof(buf2)));
+ if (IS_ZEBRA_DEBUG_VXLAN)
+ zlog_debug(
+ "%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s del to BGP",
+ ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni,
+ prefix_mac2str(&(n->emac), NULL, ETHER_ADDR_STRLEN),
+ ipaddr2str(ip, buf2, sizeof(buf2)));
- /* Remove neighbor from BGP. */
- zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac,
- ZEBRA_MACIP_TYPE_GW);
- }
+ /* Remove neighbor from BGP. */
+ zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac,
+ ZEBRA_MACIP_TYPE_GW);
/* Delete this neighbor entry. */
zvni_neigh_del(zvni, n);
@@ -1909,7 +1872,8 @@ static void zvni_gw_macip_del_for_vni_hash(struct hash_backet *backet,
zl2_info = zif->l2info.vxl;
- vlan_if = zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
+ vlan_if =
+ zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
if (!vlan_if)
return;
@@ -1948,8 +1912,8 @@ static void zvni_gw_macip_add_for_vni_hash(struct hash_backet *backet,
return;
zl2_info = zif->l2info.vxl;
- vlan_if = zvni_map_to_svi(zl2_info.access_vlan,
- zif->brslave_info.br_if);
+ vlan_if =
+ zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
if (!vlan_if)
return;
@@ -1989,8 +1953,7 @@ static int mac_cmp(const void *p1, const void *p2)
if (pmac1 == NULL || pmac2 == NULL)
return 0;
- return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet,
- ETH_ALEN)
+ return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, ETH_ALEN)
== 0);
}
@@ -2060,9 +2023,8 @@ static int zvni_mac_del_hash_entry(struct hash_backet *backet, void *arg)
&& IPV4_ADDR_SAME(&mac->fwd_info.r_vtep_ip,
&wctx->r_vtep_ip))) {
if (wctx->upd_client && (mac->flags & ZEBRA_MAC_LOCAL)) {
- zvni_mac_send_del_to_client(
- wctx->zvni->vni, &mac->macaddr,
- mac->flags);
+ zvni_mac_send_del_to_client(wctx->zvni->vni,
+ &mac->macaddr, mac->flags);
}
if (wctx->uninstall)
@@ -2099,8 +2061,8 @@ static void zvni_mac_del_from_vtep(zebra_vni_t *zvni, int uninstall,
/*
* Delete all MAC entries for this VNI.
*/
-static void zvni_mac_del_all(zebra_vni_t *zvni,
- int uninstall, int upd_client, u_int32_t flags)
+static void zvni_mac_del_all(zebra_vni_t *zvni, int uninstall, int upd_client,
+ u_int32_t flags)
{
struct mac_walk_ctx wctx;
@@ -2136,11 +2098,10 @@ static zebra_mac_t *zvni_mac_lookup(zebra_vni_t *zvni, struct ethaddr *mac)
/*
* Inform BGP about local MAC addition.
*/
-static int zvni_mac_send_add_to_client(vni_t vni,
- struct ethaddr *macaddr,
+static int zvni_mac_send_add_to_client(vni_t vni, struct ethaddr *macaddr,
u_char mac_flags)
{
- u_char flags = 0;
+ u_char flags = 0;
if (CHECK_FLAG(mac_flags, ZEBRA_MAC_STICKY))
SET_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY);
@@ -2154,11 +2115,10 @@ static int zvni_mac_send_add_to_client(vni_t vni,
/*
* Inform BGP about local MAC deletion.
*/
-static int zvni_mac_send_del_to_client(vni_t vni,
- struct ethaddr *macaddr,
+static int zvni_mac_send_del_to_client(vni_t vni, struct ethaddr *macaddr,
u_char mac_flags)
{
- u_char flags = 0;
+ u_char flags = 0;
if (CHECK_FLAG(mac_flags, ZEBRA_MAC_STICKY))
SET_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY);
@@ -2449,8 +2409,7 @@ static void zvni_deref_ip2mac(zebra_vni_t *zvni, zebra_mac_t *mac,
/*
* Read and populate local MACs and neighbors corresponding to this VNI.
*/
-static void zvni_read_mac_neigh(zebra_vni_t *zvni,
- struct interface *ifp)
+static void zvni_read_mac_neigh(zebra_vni_t *zvni, struct interface *ifp)
{
struct zebra_ns *zns;
struct zebra_if *zif;
@@ -2605,8 +2564,7 @@ static int zvni_send_add_to_client(zebra_vni_t *zvni)
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, ZEBRA_VNI_ADD, VRF_DEFAULT);
stream_putl(s, zvni->vni);
@@ -2617,13 +2575,13 @@ static int zvni_send_add_to_client(zebra_vni_t *zvni)
stream_putw_at(s, 0, stream_get_endp(s));
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Send VNI_ADD %u %s tenant vrf %s to %s",
- zvni->vni, inet_ntoa(zvni->local_vtep_ip),
+ zlog_debug("Send VNI_ADD %u %s tenant vrf %s to %s", zvni->vni,
+ inet_ntoa(zvni->local_vtep_ip),
vrf_id_to_name(zvni->vrf_id),
zebra_route_string(client->proto));
client->vniadd_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -2639,7 +2597,7 @@ static int zvni_send_del_to_client(vni_t vni)
if (!client)
return 0;
- s = client->obuf;
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
stream_reset(s);
zclient_create_header(s, ZEBRA_VNI_DEL, VRF_DEFAULT);
@@ -2653,7 +2611,7 @@ static int zvni_send_del_to_client(vni_t vni)
zebra_route_string(client->proto));
client->vnidel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -2690,8 +2648,9 @@ static void zvni_build_hash_table()
if (zl3vni) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("create L3-VNI hash for Intf %s(%u) L3-VNI %u",
- ifp->name, ifp->ifindex, vni);
+ zlog_debug(
+ "create L3-VNI hash for Intf %s(%u) L3-VNI %u",
+ ifp->name, ifp->ifindex, vni);
/* associate with vxlan_if */
zl3vni->local_vtep_ip = vxl->vtep_ip;
@@ -2893,8 +2852,7 @@ static void zvni_cleanup_all(struct hash_backet *backet, void *arg)
}
/* cleanup L3VNI */
-static void zl3vni_cleanup_all(struct hash_backet *backet,
- void *args)
+static void zl3vni_cleanup_all(struct hash_backet *backet, void *args)
{
zebra_l3vni_t *zl3vni = NULL;
@@ -2905,8 +2863,7 @@ static void zl3vni_cleanup_all(struct hash_backet *backet,
zebra_vxlan_process_l3vni_oper_down(zl3vni);
}
-static int is_host_present_in_host_list(struct list *list,
- struct prefix *host)
+static int is_host_present_in_host_list(struct list *list, struct prefix *host)
{
struct listnode *node = NULL;
struct prefix *p = NULL;
@@ -2918,8 +2875,7 @@ static int is_host_present_in_host_list(struct list *list,
return 0;
}
-static void host_list_add_host(struct list *list,
- struct prefix *host)
+static void host_list_add_host(struct list *list, struct prefix *host)
{
struct prefix *p = NULL;
@@ -2929,8 +2885,7 @@ static void host_list_add_host(struct list *list,
listnode_add_sort(list, p);
}
-static void host_list_delete_host(struct list *list,
- struct prefix *host)
+static void host_list_delete_host(struct list *list, struct prefix *host)
{
struct listnode *node = NULL, *nnode = NULL, *node_to_del = NULL;
struct prefix *p = NULL;
@@ -2979,8 +2934,7 @@ static void *zl3vni_rmac_alloc(void *p)
/*
* Add RMAC entry to l3-vni
*/
-static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni,
- struct ethaddr *rmac)
+static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac)
{
zebra_mac_t tmp_rmac;
zebra_mac_t *zrmac = NULL;
@@ -3002,8 +2956,7 @@ static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni,
/*
* Delete MAC entry.
*/
-static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni,
- zebra_mac_t *zrmac)
+static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)
{
zebra_mac_t *tmp_rmac;
@@ -3021,14 +2974,13 @@ static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni,
/*
* Install remote RMAC into the kernel.
*/
-static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni,
- zebra_mac_t *zrmac)
+static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)
{
struct zebra_if *zif = NULL;
struct zebra_l2info_vxlan *vxl = NULL;
- if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE)) ||
- !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC)))
+ if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE))
+ || !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC)))
return 0;
zif = zl3vni->vxlan_if->info;
@@ -3038,29 +2990,27 @@ static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni,
vxl = &zif->l2info.vxl;
return kernel_add_mac(zl3vni->vxlan_if, vxl->access_vlan,
- &zrmac->macaddr,
- zrmac->fwd_info.r_vtep_ip, 0);
+ &zrmac->macaddr, zrmac->fwd_info.r_vtep_ip, 0);
}
/*
* Uninstall remote RMAC from the kernel.
*/
-static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni,
- zebra_mac_t *zrmac)
+static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)
{
char buf[ETHER_ADDR_STRLEN];
struct zebra_if *zif = NULL;
struct zebra_l2info_vxlan *vxl = NULL;
- if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE)) ||
- !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC)))
+ if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE))
+ || !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC)))
return 0;
if (!zl3vni->vxlan_if) {
zlog_err(
- "RMAC %s on L3-VNI %u hash %p couldn't be uninstalled - no vxlan_if",
- prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
- zl3vni->vni, zl3vni);
+ "RMAC %s on L3-VNI %u hash %p couldn't be uninstalled - no vxlan_if",
+ prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
+ zl3vni->vni, zl3vni);
return -1;
}
@@ -3075,8 +3025,7 @@ static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni,
}
/* handle rmac add */
-static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,
- struct ethaddr *rmac,
+static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,
struct ipaddr *vtep_ip,
struct prefix *host_prefix)
{
@@ -3091,10 +3040,9 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,
if (!zrmac) {
zlog_warn(
"Failed to add RMAC %s L3VNI %u Remote VTEP %s",
- prefix_mac2str(rmac, buf,
- sizeof(buf)),
- zl3vni->vni, ipaddr2str(vtep_ip, buf1,
- sizeof(buf1)));
+ prefix_mac2str(rmac, buf, sizeof(buf)),
+ zl3vni->vni,
+ ipaddr2str(vtep_ip, buf1, sizeof(buf1)));
return -1;
}
memset(&zrmac->fwd_info, 0, sizeof(zrmac->fwd_info));
@@ -3111,8 +3059,7 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,
/* handle rmac delete */
-static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni,
- struct ethaddr *rmac,
+static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,
struct prefix *host_prefix)
{
zebra_mac_t *zrmac = NULL;
@@ -3136,8 +3083,7 @@ static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni,
/*
* Look up nh hash entry on a l3-vni.
*/
-static zebra_neigh_t *zl3vni_nh_lookup(zebra_l3vni_t *zl3vni,
- struct ipaddr *ip)
+static zebra_neigh_t *zl3vni_nh_lookup(zebra_l3vni_t *zl3vni, struct ipaddr *ip)
{
zebra_neigh_t tmp;
zebra_neigh_t *n;
@@ -3167,8 +3113,7 @@ static void *zl3vni_nh_alloc(void *p)
/*
* Add neighbor entry.
*/
-static zebra_neigh_t *zl3vni_nh_add(zebra_l3vni_t *zl3vni,
- struct ipaddr *ip,
+static zebra_neigh_t *zl3vni_nh_add(zebra_l3vni_t *zl3vni, struct ipaddr *ip,
struct ethaddr *mac)
{
zebra_neigh_t tmp_n;
@@ -3192,8 +3137,7 @@ static zebra_neigh_t *zl3vni_nh_add(zebra_l3vni_t *zl3vni,
/*
* Delete neighbor entry.
*/
-static int zl3vni_nh_del(zebra_l3vni_t *zl3vni,
- zebra_neigh_t *n)
+static int zl3vni_nh_del(zebra_l3vni_t *zl3vni, zebra_neigh_t *n)
{
zebra_neigh_t *tmp_n;
@@ -3211,14 +3155,13 @@ static int zl3vni_nh_del(zebra_l3vni_t *zl3vni,
/*
* Install remote nh as neigh into the kernel.
*/
-static int zl3vni_nh_install(zebra_l3vni_t *zl3vni,
- zebra_neigh_t *n)
+static int zl3vni_nh_install(zebra_l3vni_t *zl3vni, zebra_neigh_t *n)
{
if (!is_l3vni_oper_up(zl3vni))
return -1;
- if (!(n->flags & ZEBRA_NEIGH_REMOTE) ||
- !(n->flags & ZEBRA_NEIGH_REMOTE_NH))
+ if (!(n->flags & ZEBRA_NEIGH_REMOTE)
+ || !(n->flags & ZEBRA_NEIGH_REMOTE_NH))
return 0;
return kernel_add_neigh(zl3vni->svi_if, &n->ip, &n->emac);
@@ -3227,11 +3170,10 @@ static int zl3vni_nh_install(zebra_l3vni_t *zl3vni,
/*
* Uninstall remote nh from the kernel.
*/
-static int zl3vni_nh_uninstall(zebra_l3vni_t *zl3vni,
- zebra_neigh_t *n)
+static int zl3vni_nh_uninstall(zebra_l3vni_t *zl3vni, zebra_neigh_t *n)
{
- if (!(n->flags & ZEBRA_NEIGH_REMOTE) ||
- !(n->flags & ZEBRA_NEIGH_REMOTE_NH))
+ if (!(n->flags & ZEBRA_NEIGH_REMOTE)
+ || !(n->flags & ZEBRA_NEIGH_REMOTE_NH))
return 0;
if (!zl3vni->svi_if || !if_is_operative(zl3vni->svi_if))
@@ -3241,8 +3183,7 @@ static int zl3vni_nh_uninstall(zebra_l3vni_t *zl3vni,
}
/* add remote vtep as a neigh entry */
-static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,
- struct ipaddr *vtep_ip,
+static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip,
struct ethaddr *rmac,
struct prefix *host_prefix)
{
@@ -3257,10 +3198,8 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,
zlog_warn(
"Failed to add NH as Neigh (IP %s MAC %s L3-VNI %u)",
- ipaddr2str(vtep_ip, buf1,
- sizeof(buf1)),
- prefix_mac2str(rmac, buf,
- sizeof(buf)),
+ ipaddr2str(vtep_ip, buf1, sizeof(buf1)),
+ prefix_mac2str(rmac, buf, sizeof(buf)),
zl3vni->vni);
return -1;
}
@@ -3276,8 +3215,7 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,
}
/* handle nh neigh delete */
-static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni,
- struct ipaddr *vtep_ip,
+static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip,
struct prefix *host_prefix)
{
zebra_neigh_t *nh = NULL;
@@ -3302,8 +3240,8 @@ static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni,
/* handle neigh update from kernel - the only thing of interest is to
* readd stale entries.
*/
-static int zl3vni_local_nh_add_update(zebra_l3vni_t *zl3vni,
- struct ipaddr *ip, u_int16_t state)
+static int zl3vni_local_nh_add_update(zebra_l3vni_t *zl3vni, struct ipaddr *ip,
+ u_int16_t state)
{
#ifdef GNU_LINUX
zebra_neigh_t *n = NULL;
@@ -3322,8 +3260,7 @@ static int zl3vni_local_nh_add_update(zebra_l3vni_t *zl3vni,
}
/* handle neigh delete from kernel */
-static int zl3vni_local_nh_del(zebra_l3vni_t *zl3vni,
- struct ipaddr *ip)
+static int zl3vni_local_nh_del(zebra_l3vni_t *zl3vni, struct ipaddr *ip)
{
zebra_neigh_t *n = NULL;
@@ -3417,13 +3354,12 @@ static zebra_l3vni_t *zl3vni_add(vni_t vni, vrf_id_t vrf_id)
zl3vni->l2vnis->cmp = (int (*)(void *, void *))vni_hash_cmp;
/* Create hash table for remote RMAC */
- zl3vni->rmac_table =
- hash_create(mac_hash_keymake, mac_cmp,
- "Zebra L3-VNI RMAC-Table");
+ zl3vni->rmac_table = hash_create(mac_hash_keymake, mac_cmp,
+ "Zebra L3-VNI RMAC-Table");
/* Create hash table for neighbors */
zl3vni->nh_table = hash_create(neigh_hash_keymake, neigh_cmp,
- "Zebra L3-VNI next-hop table");
+ "Zebra L3-VNI next-hop table");
return zl3vni;
}
@@ -3492,7 +3428,7 @@ static struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni)
static struct interface *zl3vni_map_to_svi_if(zebra_l3vni_t *zl3vni)
{
- struct zebra_if *zif = NULL; /* zebra_if for vxlan_if */
+ struct zebra_if *zif = NULL; /* zebra_if for vxlan_if */
struct zebra_l2info_vxlan *vxl = NULL; /* l2 info for vxlan_if */
if (!zl3vni)
@@ -3612,11 +3548,9 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)
memset(&rmac, 0, sizeof(struct ethaddr));
zl3vni_get_rmac(zl3vni, &rmac);
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
- zclient_create_header(s, ZEBRA_L3VNI_ADD,
- zl3vni_vrf_id(zl3vni));
+ zclient_create_header(s, ZEBRA_L3VNI_ADD, zl3vni_vrf_id(zl3vni));
stream_putl(s, zl3vni->vni);
stream_put(s, &rmac, sizeof(struct ethaddr));
stream_put_in_addr(s, &zl3vni->local_vtep_ip);
@@ -3627,16 +3561,17 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
- "Send L3_VNI_ADD %u VRF %s RMAC %s local-ip %s filter %s to %s",
- zl3vni->vni, vrf_id_to_name(zl3vni_vrf_id(zl3vni)),
- prefix_mac2str(&rmac, buf, sizeof(buf)),
- inet_ntoa(zl3vni->local_vtep_ip),
- CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) ?
- "prefix-routes-only" : "none",
- zebra_route_string(client->proto));
+ "Send L3_VNI_ADD %u VRF %s RMAC %s local-ip %s filter %s to %s",
+ zl3vni->vni, vrf_id_to_name(zl3vni_vrf_id(zl3vni)),
+ prefix_mac2str(&rmac, buf, sizeof(buf)),
+ inet_ntoa(zl3vni->local_vtep_ip),
+ CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY)
+ ? "prefix-routes-only"
+ : "none",
+ zebra_route_string(client->proto));
client->l3vniadd_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -3652,24 +3587,21 @@ static int zl3vni_send_del_to_client(zebra_l3vni_t *zl3vni)
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
- zclient_create_header(s, ZEBRA_L3VNI_DEL,
- zl3vni_vrf_id(zl3vni));
+ zclient_create_header(s, ZEBRA_L3VNI_DEL, zl3vni_vrf_id(zl3vni));
stream_putl(s, zl3vni->vni);
/* Write packet size. */
stream_putw_at(s, 0, stream_get_endp(s));
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Send L3_VNI_DEL %u VRF %s to %s",
- zl3vni->vni,
+ zlog_debug("Send L3_VNI_DEL %u VRF %s to %s", zl3vni->vni,
vrf_id_to_name(zl3vni_vrf_id(zl3vni)),
zebra_route_string(client->proto));
client->l3vnidel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
static void zebra_vxlan_process_l3vni_oper_up(zebra_l3vni_t *zl3vni)
@@ -3690,11 +3622,10 @@ static void zebra_vxlan_process_l3vni_oper_down(zebra_l3vni_t *zl3vni)
zl3vni_send_del_to_client(zl3vni);
}
-static void zvni_add_to_l3vni_list(struct hash_backet *backet,
- void *ctxt)
+static void zvni_add_to_l3vni_list(struct hash_backet *backet, void *ctxt)
{
- zebra_vni_t *zvni = (zebra_vni_t *) backet->data;
- zebra_l3vni_t *zl3vni = (zebra_l3vni_t *) ctxt;
+ zebra_vni_t *zvni = (zebra_vni_t *)backet->data;
+ zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)ctxt;
if (zvni->vrf_id == zl3vni_vrf_id(zl3vni))
listnode_add_sort(zl3vni->l2vnis, zvni);
@@ -3703,8 +3634,8 @@ static void zvni_add_to_l3vni_list(struct hash_backet *backet,
/*
* handle transition of vni from l2 to l3 and vice versa
*/
-static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf,
- vni_t vni, int add)
+static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf, vni_t vni,
+ int add)
{
zebra_vni_t *zvni = NULL;
@@ -3723,8 +3654,7 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf,
return 0;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Del L2-VNI %u - transition to L3-VNI",
- vni);
+ zlog_debug("Del L2-VNI %u - transition to L3-VNI", vni);
/* Delete VNI from BGP. */
zvni_send_del_to_client(zvni->vni);
@@ -3738,8 +3668,8 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf,
/* Delete the hash entry. */
if (zvni_del(zvni)) {
- zlog_err("Failed to del VNI hash %p, VNI %u",
- zvni, zvni->vni);
+ zlog_err("Failed to del VNI hash %p, VNI %u", zvni,
+ zvni->vni);
return -1;
}
} else {
@@ -3754,8 +3684,7 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf,
}
/* delete and uninstall rmac hash entry */
-static void zl3vni_del_rmac_hash_entry(struct hash_backet *backet,
- void *ctx)
+static void zl3vni_del_rmac_hash_entry(struct hash_backet *backet, void *ctx)
{
zebra_mac_t *zrmac = NULL;
zebra_l3vni_t *zl3vni = NULL;
@@ -3767,8 +3696,7 @@ static void zl3vni_del_rmac_hash_entry(struct hash_backet *backet,
}
/* delete and uninstall nh hash entry */
-static void zl3vni_del_nh_hash_entry(struct hash_backet *backet,
- void *ctx)
+static void zl3vni_del_nh_hash_entry(struct hash_backet *backet, void *ctx)
{
zebra_neigh_t *n = NULL;
zebra_l3vni_t *zl3vni = NULL;
@@ -3779,9 +3707,8 @@ static void zl3vni_del_nh_hash_entry(struct hash_backet *backet,
zl3vni_nh_del(zl3vni, n);
}
-static int ip_prefix_send_to_client(vrf_id_t vrf_id,
- struct prefix *p,
- uint16_t cmd)
+static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p,
+ uint16_t cmd)
{
struct zserv *client = NULL;
struct stream *s = NULL;
@@ -3792,8 +3719,7 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id,
if (!client)
return 0;
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, cmd, vrf_id);
stream_put(s, p, sizeof(struct prefix));
@@ -3802,8 +3728,7 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id,
stream_putw_at(s, 0, stream_get_endp(s));
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug(
- "Send ip prefix %s %s on vrf %s",
+ zlog_debug("Send ip prefix %s %s on vrf %s",
prefix2str(p, buf, sizeof(buf)),
(cmd == ZEBRA_IP_PREFIX_ROUTE_ADD) ? "ADD" : "DEL",
vrf_id_to_name(vrf_id));
@@ -3813,12 +3738,12 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id,
else
client->prefixdel_cnt++;
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/* re-add remote rmac if needed */
static int zebra_vxlan_readd_remote_rmac(zebra_l3vni_t *zl3vni,
- struct ethaddr *rmac)
+ struct ethaddr *rmac)
{
char buf[ETHER_ADDR_STRLEN];
zebra_mac_t *zrmac = NULL;
@@ -3829,8 +3754,7 @@ static int zebra_vxlan_readd_remote_rmac(zebra_l3vni_t *zl3vni,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("Del remote RMAC %s L3VNI %u - readd",
- prefix_mac2str(rmac, buf, sizeof(buf)),
- zl3vni->vni);
+ prefix_mac2str(rmac, buf, sizeof(buf)), zl3vni->vni);
zl3vni_rmac_install(zl3vni, zrmac);
return 0;
@@ -3850,10 +3774,9 @@ int is_l3vni_for_prefix_routes_only(vni_t vni)
}
/* handle evpn route in vrf table */
-void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id,
- struct ethaddr *rmac,
- struct ipaddr *vtep_ip,
- struct prefix *host_prefix)
+void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ethaddr *rmac,
+ struct ipaddr *vtep_ip,
+ struct prefix *host_prefix)
{
zebra_l3vni_t *zl3vni = NULL;
@@ -3869,10 +3792,9 @@ void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id,
}
/* handle evpn vrf route delete */
-void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id,
- struct ethaddr *rmac,
- struct ipaddr *vtep_ip,
- struct prefix *host_prefix)
+void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id, struct ethaddr *rmac,
+ struct ipaddr *vtep_ip,
+ struct prefix *host_prefix)
{
zebra_l3vni_t *zl3vni = NULL;
@@ -3887,8 +3809,7 @@ void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id,
zl3vni_remote_rmac_del(zl3vni, rmac, host_prefix);
}
-void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty,
- vni_t l3vni,
+void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,
struct ethaddr *rmac,
u_char use_json)
{
@@ -3910,8 +3831,7 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty,
if (use_json)
vty_out(vty, "{}\n");
else
- vty_out(vty, "%% L3-VNI %u doesnt exist\n",
- l3vni);
+ vty_out(vty, "%% L3-VNI %u doesnt exist\n", l3vni);
return;
}
@@ -3935,8 +3855,7 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty,
}
}
-void zebra_vxlan_print_rmacs_l3vni(struct vty *vty,
- vni_t l3vni,
+void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni,
u_char use_json)
{
zebra_l3vni_t *zl3vni;
@@ -3966,8 +3885,7 @@ void zebra_vxlan_print_rmacs_l3vni(struct vty *vty,
wctx.vty = vty;
wctx.json = json;
if (!use_json) {
- vty_out(vty,
- "Number of Remote RMACs known for this VNI: %u\n",
+ vty_out(vty, "Number of Remote RMACs known for this VNI: %u\n",
num_rmacs);
vty_out(vty, "%-17s %-21s\n", "MAC", "Remote VTEP");
} else
@@ -3982,8 +3900,7 @@ void zebra_vxlan_print_rmacs_l3vni(struct vty *vty,
}
}
-void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty,
- u_char use_json)
+void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, u_char use_json)
{
struct zebra_ns *zns = NULL;
json_object *json = NULL;
@@ -4019,10 +3936,8 @@ void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty,
}
}
-void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty,
- vni_t l3vni,
- struct ipaddr *ip,
- u_char use_json)
+void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni,
+ struct ipaddr *ip, u_char use_json)
{
zebra_l3vni_t *zl3vni = NULL;
zebra_neigh_t *n = NULL;
@@ -4066,9 +3981,7 @@ void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty,
}
}
-void zebra_vxlan_print_nh_l3vni(struct vty *vty,
- vni_t l3vni,
- u_char use_json)
+void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, u_char use_json)
{
u_int32_t num_nh;
struct nh_walk_ctx wctx;
@@ -4097,8 +4010,7 @@ void zebra_vxlan_print_nh_l3vni(struct vty *vty,
wctx.vty = vty;
wctx.json = json;
if (!use_json) {
- vty_out(vty,
- "Number of NH Neighbors known for this VNI: %u\n",
+ vty_out(vty, "Number of NH Neighbors known for this VNI: %u\n",
num_nh);
vty_out(vty, "%-15s %-17s\n", "IP", "RMAC");
} else
@@ -4113,8 +4025,7 @@ void zebra_vxlan_print_nh_l3vni(struct vty *vty,
}
}
-void zebra_vxlan_print_nh_all_l3vni(struct vty *vty,
- u_char use_json)
+void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, u_char use_json)
{
struct zebra_ns *zns = NULL;
json_object *json = NULL;
@@ -4198,17 +4109,14 @@ void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf,
if (!json_vrfs) {
vty_out(vty, "%-37s %-10u %-20s %-20s %-5s %-18s\n",
- zvrf_name(zvrf),
- zl3vni->vni,
+ zvrf_name(zvrf), zl3vni->vni,
zl3vni_vxlan_if_name(zl3vni),
- zl3vni_svi_if_name(zl3vni),
- zl3vni_state2str(zl3vni),
+ zl3vni_svi_if_name(zl3vni), zl3vni_state2str(zl3vni),
zl3vni_rmac2str(zl3vni, buf, sizeof(buf)));
} else {
json_object *json_vrf = NULL;
json_vrf = json_object_new_object();
- json_object_string_add(json_vrf, "vrf",
- zvrf_name(zvrf));
+ json_object_string_add(json_vrf, "vrf", zvrf_name(zvrf));
json_object_int_add(json_vrf, "vni", zl3vni->vni);
json_object_string_add(json_vrf, "vxlanIntf",
zl3vni_vxlan_if_name(zl3vni));
@@ -4216,9 +4124,9 @@ void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf,
zl3vni_svi_if_name(zl3vni));
json_object_string_add(json_vrf, "state",
zl3vni_state2str(zl3vni));
- json_object_string_add(json_vrf, "routerMac",
- zl3vni_rmac2str(zl3vni, buf,
- sizeof(buf)));
+ json_object_string_add(
+ json_vrf, "routerMac",
+ zl3vni_rmac2str(zl3vni, buf, sizeof(buf)));
json_object_array_add(json_vrfs, json_vrf);
}
}
@@ -4691,10 +4599,9 @@ void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
if (use_json)
json = json_object_new_object();
else
- vty_out(vty,
- "%-10s %-4s %-21s %-8s %-8s %-15s %-37s\n",
- "VNI", "Type", "VxLAN IF", "# MACs",
- "# ARPs", "# Remote VTEPs", "Tenant VRF");
+ vty_out(vty, "%-10s %-4s %-21s %-8s %-8s %-15s %-37s\n", "VNI",
+ "Type", "VxLAN IF", "# MACs", "# ARPs",
+ "# Remote VTEPs", "Tenant VRF");
args[0] = vty;
args[1] = json;
@@ -4755,8 +4662,8 @@ int zebra_vxlan_local_neigh_del(struct interface *ifp,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("Del neighbor %s intf %s(%u) -> L2-VNI %u",
- ipaddr2str(ip, buf, sizeof(buf)),
- ifp->name, ifp->ifindex, zvni->vni);
+ ipaddr2str(ip, buf, sizeof(buf)), ifp->name,
+ ifp->ifindex, zvni->vni);
/* If entry doesn't exist, nothing to do. */
n = zvni_neigh_lookup(zvni, ip);
@@ -4785,8 +4692,7 @@ int zebra_vxlan_local_neigh_del(struct interface *ifp,
/* Remove neighbor from BGP. */
if (IS_ZEBRA_NEIGH_ACTIVE(n))
- zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac,
- 0);
+ zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac, 0);
/* Delete this neighbor entry. */
zvni_neigh_del(zvni, n);
@@ -4842,10 +4748,10 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp,
zmac = zvni_mac_lookup(zvni, macaddr);
if (!zmac) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug(
- "AUTO MAC %s created for neigh %s on VNI %u",
- prefix_mac2str(macaddr, buf, sizeof(buf)),
- ipaddr2str(ip, buf2, sizeof(buf2)), zvni->vni);
+ zlog_debug("AUTO MAC %s created for neigh %s on VNI %u",
+ prefix_mac2str(macaddr, buf, sizeof(buf)),
+ ipaddr2str(ip, buf2, sizeof(buf2)),
+ zvni->vni);
zmac = zvni_mac_add(zvni, macaddr);
if (!zmac) {
@@ -4866,8 +4772,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp,
n = zvni_neigh_lookup(zvni, ip);
if (n) {
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) {
- if (memcmp(n->emac.octet, macaddr->octet,
- ETH_ALEN)
+ if (memcmp(n->emac.octet, macaddr->octet, ETH_ALEN)
== 0) {
/* Update any params and return - client doesn't
* care about a purely local change.
@@ -4953,8 +4858,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp,
/*
* Handle message from client to delete a remote MACIP for a VNI.
*/
-int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS)
{
struct stream *s;
vni_t vni;
@@ -4974,9 +4878,9 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
memset(&ip, 0, sizeof(struct ipaddr));
memset(&vtep_ip, 0, sizeof(struct in_addr));
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote MACIP and process. */
/* Message contains VNI, followed by MAC followed by IP (if any)
* followed by remote VTEP IP.
@@ -5043,10 +4947,9 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
n = zvni_neigh_lookup(zvni, &ip);
if (n && !mac) {
- zlog_err(
- "Failed to locate MAC %s for neigh %s VNI %u",
- prefix_mac2str(&macaddr, buf, sizeof(buf)),
- ipaddr2str(&ip, buf1, sizeof(buf1)), vni);
+ zlog_err("Failed to locate MAC %s for neigh %s VNI %u",
+ prefix_mac2str(&macaddr, buf, sizeof(buf)),
+ ipaddr2str(&ip, buf1, sizeof(buf1)), vni);
continue;
}
@@ -5058,13 +4961,13 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
continue;
/* Ignore the delete if this mac is a gateway mac-ip */
- if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL) &&
- CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW)) {
- zlog_err("%u: Ignore Del for MAC %s neigh %s on VNI %u as it is configured as a default gateway",
- zvrf_id(zvrf),
- prefix_mac2str(&macaddr, buf, sizeof(buf)),
- ipaddr2str(&ip, buf1, sizeof(buf1)),
- vni);
+ if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL)
+ && CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW)) {
+ zlog_err(
+ "%u: Ignore Del for MAC %s neigh %s on VNI %u as it is configured as a default gateway",
+ zvrf_id(zvrf),
+ prefix_mac2str(&macaddr, buf, sizeof(buf)),
+ ipaddr2str(&ip, buf1, sizeof(buf1)), vni);
continue;
}
@@ -5079,8 +4982,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
* if the MAC matches.
*/
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)
- && (memcmp(n->emac.octet, macaddr.octet,
- ETH_ALEN)
+ && (memcmp(n->emac.octet, macaddr.octet, ETH_ALEN)
== 0)) {
zvni_neigh_uninstall(zvni, n);
zvni_neigh_del(zvni, n);
@@ -5088,8 +4990,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
}
} else {
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) {
- zvni_process_neigh_on_remote_mac_del(zvni,
- mac);
+ zvni_process_neigh_on_remote_mac_del(zvni, mac);
if (list_isempty(mac->neigh_list)) {
zvni_mac_uninstall(zvni, mac, 0);
@@ -5101,7 +5002,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
@@ -5109,8 +5010,7 @@ stream_failure:
* could be just the add of a MAC address or the add of a neighbor
* (IP+MAC).
*/
-int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS)
{
struct stream *s;
vni_t vni;
@@ -5135,14 +5035,15 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
memset(&vtep_ip, 0, sizeof(struct in_addr));
if (!EVPN_ENABLED(zvrf)) {
- zlog_warn("%s: EVPN Not turned on yet we have received a remote_macip add zapi callback",
- __PRETTY_FUNCTION__);
- return -1;
+ zlog_warn(
+ "%s: EVPN Not turned on yet we have received a remote_macip add zapi callback",
+ __PRETTY_FUNCTION__);
+ return;
}
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote MACIP and process. */
/* Message contains VNI, followed by MAC followed by IP (if any)
* followed by remote VTEP IP.
@@ -5219,15 +5120,16 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
/* Ignore the update if the mac is already present
as a gateway mac */
- if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW) &&
- CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW)) {
+ if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW)
+ && CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW)) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("%u:Ignore MAC %s IP %s on VNI %u as MAC is already configured as gateway mac",
- zvrf_id(zvrf),
- prefix_mac2str(&macaddr,
- buf, sizeof(buf)),
- ipaddr2str(&ip, buf1,
- sizeof(buf1)), vni);
+ zlog_debug(
+ "%u:Ignore MAC %s IP %s on VNI %u as MAC is already configured as gateway mac",
+ zvrf_id(zvrf),
+ prefix_mac2str(&macaddr, buf,
+ sizeof(buf)),
+ ipaddr2str(&ip, buf1, sizeof(buf1)),
+ vni);
continue;
}
@@ -5250,7 +5152,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
prefix_mac2str(&macaddr, buf,
sizeof(buf)),
vni, inet_ntoa(vtep_ip));
- return -1;
+ return;
}
/* Is this MAC created for a MACIP? */
@@ -5303,7 +5205,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
prefix_mac2str(&macaddr, buf,
sizeof(buf)),
vni, inet_ntoa(vtep_ip));
- return -1;
+ return;
}
} else if (memcmp(&n->emac, &macaddr, sizeof(macaddr))
@@ -5331,7 +5233,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
@@ -5376,8 +5278,8 @@ int zebra_vxlan_check_del_local_mac(struct interface *ifp,
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"Add/update remote MAC %s intf %s(%u) VNI %u - del local",
- prefix_mac2str(macaddr, buf, sizeof(buf)),
- ifp->name, ifp->ifindex, vni);
+ prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name,
+ ifp->ifindex, vni);
/* Remove MAC from BGP. */
zvni_mac_send_del_to_client(zvni->vni, macaddr, mac->flags);
@@ -5541,11 +5443,10 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,
}
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug(
- "Add/Update %sMAC %s intf %s(%u) VID %u -> VNI %u",
- sticky ? "sticky " : "",
- prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name,
- ifp->ifindex, vid, zvni->vni);
+ zlog_debug("Add/Update %sMAC %s intf %s(%u) VID %u -> VNI %u",
+ sticky ? "sticky " : "",
+ prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name,
+ ifp->ifindex, vid, zvni->vni);
/* If same entry already exists, nothing to do. */
mac = zvni_mac_lookup(zvni, macaddr);
@@ -5635,8 +5536,7 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,
/*
* Handle message from client to delete a remote VTEP for a VNI.
*/
-int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS)
{
struct stream *s;
u_short l = 0;
@@ -5648,20 +5548,21 @@ int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length,
struct zebra_if *zif;
if (!is_evpn_enabled()) {
- zlog_warn("%s: EVPN is not enabled yet we have received a vtep del command",
- __PRETTY_FUNCTION__);
- return -1;
+ zlog_warn(
+ "%s: EVPN is not enabled yet we have received a vtep del command",
+ __PRETTY_FUNCTION__);
+ return;
}
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("Recv MACIP DEL for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote VTEP and process. */
STREAM_GETL(s, vni);
l += 4;
@@ -5714,14 +5615,13 @@ int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
* Handle message from client to add a remote VTEP for a VNI.
*/
-int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS)
{
struct stream *s;
u_short l = 0;
@@ -5732,20 +5632,21 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,
struct zebra_if *zif;
if (!is_evpn_enabled()) {
- zlog_warn("%s: EVPN not enabled yet we received a vtep_add zapi call",
- __PRETTY_FUNCTION__);
- return -1;
+ zlog_warn(
+ "%s: EVPN not enabled yet we received a vtep_add zapi call",
+ __PRETTY_FUNCTION__);
+ return;
}
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("Recv MACIP ADD for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
- while (l < length) {
+ while (l < hdr->length) {
/* Obtain each remote VTEP and process. */
STREAM_GETL(s, vni);
l += 4;
@@ -5786,9 +5687,8 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,
continue;
if (zvni_vtep_add(zvni, &vtep_ip) == NULL) {
- zlog_err(
- "Failed to add remote VTEP, VNI %u zvni %p",
- vni, zvni);
+ zlog_err("Failed to add remote VTEP, VNI %u zvni %p",
+ vni, zvni);
continue;
}
@@ -5796,7 +5696,7 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
/*
@@ -5987,9 +5887,10 @@ int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if)
}
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("SVI %s(%u) VNI %u VRF %s is UP, installing neighbors",
- ifp->name, ifp->ifindex, zvni->vni,
- vrf_id_to_name(ifp->vrf_id));
+ zlog_debug(
+ "SVI %s(%u) VNI %u VRF %s is UP, installing neighbors",
+ ifp->name, ifp->ifindex, zvni->vni,
+ vrf_id_to_name(ifp->vrf_id));
/* update the vrf information for l2-vni and inform bgp */
zvni->vrf_id = ifp->vrf_id;
@@ -5998,8 +5899,7 @@ int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if)
/* Install any remote neighbors for this VNI. */
memset(&n_wctx, 0, sizeof(struct neigh_walk_ctx));
n_wctx.zvni = zvni;
- hash_iterate(zvni->neigh_table,
- zvni_install_neigh_hash,
+ hash_iterate(zvni->neigh_table, zvni_install_neigh_hash,
&n_wctx);
}
@@ -6030,15 +5930,15 @@ int zebra_vxlan_if_down(struct interface *ifp)
if (zl3vni) {
/* process-if-down for l3-vni */
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Intf %s(%u) L3-VNI %u is DOWN",
- ifp->name, ifp->ifindex, vni);
+ zlog_debug("Intf %s(%u) L3-VNI %u is DOWN", ifp->name,
+ ifp->ifindex, vni);
zebra_vxlan_process_l3vni_oper_down(zl3vni);
} else {
/* process if-down for l2-vni */
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Intf %s(%u) L2-VNI %u is DOWN",
- ifp->name, ifp->ifindex, vni);
+ zlog_debug("Intf %s(%u) L2-VNI %u is DOWN", ifp->name,
+ ifp->ifindex, vni);
/* Locate hash entry; it is expected to exist. */
zvni = zvni_lookup(vni);
@@ -6088,8 +5988,8 @@ int zebra_vxlan_if_up(struct interface *ifp)
if (zl3vni) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Intf %s(%u) L3-VNI %u is UP",
- ifp->name, ifp->ifindex, vni);
+ zlog_debug("Intf %s(%u) L3-VNI %u is UP", ifp->name,
+ ifp->ifindex, vni);
/* we need to associate with SVI, if any, we can associate with
* svi-if only after association with vxlan-intf is complete
@@ -6103,8 +6003,8 @@ int zebra_vxlan_if_up(struct interface *ifp)
struct interface *vlan_if = NULL;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Intf %s(%u) L2-VNI %u is UP",
- ifp->name, ifp->ifindex, vni);
+ zlog_debug("Intf %s(%u) L2-VNI %u is UP", ifp->name,
+ ifp->ifindex, vni);
/* Locate hash entry; it is expected to exist. */
zvni = zvni_lookup(vni);
@@ -6161,8 +6061,8 @@ int zebra_vxlan_if_del(struct interface *ifp)
if (zl3vni) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Del L3-VNI %u intf %s(%u)",
- vni, ifp->name, ifp->ifindex);
+ zlog_debug("Del L3-VNI %u intf %s(%u)", vni, ifp->name,
+ ifp->ifindex);
/* process oper-down for l3-vni */
zebra_vxlan_process_l3vni_oper_down(zl3vni);
@@ -6174,8 +6074,8 @@ int zebra_vxlan_if_del(struct interface *ifp)
/* process if-del for l2-vni*/
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("Del L2-VNI %u intf %s(%u)",
- vni, ifp->name, ifp->ifindex);
+ zlog_debug("Del L2-VNI %u intf %s(%u)", vni, ifp->name,
+ ifp->ifindex);
/* Locate hash entry; it is expected to exist. */
zvni = zvni_lookup(vni);
@@ -6237,8 +6137,8 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"Update L3-VNI %u intf %s(%u) VLAN %u local IP %s master %u chg 0x%x",
- vni, ifp->name, ifp->ifindex,
- vxl->access_vlan, inet_ntoa(vxl->vtep_ip),
+ vni, ifp->name, ifp->ifindex, vxl->access_vlan,
+ inet_ntoa(vxl->vtep_ip),
zif->brslave_info.bridge_ifindex, chgflags);
/* Removed from bridge? Cleanup and return */
@@ -6256,15 +6156,33 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)
zebra_vxlan_process_l3vni_oper_down(zl3vni);
zl3vni->svi_if = NULL;
zl3vni->svi_if = zl3vni_map_to_svi_if(zl3vni);
+ zl3vni->local_vtep_ip = vxl->vtep_ip;
+ if (is_l3vni_oper_up(zl3vni))
+ zebra_vxlan_process_l3vni_oper_up(
+ zl3vni);
+ }
+ }
+
+ /*
+ * local-ip change - process oper down, associate with new
+ * local-ip and then process oper up again
+ */
+ if (chgflags & ZEBRA_VXLIF_LOCAL_IP_CHANGE) {
+ if (if_is_operative(ifp)) {
+ zebra_vxlan_process_l3vni_oper_down(zl3vni);
+ zl3vni->local_vtep_ip = vxl->vtep_ip;
if (is_l3vni_oper_up(zl3vni))
zebra_vxlan_process_l3vni_oper_up(
- zl3vni);
+ zl3vni);
}
}
+ /* Update local tunnel IP. */
+ zl3vni->local_vtep_ip = vxl->vtep_ip;
+
/* if we have a valid new master, process l3-vni oper up */
if (chgflags & ZEBRA_VXLIF_MASTER_CHANGE) {
- if (is_l3vni_oper_up(zl3vni))
+ if (if_is_operative(ifp) && is_l3vni_oper_up(zl3vni))
zebra_vxlan_process_l3vni_oper_up(zl3vni);
}
} else {
@@ -6281,8 +6199,8 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"Update L2-VNI %u intf %s(%u) VLAN %u local IP %s master %u chg 0x%x",
- vni, ifp->name, ifp->ifindex,
- vxl->access_vlan, inet_ntoa(vxl->vtep_ip),
+ vni, ifp->name, ifp->ifindex, vxl->access_vlan,
+ inet_ntoa(vxl->vtep_ip),
zif->brslave_info.bridge_ifindex, chgflags);
/* Removed from bridge? Cleanup and return */
@@ -6336,8 +6254,7 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)
memset(&m_wctx, 0, sizeof(struct mac_walk_ctx));
m_wctx.zvni = zvni;
- hash_iterate(zvni->mac_table,
- zvni_install_mac_hash,
+ hash_iterate(zvni->mac_table, zvni_install_mac_hash,
&m_wctx);
memset(&n_wctx, 0, sizeof(struct neigh_walk_ctx));
@@ -6377,8 +6294,8 @@ int zebra_vxlan_if_add(struct interface *ifp)
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"Add L3-VNI %u intf %s(%u) VLAN %u local IP %s master %u",
- vni, ifp->name, ifp->ifindex,
- vxl->access_vlan, inet_ntoa(vxl->vtep_ip),
+ vni, ifp->name, ifp->ifindex, vxl->access_vlan,
+ inet_ntoa(vxl->vtep_ip),
zif->brslave_info.bridge_ifindex);
/* associate with vxlan_if */
@@ -6423,10 +6340,10 @@ int zebra_vxlan_if_add(struct interface *ifp)
zlog_debug(
"Add L2-VNI %u VRF %s intf %s(%u) VLAN %u local IP %s master %u",
vni,
- vlan_if ? vrf_id_to_name(vlan_if->vrf_id) :
- "Default",
- ifp->name, ifp->ifindex,
- vxl->access_vlan, inet_ntoa(vxl->vtep_ip),
+ vlan_if ? vrf_id_to_name(vlan_if->vrf_id)
+ : "Default",
+ ifp->name, ifp->ifindex, vxl->access_vlan,
+ inet_ntoa(vxl->vtep_ip),
zif->brslave_info.bridge_ifindex);
/* If down or not mapped to a bridge, we're done. */
@@ -6443,10 +6360,9 @@ int zebra_vxlan_if_add(struct interface *ifp)
return 0;
}
-int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,
- vni_t vni,
- char *err, int err_str_sz,
- int filter, int add)
+int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni,
+ char *err, int err_str_sz, int filter,
+ int add)
{
zebra_l3vni_t *zl3vni = NULL;
struct zebra_vrf *zvrf_default = NULL;
@@ -6456,9 +6372,7 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,
return -1;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug("vrf %s vni %u %s",
- zvrf_name(zvrf),
- vni,
+ zlog_debug("vrf %s vni %u %s", zvrf_name(zvrf), vni,
add ? "ADD" : "DEL");
if (add) {
@@ -6483,8 +6397,7 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,
/* add the L3-VNI to the global table */
zl3vni = zl3vni_add(vni, zvrf_id(zvrf));
if (!zl3vni) {
- snprintf(err, err_str_sz,
- "Could not add L3-VNI");
+ snprintf(err, err_str_sz, "Could not add L3-VNI");
return -1;
}
@@ -6509,8 +6422,8 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,
zl3vni->svi_if = zl3vni_map_to_svi_if(zl3vni);
/* formulate l2vni list */
- hash_iterate(zvrf_default->vni_table,
- zvni_add_to_l3vni_list, zl3vni);
+ hash_iterate(zvrf_default->vni_table, zvni_add_to_l3vni_list,
+ zl3vni);
if (is_l3vni_oper_up(zl3vni))
zebra_vxlan_process_l3vni_oper_up(zl3vni);
@@ -6525,13 +6438,11 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,
zebra_vxlan_process_l3vni_oper_down(zl3vni);
/* delete and uninstall all rmacs */
- hash_iterate(zl3vni->rmac_table,
- zl3vni_del_rmac_hash_entry,
+ hash_iterate(zl3vni->rmac_table, zl3vni_del_rmac_hash_entry,
zl3vni);
/* delete and uninstall all next-hops */
- hash_iterate(zl3vni->nh_table,
- zl3vni_del_nh_hash_entry,
+ hash_iterate(zl3vni->nh_table, zl3vni_del_nh_hash_entry,
zl3vni);
zvrf->l3vni = 0;
@@ -6592,8 +6503,7 @@ int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf)
* Handle message from client to enable/disable advertisement of g/w macip
* routes
*/
-int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS)
{
struct stream *s;
int advertise;
@@ -6607,60 +6517,56 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("EVPN GW-MACIP Adv for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
advertise = stream_getc(s);
vni = stream_get3(s);
zvni = zvni_lookup(vni);
if (!zvni)
- return 0;
+ return;
if (zvni->advertise_subnet == advertise)
- return 0;
+ return;
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_debug(
- "EVPN subnet Adv %s on VNI %d , currently %s",
- advertise ? "enabled" : "disabled", vni,
- zvni->advertise_subnet ? "enabled" : "disabled");
+ zlog_debug("EVPN subnet Adv %s on VNI %d , currently %s",
+ advertise ? "enabled" : "disabled", vni,
+ zvni->advertise_subnet ? "enabled" : "disabled");
zvni->advertise_subnet = advertise;
ifp = zvni->vxlan_if;
if (!ifp)
- return 0;
+ return;
zif = ifp->info;
/* If down or not mapped to a bridge, we're done. */
if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
- return 0;
+ return;
zl2_info = zif->l2info.vxl;
- vlan_if = zvni_map_to_svi(zl2_info.access_vlan,
- zif->brslave_info.br_if);
+ vlan_if =
+ zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);
if (!vlan_if)
- return 0;
+ return;
if (zvni->advertise_subnet)
zvni_advertise_subnet(zvni, vlan_if, 1);
else
zvni_advertise_subnet(zvni, vlan_if, 0);
-
- return 0;
}
/*
* Handle message from client to enable/disable advertisement of g/w macip
* routes
*/
-int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
+void zebra_vxlan_advertise_gw_macip(ZAPI_HANDLER_ARGS)
{
struct stream *s;
int advertise;
@@ -6671,10 +6577,10 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_err("EVPN GW-MACIP Adv for non-default VRF %u",
zvrf_id(zvrf));
- return -1;
+ return;
}
- s = client->ibuf;
+ s = msg;
STREAM_GETC(s, advertise);
STREAM_GET(&vni, s, 3);
@@ -6687,7 +6593,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
: "disabled");
if (zvrf->advertise_gw_macip == advertise)
- return 0;
+ return;
zvrf->advertise_gw_macip = advertise;
@@ -6704,39 +6610,38 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
struct interface *vlan_if = NULL;
struct interface *vrr_if = NULL;
+ zvni = zvni_lookup(vni);
+ if (!zvni)
+ return;
+
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug(
"EVPN gateway macip Adv %s on VNI %d , currently %s",
advertise ? "enabled" : "disabled", vni,
- advertise_gw_macip_enabled(zvni)
- ? "enabled"
- : "disabled");
-
- zvni = zvni_lookup(vni);
- if (!zvni)
- return 0;
+ advertise_gw_macip_enabled(zvni) ? "enabled"
+ : "disabled");
if (zvni->advertise_gw_macip == advertise)
- return 0;
+ return;
zvni->advertise_gw_macip = advertise;
ifp = zvni->vxlan_if;
if (!ifp)
- return 0;
+ return;
zif = ifp->info;
/* If down or not mapped to a bridge, we're done. */
if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
- return 0;
+ return;
zl2_info = zif->l2info.vxl;
vlan_if = zvni_map_to_svi(zl2_info.access_vlan,
zif->brslave_info.br_if);
if (!vlan_if)
- return 0;
+ return;
if (advertise_gw_macip_enabled(zvni)) {
/* Add primary SVI MAC-IP */
@@ -6758,7 +6663,7 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,
}
stream_failure:
- return 0;
+ return;
}
@@ -6768,20 +6673,18 @@ stream_failure:
* when disabled, the entries should be deleted and remote VTEPs and MACs
* uninstalled from the kernel.
*/
-int zebra_vxlan_advertise_all_vni(struct zserv *client,
- u_short length, struct zebra_vrf *zvrf)
+void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
{
struct stream *s = NULL;
int advertise = 0;
struct zebra_ns *zns = NULL;
if (zvrf_id(zvrf) != VRF_DEFAULT) {
- zlog_err("EVPN VNI Adv for non-default VRF %u",
- zvrf_id(zvrf));
- return -1;
+ zlog_err("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf));
+ return;
}
- s = client->ibuf;
+ s = msg;
STREAM_GETC(s, advertise);
if (IS_ZEBRA_DEBUG_VXLAN)
@@ -6790,7 +6693,7 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client,
is_evpn_enabled() ? "enabled" : "disabled");
if (zvrf->advertise_all_vni == advertise)
- return 0;
+ return;
zvrf->advertise_all_vni = advertise;
if (is_evpn_enabled()) {
@@ -6815,13 +6718,13 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client,
/* cleanup all l3vnis */
zns = zebra_ns_lookup(NS_DEFAULT);
if (!zns)
- return -1;
+ return;
hash_iterate(zns->l3vni_table, zl3vni_cleanup_all, NULL);
}
stream_failure:
- return 0;
+ return;
}
/*