Coverage Report

Created: 2025-08-28 06:29

/src/frr/bgpd/bgp_label.h
Line
Count
Source (jump to first uncovered line)
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
/* BGP carrying Label information
3
 * Copyright (C) 2013 Cumulus Networks, Inc.
4
 */
5
6
#ifndef _BGP_LABEL_H
7
#define _BGP_LABEL_H
8
9
0
#define BGP_LABEL_BYTES 3
10
#define BGP_LABEL_BITS 24
11
#define BGP_WITHDRAW_LABEL 0x800000
12
0
#define BGP_PREVENT_VRF_2_VRF_LEAK 0xFFFFFFFE
13
14
struct bgp_dest;
15
struct bgp_path_info;
16
struct peer;
17
18
extern int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
19
            bool allocated);
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);
26
27
extern int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
28
        struct bgp_nlri *packet);
29
30
static inline int bgp_labeled_safi(safi_t safi)
31
0
{
32
  /* NOTE: This API really says a label (tag) MAY be present. Not all EVPN
33
   * routes will have a label.
34
   */
35
0
  if ((safi == SAFI_LABELED_UNICAST) || (safi == SAFI_MPLS_VPN)
36
0
      || (safi == SAFI_EVPN))
37
0
    return 1;
38
0
  return 0;
39
0
}
Unexecuted instantiation: bgp_attr.c:bgp_labeled_safi
Unexecuted instantiation: bgp_debug.c:bgp_labeled_safi
Unexecuted instantiation: bgp_evpn.c:bgp_labeled_safi
Unexecuted instantiation: bgp_evpn_mh.c:bgp_labeled_safi
Unexecuted instantiation: bgp_mplsvpn.c:bgp_labeled_safi
Unexecuted instantiation: bgp_packet.c:bgp_labeled_safi
Unexecuted instantiation: bgp_route.c:bgp_labeled_safi
Unexecuted instantiation: bgp_updgrp_packet.c:bgp_labeled_safi
Unexecuted instantiation: bgp_zebra.c:bgp_labeled_safi
Unexecuted instantiation: rfapi_vty.c:bgp_labeled_safi
Unexecuted instantiation: bgp_label.c:bgp_labeled_safi
40
41
static inline int bgp_is_withdraw_label(mpls_label_t *label)
42
0
{
43
0
  uint8_t *pkt = (uint8_t *)label;
44
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
0
  if (((pkt[0] == 0x80) || (pkt[0] == 0x00)) && (pkt[1] == 0x00)
48
0
      && ((pkt[2] == 0x00) || (pkt[2] == 0x02)))
49
0
    return 1;
50
0
  return 0;
51
0
}
Unexecuted instantiation: bgp_attr.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_debug.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_evpn.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_evpn_mh.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_mplsvpn.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_packet.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_route.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_updgrp_packet.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_zebra.c:bgp_is_withdraw_label
Unexecuted instantiation: rfapi_vty.c:bgp_is_withdraw_label
Unexecuted instantiation: bgp_label.c:bgp_is_withdraw_label
52
53
static inline int bgp_is_valid_label(const mpls_label_t *label)
54
0
{
55
0
  uint8_t *t = (uint8_t *)label;
56
0
  if (!t)
57
0
    return 0;
58
0
  return (t[2] & 0x02);
59
0
}
Unexecuted instantiation: bgp_attr.c:bgp_is_valid_label
Unexecuted instantiation: bgp_debug.c:bgp_is_valid_label
Unexecuted instantiation: bgp_evpn.c:bgp_is_valid_label
Unexecuted instantiation: bgp_evpn_mh.c:bgp_is_valid_label
Unexecuted instantiation: bgp_mplsvpn.c:bgp_is_valid_label
Unexecuted instantiation: bgp_packet.c:bgp_is_valid_label
Unexecuted instantiation: bgp_route.c:bgp_is_valid_label
Unexecuted instantiation: bgp_updgrp_packet.c:bgp_is_valid_label
Unexecuted instantiation: bgp_zebra.c:bgp_is_valid_label
Unexecuted instantiation: rfapi_vty.c:bgp_is_valid_label
Unexecuted instantiation: bgp_label.c:bgp_is_valid_label
60
61
static inline void bgp_set_valid_label(mpls_label_t *label)
62
0
{
63
0
  uint8_t *t = (uint8_t *)label;
64
0
  if (t)
65
0
    t[2] |= 0x02;
66
0
}
Unexecuted instantiation: bgp_attr.c:bgp_set_valid_label
Unexecuted instantiation: bgp_debug.c:bgp_set_valid_label
Unexecuted instantiation: bgp_evpn.c:bgp_set_valid_label
Unexecuted instantiation: bgp_evpn_mh.c:bgp_set_valid_label
Unexecuted instantiation: bgp_mplsvpn.c:bgp_set_valid_label
Unexecuted instantiation: bgp_packet.c:bgp_set_valid_label
Unexecuted instantiation: bgp_route.c:bgp_set_valid_label
Unexecuted instantiation: bgp_updgrp_packet.c:bgp_set_valid_label
Unexecuted instantiation: bgp_zebra.c:bgp_set_valid_label
Unexecuted instantiation: rfapi_vty.c:bgp_set_valid_label
Unexecuted instantiation: bgp_label.c:bgp_set_valid_label
67
68
static inline void bgp_unset_valid_label(mpls_label_t *label)
69
0
{
70
0
  uint8_t *t = (uint8_t *)label;
71
0
  if (t)
72
0
    t[2] &= ~0x02;
73
0
}
Unexecuted instantiation: bgp_attr.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_debug.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_evpn.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_evpn_mh.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_mplsvpn.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_packet.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_route.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_updgrp_packet.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_zebra.c:bgp_unset_valid_label
Unexecuted instantiation: rfapi_vty.c:bgp_unset_valid_label
Unexecuted instantiation: bgp_label.c:bgp_unset_valid_label
74
75
static inline void bgp_register_for_label(struct bgp_dest *dest,
76
            struct bgp_path_info *pi)
