Coverage Report

Created: 2025-08-26 06:20

/src/frr/bgpd/bgp_evpn.h
Line
Count
Source (jump to first uncovered line)
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
/* E-VPN header for packet handling
3
 * Copyright (C) 2016 6WIND
4
 */
5
6
#ifndef _QUAGGA_BGP_EVPN_H
7
#define _QUAGGA_BGP_EVPN_H
8
9
#include "vxlan.h"
10
#include "bgpd.h"
11
12
#define EVPN_ROUTE_STRLEN 200 /* Must be >> MAC + IPv6 strings. */
13
0
#define EVPN_AUTORT_VXLAN 0x10000000
14
15
0
#define EVPN_ENABLED(bgp)  (bgp)->advertise_all_vni
16
static inline int is_evpn_enabled(void)
17
0
{
18
0
  struct bgp *bgp = NULL;
19
20
0
  bgp = bgp_get_evpn();
21
0
  return bgp ? EVPN_ENABLED(bgp) : 0;
22
0
}
Unexecuted instantiation: bgp_main.c:is_evpn_enabled
Unexecuted instantiation: bgp_attr.c:is_evpn_enabled
Unexecuted instantiation: bgp_attr_evpn.c:is_evpn_enabled
Unexecuted instantiation: bgp_debug.c:is_evpn_enabled
Unexecuted instantiation: bgp_evpn.c:is_evpn_enabled
Unexecuted instantiation: bgp_evpn_mh.c:is_evpn_enabled
Unexecuted instantiation: bgp_evpn_vty.c:is_evpn_enabled
Unexecuted instantiation: bgp_mplsvpn.c:is_evpn_enabled
Unexecuted instantiation: bgp_nht.c:is_evpn_enabled
Unexecuted instantiation: bgp_packet.c:is_evpn_enabled
Unexecuted instantiation: bgp_route.c:is_evpn_enabled
Unexecuted instantiation: bgp_routemap.c:is_evpn_enabled
Unexecuted instantiation: bgp_vty.c:is_evpn_enabled
Unexecuted instantiation: bgp_zebra.c:is_evpn_enabled
Unexecuted instantiation: bgpd.c:is_evpn_enabled
23
24
static inline int advertise_type5_routes(struct bgp *bgp_vrf,
25
           afi_t afi)
26
0
{
27
0
  if (!bgp_vrf->l3vni)
28
0
    return 0;
29
30
0
  if ((afi == AFI_IP)
31
0
      && ((CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
32
0
          BGP_L2VPN_EVPN_ADV_IPV4_UNICAST))
33
0
    || (CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
34
0
             BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP))))
35
0
    return 1;
36
37
0
  if ((afi == AFI_IP6)
38
0
      && ((CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
39
0
          BGP_L2VPN_EVPN_ADV_IPV6_UNICAST))
40
0
    || (CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
41
0
             BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))))
42
0
    return 1;
43
44
0
  return 0;
