From 6005fe55bce1c9cd54f4f7773fc2b0e15a99008f Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Wed, 2 Jan 2019 16:48:32 -0800 Subject: [PATCH] zebra: use default vrf_id for zvrf reference Duplicate address detection should operate at default vrf instance. For mac and neigh show command, auto recovery and few places where tanent vrf_id used for zvrf instead use default vrf instance. Use vxlan_if's or VRF_DEFAULT vrf_id to fetch zebra's default vrf instance. Signed-off-by: Chirag Shah --- zebra/zebra_vxlan.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 20dc64b0bc..2f156e05f4 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -692,10 +692,11 @@ static void zvni_print_neigh(zebra_neigh_t *n, void *ctxt, json_object *json) struct zebra_vrf *zvrf = NULL; struct timeval detect_start_time = {0, 0}; - zvrf = zebra_vrf_lookup_by_id(n->zvni->vrf_id); + zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); if (!zvrf) return; + zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); ipaddr2str(&n->ip, buf2, sizeof(buf2)); prefix_mac2str(&n->emac, buf1, sizeof(buf1)); type_str = CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL) ? @@ -1140,7 +1141,7 @@ static void zvni_print_mac(zebra_mac_t *mac, void *ctxt, json_object *json) struct zebra_vrf *zvrf; struct timeval detect_start_time = {0, 0}; - zvrf = zebra_vrf_lookup_by_id(mac->zvni->vrf_id); + zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); vty = (struct vty *)ctxt; prefix_mac2str(&mac->macaddr, buf1, sizeof(buf1)); @@ -2301,7 +2302,7 @@ static void zvni_process_neigh_on_local_mac_change(zebra_vni_t *zvni, struct zebra_vrf *zvrf = NULL; char buf[ETHER_ADDR_STRLEN]; - zvrf = vrf_info_lookup(zvni->vrf_id); + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); if (IS_ZEBRA_DEBUG_VXLAN) zlog_debug("Processing neighbors on local MAC %s %s, VNI %u", @@ -2896,7 +2897,7 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni, } } - zvrf = vrf_info_lookup(zvni->vrf_id); + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); if (!zvrf) return -1; @@ -6907,8 +6908,8 @@ void zebra_vxlan_dup_addr_detection(ZAPI_HANDLER_ARGS) if (IS_ZEBRA_DEBUG_VXLAN) zlog_debug( - "%s: duplicate detect %s max_moves %u timeout %u freeze %s freeze_time %u", - __PRETTY_FUNCTION__, + "VRF %s duplicate detect %s max_moves %u timeout %u freeze %s freeze_time %u", + vrf_id_to_name(zvrf->vrf->vrf_id), zvrf->dup_addr_detect ? "enable" : "disable", zvrf->dad_max_moves, zvrf->dad_time, @@ -8899,16 +8900,16 @@ static int zebra_vxlan_dad_ip_auto_recovery_exp(struct thread *t) nbr = THREAD_ARG(t); /* since this is asynchronous we need sanity checks*/ - zvrf = vrf_info_lookup(nbr->zvni->vrf_id); - if (!zvrf) + nbr = zvni_neigh_lookup(zvni, &nbr->ip); + if (!nbr) return 0; zvni = zvni_lookup(nbr->zvni->vni); if (!zvni) return 0; - nbr = zvni_neigh_lookup(zvni, &nbr->ip); - if (!nbr) + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + if (!zvrf) return 0; if (IS_ZEBRA_DEBUG_VXLAN) @@ -8949,16 +8950,16 @@ static int zebra_vxlan_dad_mac_auto_recovery_exp(struct thread *t) mac = THREAD_ARG(t); /* since this is asynchronous we need sanity checks*/ - zvrf = vrf_info_lookup(mac->zvni->vrf_id); - if (!zvrf) + mac = zvni_mac_lookup(zvni, &mac->macaddr); + if (!mac) return 0; zvni = zvni_lookup(mac->zvni->vni); if (!zvni) return 0; - mac = zvni_mac_lookup(zvni, &mac->macaddr); - if (!mac) + zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id); + if (!zvrf) return 0; if (IS_ZEBRA_DEBUG_VXLAN) -- 2.39.5