From 2ff12693b1d3aae8e1790a71bf280a98e4d9e910 Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Mon, 13 Jul 2020 18:21:27 -0700 Subject: [PATCH] bgpd, lib: move EVPN route type def to lib and use it in the prefix macros Use route names instead of route type number in the EVPN prefix macros. Signed-off-by: Anuradha Karuppiah --- bgpd/bgp_evpn_private.h | 9 --------- lib/prefix.h | 39 ++++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index b7dc218b00..ca45b198a7 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -48,15 +48,6 @@ #define BGP_EVPN_TYPE4_V4_PSIZE 23 #define BGP_EVPN_TYPE4_V6_PSIZE 34 -/* EVPN route types. */ -typedef enum { - BGP_EVPN_AD_ROUTE = 1, /* Ethernet Auto-Discovery (A-D) route */ - BGP_EVPN_MAC_IP_ROUTE, /* MAC/IP Advertisement route */ - BGP_EVPN_IMET_ROUTE, /* Inclusive Multicast Ethernet Tag route */ - BGP_EVPN_ES_ROUTE, /* Ethernet Segment route */ - BGP_EVPN_IP_PREFIX_ROUTE, /* IP Prefix route */ -} bgp_evpn_route_type; - RB_HEAD(bgp_es_evi_rb_head, bgp_evpn_es_evi); RB_PROTOTYPE(bgp_es_evi_rb_head, bgp_evpn_es_evi, rb_node, bgp_es_evi_rb_cmp); diff --git a/lib/prefix.h b/lib/prefix.h index d9edd9ee96..400f07386f 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -43,6 +43,15 @@ extern "C" { #define ETH_ALEN 6 #endif +/* EVPN route types. */ +typedef enum { + BGP_EVPN_AD_ROUTE = 1, /* Ethernet Auto-Discovery (A-D) route */ + BGP_EVPN_MAC_IP_ROUTE, /* MAC/IP Advertisement route */ + BGP_EVPN_IMET_ROUTE, /* Inclusive Multicast Ethernet Tag route */ + BGP_EVPN_ES_ROUTE, /* Ethernet Segment route */ + BGP_EVPN_IP_PREFIX_ROUTE, /* IP Prefix route */ +} bgp_evpn_route_type; + /* value of first byte of ESI */ #define ESI_TYPE_ARBITRARY 0 /* */ #define ESI_TYPE_LACP 1 /* <> */ @@ -236,45 +245,45 @@ struct prefix_evpn { static inline int is_evpn_prefix_ipaddr_none(const struct prefix_evpn *evp) { - if (evp->prefix.route_type == 1) + if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE) return IS_IPADDR_NONE(&(evp)->prefix.ead_addr.ip); - if (evp->prefix.route_type == 2) + if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) return IS_IPADDR_NONE(&(evp)->prefix.macip_addr.ip); - if (evp->prefix.route_type == 3) + if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE) return IS_IPADDR_NONE(&(evp)->prefix.imet_addr.ip); - if (evp->prefix.route_type == 4) + if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE) return IS_IPADDR_NONE(&(evp)->prefix.es_addr.ip); - if (evp->prefix.route_type == 5) + if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE) return IS_IPADDR_NONE(&(evp)->prefix.prefix_addr.ip); return 0; } static inline int is_evpn_prefix_ipaddr_v4(const struct prefix_evpn *evp) { - if (evp->prefix.route_type == 1) + if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE) return IS_IPADDR_V4(&(evp)->prefix.ead_addr.ip); - if (evp->prefix.route_type == 2) + if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) return IS_IPADDR_V4(&(evp)->prefix.macip_addr.ip); - if (evp->prefix.route_type == 3) + if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE) return IS_IPADDR_V4(&(evp)->prefix.imet_addr.ip); - if (evp->prefix.route_type == 4) + if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE) return IS_IPADDR_V4(&(evp)->prefix.es_addr.ip); - if (evp->prefix.route_type == 5) + if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE) return IS_IPADDR_V4(&(evp)->prefix.prefix_addr.ip); return 0; } static inline int is_evpn_prefix_ipaddr_v6(const struct prefix_evpn *evp) { - if (evp->prefix.route_type == 1) + if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE) return IS_IPADDR_V6(&(evp)->prefix.ead_addr.ip); - if (evp->prefix.route_type == 2) + if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) return IS_IPADDR_V6(&(evp)->prefix.macip_addr.ip); - if (evp->prefix.route_type == 3) + if (evp->prefix.route_type == BGP_EVPN_IMET_ROUTE) return IS_IPADDR_V6(&(evp)->prefix.imet_addr.ip); - if (evp->prefix.route_type == 4) + if (evp->prefix.route_type == BGP_EVPN_ES_ROUTE) return IS_IPADDR_V6(&(evp)->prefix.es_addr.ip); - if (evp->prefix.route_type == 5) + if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE) return IS_IPADDR_V6(&(evp)->prefix.prefix_addr.ip); return 0; } -- 2.39.5