Skip to content

Commit

Permalink
Merge branch 'FRRouting:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
askorichenko authored Mar 12, 2024
2 parents c87a82c + 1942951 commit f5626ec
Show file tree
Hide file tree
Showing 124 changed files with 5,355 additions and 1,927 deletions.
36 changes: 25 additions & 11 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,8 @@ static void bmp_eor(struct bmp *bmp, afi_t afi, safi_t safi, uint8_t flags,

static struct stream *bmp_update(const struct prefix *p, struct prefix_rd *prd,
struct peer *peer, struct attr *attr,
afi_t afi, safi_t safi)
afi_t afi, safi_t safi, mpls_label_t *label,
uint32_t num_labels)
{
struct bpacket_attr_vec_arr vecarr;
struct stream *s;
Expand Down Expand Up @@ -946,8 +947,8 @@ static struct stream *bmp_update(const struct prefix *p, struct prefix_rd *prd,

mpattrlen_pos = bgp_packet_mpattr_start(s, peer, afi, safi,
&vecarr, attr);
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, NULL, 0, 0, 0,
attr);
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label,
num_labels, 0, 0, attr);
bgp_packet_mpattr_end(s, mpattrlen_pos);
total_attr_len += stream_get_endp(s) - p1;
}
Expand Down Expand Up @@ -1002,7 +1003,8 @@ static struct stream *bmp_withdraw(const struct prefix *p,
static void bmp_monitor(struct bmp *bmp, struct peer *peer, uint8_t flags,
uint8_t peer_type_flag, const struct prefix *p,
struct prefix_rd *prd, struct attr *attr, afi_t afi,
safi_t safi, time_t uptime)
safi_t safi, time_t uptime, mpls_label_t *label,
uint32_t num_labels)
{
struct stream *hdr, *msg;
struct timeval tv = { .tv_sec = uptime, .tv_usec = 0 };
Expand All @@ -1019,7 +1021,8 @@ static void bmp_monitor(struct bmp *bmp, struct peer *peer, uint8_t flags,

monotime_to_realtime(&tv, &uptime_real);
if (attr)
msg = bmp_update(p, prd, peer, attr, afi, safi);
msg = bmp_update(p, prd, peer, attr, afi, safi, label,
num_labels);
else
msg = bmp_withdraw(p, prd, afi, safi);

Expand Down Expand Up @@ -1219,18 +1222,24 @@ static bool bmp_wrsync(struct bmp *bmp, struct pullwr *pullwr)
bmp_monitor(bmp, bpi->peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE,
bn_p, prd, bpi->attr, afi, safi,
bpi && bpi->extra ? bpi->extra->bgp_rib_uptime
: (time_t)(-1L));
: (time_t)(-1L),
bpi->extra ? bpi->extra->label : NULL,
bpi->extra ? bpi->extra->num_labels : 0);
}

if (bpi && CHECK_FLAG(bpi->flags, BGP_PATH_VALID) &&
CHECK_FLAG(bmp->targets->afimon[afi][safi], BMP_MON_POSTPOLICY))
bmp_monitor(bmp, bpi->peer, BMP_PEER_FLAG_L,
BMP_PEER_TYPE_GLOBAL_INSTANCE, bn_p, prd, bpi->attr,
afi, safi, bpi->uptime);
afi, safi, bpi->uptime,
bpi->extra ? bpi->extra->label : NULL,
bpi->extra ? bpi->extra->num_labels : 0);

if (adjin)
/* TODO: set label here when adjin supports labels */
bmp_monitor(bmp, adjin->peer, 0, BMP_PEER_TYPE_GLOBAL_INSTANCE,
bn_p, prd, adjin->attr, afi, safi, adjin->uptime);
bn_p, prd, adjin->attr, afi, safi, adjin->uptime,
NULL, 0);

if (bn)
bgp_dest_unlock_node(bn);
Expand Down Expand Up @@ -1343,7 +1352,9 @@ static bool bmp_wrqueue_locrib(struct bmp *bmp, struct pullwr *pullwr)
bmp_monitor(bmp, peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE, &bqe->p, prd,
bpi ? bpi->attr : NULL, afi, safi,
bpi && bpi->extra ? bpi->extra->bgp_rib_uptime
: (time_t)(-1L));
: (time_t)(-1L),
(bpi && bpi->extra) ? bpi->extra->label : NULL,
(bpi && bpi->extra) ? bpi->extra->num_labels : 0);
written = true;

