Skip to content

Commit

Permalink
Merge pull request #14909 from chiragshah6/fdev4
Browse files Browse the repository at this point in the history
bgpd: aggr summary-only suppressed export to evpn
  • Loading branch information
ton31337 authored Nov 30, 2023
2 parents 3ed1bc8 + ac30911 commit 498505c
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 26 deletions.
38 changes: 38 additions & 0 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,39 @@ static int is_vni_present_in_irt_vnis(struct list *vnis, struct bgpevpn *vpn)
return 0;
}

/* Flag if the route is injectable into EVPN.
* This would be following category:
* Non-imported route,
* Non-EVPN imported route,
* Non Aggregate suppressed route.
*/
bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
{
struct bgp_path_info *parent_pi;
struct bgp_table *table;
struct bgp_dest *dest;

/* do not import aggr suppressed routes */
if (bgp_path_suppressed(pi))
return false;

if (pi->sub_type != BGP_ROUTE_IMPORTED || !pi->extra ||
!pi->extra->vrfleak || !pi->extra->vrfleak->parent)
return true;

parent_pi = (struct bgp_path_info *)pi->extra->vrfleak->parent;
dest = parent_pi->net;
if (!dest)
return true;
table = bgp_dest_table(dest);
if (table &&
table->afi == AFI_L2VPN &&
table->safi == SAFI_EVPN)
return false;

return true;
}

/*
* Compare Route Targets.
*/
Expand Down Expand Up @@ -1638,6 +1671,9 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
vrf_id_to_name(bgp_vrf->vrf_id), evp, &attr.rmac,
&attr.nexthop);

frrtrace(4, frr_bgp, evpn_advertise_type5, bgp_vrf->vrf_id, evp,
&attr.rmac, attr.nexthop);

attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;

if (src_afi == AFI_IP6 &&
Expand Down Expand Up @@ -2280,6 +2316,8 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp)
if (!dest)
return 0;

frrtrace(2, frr_bgp, evpn_withdraw_type5, bgp_vrf->vrf_id, evp);

delete_evpn_route_entry(bgp_evpn, afi, safi, dest, &pi);
if (pi)
bgp_process(bgp_evpn, dest, afi, safi);
Expand Down
26 changes: 1 addition & 25 deletions bgpd/bgp_evpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,6 @@ static inline bool is_pi_family_evpn(struct bgp_path_info *pi)
return is_pi_family_matching(pi, AFI_L2VPN, SAFI_EVPN);
}

/* Flag if the route is injectable into EVPN. This would be either a
* non-imported route or a non-EVPN imported route.
*/
static inline bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
{
struct bgp_path_info *parent_pi;
struct bgp_table *table;
struct bgp_dest *dest;

if (pi->sub_type != BGP_ROUTE_IMPORTED || !pi->extra ||
!pi->extra->vrfleak || !pi->extra->vrfleak->parent)
return true;

parent_pi = (struct bgp_path_info *)pi->extra->vrfleak->parent;
dest = parent_pi->net;
if (!dest)
return true;
table = bgp_dest_table(dest);
if (table &&
table->afi == AFI_L2VPN &&
table->safi == SAFI_EVPN)
return false;
return true;
}

static inline bool evpn_resolve_overlay_index(void)
{
struct bgp *bgp = NULL;
Expand Down Expand Up @@ -206,5 +181,6 @@ extern mpls_label_t *bgp_evpn_path_info_labels_get_l3vni(mpls_label_t *labels,
extern vni_t bgp_evpn_path_info_get_l3vni(const struct bgp_path_info *pi);
extern bool bgp_evpn_mpath_has_dvni(const struct bgp *bgp_vrf,
struct bgp_path_info *mpinfo);
extern bool is_route_injectable_into_evpn(struct bgp_path_info *pi);

#endif /* _QUAGGA_BGP_EVPN_H */
14 changes: 14 additions & 0 deletions bgpd/bgp_evpn_mh.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es,
? "esr"
: (vpn ? "ead-evi" : "ead-es"),
&attr->mp_nexthop_global_in);

frrtrace(4, frr_bgp, evpn_mh_local_ead_es_evi_route_upd,
&es->esi, (vpn ? vpn->vni : 0), evp->prefix.route_type,
attr->mp_nexthop_global_in);
}

/* Return back the route entry. */
Expand Down Expand Up @@ -491,6 +495,8 @@ static int bgp_evpn_mh_route_delete(struct bgp *bgp, struct bgp_evpn_es *es,
: (vpn ? "ead-evi" : "ead-es"),
&es->originator_ip);

