mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 11:25:41 +00:00
bgpd: introduction of vxlan tunnel attribute
As per draft-ietf-idr-tunnel-encaps-02, section 3.2.1, BGP Encap attribute supports vxlan tunnel type. A new tunnel attribute has been appended to subtlv list, describing the vxlan network identifier to be used for the routing information of the BGP update message. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
4fadf88120
commit
aee875b537
@ -3390,8 +3390,9 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
|
|||||||
stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr);
|
stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((afi == AFI_IP || afi == AFI_IP6) &&
|
if (((afi == AFI_IP || afi == AFI_IP6) &&
|
||||||
(safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN))
|
(safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN)) ||
|
||||||
|
(afi == AFI_L2VPN && safi == SAFI_EVPN))
|
||||||
{
|
{
|
||||||
/* Tunnel Encap attribute */
|
/* Tunnel Encap attribute */
|
||||||
bgp_packet_mpattr_tea(bgp, peer, s, attr, BGP_ATTR_ENCAP);
|
bgp_packet_mpattr_tea(bgp, peer, s, attr, BGP_ATTR_ENCAP);
|
||||||
|
@ -391,8 +391,30 @@ bgp_encap_type_vxlan_to_tlv(
|
|||||||
struct attr *attr)
|
struct attr *attr)
|
||||||
{
|
{
|
||||||
struct attr_extra *extra = bgp_attr_extra_get(attr);
|
struct attr_extra *extra = bgp_attr_extra_get(attr);
|
||||||
|
struct bgp_attr_encap_subtlv *tlv;
|
||||||
|
uint32_t vnid;
|
||||||
|
|
||||||
extra->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN;
|
extra->encap_tunneltype = BGP_ENCAP_TYPE_VXLAN;
|
||||||
|
|
||||||
|
if(bet == NULL ||!bet->vnid)
|
||||||
|
return;
|
||||||
|
if(extra->encap_subtlvs)
|
||||||
|
XFREE(MTYPE_ENCAP_TLV, extra->encap_subtlvs);
|
||||||
|
tlv = XCALLOC (MTYPE_ENCAP_TLV, sizeof(struct bgp_attr_encap_subtlv)-1+12);
|
||||||
|
tlv->type = 1; /* encapsulation type */
|
||||||
|
tlv->length = 12;
|
||||||
|
if(bet->vnid)
|
||||||
|
{
|
||||||
|
vnid = htonl(bet->vnid | VXLAN_ENCAP_MASK_VNID_VALID);
|
||||||
|
memcpy(&tlv->value, &vnid, 4);
|
||||||
|
}
|
||||||
|
if(bet->mac_address)
|
||||||
|
{
|
||||||
|
char *ptr = (char *)&tlv->value + 4;
|
||||||
|
memcpy( ptr, bet->mac_address, 6);
|
||||||
|
}
|
||||||
|
extra->encap_subtlvs = tlv;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -167,10 +167,15 @@ struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode {
|
|||||||
struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
|
struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define VXLAN_ENCAP_MASK_VNID_VALID 0x80000000
|
||||||
|
#define VXLAN_ENCAP_MASK_MAC_VALID 0x40000000
|
||||||
|
|
||||||
struct bgp_encap_type_vxlan {
|
struct bgp_encap_type_vxlan {
|
||||||
uint32_t valid_subtlvs;
|
uint32_t valid_subtlvs;
|
||||||
struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
|
struct bgp_tea_subtlv_remote_endpoint st_endpoint; /* optional */
|
||||||
/* No subtlvs defined in spec? */
|
/* draft-ietf-idr-tunnel-encaps-02 */
|
||||||
|
uint32_t vnid; /* does not include V and M bit */
|
||||||
|
uint8_t *mac_address; /* optional */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bgp_encap_type_nvgre {
|
struct bgp_encap_type_nvgre {
|
||||||
|
@ -68,8 +68,11 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|||||||
#include "bgpd/rfapi/vnc_import_bgp.h"
|
#include "bgpd/rfapi/vnc_import_bgp.h"
|
||||||
#include "bgpd/rfapi/vnc_export_bgp.h"
|
#include "bgpd/rfapi/vnc_export_bgp.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "bgpd/bgp_encap_types.h"
|
||||||
|
#include "bgpd/bgp_encap_tlv.h"
|
||||||
#include "bgpd/bgp_evpn.h"
|
#include "bgpd/bgp_evpn.h"
|
||||||
|
|
||||||
|
|
||||||
/* Extern from bgp_dump.c */
|
/* Extern from bgp_dump.c */
|
||||||
extern const char *bgp_origin_str[];
|
extern const char *bgp_origin_str[];
|
||||||
extern const char *bgp_origin_long_str[];
|
extern const char *bgp_origin_long_str[];
|
||||||
@ -4002,7 +4005,16 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
|
|||||||
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
|
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
|
||||||
|
|
||||||
if(afi == AFI_L2VPN)
|
if(afi == AFI_L2VPN)
|
||||||
|
{
|
||||||
overlay_index_update(&attr, bgp_static->eth_s_id, NULL);
|
overlay_index_update(&attr, bgp_static->eth_s_id, NULL);
|
||||||
|
if (bgp_static->encap_tunneltype == BGP_ENCAP_TYPE_VXLAN)
|
||||||
|
{
|
||||||
|
struct bgp_encap_type_vxlan bet;
|
||||||
|
memset(&bet, 0, sizeof(struct bgp_encap_type_vxlan));
|
||||||
|
bet.vnid = p->u.prefix_evpn.eth_tag;
|
||||||
|
bgp_encap_type_vxlan_to_tlv(&bet, &attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Apply route-map. */
|
/* Apply route-map. */
|
||||||
if (bgp_static->rmap.name)
|
if (bgp_static->rmap.name)
|
||||||
{
|
{
|
||||||
|
@ -207,6 +207,7 @@ struct bgp_static
|
|||||||
/* EVPN */
|
/* EVPN */
|
||||||
struct eth_segment_id *eth_s_id;
|
struct eth_segment_id *eth_s_id;
|
||||||
char *router_mac;
|
char *router_mac;
|
||||||
|
uint16_t encap_tunneltype;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen) \
|
#define BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen) \
|
||||||
|
Loading…
Reference in New Issue
Block a user