]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_evpn_vty.c
Merge pull request #3448 from chiragshah6/evpn_dev1
[mirror_frr.git] / bgpd / bgp_evpn_vty.c
index e915574ed0a0f264ce3a99a7214c5442c9e35419..13f899e8806245f0159cd1997df73d23cc1deb55 100644 (file)
@@ -556,7 +556,8 @@ static void show_esi_routes(struct bgp *bgp,
                if (json)
                        json_prefix = json_object_new_object();
 
-               if (rn->info) {
+               pi = bgp_node_get_bgp_path_info(rn);
+               if (pi) {
                        /* Overall header/legend displayed once. */
                        if (header) {
                                bgp_evpn_show_route_header(vty, bgp,
@@ -573,7 +574,7 @@ static void show_esi_routes(struct bgp *bgp,
                /* For EVPN, the prefix is displayed for each path (to fit in
                 * with code that already exists).
                 */
-               for (pi = rn->info; pi; pi = pi->next) {
+               for (; pi; pi = pi->next) {
                        json_object *json_path = NULL;
 
                        if (json)
@@ -643,7 +644,8 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
                if (json)
                        json_prefix = json_object_new_object();
 
-               if (rn->info) {
+               pi = bgp_node_get_bgp_path_info(rn);
+               if (pi) {
                        /* Overall header/legend displayed once. */
                        if (header) {
                                bgp_evpn_show_route_header(vty, bgp,
@@ -660,7 +662,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
                /* For EVPN, the prefix is displayed for each path (to fit in
                 * with code that already exists).
                 */
-               for (pi = rn->info; pi; pi = pi->next) {
+               for (; pi; pi = pi->next) {
                        json_object *json_path = NULL;
 
                        if (vtep_ip.s_addr
@@ -1039,14 +1041,16 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
                if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
                        continue;
 
-               if ((table = rn->info) == NULL)
+               table = bgp_node_get_bgp_table_info(rn);
+               if (!table)
                        continue;
 
                rd_header = 1;
                tbl_ver = table->version;
 
                for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm))
-                       for (pi = rm->info; pi; pi = pi->next) {
+                       for (pi = bgp_node_get_bgp_path_info(rm); pi;
+                            pi = pi->next) {
                                total_count++;
                                if (type == bgp_show_type_neighbor) {
                                        union sockunion *su = output_arg;
@@ -2036,7 +2040,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
        /* See if route exists. */
        build_evpn_type3_prefix(&p, orig_ip);
        rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
-       if (!rn || !rn->info) {
+       if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
                if (!json)
                        vty_out(vty, "%% Network not in table\n");
                return;
@@ -2049,7 +2053,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
        route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json);
 
        /* Display each path for this prefix. */
-       for (pi = rn->info; pi; pi = pi->next) {
+       for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
                json_object *json_path = NULL;
 
                if (json)
@@ -2106,7 +2110,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
        /* See if route exists. Look for both non-sticky and sticky. */
        build_evpn_type2_prefix(&p, mac, ip);
        rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
-       if (!rn || !rn->info) {
+       if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
                if (!json)
                        vty_out(vty, "%% Network not in table\n");
                return;
@@ -2119,7 +2123,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
        route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json);
 
        /* Display each path for this prefix. */
-       for (pi = rn->info; pi; pi = pi->next) {
+       for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
                json_object *json_path = NULL;
 
                if (json)
@@ -2210,7 +2214,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
        build_evpn_type2_prefix(&p, mac, ip);
        rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
                                 (struct prefix *)&p, prd);
-       if (!rn || !rn->info) {
+       if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
                if (!json)
                        vty_out(vty, "%% Network not in table\n");
                return;
@@ -2226,7 +2230,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
                json_paths = json_object_new_array();
 
        /* Display each path for this prefix. */
-       for (pi = rn->info; pi; pi = pi->next) {
+       for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
                json_object *json_path = NULL;
 
                if (json)
@@ -2281,7 +2285,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
        if (!rd_rn)
                return;
 
-       table = (struct bgp_table *)rd_rn->info;
+       table = bgp_node_get_bgp_table_info(rd_rn);
        if (table == NULL)
                return;
 
@@ -2307,7 +2311,8 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
                if (json)
                        json_prefix = json_object_new_object();
 
-               if (rn->info) {
+               pi = bgp_node_get_bgp_path_info(rn);
+               if (pi) {
                        /* RD header and legend - once overall. */
                        if (rd_header && !json) {
                                vty_out(vty,
@@ -2330,7 +2335,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
                        json_paths = json_object_new_array();
 
                /* Display each path for this prefix. */
-               for (pi = rn->info; pi; pi = pi->next) {
+               for (; pi; pi = pi->next) {
                        json_object *json_path = NULL;
 
                        if (json)
@@ -2404,7 +2409,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
                int add_rd_to_json = 0;
                uint64_t tbl_ver;
 
-               table = (struct bgp_table *)rd_rn->info;
+               table = bgp_node_get_bgp_table_info(rd_rn);
                if (table == NULL)
                        continue;
 
@@ -2435,7 +2440,8 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
                        if (type && evp->prefix.route_type != type)
                                continue;
 
-                       if (rn->info) {
+                       pi = bgp_node_get_bgp_path_info(rn);
+                       if (pi) {
                                /* Overall header/legend displayed once. */
                                if (header) {
                                        bgp_evpn_show_route_header(vty, bgp,
@@ -2467,7 +2473,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
                         * fit in
                         * with code that already exists).
                         */
-                       for (pi = rn->info; pi; pi = pi->next) {
+                       for (; pi; pi = pi->next) {
                                json_object *json_path = NULL;
                                path_cnt++;
                                add_prefix_to_json = 1;
@@ -2661,16 +2667,10 @@ static void evpn_unset_advertise_default_gw(struct bgp *bgp,
  * evpn - enable advertisement of default g/w
  */
 static void evpn_process_default_originate_cmd(struct bgp *bgp_vrf,
-                                              afi_t afi, int add)
+                                              afi_t afi, bool add)
 {
-       struct prefix ip_prefix;
        safi_t safi = SAFI_UNICAST; /* ipv4/ipv6 unicast */
 
-       /* form the default prefix 0.0.0.0/0 */
-       memset(&ip_prefix, 0, sizeof(struct prefix));
-       ip_prefix.family = afi2family(afi);
-       ip_prefix.prefixlen = 0;
-
        if (add) {
                /* bail if we are already advertising default route */
                if (evpn_default_originate_set(bgp_vrf, afi, safi))
@@ -2682,8 +2682,6 @@ static void evpn_process_default_originate_cmd(struct bgp *bgp_vrf,
                else if (afi == AFI_IP6)
                        SET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
                                 BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6);
-               bgp_evpn_advertise_type5_route(bgp_vrf, &ip_prefix,
-                                              NULL, afi, safi);
        } else {
                /* bail out if we havent advertised the default route */
                if (!evpn_default_originate_set(bgp_vrf, afi, safi))
@@ -2694,9 +2692,9 @@ static void evpn_process_default_originate_cmd(struct bgp *bgp_vrf,
                else if (afi == AFI_IP6)
                        UNSET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
                                   BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6);
-               bgp_evpn_withdraw_type5_route(bgp_vrf, &ip_prefix,
-                                             afi, safi);
        }
+
+       bgp_evpn_install_uninstall_default_route(bgp_vrf, afi, safi, add);
 }
 
 /*
@@ -2976,7 +2974,7 @@ DEFUN (bgp_evpn_default_originate,
        if (!bgp_vrf)
                return CMD_WARNING;
        argv_find_and_parse_afi(argv, argc, &idx_afi, &afi);
-       evpn_process_default_originate_cmd(bgp_vrf, afi, 1);
+       evpn_process_default_originate_cmd(bgp_vrf, afi, true);
        return CMD_SUCCESS;
 }
 
@@ -2995,7 +2993,7 @@ DEFUN (no_bgp_evpn_default_originate,
        if (!bgp_vrf)
                return CMD_WARNING;
        argv_find_and_parse_afi(argv, argc, &idx_afi, &afi);
-       evpn_process_default_originate_cmd(bgp_vrf, afi, 0);
+       evpn_process_default_originate_cmd(bgp_vrf, afi, false);
        return CMD_SUCCESS;
 }
 
@@ -5106,7 +5104,7 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
                                       ecom)) {
                        ecom_str = ecommunity_ecom2str(
                                ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       vty_out(vty, "   route-target import %s\n", ecom_str);
+                       vty_out(vty, "  route-target import %s\n", ecom_str);
                        XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
                }
        }
@@ -5121,7 +5119,7 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
                                       ecom)) {
                        ecom_str = ecommunity_ecom2str(
                                ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-                       vty_out(vty, "   route-target export %s\n", ecom_str);
+                       vty_out(vty, "  route-target export %s\n", ecom_str);
                        XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
                }
        }