]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_label.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP carrying Label information
3 * Copyright (C) 2013 Cumulus Networks, Inc.
9 #define BGP_LABEL_BYTES 3
10 #define BGP_LABEL_BITS 24
11 #define BGP_WITHDRAW_LABEL 0x800000
12 #define BGP_PREVENT_VRF_2_VRF_LEAK 0xFFFFFFFE
18 extern int bgp_reg_for_label_callback(mpls_label_t new_label
, void *labelid
,
20 extern void bgp_reg_dereg_for_label(struct bgp_dest
*dest
,
21 struct bgp_path_info
*pi
, bool reg
);
22 extern int bgp_parse_fec_update(void);
23 extern mpls_label_t
bgp_adv_label(struct bgp_dest
*dest
,
24 struct bgp_path_info
*pi
, struct peer
*to
,
25 afi_t afi
, safi_t safi
);
27 extern int bgp_nlri_parse_label(struct peer
*peer
, struct attr
*attr
,
28 struct bgp_nlri
*packet
);
30 static inline int bgp_labeled_safi(safi_t safi
)
32 /* NOTE: This API really says a label (tag) MAY be present. Not all EVPN
33 * routes will have a label.
35 if ((safi
== SAFI_LABELED_UNICAST
) || (safi
== SAFI_MPLS_VPN
)
36 || (safi
== SAFI_EVPN
))
41 static inline int bgp_is_withdraw_label(mpls_label_t
*label
)
43 uint8_t *pkt
= (uint8_t *)label
;
45 /* The check on pkt[2] for 0x00 or 0x02 is in case bgp_set_valid_label()
46 * was called on the withdraw label */
47 if (((pkt
[0] == 0x80) || (pkt
[0] == 0x00)) && (pkt
[1] == 0x00)
48 && ((pkt
[2] == 0x00) || (pkt
[2] == 0x02)))
53 static inline int bgp_is_valid_label(const mpls_label_t
*label
)
55 uint8_t *t
= (uint8_t *)label
;
61 static inline void bgp_set_valid_label(mpls_label_t
*label
)
63 uint8_t *t
= (uint8_t *)label
;
68 static inline void bgp_unset_valid_label(mpls_label_t
*label
)
70 uint8_t *t
= (uint8_t *)label
;
75 static inline void bgp_register_for_label(struct bgp_dest
*dest
,
76 struct bgp_path_info
*pi
)
78 bgp_reg_dereg_for_label(dest
, pi
, true);
81 static inline void bgp_unregister_for_label(struct bgp_dest
*dest
)
83 bgp_reg_dereg_for_label(dest
, NULL
, false);
86 /* Return BOS value of label stream */
87 static inline uint8_t label_bos(mpls_label_t
*label
)
89 uint8_t *t
= (uint8_t *)label
;
93 #endif /* _BGP_LABEL_H */