From: David Lamparter Date: Tue, 4 Dec 2018 16:29:50 +0000 (+0100) Subject: Merge pull request #3340 from nitinsoniism/show_evpn_vni_detail X-Git-Tag: frr-7.1-dev~131 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=21e2819dbf18fafabb532475cb5b07627d9372e2;p=matthieu%2Ffrr.git Merge pull request #3340 from nitinsoniism/show_evpn_vni_detail zebra: Add "show evpn vni detail" command --- 21e2819dbf18fafabb532475cb5b07627d9372e2 diff --cc zebra/zebra_vxlan.c index a9f8289467,ee6091a18e..6a664ef1c0 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@@ -6689,48 -5478,49 +6741,91 @@@ void zebra_vxlan_print_vnis(struct vty } } +void zebra_vxlan_dup_addr_detection(ZAPI_HANDLER_ARGS) +{ + struct stream *s; + int time = 0; + uint32_t max_moves = 0; + uint32_t freeze_time = 0; + bool dup_addr_detect = false; + bool freeze = false; + + s = msg; + STREAM_GETL(s, dup_addr_detect); + STREAM_GETL(s, time); + STREAM_GETL(s, max_moves); + STREAM_GETL(s, freeze); + STREAM_GETL(s, freeze_time); + + /* DAD previous state was enabled, and new state is disable, + * clear all duplicate detected addresses. + */ + if (zvrf->dup_addr_detect && !dup_addr_detect) + zebra_vxlan_clear_dup_detect_vni_all(NULL, zvrf); + + zvrf->dup_addr_detect = dup_addr_detect; + zvrf->dad_time = time; + zvrf->dad_max_moves = max_moves; + zvrf->dad_freeze = freeze; + zvrf->dad_freeze_time = freeze_time; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug( + "%s: duplicate detect %s max_moves %u timeout %u freeze %s freeze_time %u", + __PRETTY_FUNCTION__, + zvrf->dup_addr_detect ? "enable" : "disable", + zvrf->dad_max_moves, + zvrf->dad_time, + zvrf->dad_freeze ? "enable" : "disable", + zvrf->dad_freeze_time); + +stream_failure: + return; +} + + /* + * Display VNI hash table in detail(VTY command handler). + */ + void zebra_vxlan_print_vnis_detail(struct vty *vty, struct zebra_vrf *zvrf, + bool use_json) + { + json_object *json = NULL; + struct zebra_ns *zns = NULL; + struct zvni_evpn_show zes; + + if (!is_evpn_enabled()) + return; + + zns = zebra_ns_lookup(NS_DEFAULT); + if (!zns) + return; + + + if (use_json) + json = json_object_new_object(); + + zes.vty = vty; + zes.json = json; + zes.zvrf = zvrf; + + /* Display all L2-VNIs */ + hash_iterate(zvrf->vni_table, (void (*)(struct hash_backet *, + void *))zvni_print_hash_detail, + &zes); + + /* Display all L3-VNIs */ + hash_iterate(zrouter.l3vni_table, + (void (*)(struct hash_backet *, + void *))zl3vni_print_hash_detail, + &zes); + + if (use_json) { + vty_out(vty, "%s\n", json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); + json_object_free(json); + } + } + /* * Handle neighbor delete notification from the kernel (on a VLAN device * / L3 interface). This may result in either the neighbor getting deleted