out:
Expand Down Expand Up @@ -1416,7 +1427,9 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)
bmp_monitor(bmp, peer, BMP_PEER_FLAG_L,
BMP_PEER_TYPE_GLOBAL_INSTANCE, &bqe->p, prd,
bpi ? bpi->attr : NULL, afi, safi,
bpi ? bpi->uptime : monotime(NULL));
bpi ? bpi->uptime : monotime(NULL),
(bpi && bpi->extra) ? bpi->extra->label : NULL,
(bpi && bpi->extra) ? bpi->extra->num_labels : 0);
written = true;
}

Expand All @@ -1428,9 +1441,10 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)
if (adjin->peer == peer)
break;
}
/* TODO: set label here when adjin supports labels */
bmp_monitor(bmp, peer, 0, BMP_PEER_TYPE_GLOBAL_INSTANCE,
&bqe->p, prd, adjin ? adjin->attr : NULL, afi, safi,
adjin ? adjin->uptime : monotime(NULL));
adjin ? adjin->uptime : monotime(NULL), NULL, 0);
written = true;
}

Expand Down
2 changes: 2 additions & 0 deletions bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static const struct message bgp_notify_msg[] = {
{BGP_NOTIFY_FSM_ERR, "Neighbor Events Error"},
{BGP_NOTIFY_CEASE, "Cease"},
{BGP_NOTIFY_ROUTE_REFRESH_ERR, "ROUTE-REFRESH Message Error"},
{BGP_NOTIFY_SEND_HOLD_ERR, "Send Hold Timer Expired"},
{0}};

static const struct message bgp_notify_head_msg[] = {
Expand Down Expand Up @@ -515,6 +516,7 @@ const char *bgp_notify_subcode_str(char code, char subcode)
return lookup_msg(bgp_notify_update_msg, subcode,
"Unrecognized Error Subcode");
case BGP_NOTIFY_HOLD_ERR:
case BGP_NOTIFY_SEND_HOLD_ERR:
break;
case BGP_NOTIFY_FSM_ERR:
return lookup_msg(bgp_notify_fsm_msg, subcode,
Expand Down
83 changes: 77 additions & 6 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,18 +315,13 @@ static int is_vni_present_in_irt_vnis(struct list *vnis, struct bgpevpn *vpn)
* 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)
bool is_route_injectable_into_evpn_non_supp(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;
Expand All @@ -344,6 +339,21 @@ bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
return true;
}

/* 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)
{
/* do not import aggr suppressed routes */
if (bgp_path_suppressed(pi))
return false;

return is_route_injectable_into_evpn_non_supp(pi);
}

/*
* Compare Route Targets.
*/
Expand Down Expand Up @@ -7711,3 +7721,64 @@ bool bgp_evpn_mpath_has_dvni(const struct bgp *bgp_vrf,

return false;
}

/* Upon aggregate set trigger unimport suppressed routes
* from EVPN
*/
void bgp_aggr_supp_withdraw_from_evpn(struct bgp *bgp, afi_t afi, safi_t safi)
{
struct bgp_dest *agg_dest, *dest, *top;
const struct prefix *aggr_p;
struct bgp_aggregate *bgp_aggregate;
struct bgp_table *table;
struct bgp_path_info *pi;

if (!bgp_get_evpn() && !advertise_type5_routes(bgp, afi))
return;

/* Aggregate-address table walk. */
table = bgp->rib[afi][safi];
for (agg_dest = bgp_table_top(bgp->aggregate[afi][safi]); agg_dest;
agg_dest = bgp_route_next(agg_dest)) {
bgp_aggregate = bgp_dest_get_bgp_aggregate_info(agg_dest);

if (bgp_aggregate == NULL)
continue;

aggr_p = bgp_dest_get_prefix(agg_dest);

/* Look all nodes below the aggregate prefix in
* global AFI/SAFI table (IPv4/IPv6).
* Trigger withdrawal (this will be Type-5 routes only)
* from EVPN Global table.
*/
top = bgp_node_get(table, aggr_p);
for (dest = bgp_node_get(table, aggr_p); dest;
dest = bgp_route_next_until(dest, top)) {
const struct prefix *dest_p = bgp_dest_get_prefix(dest);

if (dest_p->prefixlen <= aggr_p->prefixlen)
continue;

for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
if (pi->sub_type == BGP_ROUTE_AGGREGATE)
continue;

/* Only Suppressed route remove from EVPN */
if (!bgp_path_suppressed(pi))
continue;

if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s aggregated %pFX remove suppressed route %pFX",
__func__, aggr_p, dest_p);

if (!is_route_injectable_into_evpn_non_supp(pi))
continue;

bgp_evpn_withdraw_type5_route(bgp, dest_p, afi,
safi);
}
}
}
}
3 changes: 3 additions & 0 deletions bgpd/bgp_evpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,8 @@ 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);
extern bool is_route_injectable_into_evpn_non_supp(struct bgp_path_info *pi);
extern void bgp_aggr_supp_withdraw_from_evpn(struct bgp *bgp, afi_t afi,
safi_t safi);

