/* 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,
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);
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,
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);
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);
}
/* 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];
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))
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];
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);
}
}
}
}
-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;
} 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);
}
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);
}
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);
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;
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);
}
}
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: ");
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));
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",
}
/* 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;
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];
zl3vni_vrf_name(zl3vni));
json_object_object_add(json, vni_str, json_vni);
}
-
}
/*
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,
/*
* 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)
{
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));
/*
* 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;
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)
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);
}
}
}
/*
* 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);
/*
* 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,
}
-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;
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);
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;
}
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);
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;
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;
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);
}
&& 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)
/*
* 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;
/*
* 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);
/*
* 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);
/*
* 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;
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));
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;
}
/* 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;
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;
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;
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;
/*
* 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;
/*
* 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;
/*
* 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;
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;
}
}
/* 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)
{
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));
/* 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;
/*
* 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;
/*
* 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;
/*
* 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;
/*
* 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);
/*
* 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))
}
/* 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)
{
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;
}
}
/* 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;
/* 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;
}
/* 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;
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;
}
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)
s = client->obuf;
stream_reset(s);
- 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);
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);
s = client->obuf;
stream_reset(s);
- 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));
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);
/*
* 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;
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);
/* 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 {
}
/* 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;
}
/* 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;
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;
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));
/* 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;
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;
}
/* 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;
}
/* 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;
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)
{
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;
}
}
}
-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;
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
}
}
-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;
}
}
-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;
}
}
-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;
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
}
}
-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;
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));
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);
}
}
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;
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);
/* 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);
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) {
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.
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;
}
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;
}
* 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);
}
} 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);
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__);
+ zlog_warn(
+ "%s: EVPN Not turned on yet we have received a remote_macip add zapi callback",
+ __PRETTY_FUNCTION__);
return -1;
}
/* 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;
}
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);
}
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);
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__);
+ zlog_warn(
+ "%s: EVPN is not enabled yet we have received a vtep del command",
+ __PRETTY_FUNCTION__);
return -1;
}
struct zebra_if *zif;
if (!is_evpn_enabled()) {
- zlog_warn("%s: EVPN not enabled yet we received a vtep_add zapi call",
- __PRETTY_FUNCTION__);
+ zlog_warn(
+ "%s: EVPN not enabled yet we received a vtep_add zapi call",
+ __PRETTY_FUNCTION__);
return -1;
}
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;
}
}
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;
/* 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);
}
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);
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
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);
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);
/* 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);
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 */
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 {
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 */
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));
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 */
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. */
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;
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) {
/* 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;
}
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);
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;
return 0;
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;
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;
struct interface *vlan_if = NULL;
struct interface *vrr_if = NULL;
+ zvni = zvni_lookup(vni);
+ if (!zvni)
+ return 0;
+
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;
* 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)
+int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length,
+ struct zebra_vrf *zvrf)
{
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));
+ zlog_err("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf));
return -1;
}