mirror of
https://git.proxmox.com/git/frr
synced 2025-04-28 12:38:27 +00:00

Signed-off-by: Alexandre Derumier <aderumier@odiso.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
153 lines
4.8 KiB
Diff
153 lines
4.8 KiB
Diff
From f5658ed4cecb3ad81cb838fb90467930943ab2ef Mon Sep 17 00:00:00 2001
|
|
From: Alexandre Derumier <aderumier@odiso.com>
|
|
Date: Mon, 22 May 2023 19:31:28 +0200
|
|
Subject: [PATCH] bgpd : add an option for RT auto-derivation to force AS
|
|
|
|
Allow to define a custom AS for autort AS:VNI
|
|
|
|
Usefull for evpn with ebgp, where we can't auto-derivated from the router AS,
|
|
as route-target AS:VNI need to be the same on the each peer
|
|
|
|
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
|
|
---
|
|
bgpd/bgp_evpn.c | 12 ++++++++++--
|
|
bgpd/bgp_evpn_vty.c | 47 +++++++++++++++++++++++++++++++++------------
|
|
bgpd/bgpd.h | 3 +++
|
|
3 files changed, 48 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
|
|
index 28ea443c6..d44c6bd5d 100644
|
|
--- a/bgpd/bgp_evpn.c
|
|
+++ b/bgpd/bgp_evpn.c
|
|
@@ -591,7 +591,11 @@ static void form_auto_rt(struct bgp *bgp, vni_t vni, struct list *rtl,
|
|
|
|
if (bgp->advertise_autort_rfc8365)
|
|
vni |= EVPN_AUTORT_VXLAN;
|
|
- encode_route_target_as((bgp->as & 0xFFFF), vni, &eval);
|
|
+ if (bgp->autort_as) {
|
|
+ encode_route_target_as((bgp->autort_as & 0xFFFF), vni, &eval);
|
|
+ } else {
|
|
+ encode_route_target_as((bgp->as & 0xFFFF), vni, &eval);
|
|
+ }
|
|
|
|
ecomadd = ecommunity_new();
|
|
ecommunity_add_val(ecomadd, &eval, false, false);
|
|
@@ -5174,7 +5178,11 @@ void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl,
|
|
if (bgp->advertise_autort_rfc8365)
|
|
vni |= EVPN_AUTORT_VXLAN;
|
|
|
|
- encode_route_target_as((bgp->as & 0xFFFF), vni, &eval);
|
|
+ if (bgp->autort_as) {
|
|
+ encode_route_target_as((bgp->autort_as & 0xFFFF), vni, &eval);
|
|
+ } else {
|
|
+ encode_route_target_as((bgp->as & 0xFFFF), vni, &eval);
|
|
+ }
|
|
|
|
ecom_auto = ecommunity_new();
|
|
ecommunity_add_val(ecom_auto, &eval, false, false);
|
|
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
|
|
index 6b63c6e3a..11012f3b8 100644
|
|
--- a/bgpd/bgp_evpn_vty.c
|
|
+++ b/bgpd/bgp_evpn_vty.c
|
|
@@ -3649,32 +3649,52 @@ DEFUN (no_bgp_evpn_advertise_all_vni,
|
|
return CMD_SUCCESS;
|
|
}
|
|
|
|
-DEFUN (bgp_evpn_advertise_autort_rfc8365,
|
|
- bgp_evpn_advertise_autort_rfc8365_cmd,
|
|
- "autort rfc8365-compatible",
|
|
+DEFPY (bgp_evpn_advertise_autort,
|
|
+ bgp_evpn_advertise_autort_cmd,
|
|
+ "autort [rfc8365-compatible]$rfc8365 [as (1-65536)$as]",
|
|
"Auto-derivation of RT\n"
|
|
- "Auto-derivation of RT using RFC8365\n")
|
|
+ "Auto-derivation of RT using RFC8365\n"
|
|
+ "Auto-derivation AS\n"
|
|
+ "ASN\n")
|
|
{
|
|
struct bgp *bgp = VTY_GET_CONTEXT(bgp);
|
|
|
|
if (!bgp)
|
|
return CMD_WARNING;
|
|
- evpn_set_advertise_autort_rfc8365(bgp);
|
|
+
|
|
+ if (as) {
|
|
+ bgp->autort_as = as;
|
|
+ bgp_evpn_handle_autort_change(bgp);
|
|
+ }
|
|
+
|
|
+ if (rfc8365)
|
|
+ evpn_set_advertise_autort_rfc8365(bgp);
|
|
+
|
|
return CMD_SUCCESS;
|
|
}
|
|
|
|
-DEFUN (no_bgp_evpn_advertise_autort_rfc8365,
|
|
- no_bgp_evpn_advertise_autort_rfc8365_cmd,
|
|
- "no autort rfc8365-compatible",
|
|
+DEFPY (no_bgp_evpn_advertise_autort,
|
|
+ no_bgp_evpn_advertise_autort_cmd,
|
|
+ "no autort [rfc8365-compatible]$rfc8365 [as (1-65536)$as]",
|
|
NO_STR
|
|
"Auto-derivation of RT\n"
|
|
- "Auto-derivation of RT using RFC8365\n")
|
|
+ "Auto-derivation of RT using RFC8365\n"
|
|
+ "Auto-derivation AS\n"
|
|
+ "ASN\n")
|
|
{
|
|
struct bgp *bgp = VTY_GET_CONTEXT(bgp);
|
|
|
|
if (!bgp)
|
|
return CMD_WARNING;
|
|
- evpn_unset_advertise_autort_rfc8365(bgp);
|
|
+
|
|
+ if (as) {
|
|
+ bgp->autort_as = 0;
|
|
+ bgp_evpn_handle_autort_change(bgp);
|
|
+ }
|
|
+
|
|
+ if (rfc8365)
|
|
+ evpn_unset_advertise_autort_rfc8365(bgp);
|
|
+
|
|
return CMD_SUCCESS;
|
|
}
|
|
|
|
@@ -7121,6 +7141,9 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
|
|
if (bgp->advertise_autort_rfc8365)
|
|
vty_out(vty, " autort rfc8365-compatible\n");
|
|
|
|
+ if (bgp->autort_as)
|
|
+ vty_out(vty, " autort as %u\n", bgp->autort_as);
|
|
+
|
|
if (bgp->advertise_gw_macip)
|
|
vty_out(vty, " advertise-default-gw\n");
|
|
|
|
@@ -7354,8 +7377,8 @@ void bgp_ethernetvpn_init(void)
|
|
install_element(BGP_EVPN_NODE, &evpnrt5_network_cmd);
|
|
install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_all_vni_cmd);
|
|
install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_all_vni_cmd);
|
|
- install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_autort_rfc8365_cmd);
|
|
- install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_autort_rfc8365_cmd);
|
|
+ install_element(BGP_EVPN_NODE, &bgp_evpn_advertise_autort_cmd);
|
|
+ install_element(BGP_EVPN_NODE, &no_bgp_evpn_advertise_autort_cmd);
|
|
install_element(BGP_EVPN_NODE, &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_svi_ip_cmd);
|
|
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
|
|
index 72b5b50fb..452062e3d 100644
|
|
--- a/bgpd/bgpd.h
|
|
+++ b/bgpd/bgpd.h
|
|
@@ -685,6 +685,9 @@ struct bgp {
|
|
/* EVPN - use RFC 8365 to auto-derive RT */
|
|
int advertise_autort_rfc8365;
|
|
|
|
+ /* EVPN - auto-derive RT AS */
|
|
+ uint16_t autort_as;
|
|
+
|
|
/*
|
|
* Flooding mechanism for BUM packets for VxLAN-EVPN.
|
|
*/
|
|
--
|
|
2.30.2
|
|
|