Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "bgp_vnc_types.h"
#endif
#include "bgp_evpn.h"
#include "bgp_mup.h"
#include "bgp_flowspec_private.h"
#include "bgp_mac.h"
#include "bgpd/bgp_ls_nlri.h"
Expand Down Expand Up @@ -4959,6 +4960,16 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
stream_putc(s, IPV4_MAX_BYTELEN);
stream_put_ipv4(s, attr->mp_nexthop_global_in.s_addr);
break;
case SAFI_MUP:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the case here belongs here definately, but the stream_put code belongs in a later commit.

/* Keep whichever nexthop family the route carries. */
if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) {
stream_putc(s, BGP_ATTR_NHLEN_IPV4);
stream_put(s, &attr->mp_nexthop_global_in, 4);
} else {
stream_putc(s, IPV6_MAX_BYTELEN);
stream_put(s, &attr->mp_nexthop_global, IPV6_MAX_BYTELEN);
}
break;
case SAFI_UNSPEC:
case SAFI_MAX:
assert(!"SAFI's UNSPEC or MAX being specified are a DEV ESCAPE");
Expand All @@ -4970,7 +4981,8 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
case SAFI_UNICAST:
case SAFI_MULTICAST:
case SAFI_LABELED_UNICAST:
case SAFI_EVPN: {
case SAFI_EVPN:
case SAFI_MUP: {
if (attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
stream_putc(s,
Expand Down Expand Up @@ -5220,6 +5232,9 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi, const st
case SAFI_ENCAP:
assert(!"Please add proper encoding of SAFI_ENCAP");
break;
case SAFI_MUP:
bgp_mup_encode_prefix(s, afi, p, prd, addpath_capable, addpath_tx_id);
break;
}
}

Expand Down Expand Up @@ -5263,6 +5278,9 @@ size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
/* TODO: add explaination */
size = 0;
break;
case SAFI_MUP:
size = bgp_mup_prefix_size(p);
break;
}

return size;
Expand Down Expand Up @@ -5792,7 +5810,8 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, struct strea
if ((afi == AFI_IP || afi == AFI_IP6)) {
struct bgp_attr_srv6_l3service *srv6_l3service = NULL;

if (safi == SAFI_MPLS_VPN && bgp_attr_get_srv6_l3service(attr))
if ((safi == SAFI_MPLS_VPN || safi == SAFI_MUP) &&
bgp_attr_get_srv6_l3service(attr))
srv6_l3service = bgp_attr_get_srv6_l3service(attr);
else if (peer_af_flag_check(peer, afi, safi,
PEER_FLAG_CONFIG_ENCAPSULATION_SRV6_RELAX) ||
Expand Down
18 changes: 18 additions & 0 deletions bgpd/bgp_ecommunity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,24 @@ static char *_ecommunity_ecom2str(struct ecommunity *ecom, int format, int filte
l2mtu);
} else
unk_ecom = true;
} else if (type == ECOMMUNITY_ENCODE_MUP) {
sub_type = *pnt++;
if (sub_type == ECOMMUNITY_MUP_SUBTYPE_DIRECT_SEG_ID) {
/* draft-ietf-bess-mup-safi section 3.2:
* 6-byte segment identifier; display it as a
* uint16:uint32 pair like the "AS:NN" RD form.
*/
uint16_t sid_hi;
uint32_t sid_lo;

memcpy(&sid_hi, pnt, 2);
sid_hi = ntohs(sid_hi);
memcpy(&sid_lo, pnt + 2, 4);
sid_lo = ntohl(sid_lo);
snprintf(encbuf, sizeof(encbuf), "MUP:%u:%u", sid_hi, sid_lo);
} else {
unk_ecom = true;
}
} else if (type == ECOMMUNITY_ENCODE_REDIRECT_IP_NH) {
sub_type = *pnt++;
if (sub_type == ECOMMUNITY_REDIRECT_IP_NH) {
Expand Down
4 changes: 4 additions & 0 deletions bgpd/bgp_ecommunity.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define ECOMMUNITY_ENCODE_OPAQUE 0x03
#define ECOMMUNITY_ENCODE_EVPN 0x06
#define ECOMMUNITY_ENCODE_REDIRECT_IP_NH 0x08 /* Flow Spec */
#define ECOMMUNITY_ENCODE_MUP 0x0c
/* Generic Transitive Experimental */
#define ECOMMUNITY_ENCODE_TRANS_EXP 0x80

Expand Down Expand Up @@ -93,6 +94,9 @@
#define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c
#define ECOMMUNITY_OPAQUE_SUBTYPE_COLOR 0x0b

/* Sub-Types for ECOMMUNITY_ENCODE_MUP (draft 3.2). */
#define ECOMMUNITY_MUP_SUBTYPE_DIRECT_SEG_ID 0x00

/* Extended communities attribute string format. */
#define ECOMMUNITY_FORMAT_ROUTE_MAP 0
#define ECOMMUNITY_FORMAT_COMMUNITY_LIST 1
Expand Down
7 changes: 7 additions & 0 deletions bgpd/bgp_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,13 @@ static struct log_ref ferr_bgp_err[] = {
.description = "BGP-LS NLRI or attribute packet parsing/encoding error",
.suggestion = "Check that BGP-LS peer is sending valid packets per RFC 9552. May indicate interoperability issue or malformed data.",
},
{
.code = EC_BGP_MUP_PACKET,
.title = "BGP-MUP packet error",
.description = "BGP-MUP NLRI or attribute packet parsing/encoding error",
.suggestion =
"Check that the BGP-MUP peer is sending valid packets per draft-ietf-bess-mup-safi. May indicate an interoperability issue or malformed data.",
},
{
.code = END_FERR,
}
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ enum bgp_log_refs {
EC_BGP_LABEL_POOL_INSERT_FAIL,
EC_BGP_TTL_SECURITY_FAIL,
EC_BGP_LS_PACKET,
EC_BGP_MUP_PACKET,
};

extern void bgp_error_init(void);
Expand Down
Loading
Loading