frrtrace(4, frr_bgp, evpn_mh_local_ead_es_evi_route_del, &es->esi,
(vpn ? vpn->vni : 0), p->prefix.route_type, es->originator_ip);
/* Next, locate route node in the global EVPN routing table.
* Note that this table is a 2-level tree (RD-level + Prefix-level)
*/
Expand Down Expand Up @@ -3460,6 +3466,10 @@ static void bgp_evpn_es_evi_vtep_add(struct bgp *bgp,
evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
ead_es ? "ead_es" : "ead_evi");

frrtrace(4, frr_bgp, evpn_mh_es_evi_vtep_add,
&evi_vtep->es_evi->es->esi, evi_vtep->es_evi->vpn->vni,
evi_vtep->vtep_ip, ead_es);

if (ead_es)
SET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_ES);
else
Expand All @@ -3484,6 +3494,10 @@ static void bgp_evpn_es_evi_vtep_del(struct bgp *bgp,
evi_vtep->es_evi->vpn->vni, &evi_vtep->vtep_ip,
ead_es ? "ead_es" : "ead_evi");

frrtrace(4, frr_bgp, evpn_mh_es_evi_vtep_del,
&evi_vtep->es_evi->es->esi, evi_vtep->es_evi->vpn->vni,
evi_vtep->vtep_ip, ead_es);

if (ead_es)
UNSET_FLAG(evi_vtep->flags, BGP_EVPN_EVI_VTEP_EAD_PER_ES);
else
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ DEFINE_HOOK(bgp_process,
(bgp, afi, safi, bn, peer, withdraw));