45
0
}
Unexecuted instantiation: bgp_main.c:advertise_type5_routes
Unexecuted instantiation: bgp_attr.c:advertise_type5_routes
Unexecuted instantiation: bgp_attr_evpn.c:advertise_type5_routes
Unexecuted instantiation: bgp_debug.c:advertise_type5_routes
Unexecuted instantiation: bgp_evpn.c:advertise_type5_routes
Unexecuted instantiation: bgp_evpn_mh.c:advertise_type5_routes
Unexecuted instantiation: bgp_evpn_vty.c:advertise_type5_routes
Unexecuted instantiation: bgp_mplsvpn.c:advertise_type5_routes
Unexecuted instantiation: bgp_nht.c:advertise_type5_routes
Unexecuted instantiation: bgp_packet.c:advertise_type5_routes
Unexecuted instantiation: bgp_route.c:advertise_type5_routes
Unexecuted instantiation: bgp_routemap.c:advertise_type5_routes
Unexecuted instantiation: bgp_vty.c:advertise_type5_routes
Unexecuted instantiation: bgp_zebra.c:advertise_type5_routes
Unexecuted instantiation: bgpd.c:advertise_type5_routes
46
47
/* Flag if the route's parent is a EVPN route. */
48
static inline struct bgp_path_info *
49
get_route_parent_evpn(struct bgp_path_info *ri)
50
0
{
51
0
  struct bgp_path_info *parent_ri;
52
53
  /* If not imported (or doesn't have a parent), bail. */
54
0
  if (ri->sub_type != BGP_ROUTE_IMPORTED ||
55
0
      !ri->extra ||
56
0
      !ri->extra->parent)
57
0
    return NULL;
58
59
  /* Determine parent recursively */
60
0
  for (parent_ri = ri->extra->parent;
61
0
       parent_ri->extra && parent_ri->extra->parent;
62
0
       parent_ri = parent_ri->extra->parent)
63
0
    ;
64
65
0
  return parent_ri;
66
0
}
Unexecuted instantiation: bgp_main.c:get_route_parent_evpn
Unexecuted instantiation: bgp_attr.c:get_route_parent_evpn
Unexecuted instantiation: bgp_attr_evpn.c:get_route_parent_evpn
Unexecuted instantiation: bgp_debug.c:get_route_parent_evpn
Unexecuted instantiation: bgp_evpn.c:get_route_parent_evpn
Unexecuted instantiation: bgp_evpn_mh.c:get_route_parent_evpn
Unexecuted instantiation: bgp_evpn_vty.c:get_route_parent_evpn
Unexecuted instantiation: bgp_mplsvpn.c:get_route_parent_evpn
Unexecuted instantiation: bgp_nht.c:get_route_parent_evpn
Unexecuted instantiation: bgp_packet.c:get_route_parent_evpn
Unexecuted instantiation: bgp_route.c:get_route_parent_evpn
Unexecuted instantiation: bgp_routemap.c:get_route_parent_evpn
Unexecuted instantiation: bgp_vty.c:get_route_parent_evpn
Unexecuted instantiation: bgp_zebra.c:get_route_parent_evpn
Unexecuted instantiation: bgpd.c:get_route_parent_evpn
67
68
/* Flag if the route's parent is a EVPN route. */
69
static inline int is_route_parent_evpn(struct bgp_path_info *ri)
70
0
{
71
0
  struct bgp_path_info *parent_ri;
72
0
  struct bgp_table *table;
73
0
  struct bgp_dest *dest;
74
75
0
  parent_ri = get_route_parent_evpn(ri);
76
0
  if (!parent_ri)
77
0
    return 0;
78
79
  /* See if of family L2VPN/EVPN */
80
0
  dest = parent_ri->net;
81
0
  if (!dest)
82
0
    return 0;
83
0
  table = bgp_dest_table(dest);
84
0
  if (table &&
85
0
      table->afi == AFI_L2VPN &&
86
0
      table->safi == SAFI_EVPN)
87
0
    return 1;
88
0
  return 0;
89
0
}
Unexecuted instantiation: bgp_main.c:is_route_parent_evpn
Unexecuted instantiation: bgp_attr.c:is_route_parent_evpn
Unexecuted instantiation: bgp_attr_evpn.c:is_route_parent_evpn
Unexecuted instantiation: bgp_debug.c:is_route_parent_evpn
Unexecuted instantiation: bgp_evpn.c:is_route_parent_evpn
Unexecuted instantiation: bgp_evpn_mh.c:is_route_parent_evpn
Unexecuted instantiation: bgp_evpn_vty.c:is_route_parent_evpn
Unexecuted instantiation: bgp_mplsvpn.c:is_route_parent_evpn
Unexecuted instantiation: bgp_nht.c:is_route_parent_evpn
Unexecuted instantiation: bgp_packet.c:is_route_parent_evpn
Unexecuted instantiation: bgp_route.c:is_route_parent_evpn
Unexecuted instantiation: bgp_routemap.c:is_route_parent_evpn
Unexecuted instantiation: bgp_vty.c:is_route_parent_evpn
Unexecuted instantiation: bgp_zebra.c:is_route_parent_evpn
Unexecuted instantiation: bgpd.c:is_route_parent_evpn
90
91
/* Flag if the route path's family is EVPN. */
92
static inline bool is_pi_family_evpn(struct bgp_path_info *pi)
93
0
{
94
0
  return is_pi_family_matching(pi, AFI_L2VPN, SAFI_EVPN);
95
0
}
Unexecuted instantiation: bgp_main.c:is_pi_family_evpn
Unexecuted instantiation: bgp_attr.c:is_pi_family_evpn
Unexecuted instantiation: bgp_attr_evpn.c:is_pi_family_evpn
Unexecuted instantiation: bgp_debug.c:is_pi_family_evpn
Unexecuted instantiation: bgp_evpn.c:is_pi_family_evpn
Unexecuted instantiation: bgp_evpn_mh.c:is_pi_family_evpn
Unexecuted instantiation: bgp_evpn_vty.c:is_pi_family_evpn
Unexecuted instantiation: bgp_mplsvpn.c:is_pi_family_evpn
Unexecuted instantiation: bgp_nht.c:is_pi_family_evpn
Unexecuted instantiation: bgp_packet.c:is_pi_family_evpn
Unexecuted instantiation: bgp_route.c:is_pi_family_evpn
Unexecuted instantiation: bgp_routemap.c:is_pi_family_evpn
Unexecuted instantiation: bgp_vty.c:is_pi_family_evpn
Unexecuted instantiation: bgp_zebra.c:is_pi_family_evpn
Unexecuted instantiation: bgpd.c:is_pi_family_evpn
96
97
/* Flag if the route is injectable into EVPN. This would be either a
98
 * non-imported route or a non-EVPN imported route.
99
 */