77
0
{
78
0
  bgp_reg_dereg_for_label(dest, pi, true);
79
0
}
Unexecuted instantiation: bgp_attr.c:bgp_register_for_label
Unexecuted instantiation: bgp_debug.c:bgp_register_for_label
Unexecuted instantiation: bgp_evpn.c:bgp_register_for_label
Unexecuted instantiation: bgp_evpn_mh.c:bgp_register_for_label
Unexecuted instantiation: bgp_mplsvpn.c:bgp_register_for_label
Unexecuted instantiation: bgp_packet.c:bgp_register_for_label
Unexecuted instantiation: bgp_route.c:bgp_register_for_label
Unexecuted instantiation: bgp_updgrp_packet.c:bgp_register_for_label
Unexecuted instantiation: bgp_zebra.c:bgp_register_for_label
Unexecuted instantiation: rfapi_vty.c:bgp_register_for_label
Unexecuted instantiation: bgp_label.c:bgp_register_for_label
80
81
static inline void bgp_unregister_for_label(struct bgp_dest *dest)
82
0
{
83
0
  bgp_reg_dereg_for_label(dest, NULL, false);
84
0
}
Unexecuted instantiation: bgp_attr.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_debug.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_evpn.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_evpn_mh.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_mplsvpn.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_packet.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_route.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_updgrp_packet.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_zebra.c:bgp_unregister_for_label
Unexecuted instantiation: rfapi_vty.c:bgp_unregister_for_label
Unexecuted instantiation: bgp_label.c:bgp_unregister_for_label
85
86
/* Return BOS value of label stream */
87
static inline uint8_t label_bos(mpls_label_t *label)
88
0
{
89
0
  uint8_t *t = (uint8_t *)label;
90
0
  return (t[2] & 0x01);
91
0
};
Unexecuted instantiation: bgp_attr.c:label_bos
Unexecuted instantiation: bgp_debug.c:label_bos
Unexecuted instantiation: bgp_evpn.c:label_bos
Unexecuted instantiation: bgp_evpn_mh.c:label_bos
Unexecuted instantiation: bgp_mplsvpn.c:label_bos
Unexecuted instantiation: bgp_packet.c:label_bos
Unexecuted instantiation: bgp_route.c:label_bos
Unexecuted instantiation: bgp_updgrp_packet.c:label_bos
Unexecuted instantiation: bgp_zebra.c:label_bos
Unexecuted instantiation: rfapi_vty.c:label_bos
Unexecuted instantiation: bgp_label.c:label_bos
92
93
#endif /* _BGP_LABEL_H */