#endif /* _QUAGGA_BGP_EVPN_H */
2 changes: 1 addition & 1 deletion bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ bgp_stop_with_error(struct peer_connection *connection)


/* something went wrong, send notify and tear down */
static enum bgp_fsm_state_progress
enum bgp_fsm_state_progress
bgp_stop_with_notify(struct peer_connection *connection, uint8_t code,
uint8_t sub_code)
{
Expand Down
3 changes: 3 additions & 0 deletions bgpd/bgp_fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ extern void bgp_maxmed_update(struct bgp *);
extern bool bgp_maxmed_onstartup_configured(struct bgp *);
extern bool bgp_maxmed_onstartup_active(struct bgp *);
extern int bgp_fsm_error_subcode(int status);
extern enum bgp_fsm_state_progress
bgp_stop_with_notify(struct peer_connection *connection, uint8_t code,
uint8_t sub_code);

/**
* Start the route advertisement timer (that honors MRAI) for all the
Expand Down
19 changes: 10 additions & 9 deletions bgpd/bgp_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
break;
case AFI_IP6:
p->family = AF_INET6;
if (pi->attr && pi->attr->srv6_l3vpn) {
if (pi->attr->srv6_l3vpn) {
IPV6_ADDR_COPY(&(p->u.prefix6),
&(pi->attr->srv6_l3vpn->sid));
p->prefixlen = IPV6_MAX_BITLEN;
Expand All @@ -1068,18 +1068,19 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
/* If we receive MP_REACH nexthop with ::(LL)
* or LL(LL), use LL address as nexthop cache.
*/
if (pi->attr->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
&& (IN6_IS_ADDR_UNSPECIFIED(
&pi->attr->mp_nexthop_global)
|| IN6_IS_ADDR_LINKLOCAL(
&pi->attr->mp_nexthop_global)))
if (pi->attr &&
pi->attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL &&
(IN6_IS_ADDR_UNSPECIFIED(
&pi->attr->mp_nexthop_global) ||
IN6_IS_ADDR_LINKLOCAL(&pi->attr->mp_nexthop_global)))
p->u.prefix6 = pi->attr->mp_nexthop_local;
/* If we receive MR_REACH with (GA)::(LL)
* then check for route-map to choose GA or LL
*/
else if (pi->attr->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
else if (pi->attr &&
pi->attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
if (CHECK_FLAG(pi->attr->nh_flags,
BGP_ATTR_NH_MP_PREFER_GLOBAL))
p->u.prefix6 =
Expand Down
1 change: 0 additions & 1 deletion bgpd/bgp_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,6 @@ uint16_t bgp_open_capability(struct stream *s, struct peer *peer,
* or disable its use, and that switch MUST be off by default.
*/
if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_SOFT_VERSION) ||
CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY) ||
peer->sort == BGP_PEER_IBGP || peer->sub_sort == BGP_PEER_EBGP_OAD) {
SET_FLAG(peer->cap, PEER_CAP_SOFT_VERSION_ADV);
stream_putc(s, BGP_OPEN_OPT_CAP);
Expand Down
Loading

0 comments on commit f5626ec

Please sign in to comment.