100
static inline bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
101
0
{
102
0
  struct bgp_path_info *parent_pi;
103
0
  struct bgp_table *table;
104
0
  struct bgp_dest *dest;
105
106
0
  if (pi->sub_type != BGP_ROUTE_IMPORTED ||
107
0
      !pi->extra ||
108
0
      !pi->extra->parent)
109
0
    return true;
110
111
0
  parent_pi = (struct bgp_path_info *)pi->extra->parent;
112
0
  dest = parent_pi->net;
113
0
  if (!dest)
114
0
    return true;
115
0
  table = bgp_dest_table(dest);
116
0
  if (table &&
117
0
      table->afi == AFI_L2VPN &&
118
0
      table->safi == SAFI_EVPN)
119
0
    return false;
120
0
  return true;
121
0
}
Unexecuted instantiation: bgp_main.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_attr.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_attr_evpn.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_debug.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_evpn.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_evpn_mh.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_evpn_vty.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_mplsvpn.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_nht.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_packet.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_route.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_routemap.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_vty.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgp_zebra.c:is_route_injectable_into_evpn
Unexecuted instantiation: bgpd.c:is_route_injectable_into_evpn
122
123
static inline bool evpn_resolve_overlay_index(void)
124
0
{
125
0
  struct bgp *bgp = NULL;
126
127
0
  bgp = bgp_get_evpn();
128
0
  return bgp ? bgp->resolve_overlay_index : false;
129
0
}
Unexecuted instantiation: bgp_main.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_attr.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_attr_evpn.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_debug.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_evpn.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_evpn_mh.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_evpn_vty.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_mplsvpn.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_nht.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_packet.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_route.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_routemap.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_vty.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgp_zebra.c:evpn_resolve_overlay_index
Unexecuted instantiation: bgpd.c:evpn_resolve_overlay_index
130
131
extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,
132
             const struct prefix *p,
