mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-26 23:23:35 +00:00
Merge pull request #1781 from mkanjari/type5-default-originate
Type5 default originate
This commit is contained in:
commit
6b63fd5c51
@ -2577,10 +2577,12 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi,
|
|||||||
static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
|
static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
|
||||||
{
|
{
|
||||||
/* delete all ipv4 routes and withdraw from peers */
|
/* delete all ipv4 routes and withdraw from peers */
|
||||||
bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
|
if (advertise_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 */
|
/* delete all ipv6 routes and withdraw from peers */
|
||||||
bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
|
if (advertise_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
|
/* update and advertise all ipv4 and ipv6 routes in thr vrf table as type-5
|
||||||
@ -2588,10 +2590,12 @@ static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
|
|||||||
static void update_advertise_vrf_routes(struct bgp *bgp_vrf)
|
static void update_advertise_vrf_routes(struct bgp *bgp_vrf)
|
||||||
{
|
{
|
||||||
/* update all ipv4 routes */
|
/* update all ipv4 routes */
|
||||||
bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
|
if (advertise_type5_routes(bgp_vrf, AFI_IP))
|
||||||
|
bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
|
||||||
|
|
||||||
/* update all ipv6 routes */
|
/* update all ipv6 routes */
|
||||||
bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
|
if (advertise_type5_routes(bgp_vrf, AFI_IP6))
|
||||||
|
bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3214,10 +3218,6 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p,
|
|||||||
struct prefix_evpn evp;
|
struct prefix_evpn evp;
|
||||||
char buf[PREFIX_STRLEN];
|
char buf[PREFIX_STRLEN];
|
||||||
|
|
||||||
/* NOTE: Check needed as this is called per-route also. */
|
|
||||||
if (!advertise_type5_routes(bgp_vrf, afi))
|
|
||||||
return;
|
|
||||||
|
|
||||||
build_type5_prefix_from_ip_prefix(&evp, p);
|
build_type5_prefix_from_ip_prefix(&evp, p);
|
||||||
ret = delete_evpn_type5_route(bgp_vrf, &evp);
|
ret = delete_evpn_type5_route(bgp_vrf, &evp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -3235,10 +3235,6 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi, safi_t safi)
|
|||||||
struct bgp_node *rn = NULL;
|
struct bgp_node *rn = NULL;
|
||||||
struct bgp_info *ri;
|
struct bgp_info *ri;
|
||||||
|
|
||||||
/* Bail out early if we don't have to advertise type-5 routes. */
|
|
||||||
if (!advertise_type5_routes(bgp_vrf, afi))
|
|
||||||
return;
|
|
||||||
|
|
||||||
table = bgp_vrf->rib[afi][safi];
|
table = bgp_vrf->rib[afi][safi];
|
||||||
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
|
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
|
||||||
/* Only care about "selected" routes - non-imported. */
|
/* Only care about "selected" routes - non-imported. */
|
||||||
@ -3267,11 +3263,7 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct prefix_evpn evp;
|
struct prefix_evpn evp;
|
||||||
char buf[PREFIX_STRLEN];
|
char buf[PREFIX_STRLEN];
|
||||||
|
|
||||||
/* NOTE: Check needed as this is called per-route also. */
|
|
||||||
if (!advertise_type5_routes(bgp_vrf, afi))
|
|
||||||
return;
|
|
||||||
|
|
||||||
build_type5_prefix_from_ip_prefix(&evp, p);
|
build_type5_prefix_from_ip_prefix(&evp, p);
|
||||||
ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr);
|
ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -3290,10 +3282,6 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
|
|||||||
struct bgp_node *rn = NULL;
|
struct bgp_node *rn = NULL;
|
||||||
struct bgp_info *ri;
|
struct bgp_info *ri;
|
||||||
|
|
||||||
/* Bail out early if we don't have to advertise type-5 routes. */
|
|
||||||
if (!advertise_type5_routes(bgp_vrf, afi))
|
|
||||||
return;
|
|
||||||
|
|
||||||
table = bgp_vrf->rib[afi][safi];
|
table = bgp_vrf->rib[afi][safi];
|
||||||
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
|
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
|
||||||
/* Need to identify the "selected" route entry to use its
|
/* Need to identify the "selected" route entry to use its
|
||||||
|
@ -55,6 +55,25 @@ static inline vni_t label2vni(mpls_label_t *label)
|
|||||||
return vni;
|
return vni;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int advertise_type5_routes(struct bgp *bgp_vrf,
|
||||||
|
afi_t afi)
|
||||||
|
{
|
||||||
|
if (!bgp_vrf->l3vni)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (afi == AFI_IP &&
|
||||||
|
CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (afi == AFI_IP6 &&
|
||||||
|
CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,
|
extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,
|
||||||
struct prefix *p,
|
struct prefix *p,
|
||||||
struct attr *src_attr, afi_t afi,
|
struct attr *src_attr, afi_t afi,
|
||||||
|
@ -285,6 +285,14 @@ static inline void ip_prefix_from_type5_prefix(struct prefix_evpn *evp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int is_evpn_prefix_default(struct prefix *evp)
|
||||||
|
{
|
||||||
|
if (evp->family != AF_EVPN)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return ((evp->u.prefix_evpn.ip_prefix_length == 0) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void ip_prefix_from_type2_prefix(struct prefix_evpn *evp,
|
static inline void ip_prefix_from_type2_prefix(struct prefix_evpn *evp,
|
||||||
struct prefix *ip)
|
struct prefix *ip)
|
||||||
{
|
{
|
||||||
@ -352,19 +360,17 @@ static inline void build_evpn_type3_prefix(struct prefix_evpn *p,
|
|||||||
p->prefix.ip.ipaddr_v4 = originator_ip;
|
p->prefix.ip.ipaddr_v4 = originator_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi)
|
static inline int evpn_default_originate_set(struct bgp *bgp, afi_t afi,
|
||||||
|
safi_t safi)
|
||||||
{
|
{
|
||||||
if (!bgp_vrf->l3vni)
|
if (afi == AFI_IP &&
|
||||||
return 0;
|
CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4))
|
||||||
if (afi == AFI_IP
|
|
||||||
&& CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
else if (afi == AFI_IP6 &&
|
||||||
if (afi == AFI_IP6
|
CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
&& CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN))
|
BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2419,7 +2419,50 @@ static void evpn_unset_advertise_default_gw(struct bgp *bgp,
|
|||||||
/*
|
/*
|
||||||
* evpn - enable advertisement of default g/w
|
* evpn - enable advertisement of default g/w
|
||||||
*/
|
*/
|
||||||
static void evpn_set_advertise_subnet(struct bgp *bgp, struct bgpevpn *vpn)
|
static void evpn_process_default_originate_cmd(struct bgp *bgp_vrf,
|
||||||
|
afi_t afi, int 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))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (afi == AFI_IP)
|
||||||
|
SET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4);
|
||||||
|
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))
|
||||||
|
return;
|
||||||
|
if (afi == AFI_IP)
|
||||||
|
UNSET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* evpn - enable advertisement of default g/w
|
||||||
|
*/
|
||||||
|
static void evpn_set_advertise_subnet(struct bgp *bgp,
|
||||||
|
struct bgpevpn *vpn)
|
||||||
{
|
{
|
||||||
if (vpn->advertise_subnet)
|
if (vpn->advertise_subnet)
|
||||||
return;
|
return;
|
||||||
@ -2612,6 +2655,43 @@ DEFUN (no_bgp_evpn_advertise_all_vni,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFUN (bgp_evpn_default_originate,
|
||||||
|
bgp_evpn_default_originate_cmd,
|
||||||
|
"default-originate <ipv4 | ipv6>",
|
||||||
|
"originate a default route\n"
|
||||||
|
"ipv4 address family\n"
|
||||||
|
"ipv6 address family\n")
|
||||||
|
{
|
||||||
|
afi_t afi = 0;
|
||||||
|
int idx_afi = 0;
|
||||||
|
struct bgp *bgp_vrf = VTY_GET_CONTEXT(bgp);
|
||||||
|
|
||||||
|
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);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN (no_bgp_evpn_default_originate,
|
||||||
|
no_bgp_evpn_default_originate_cmd,
|
||||||
|
"no default-originate <ipv4 | ipv6>",
|
||||||
|
NO_STR
|
||||||
|
"withdraw a default route\n"
|
||||||
|
"ipv4 address family\n"
|
||||||
|
"ipv6 address family\n")
|
||||||
|
{
|
||||||
|
afi_t afi = 0;
|
||||||
|
int idx_afi = 0;
|
||||||
|
struct bgp *bgp_vrf = VTY_GET_CONTEXT(bgp);
|
||||||
|
|
||||||
|
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);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
DEFUN (bgp_evpn_advertise_vni_subnet,
|
DEFUN (bgp_evpn_advertise_vni_subnet,
|
||||||
bgp_evpn_advertise_vni_subnet_cmd,
|
bgp_evpn_advertise_vni_subnet_cmd,
|
||||||
"advertise-subnet",
|
"advertise-subnet",
|
||||||
@ -2631,14 +2711,6 @@ DEFUN (bgp_evpn_advertise_vni_subnet,
|
|||||||
if (!bgp_vrf)
|
if (!bgp_vrf)
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
|
|
||||||
if (!(advertise_type5_routes(bgp_vrf, AFI_IP)
|
|
||||||
|| advertise_type5_routes(bgp_vrf, AFI_IP6))) {
|
|
||||||
vty_out(vty,
|
|
||||||
"%%Please enable ip prefix advertisement under l2vpn evpn in %s",
|
|
||||||
vrf_id_to_name(bgp_vrf->vrf_id));
|
|
||||||
return CMD_WARNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
evpn_set_advertise_subnet(bgp, vpn);
|
evpn_set_advertise_subnet(bgp, vpn);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -2711,19 +2783,23 @@ DEFUN (bgp_evpn_advertise_type5,
|
|||||||
/* if we are already advertising ipv4 prefix as type-5
|
/* if we are already advertising ipv4 prefix as type-5
|
||||||
* nothing to do
|
* nothing to do
|
||||||
*/
|
*/
|
||||||
if (!rmap_changed && CHECK_FLAG(bgp_vrf->vrf_flags,
|
if (!rmap_changed &&
|
||||||
BGP_VRF_ADVERTISE_IPV4_IN_EVPN))
|
CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST))
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN);
|
SET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* if we are already advertising ipv6 prefix as type-5
|
/* if we are already advertising ipv6 prefix as type-5
|
||||||
* nothing to do
|
* nothing to do
|
||||||
*/
|
*/
|
||||||
if (!rmap_changed && CHECK_FLAG(bgp_vrf->vrf_flags,
|
if (!rmap_changed &&
|
||||||
BGP_VRF_ADVERTISE_IPV6_IN_EVPN))
|
CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN);
|
SET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rmap_changed) {
|
if (rmap_changed) {
|
||||||
@ -2780,25 +2856,25 @@ DEFUN (no_bgp_evpn_advertise_type5,
|
|||||||
|
|
||||||
if (afi == AFI_IP) {
|
if (afi == AFI_IP) {
|
||||||
|
|
||||||
/* if we are already advertising ipv4 prefix as type-5
|
/* if we are not advertising ipv4 prefix as type-5
|
||||||
* nothing to do
|
* nothing to do
|
||||||
*/
|
*/
|
||||||
if (CHECK_FLAG(bgp_vrf->vrf_flags,
|
if (CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) {
|
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST)) {
|
||||||
bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
|
bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
|
||||||
UNSET_FLAG(bgp_vrf->vrf_flags,
|
UNSET_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
BGP_VRF_ADVERTISE_IPV4_IN_EVPN);
|
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* if we are already advertising ipv6 prefix as type-5
|
/* if we are not advertising ipv6 prefix as type-5
|
||||||
* nothing to do
|
* nothing to do
|
||||||
*/
|
*/
|
||||||
if (CHECK_FLAG(bgp_vrf->vrf_flags,
|
if (CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) {
|
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST)) {
|
||||||
bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
|
bgp_evpn_withdraw_type5_routes(bgp_vrf, afi, safi);
|
||||||
UNSET_FLAG(bgp_vrf->vrf_flags,
|
UNSET_FLAG(bgp_vrf->vrf_flags,
|
||||||
BGP_VRF_ADVERTISE_IPV6_IN_EVPN);
|
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4305,12 +4381,22 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
|
|||||||
if (bgp->advertise_gw_macip)
|
if (bgp->advertise_gw_macip)
|
||||||
vty_out(vty, " advertise-default-gw\n");
|
vty_out(vty, " advertise-default-gw\n");
|
||||||
|
|
||||||
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN))
|
if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST))
|
||||||
vty_out(vty, " advertise ipv4 unicast\n");
|
vty_out(vty, " advertise ipv4 unicast\n");
|
||||||
|
|
||||||
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN))
|
if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))
|
||||||
vty_out(vty, " advertise ipv6 unicast\n");
|
vty_out(vty, " advertise ipv6 unicast\n");
|
||||||
|
|
||||||
|
if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4))
|
||||||
|
vty_out(vty, " default-originate ipv4\n");
|
||||||
|
|
||||||
|
if (CHECK_FLAG(bgp->af_flags[AFI_L2VPN][SAFI_EVPN],
|
||||||
|
BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6))
|
||||||
|
vty_out(vty, " default-originate ipv6\n");
|
||||||
|
|
||||||
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_RD_CFGD))
|
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_RD_CFGD))
|
||||||
vty_out(vty, " rd %s\n",
|
vty_out(vty, " rd %s\n",
|
||||||
prefix_rd2str(&bgp->vrf_prd, buf1, sizeof(buf1)));
|
prefix_rd2str(&bgp->vrf_prd, buf1, sizeof(buf1)));
|
||||||
@ -4373,6 +4459,8 @@ void bgp_ethernetvpn_init(void)
|
|||||||
install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_default_gw_cmd);
|
install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_default_gw_cmd);
|
||||||
install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_type5_cmd);
|
install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_type5_cmd);
|
||||||
install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_type5_cmd);
|
install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_type5_cmd);
|
||||||
|
install_element(BGP_EVPN_NODE, &bgp_evpn_default_originate_cmd);
|
||||||
|
install_element(BGP_EVPN_NODE, &no_bgp_evpn_default_originate_cmd);
|
||||||
|
|
||||||
/* "show bgp l2vpn evpn" commands. */
|
/* "show bgp l2vpn evpn" commands. */
|
||||||
install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_vni_cmd);
|
install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_vni_cmd);
|
||||||
|
@ -2227,12 +2227,13 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
|
|||||||
|
|
||||||
/* advertise/withdraw type-5 routes */
|
/* advertise/withdraw type-5 routes */
|
||||||
if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) {
|
if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) {
|
||||||
if (new_select
|
if (advertise_type5_routes(bgp, afi) && new_select &&
|
||||||
&& (!new_select->extra || !new_select->extra->parent))
|
(!new_select->extra || !new_select->extra->parent))
|
||||||
bgp_evpn_advertise_type5_route(
|
bgp_evpn_advertise_type5_route(bgp, &rn->p,
|
||||||
bgp, &rn->p, new_select->attr, afi, safi);
|
new_select->attr,
|
||||||
else if (old_select
|
afi, safi);
|
||||||
&& (!old_select->extra || !old_select->extra->parent))
|
else if (advertise_type5_routes(bgp, afi) && old_select &&
|
||||||
|
(!old_select->extra || !old_select->extra->parent))
|
||||||
bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi);
|
bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,6 +594,24 @@ struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd = {
|
|||||||
route_match_ip_route_source_prefix_list_compile,
|
route_match_ip_route_source_prefix_list_compile,
|
||||||
route_match_ip_route_source_prefix_list_free};
|
route_match_ip_route_source_prefix_list_free};
|
||||||
|
|
||||||
|
/* `match evpn default-route' */
|
||||||
|
|
||||||
|
/* Match function should return 1 if match is success else 0 */
|
||||||
|
static route_map_result_t route_match_evpn_default_route(void *rule,
|
||||||
|
struct prefix *p,
|
||||||
|
route_map_object_t
|
||||||
|
type, void *object)
|
||||||
|
{
|
||||||
|
if (type == RMAP_BGP && is_evpn_prefix_default(p))
|
||||||
|
return RMAP_MATCH;
|
||||||
|
|
||||||
|
return RMAP_NOMATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Route map commands for default-route matching. */
|
||||||
|
struct route_map_rule_cmd route_match_evpn_default_route_cmd = {
|
||||||
|
"evpn default-route", route_match_evpn_default_route, NULL, NULL};
|
||||||
|
|
||||||
/* `match mac address MAC_ACCESS_LIST' */
|
/* `match mac address MAC_ACCESS_LIST' */
|
||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
@ -3249,6 +3267,29 @@ DEFUN (no_match_evpn_vni,
|
|||||||
RMAP_EVENT_MATCH_DELETED);
|
RMAP_EVENT_MATCH_DELETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFUN (match_evpn_default_route,
|
||||||
|
match_evpn_default_route_cmd,
|
||||||
|
"match evpn default-route",
|
||||||
|
MATCH_STR
|
||||||
|
EVPN_HELP_STR
|
||||||
|
"default EVPN type-5 route\n")
|
||||||
|
{
|
||||||
|
return bgp_route_match_add(vty, "evpn default-route", NULL,
|
||||||
|
RMAP_EVENT_MATCH_ADDED);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN (no_match_evpn_default_route,
|
||||||
|
no_match_evpn_default_route_cmd,
|
||||||
|
"no match evpn default-route",
|
||||||
|
NO_STR
|
||||||
|
MATCH_STR
|
||||||
|
EVPN_HELP_STR
|
||||||
|
"default EVPN type-5 route\n")
|
||||||
|
{
|
||||||
|
return bgp_route_match_delete(vty, "evpn default-route", NULL,
|
||||||
|
RMAP_EVENT_MATCH_DELETED);
|
||||||
|
}
|
||||||
|
|
||||||
DEFUN (match_peer,
|
DEFUN (match_peer,
|
||||||
match_peer_cmd,
|
match_peer_cmd,
|
||||||
"match peer <A.B.C.D|X:X::X:X|WORD>",
|
"match peer <A.B.C.D|X:X::X:X|WORD>",
|
||||||
@ -4628,6 +4669,7 @@ void bgp_route_map_init(void)
|
|||||||
route_map_install_match(&route_match_mac_address_cmd);
|
route_map_install_match(&route_match_mac_address_cmd);
|
||||||
route_map_install_match(&route_match_evpn_vni_cmd);
|
route_map_install_match(&route_match_evpn_vni_cmd);
|
||||||
route_map_install_match(&route_match_evpn_route_type_cmd);
|
route_map_install_match(&route_match_evpn_route_type_cmd);
|
||||||
|
route_map_install_match(&route_match_evpn_default_route_cmd);
|
||||||
|
|
||||||
route_map_install_set(&route_set_ip_nexthop_cmd);
|
route_map_install_set(&route_set_ip_nexthop_cmd);
|
||||||
route_map_install_set(&route_set_local_pref_cmd);
|
route_map_install_set(&route_set_local_pref_cmd);
|
||||||
@ -4664,6 +4706,8 @@ void bgp_route_map_init(void)
|
|||||||
install_element(RMAP_NODE, &no_match_evpn_vni_cmd);
|
install_element(RMAP_NODE, &no_match_evpn_vni_cmd);
|
||||||
install_element(RMAP_NODE, &match_evpn_route_type_cmd);
|
install_element(RMAP_NODE, &match_evpn_route_type_cmd);
|
||||||
install_element(RMAP_NODE, &no_match_evpn_route_type_cmd);
|
install_element(RMAP_NODE, &no_match_evpn_route_type_cmd);
|
||||||
|
install_element(RMAP_NODE, &match_evpn_default_route_cmd);
|
||||||
|
install_element(RMAP_NODE, &no_match_evpn_default_route_cmd);
|
||||||
|
|
||||||
install_element(RMAP_NODE, &match_aspath_cmd);
|
install_element(RMAP_NODE, &match_aspath_cmd);
|
||||||
install_element(RMAP_NODE, &no_match_aspath_cmd);
|
install_element(RMAP_NODE, &no_match_aspath_cmd);
|
||||||
|
18
bgpd/bgpd.h
18
bgpd/bgpd.h
@ -312,6 +312,13 @@ struct bgp {
|
|||||||
u_int16_t af_flags[AFI_MAX][SAFI_MAX];
|
u_int16_t af_flags[AFI_MAX][SAFI_MAX];
|
||||||
#define BGP_CONFIG_DAMPENING (1 << 0)
|
#define BGP_CONFIG_DAMPENING (1 << 0)
|
||||||
|
|
||||||
|
/* l2vpn evpn flags - 1 << 0 is used for DAMPENNG */
|
||||||
|
#define BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST (1 << 1)
|
||||||
|
#define BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST (1 << 2)
|
||||||
|
#define BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV4 (1 << 3)
|
||||||
|
#define BGP_L2VPN_EVPN_DEFAULT_ORIGINATE_IPV6 (1 << 4)
|
||||||
|
|
||||||
|
|
||||||
/* Route table for next-hop lookup cache. */
|
/* Route table for next-hop lookup cache. */
|
||||||
struct bgp_table *nexthop_cache_table[AFI_MAX];
|
struct bgp_table *nexthop_cache_table[AFI_MAX];
|
||||||
|
|
||||||
@ -423,12 +430,11 @@ struct bgp {
|
|||||||
/* vrf flags */
|
/* vrf flags */
|
||||||
uint32_t vrf_flags;
|
uint32_t vrf_flags;
|
||||||
#define BGP_VRF_AUTO (1 << 0)
|
#define BGP_VRF_AUTO (1 << 0)
|
||||||
#define BGP_VRF_ADVERTISE_IPV4_IN_EVPN (1 << 1)
|
#define BGP_VRF_IMPORT_RT_CFGD (1 << 1)
|
||||||
#define BGP_VRF_ADVERTISE_IPV6_IN_EVPN (1 << 2)
|
#define BGP_VRF_EXPORT_RT_CFGD (1 << 2)
|
||||||
#define BGP_VRF_IMPORT_RT_CFGD (1 << 3)
|
#define BGP_VRF_RD_CFGD (1 << 3)
|
||||||
#define BGP_VRF_EXPORT_RT_CFGD (1 << 4)
|
#define BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY (1 << 4)
|
||||||
#define BGP_VRF_RD_CFGD (1 << 5)
|
|
||||||
#define BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY (1 << 6)
|
|
||||||
|
|
||||||
/* unique ID for auto derivation of RD for this vrf */
|
/* unique ID for auto derivation of RD for this vrf */
|
||||||
uint16_t vrf_rd_id;
|
uint16_t vrf_rd_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user