]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Add accessor for bgp_attr.pmsi_tnl_type
authorDonald Sharp <sharpd@nvidia.com>
Mon, 2 Nov 2020 15:52:40 +0000 (10:52 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Sun, 15 Nov 2020 14:44:47 +0000 (09:44 -0500)
Add an accessor for the bgp_attr.pmsi_tnl_type to allow
us to abstract where it is.  Every attribute is paying
the price of this bit of data as part of `struct bgp_attr`
In the future we'll move it elsewhere.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_attr.c
bgpd/bgp_attr.h
bgpd/bgp_debug.c
bgpd/bgp_evpn.c
bgpd/bgp_route.c

index a804968605bc4aca1e75ef68f1ca36f265ea9664..ab1173ba8d53652ab98c9bb12fcdb1f5a4f08e95 100644 (file)
@@ -2785,7 +2785,7 @@ bgp_attr_pmsi_tunnel(struct bgp_attr_parser_args *args)
        }
 
        attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL);
-       attr->pmsi_tnl_type = tnl_type;
+       bgp_attr_set_pmsi_tnl_type(attr, tnl_type);
        stream_get(&attr->label, peer->curr, BGP_LABEL_BYTES);
 
        /* Forward read pointer of input stream. */
@@ -4110,7 +4110,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
                stream_putc(s, BGP_ATTR_PMSI_TUNNEL);
                stream_putc(s, 9); // Length
                stream_putc(s, 0); // Flags
-               stream_putc(s, attr->pmsi_tnl_type);
+               stream_putc(s, bgp_attr_get_pmsi_tnl_type(attr));
                stream_put(s, &(attr->label),
                           BGP_LABEL_BYTES); // MPLS Label / VXLAN VNI
                stream_put_ipv4(s, attr->nexthop.s_addr);
index ef0e74344a968be7dc0adaa2ae4d55a58b862597..6ce5d1894227a6634c242bc88f5693533bf167a8 100644 (file)
@@ -457,4 +457,16 @@ static inline uint32_t mac_mobility_seqnum(struct attr *attr)
 {
        return (attr) ? attr->mm_seqnum : 0;
 }
+
+static inline enum pta_type bgp_attr_get_pmsi_tnl_type(struct attr *attr)
+{
+       return attr->pmsi_tnl_type;
+}
+
+static inline void bgp_attr_set_pmsi_tnl_type(struct attr *attr,
+                                             enum pta_type pmsi_tnl_type)
+{
+       attr->pmsi_tnl_type = pmsi_tnl_type;
+}
+
 #endif /* _QUAGGA_BGP_ATTR_H */
index c2c2d17a249bb9bc1de8a29568f94cb59eecb0a1..811634e8e0ebca78c05ed63b6a62ce9156e5cf0f 100644 (file)
@@ -440,7 +440,7 @@ bool bgp_dump_attr(struct attr *attr, char *buf, size_t size)
 
        if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)))
                snprintf(buf + strlen(buf), size - strlen(buf),
-                        ", pmsi tnltype %u", attr->pmsi_tnl_type);
+                        ", pmsi tnltype %u", bgp_attr_get_pmsi_tnl_type(attr));
 
        if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH)))
                snprintf(buf + strlen(buf), size - strlen(buf), ", path %s",
index 67d0a95cb6bcaaaa45c30d97514f567051b427dc..21eb371ec6b717c3f20e7839fb4e3de65a13f112 100644 (file)
@@ -980,7 +980,7 @@ static int evpn_zebra_install(struct bgp *bgp, struct bgpevpn *vpn,
        } else if (p->prefix.route_type == BGP_EVPN_AD_ROUTE) {
                ret = bgp_evpn_remote_es_evi_add(bgp, vpn, p);
        } else {
-               switch (pi->attr->pmsi_tnl_type) {
+               switch (bgp_attr_get_pmsi_tnl_type(pi->attr)) {
                case PMSI_TNLTYPE_INGR_REPL:
                        flood_control = VXLAN_FLOOD_HEAD_END_REPL;
                        break;
@@ -1711,7 +1711,7 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
        /* PMSI is only needed for type-3 routes */
        if (p->prefix.route_type == BGP_EVPN_IMET_ROUTE) {
                attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL);
-               attr.pmsi_tnl_type = PMSI_TNLTYPE_INGR_REPL;
+               bgp_attr_set_pmsi_tnl_type(&attr, PMSI_TNLTYPE_INGR_REPL);
        }
 
        if (bgp_debug_zebra(NULL)) {
@@ -3738,12 +3738,14 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi,
         */
        if (attr &&
            (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) {
-               if (attr->pmsi_tnl_type != PMSI_TNLTYPE_INGR_REPL &&
-                       attr->pmsi_tnl_type != PMSI_TNLTYPE_PIM_SM) {
-                       flog_warn(EC_BGP_EVPN_PMSI_PRESENT,
-                                 "%u:%s - Rx EVPN Type-3 NLRI with unsupported PTA %d",
-                                 peer->bgp->vrf_id, peer->host,
-                                 attr->pmsi_tnl_type);
+               enum pta_type pmsi_tnl_type = bgp_attr_get_pmsi_tnl_type(attr);
+
+               if (pmsi_tnl_type != PMSI_TNLTYPE_INGR_REPL
+                   && pmsi_tnl_type != PMSI_TNLTYPE_PIM_SM) {
+                       flog_warn(
+                               EC_BGP_EVPN_PMSI_PRESENT,
+                               "%u:%s - Rx EVPN Type-3 NLRI with unsupported PTA %d",
+                               peer->bgp->vrf_id, peer->host, pmsi_tnl_type);
                }
        }
 
index 9873057fa2471890310ccfca4c845211c769f524..82989b67646b97857d4012111e5b80687ab0f20e 100644 (file)
@@ -10221,9 +10221,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
 
        /* Line 10 display PMSI tunnel attribute, if present */
        if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) {
-               const char *str =
-                       lookup_msg(bgp_pmsi_tnltype_str, attr->pmsi_tnl_type,
-                                  PMSI_TNLTYPE_STR_DEFAULT);
+               const char *str = lookup_msg(bgp_pmsi_tnltype_str,
+                                            bgp_attr_get_pmsi_tnl_type(attr),
+                                            PMSI_TNLTYPE_STR_DEFAULT);
 
                if (json_paths) {
                        json_pmsi = json_object_new_object();