133
             struct attr *src_attr, afi_t afi,
134
             safi_t safi);
135
extern void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf,
136
            const struct prefix *p, afi_t afi,
137
            safi_t safi);
138
extern void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi,
139
             safi_t safi);
140
extern void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
141
              safi_t safi);
142
extern void bgp_evpn_vrf_delete(struct bgp *bgp_vrf);
143
extern void bgp_evpn_handle_router_id_update(struct bgp *bgp, int withdraw);
144
extern char *bgp_evpn_label2str(mpls_label_t *label, uint32_t num_labels,
145
        char *buf, int len);
146
extern void bgp_evpn_route2json(const struct prefix_evpn *p, json_object *json);
147
extern void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
148
           const struct prefix_rd *prd,
149
           mpls_label_t *label, uint32_t num_labels,
150
           struct attr *attr, bool addpath_capable,
151
           uint32_t addpath_tx_id);
152
extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
153
             struct bgp_nlri *packet, bool withdraw);
154
extern int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi,
155
         const struct prefix *p,
156
         struct bgp_path_info *ri);
157
extern int bgp_evpn_unimport_route(struct bgp *bgp, afi_t afi, safi_t safi,
158
           const struct prefix *p,
159
           struct bgp_path_info *ri);
160
extern int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp);
161
extern int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni,
162
            struct ethaddr *mac, struct ipaddr *ip,
163
          int state);
164
extern int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni,
165
            struct ethaddr *mac, struct ipaddr *ip,
166
            uint8_t flags, uint32_t seq, esi_t *esi);
167
extern int bgp_evpn_local_l3vni_add(vni_t vni, vrf_id_t vrf_id,
168
            struct ethaddr *rmac,
169
            struct ethaddr *vrr_rmac,
170
            struct in_addr originator_ip, int filter,
171
            ifindex_t svi_ifindex, bool is_anycast_mac);
172
extern int bgp_evpn_local_l3vni_del(vni_t vni, vrf_id_t vrf_id);
173
extern int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni);
174
extern int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni,
175
          struct in_addr originator_ip,
176
          vrf_id_t tenant_vrf_id,
177
          struct in_addr mcast_grp,
178
          ifindex_t svi_ifindex);
179
extern void bgp_evpn_flood_control_change(struct bgp *bgp);
180
extern void bgp_evpn_cleanup_on_disable(struct bgp *bgp);
181
extern void bgp_evpn_cleanup(struct bgp *bgp);
182
extern void bgp_evpn_init(struct bgp *bgp);
183
extern int bgp_evpn_get_type5_prefixlen(const struct prefix *pfx);
184
extern bool bgp_evpn_is_prefix_nht_supported(const struct prefix *pfx);
185
extern void update_advertise_vrf_routes(struct bgp *bgp_vrf);
186
extern void bgp_evpn_show_remote_ip_hash(struct hash_bucket *bucket,
187
           void *args);
188
extern void bgp_evpn_show_vni_svi_hash(struct hash_bucket *bucket, void *args);
189
extern bool bgp_evpn_is_gateway_ip_resolved(struct bgp_nexthop_cache *bnc);
190
extern void
191
bgp_evpn_handle_resolve_overlay_index_set(struct hash_bucket *bucket,
192
            void *arg);
193
extern void
194
bgp_evpn_handle_resolve_overlay_index_unset(struct hash_bucket *bucket,
195
              void *arg);
196
extern mpls_label_t *bgp_evpn_path_info_labels_get_l3vni(mpls_label_t *labels,
197
               uint32_t num_labels);
198
extern vni_t bgp_evpn_path_info_get_l3vni(const struct bgp_path_info *pi);
199
extern bool bgp_evpn_mpath_has_dvni(const struct bgp *bgp_vrf,
200
            struct bgp_path_info *mpinfo);
201
202
#endif /* _QUAGGA_BGP_EVPN_H */