/** Test if path is suppressed. */
static bool bgp_path_suppressed(struct bgp_path_info *pi)
bool bgp_path_suppressed(struct bgp_path_info *pi)
{
if (pi->extra == NULL || pi->extra->aggr_suppressors == NULL)
return false;
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ extern void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
extern void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr);
const char *
bgp_path_selection_reason2str(enum bgp_path_selection_reason reason);
extern bool bgp_path_suppressed(struct bgp_path_info *pi);
extern bool bgp_addpath_encode_rx(struct peer *peer, afi_t afi, safi_t safi);
extern const struct prefix_rd *bgp_rd_from_dest(const struct bgp_dest *dest,
safi_t safi);
Expand Down
86 changes: 86 additions & 0 deletions bgpd/bgp_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,64 @@ TRACEPOINT_EVENT(
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_evi_del_zrecv, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_mh_es_evi_vtep_add,
TP_ARGS(esi_t *, esi, vni_t, vni, struct in_addr, vtep,
uint8_t, ead_es),
TP_FIELDS(
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
ctf_integer(vni_t, vni, vni)
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
ctf_integer(uint8_t, ead_es, ead_es)
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_es_evi_vtep_add, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_mh_es_evi_vtep_del,
TP_ARGS(esi_t *, esi, vni_t, vni, struct in_addr, vtep,
uint8_t, ead_es),
TP_FIELDS(
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
ctf_integer(vni_t, vni, vni)
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
ctf_integer(uint8_t, ead_es, ead_es)
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_es_evi_vtep_del, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_mh_local_ead_es_evi_route_upd,
TP_ARGS(esi_t *, esi, vni_t, vni,
uint8_t, route_type,
struct in_addr, vtep),
TP_FIELDS(
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
ctf_integer(vni_t, vni, vni)
ctf_integer(uint8_t, route_type, route_type)
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_ead_es_evi_route_upd, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_mh_local_ead_es_evi_route_del,
TP_ARGS(esi_t *, esi, vni_t, vni,
uint8_t, route_type,
struct in_addr, vtep),
TP_FIELDS(
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
ctf_integer(vni_t, vni, vni)
ctf_integer(uint8_t, route_type, route_type)
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_ead_es_evi_route_del, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_local_vni_add_zrecv,
Expand Down Expand Up @@ -495,6 +553,34 @@ TRACEPOINT_EVENT(
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_macip_del_zrecv, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_advertise_type5,
TP_ARGS(vrf_id_t, vrf, const struct prefix_evpn *, pfx,
struct ethaddr *, rmac, struct in_addr, vtep),
TP_FIELDS(
ctf_integer(int, vrf_id, vrf)
ctf_array(unsigned char, ip, &pfx->prefix.prefix_addr.ip,
sizeof(struct ipaddr))
ctf_array(unsigned char, rmac, rmac,
sizeof(struct ethaddr))
ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_advertise_type5, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_withdraw_type5,
TP_ARGS(vrf_id_t, vrf, const struct prefix_evpn *, pfx),
TP_FIELDS(
ctf_integer(int, vrf_id, vrf)
ctf_array(unsigned char, ip, &pfx->prefix.prefix_addr.ip,
sizeof(struct ipaddr))
)
)
TRACEPOINT_LOGLEVEL(frr_bgp, evpn_withdraw_type5, TRACE_INFO)

TRACEPOINT_EVENT(
frr_bgp,
evpn_local_l3vni_add_zrecv,
Expand Down
70 changes: 70 additions & 0 deletions tools/frr_babeltrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,46 @@ def parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv(event):

parse_event(event, field_parsers)

def parse_frr_bgp_evpn_mh_es_evi_vtep_add(event):
"""
bgp evpn remote ead evi remote vtep add; raw format -
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
"""
field_parsers = {"esi": print_esi,
"vtep": print_net_ipv4_addr}

parse_event(event, field_parsers)

def parse_frr_bgp_evpn_mh_es_evi_vtep_del(event):
"""
bgp evpn remote ead evi remote vtep del; raw format -
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
"""
field_parsers = {"esi": print_esi,
"vtep": print_net_ipv4_addr}

parse_event(event, field_parsers)

def parse_frr_bgp_evpn_mh_local_ead_es_evi_route_upd(event):
"""
bgp evpn local ead evi vtep; raw format -
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
"""
field_parsers = {"esi": print_esi,
"vtep": print_net_ipv4_addr}

parse_event(event, field_parsers)

def parse_frr_bgp_evpn_mh_local_ead_es_evi_route_del(event):
"""
bgp evpn local ead evi vtep del; raw format -
ctf_array(unsigned char, esi, esi, sizeof(esi_t))
"""
field_parsers = {"esi": print_esi,
"vtep": print_net_ipv4_addr}

parse_event(event, field_parsers)

def parse_frr_bgp_evpn_local_vni_add_zrecv(event):
"""
bgp evpn local-vni parser; raw format -
Expand Down Expand Up @@ -205,6 +245,24 @@ def parse_frr_bgp_evpn_local_macip_del_zrecv(event):

parse_event(event, field_parsers)

def parse_frr_bgp_evpn_advertise_type5(event):
"""
local originated type-5 route
"""
field_parsers = {"ip": print_ip_addr,
"rmac": print_mac,
"vtep": print_net_ipv4_addr}

parse_event(event, field_parsers)

def parse_frr_bgp_evpn_withdraw_type5(event):
"""
local originated type-5 route withdraw
"""
field_parsers = {"ip": print_ip_addr}

parse_event(event, field_parsers)

############################ evpn parsers - end *#############################

def main():
Expand All @@ -225,6 +283,14 @@ def main():
parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv,
"frr_bgp:evpn_mh_local_es_evi_del_zrecv":
parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv,
"frr_bgp:evpn_mh_es_evi_vtep_add":
parse_frr_bgp_evpn_mh_es_evi_vtep_add,
"frr_bgp:evpn_mh_es_evi_vtep_del":
parse_frr_bgp_evpn_mh_es_evi_vtep_del,
"frr_bgp:evpn_mh_local_ead_es_evi_route_upd":
parse_frr_bgp_evpn_mh_local_ead_es_evi_route_upd,
"frr_bgp:evpn_mh_local_ead_es_evi_route_del":
parse_frr_bgp_evpn_mh_local_ead_es_evi_route_del,
"frr_bgp:evpn_local_vni_add_zrecv":
parse_frr_bgp_evpn_local_vni_add_zrecv,
"frr_bgp:evpn_local_l3vni_add_zrecv":
Expand All @@ -233,6 +299,10 @@ def main():
parse_frr_bgp_evpn_local_macip_add_zrecv,
"frr_bgp:evpn_local_macip_del_zrecv":
parse_frr_bgp_evpn_local_macip_del_zrecv,
"frr_bgp:evpn_advertise_type5":
parse_frr_bgp_evpn_advertise_type5,
"frr_bgp:evpn_withdraw_type5":
parse_frr_bgp_evpn_withdraw_type5,
}

# get the trace path from the first command line argument
Expand Down

0 comments on commit 498505c

Please sign in to comment.