static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
{
/* delete all ipv4 routes and withdraw from peers */
- bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP);
+ bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
/* delete all ipv6 routes and withdraw from peers */
- bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6);
+ bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
}
/* update and advertise all ipv4 and ipv6 routes in thr vrf table as type-5
static void update_advertise_vrf_routes(struct bgp *bgp_vrf)
{
/* update all ipv4 routes */
- bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP);
+ bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
/* update all ipv6 routes */
- bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6);
+ bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
}
/*
/* withdraw all type-5 routes for an address family */
void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
- afi_t afi)
+ afi_t afi, safi_t safi)
{
struct bgp_table *table = NULL;
struct bgp_node *rn = NULL;
if (!advertise_type5_routes(bgp_vrf, afi))
return;
- table = bgp_vrf->rib[afi][SAFI_UNICAST];
+ table = bgp_vrf->rib[afi][safi];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
int ret = 0;
/* advertise all type-5 routes for an address family */
void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf,
- afi_t afi)
+ afi_t afi, safi_t safi)
{
struct bgp_table *table = NULL;
struct bgp_node *rn = NULL;
if (!advertise_type5_routes(bgp_vrf, afi))
return;
- table = bgp_vrf->rib[afi][SAFI_UNICAST];
+ table = bgp_vrf->rib[afi][safi];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
int ret = 0;
DEFUN (bgp_evpn_advertise_type5,
bgp_evpn_advertise_type5_cmd,
- "advertise <ipv4|ipv6|both>",
+ "advertise " BGP_AFI_CMD_STR "" BGP_SAFI_CMD_STR,
"Advertise prefix routes\n"
- "advertise ipv4 prefix only\n"
- "advertise ipv6 prefix only\n"
- "advertise both ipv4/ipv6 prefix\n")
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR)
{
struct bgp *bgp_vrf = VTY_GET_CONTEXT(bgp); /* bgp vrf instance */
- uint32_t type = 0;
-
- if (strcmp(argv[1]->text, "ipv4")) {
- type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
- } else if (strcmp(argv[1]->text, "ipv6")) {
- type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
- } else if (strcmp(argv[1]->text, "both")) {
- type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN |
- BGP_VRF_ADVERTISE_IPV6_IN_EVPN;
- } else {
- vty_out(vty, "%%invalid command");
+ int idx_afi = 0;
+ int idx_safi = 0;
+ afi_t afi = 0;
+ safi_t safi = 0;
+
+ argv_find_and_parse_afi(argv, argc, &idx_afi, &afi);
+ argv_find_and_parse_safi(argv, argc, &idx_safi, &safi);
+
+ if (!(afi == AFI_IP) || (afi == AFI_IP6)) {
+ vty_out(vty,
+ "%%only ipv4 or ipv6 address families are supported");
return CMD_WARNING;
}
- if (CHECK_FLAG(type, BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
+ if (safi != SAFI_UNICAST) {
+ vty_out(vty,
+ "%%only ipv4 unicast or ipv6 unicast are supported");
+ return CMD_WARNING;
+ }
+
+ if (afi == AFI_IP) {
/* if we are already advertising ipv4 prefix as type-5
* nothing to do */
BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
SET_FLAG(bgp_vrf->vrf_flags,
BGP_VRF_ADVERTISE_IPV4_IN_EVPN);
- bgp_evpn_advertise_type5_routes(bgp_vrf,
- AFI_IP);
+ bgp_evpn_advertise_type5_routes(bgp_vrf, afi, safi);
}
} else {
BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) {
SET_FLAG(bgp_vrf->vrf_flags,
BGP_VRF_ADVERTISE_IPV6_IN_EVPN);
- bgp_evpn_advertise_type5_routes(bgp_vrf,
- AFI_IP6);
+ bgp_evpn_advertise_type5_routes(bgp_vrf, afi, safi);
}
}
-
return CMD_SUCCESS;
}
DEFUN (no_bgp_evpn_advertise_type5,
no_bgp_evpn_advertise_type5_cmd,
- "no advertise <ipv4|ipv6|both>",
+ "no advertise " BGP_AFI_CMD_STR "" BGP_SAFI_CMD_STR,
NO_STR
"Advertise prefix routes\n"
- "advertise ipv4 prefix only\n"
- "advertise ipv6 prefix only\n"
- "advertise both ipv4/ipv6 prefix\n")
+ BGP_AFI_HELP_STR
+ BGP_SAFI_HELP_STR)
{
struct bgp *bgp_vrf = VTY_GET_CONTEXT(bgp); /* bgp vrf instance */
- uint32_t type = 0;
-
- if (strcmp(argv[1]->text, "ipv4")) {
- type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
- } else if (strcmp(argv[1]->text, "ipv6")) {
- type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN;
- } else if (strcmp(argv[1]->text, "both")) {
- type = BGP_VRF_ADVERTISE_IPV4_IN_EVPN |
- BGP_VRF_ADVERTISE_IPV6_IN_EVPN;
- } else {
- vty_out(vty, "%%invalid command");
+ int idx_afi = 0;
+ int idx_safi = 0;
+ afi_t afi = 0;
+ safi_t safi = 0;
+
+ argv_find_and_parse_afi(argv, argc, &idx_afi, &afi);
+ argv_find_and_parse_safi(argv, argc, &idx_safi, &safi);
+
+ if (!(afi == AFI_IP) || (afi == AFI_IP6)) {
+ vty_out(vty,
+ "%%only ipv4 or ipv6 address families are supported");
+ return CMD_WARNING;
+ }
+
+ if (safi != SAFI_UNICAST) {
+ vty_out(vty,
+ "%%only ipv4 unicast or ipv6 unicast are supported");
return CMD_WARNING;
}
- if (CHECK_FLAG(type, BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
+ if (afi == AFI_IP) {
/* if we are already advertising ipv4 prefix as type-5
* nothing to do */
if (CHECK_FLAG(bgp_vrf->vrf_flags,
BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
- bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP);
+ bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
UNSET_FLAG(bgp_vrf->vrf_flags,
BGP_VRF_ADVERTISE_IPV4_IN_EVPN);
}
* nothing to do */
if (CHECK_FLAG(bgp_vrf->vrf_flags,
BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) {
- bgp_evpn_withdraw_type5_routes(bgp_vrf,
- AFI_IP6);
+ bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
UNSET_FLAG(bgp_vrf->vrf_flags,
BGP_VRF_ADVERTISE_IPV6_IN_EVPN);
}