]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_attr.h
bgpd: IPv6 session flapping with MP_REACH_NLRI and 0.0.0.0 in NEXT_HOP attribute
[mirror_frr.git] / bgpd / bgp_attr.h
index 1a49e4ecf26ec510f4fdb359a02fb64d9b702d6b..f6b23a36bd6e054d912a74726d7c71c0edd26a03 100644 (file)
@@ -66,6 +66,8 @@
 #define BGP_PREFIX_SID_IPV6_LENGTH            19
 #define BGP_PREFIX_SID_ORIGINATOR_SRGB_LENGTH  6
 
+/* PMSI tunnel types (RFC 6514) */
+
 struct bgp_attr_encap_subtlv {
        struct bgp_attr_encap_subtlv *next; /* for chaining */
        /* Reference count of this attribute. */
@@ -90,10 +92,16 @@ struct bgp_tea_options {
 
 #endif
 
-/* Overlay Index Info */
-struct overlay_index {
-       struct eth_segment_id eth_s_id;
-       union gw_addr gw_ip;
+enum pta_type {
+       PMSI_TNLTYPE_NO_INFO = 0,
+       PMSI_TNLTYPE_RSVP_TE_P2MP,
+       PMSI_TNLTYPE_MLDP_P2MP,
+       PMSI_TNLTYPE_PIM_SSM,
+       PMSI_TNLTYPE_PIM_SM,
+       PMSI_TNLTYPE_PIM_BIDIR,
+       PMSI_TNLTYPE_INGR_REPL,
+       PMSI_TNLTYPE_MLDP_MP2MP,
+       PMSI_TNLTYPE_MAX = PMSI_TNLTYPE_MLDP_MP2MP
 };
 
 /* BGP core attribute structure. */
@@ -112,21 +120,27 @@ struct attr {
 
        /* Apart from in6_addr, the remaining static attributes */
        struct in_addr nexthop;
-       u_int32_t med;
-       u_int32_t local_pref;
+       uint32_t med;
+       uint32_t local_pref;
        ifindex_t nh_ifindex;
 
        /* Path origin attribute */
-       u_char origin;
+       uint8_t origin;
+
+       /* PMSI tunnel type (RFC 6514). */
+       enum pta_type pmsi_tnl_type;
 
        /* has the route-map changed any attribute?
           Used on the peer outbound side. */
-       u_int32_t rmap_change_flags;
+       uint32_t rmap_change_flags;
 
        /* Multi-Protocol Nexthop, AFI IPv6 */
        struct in6_addr mp_nexthop_global;
        struct in6_addr mp_nexthop_local;
 
+       /* ifIndex corresponding to mp_nexthop_local. */
+       ifindex_t nh_lla_ifindex;
+
        /* Extended Communities attribute. */
        struct ecommunity *ecommunity;
 
@@ -148,28 +162,31 @@ struct attr {
        struct in_addr originator_id;
 
        /* Local weight, not actually an attribute */
-       u_int32_t weight;
+       uint32_t weight;
 
        /* Aggregator ASN */
        as_t aggregator_as;
 
        /* MP Nexthop length */
-       u_char mp_nexthop_len;
+       uint8_t mp_nexthop_len;
 
        /* MP Nexthop preference */
-       u_char mp_nexthop_prefer_global;
+       uint8_t mp_nexthop_prefer_global;
 
        /* Static MAC for EVPN */
-       u_char sticky;
+       uint8_t sticky;
 
        /* Flag for default gateway extended community in EVPN */
-       u_char default_gw;
+       uint8_t default_gw;
+
+       /* NA router flag (R-bit) support in EVPN */
+       uint8_t router_flag;
 
        /* route tag */
        route_tag_t tag;
 
        /* Label index */
-       u_int32_t label_index;
+       uint32_t label_index;
 
        /* MPLS label */
        mpls_label_t label;
@@ -181,10 +198,10 @@ struct attr {
        struct bgp_attr_encap_subtlv *vnc_subtlvs; /* VNC-specific */
 #endif
        /* EVPN */
-       struct overlay_index evpn_overlay;
+       struct bgp_route_evpn evpn_overlay;
 
        /* EVPN MAC Mobility sequence number, if any. */
-       u_int32_t mm_seqnum;
+       uint32_t mm_seqnum;
 
        /* EVPN local router-mac */
        struct ethaddr rmac;
@@ -210,7 +227,7 @@ struct cluster_list {
 struct transit {
        unsigned long refcnt;
        int length;
-       u_char *val;
+       uint8_t *val;
 };
 
 /* "(void) 0" will generate a compiler error.  this is a safety check to
@@ -248,21 +265,23 @@ extern struct attr *bgp_attr_intern(struct attr *attr);
 extern void bgp_attr_unintern_sub(struct attr *);
 extern void bgp_attr_unintern(struct attr **);
 extern void bgp_attr_flush(struct attr *);
-extern struct attr *bgp_attr_default_set(struct attr *attr, u_char);
-extern struct attr *bgp_attr_aggregate_intern(struct bgp *, u_char,
-                                             struct aspath *,
-                                             struct community *, int as_set,
-                                             u_char);
+extern struct attr *bgp_attr_default_set(struct attr *attr, uint8_t);
+extern struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin,
+                                             struct aspath *aspath,
+                                             struct community *community,
+                                             struct ecommunity *ecommunity,
+                                             struct lcommunity *lcommunity,
+                                             int as_set,
+                                             uint8_t atomic_aggregate);
 extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,
                                       struct stream *, struct attr *,
                                       struct bpacket_attr_vec_arr *vecarr,
                                       struct prefix *, afi_t, safi_t,
                                       struct peer *, struct prefix_rd *,
-                                      mpls_label_t *, u_int32_t, int,
-                                      u_int32_t);
+                                      mpls_label_t *, uint32_t, int, uint32_t);
 extern void bgp_dump_routes_attr(struct stream *, struct attr *,
                                 struct prefix *);
-extern int attrhash_cmp(const void *, const void *);
+extern bool attrhash_cmp(const void *arg1, const void *arg2);
 extern unsigned int attrhash_key_make(void *);
 extern void attr_show_all(struct vty *);
 extern unsigned long int attr_count(void);
@@ -281,14 +300,17 @@ struct bgp_attr_parser_args {
        bgp_size_t length; /* attribute data length; */
        bgp_size_t total;  /* total length, inc header */
        struct attr *attr;
-       u_int8_t type;
-       u_int8_t flags;
-       u_char *startp;
+       uint8_t type;
+       uint8_t flags;
+       uint8_t *startp;
 };
 extern int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
                              struct bgp_nlri *);
 extern int bgp_mp_unreach_parse(struct bgp_attr_parser_args *args,
                                struct bgp_nlri *);
+extern bgp_attr_parse_ret_t
+bgp_attr_prefix_sid(int32_t tlength, struct bgp_attr_parser_args *args,
+                   struct bgp_nlri *mp_update);
 
 extern struct bgp_attr_encap_subtlv *
 encap_tlv_dup(struct bgp_attr_encap_subtlv *orig);
@@ -307,9 +329,9 @@ extern size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer,
                                      struct attr *attr);
 extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
                                     struct prefix *p, struct prefix_rd *prd,
-                                    mpls_label_t *label, u_int32_t num_labels,
-                                    int addpath_encode,
-                                    u_int32_t addpath_tx_id, struct attr *);
+                                    mpls_label_t *label, uint32_t num_labels,
+                                    int addpath_encode, uint32_t addpath_tx_id,
+                                    struct attr *);
 extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
                                            struct prefix *p);
 extern void bgp_packet_mpattr_end(struct stream *s, size_t sizep);
@@ -319,12 +341,14 @@ extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,
 extern void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p,
                                        afi_t afi, safi_t safi,
                                        struct prefix_rd *prd, mpls_label_t *,
-                                       u_int32_t, int, u_int32_t,
-                                       struct attr *);
+                                       uint32_t, int, uint32_t, struct attr *);
 extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);
 
-static inline int bgp_rmap_nhop_changed(u_int32_t out_rmap_flags,
-                                       u_int32_t in_rmap_flags)
+extern bgp_attr_parse_ret_t bgp_attr_nexthop_valid(struct peer *peer,
+                                                  struct attr *attr);
+
+static inline int bgp_rmap_nhop_changed(uint32_t out_rmap_flags,
+                                       uint32_t in_rmap_flags)
 {
        return ((CHECK_FLAG(out_rmap_flags, BATTR_RMAP_NEXTHOP_PEER_ADDRESS)
                 || CHECK_FLAG(out_rmap_flags, BATTR_RMAP_NEXTHOP_UNCHANGED)
@@ -339,7 +363,7 @@ static inline int bgp_rmap_nhop_changed(u_int32_t out_rmap_flags,
                        : 0);
 }
 
-static inline u_int32_t mac_mobility_seqnum(struct attr *attr)
+static inline uint32_t mac_mobility_seqnum(struct attr *attr)
 {
        return (attr) ? attr->mm_seqnum : 0;
 }