]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
Merge pull request #12114 from opensourcerouting/feature/bgp_aigp_attribute
[mirror_frr.git] / bgpd / bgp_vty.c
index c27b1c4bb8a9b240992ec18c236ba4cec94000cc..73919ffab24b00d319c2f775e05a55d521cc010c 100644 (file)
@@ -3567,6 +3567,26 @@ DEFUN (no_bgp_fast_external_failover,
        return CMD_SUCCESS;
 }
 
+DEFPY (bgp_bestpath_aigp,
+       bgp_bestpath_aigp_cmd,
+       "[no$no] bgp bestpath aigp",
+       NO_STR
+       BGP_STR
+       "Change the default bestpath selection\n"
+       "Evaluate the AIGP attribute during the best path selection process\n")
+{
+       VTY_DECLVAR_CONTEXT(bgp, bgp);
+
+       if (no)
+               UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP);
+       else
+               SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP);
+
+       bgp_recalculate_all_bestpaths(bgp);
+
+       return CMD_SUCCESS;
+}
+
 /* "bgp bestpath compare-routerid" configuration.  */
 DEFUN (bgp_bestpath_compare_router_id,
        bgp_bestpath_compare_router_id_cmd,
@@ -6547,6 +6567,26 @@ DEFUN (no_neighbor_ebgp_multihop,
        return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg);
 }
 
+DEFPY (neighbor_aigp,
+       neighbor_aigp_cmd,
+       "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp",
+       NO_STR
+       NEIGHBOR_STR
+       NEIGHBOR_ADDR_STR2
+       "Enable send and receive of the AIGP attribute per neighbor\n")
+{
+       struct peer *peer;
+
+       peer = peer_and_group_lookup_vty(vty, neighbor);
+       if (!peer)
+               return CMD_WARNING_CONFIG_FAILED;
+
+       if (no)
+               return peer_flag_unset_vty(vty, neighbor, PEER_FLAG_AIGP);
+       else
+               return peer_flag_set_vty(vty, neighbor, PEER_FLAG_AIGP);
+}
+
 static uint8_t get_role_by_name(const char *role_str)
 {
        if (strncmp(role_str, "peer", 2) == 0)
@@ -17154,6 +17194,10 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
                }
        }
 
+       /* aigp */
+       if (peergroup_flag_check(peer, PEER_FLAG_AIGP))
+               vty_out(vty, " neighbor %s aigp\n", addr);
+
        /* role */
        if (peergroup_flag_check(peer, PEER_FLAG_ROLE) &&
            peer->local_role != ROLE_UNDEFINED)
@@ -17992,6 +18036,8 @@ int bgp_config_write(struct vty *vty)
                }
                if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID))
                        vty_out(vty, " bgp bestpath compare-routerid\n");
+               if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP))
+                       vty_out(vty, " bgp bestpath aigp\n");
                if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)
                    || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) {
                        vty_out(vty, " bgp bestpath med");
@@ -18595,6 +18641,9 @@ void bgp_vty_init(void)
        install_element(BGP_NODE, &neighbor_role_strict_cmd);
        install_element(BGP_NODE, &no_neighbor_role_cmd);
 
+       /* "neighbor aigp" commands. */
+       install_element(BGP_NODE, &neighbor_aigp_cmd);
+
        /* bgp disable-ebgp-connected-nh-check */
        install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd);
        install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
@@ -18733,6 +18782,9 @@ void bgp_vty_init(void)
        install_element(BGP_NODE, &bgp_fast_external_failover_cmd);
        install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd);
 
+       /* "bgp bestpath aigp" commands */
+       install_element(BGP_NODE, &bgp_bestpath_aigp_cmd);
+
        /* "bgp bestpath compare-routerid" commands */
        install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
        install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);