]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_label.h
bgpd, zebra: auto assign labels from label pool to regular prefixes in BGP labeled...
[mirror_frr.git] / bgpd / bgp_label.h
index a0994d68a3063339863745bc2a20630841f0880d..89bc9aabb03b18c8efdbdb1a18480be63d3c97f2 100644 (file)
 #define BGP_LABEL_BYTES 3
 #define BGP_LABEL_BITS 24
 #define BGP_WITHDRAW_LABEL 0x800000
+#define BGP_PREVENT_VRF_2_VRF_LEAK 0xFFFFFFFE
 
 struct bgp_node;
-struct bgp_info;
+struct bgp_path_info;
 struct peer;
 
-extern void bgp_reg_dereg_for_label (struct bgp_node *rn, struct bgp_info *ri,
-                                     int reg);
+extern int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
+                                   bool allocated);
+extern void bgp_reg_dereg_for_label(struct bgp_node *rn,
+                                   struct bgp_path_info *pi, bool reg);
 extern int bgp_parse_fec_update(void);
-extern mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_info *ri,
-                                  struct peer *to, afi_t afi, safi_t safi);
+extern mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi,
+                                 struct peer *to, afi_t afi, safi_t safi);
 
-extern int bgp_nlri_parse_label (struct peer *peer, struct attr *attr,
-                                 struct bgp_nlri *packet);
+extern int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
+                               struct bgp_nlri *packet);
 
-static inline int
-bgp_labeled_safi (safi_t safi)
+static inline int bgp_labeled_safi(safi_t safi)
 {
-  /* NOTE: This API really says a label (tag) MAY be present. Not all EVPN
-   * routes will have a label.
-   */
-  if ((safi == SAFI_LABELED_UNICAST) || (safi == SAFI_MPLS_VPN) ||
-      (safi == SAFI_EVPN))
-    return 1;
-  return 0;
+       /* NOTE: This API really says a label (tag) MAY be present. Not all EVPN
+        * routes will have a label.
+        */
+       if ((safi == SAFI_LABELED_UNICAST) || (safi == SAFI_MPLS_VPN)
+           || (safi == SAFI_EVPN))
+               return 1;
+       return 0;
 }
 
-static inline int
-bgp_is_withdraw_label (mpls_label_t *label)
+static inline int bgp_is_withdraw_label(mpls_label_t *label)
 {
-  u_char *pkt = (u_char *) label;
-
-  /* The check on pkt[2] for 0x00 or 0x02 is in case bgp_set_valid_label()
-   * was called on the withdraw label */
-  if ((pkt[0] == 0x80) && (pkt[1] == 0x00) && ((pkt[2] == 0x00) || (pkt[2] == 0x02)))
-      return 1;
-  return 0;
+       uint8_t *pkt = (uint8_t *)label;
+
+       /* The check on pkt[2] for 0x00 or 0x02 is in case bgp_set_valid_label()
+        * was called on the withdraw label */
+       if ((pkt[0] == 0x80) && (pkt[1] == 0x00)
+           && ((pkt[2] == 0x00) || (pkt[2] == 0x02)))
+               return 1;
+       return 0;
 }
 
-static inline int
-bgp_is_valid_label (mpls_label_t *label)
+static inline int bgp_is_valid_label(mpls_label_t *label)
 {
-  u_char *t= (u_char *) label;
-  if (!t)
-    return 0;
-  return (t[2] & 0x02);
+       uint8_t *t = (uint8_t *)label;
+       if (!t)
+               return 0;
+       return (t[2] & 0x02);
 }
 
-static inline void
-bgp_set_valid_label (mpls_label_t *label)
+static inline void bgp_set_valid_label(mpls_label_t *label)
 {
-  u_char *t= (u_char *) label;
-  if (t)
-    t[2] |= 0x02;
+       uint8_t *t = (uint8_t *)label;
+       if (t)
+               t[2] |= 0x02;
 }
 
-static inline void
-bgp_unset_valid_label (mpls_label_t *label)
+static inline void bgp_unset_valid_label(mpls_label_t *label)
 {
-  u_char *t= (u_char *) label;
-  if (t)
-    t[2] &= ~0x02;
+       uint8_t *t = (uint8_t *)label;
+       if (t)
+               t[2] &= ~0x02;
 }
 
-static inline void
-bgp_register_for_label (struct bgp_node *rn, struct bgp_info *ri)
+static inline void bgp_register_for_label(struct bgp_node *rn,
+                                         struct bgp_path_info *pi)
 {
-  bgp_reg_dereg_for_label (rn, ri, 1);
+       bgp_reg_dereg_for_label(rn, pi, true);
 }
 
-static inline void
-bgp_unregister_for_label (struct bgp_node *rn)
+static inline void bgp_unregister_for_label(struct bgp_node *rn)
 {
-  bgp_reg_dereg_for_label (rn, NULL, 0);
+       bgp_reg_dereg_for_label(rn, NULL, false);
 }
 
 /* Label stream to value */
-static inline u_int32_t
-label_pton (mpls_label_t *label)
+static inline uint32_t label_pton(mpls_label_t *label)
 {
-  u_char *t= (u_char *) label;
-  return ((((unsigned int) t[0]) << 12) | (((unsigned int) t[1]) << 4) |
-         ((unsigned int) ((t[2] & 0xF0) >> 4)));
+       uint8_t *t = (uint8_t *)label;
+       return ((((unsigned int)t[0]) << 12) | (((unsigned int)t[1]) << 4)
+               | ((unsigned int)((t[2] & 0xF0) >> 4)));
 }
 
 /* Encode label values */
-static inline void
-label_ntop (u_int32_t l, int bos, mpls_label_t *label)
+static inline void label_ntop(uint32_t l, int bos, mpls_label_t *label)
 {
-  u_char *t= (u_char *) label;
-  t[0] = ((l & 0x000FF000) >> 12);
-  t[1] = ((l & 0x00000FF0) >> 4);
-  t[2] = ((l & 0x0000000F) << 4);
-  if (bos)
-    t[2] |= 0x01;
+       uint8_t *t = (uint8_t *)label;
+       t[0] = ((l & 0x000FF000) >> 12);
+       t[1] = ((l & 0x00000FF0) >> 4);
+       t[2] = ((l & 0x0000000F) << 4);
+       if (bos)
+               t[2] |= 0x01;
 }
 
 /* Return BOS value of label stream */
-static inline u_char
-label_bos (mpls_label_t *label)
+static inline uint8_t label_bos(mpls_label_t *label)
 {
-  u_char *t= (u_char *) label;
-  return (t[2] & 0x01);
+       uint8_t *t = (uint8_t *)label;
+       return (t[2] & 0x01);
 };
 
 #endif /* _BGP_LABEL_H */