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
21 changes: 18 additions & 3 deletions bgpdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,9 +1183,10 @@ void mrtd_table_line_announce(struct prefix *prefix, int count, BGPDUMP_ENTRY *e
printf("|%s|", aggregate);

if (entry->attr->aggregator_addr.s_addr != -1)
printf("%u %s|\n", entry->attr->aggregator_as, inet_ntoa(entry->attr->aggregator_addr));
else
printf("|\n");
printf("%u %s", entry->attr->aggregator_as, inet_ntoa(entry->attr->aggregator_addr));
printf("|");

printf("%u|\n", entry->attr->otc_as);
}
else
printf("\n");
Expand Down Expand Up @@ -1408,6 +1409,10 @@ void show_attr(attributes_t *attr) {

if( (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES) ) !=0)
printf("LARGE_COMMUNITY:%s\n",attr->lcommunity->str);

/* RFC 9234: OTC attribute (type 35) - check value directly since flag is 32-bit */
if(attr->otc_as != 0)
printf("OTC: AS%u\n", attr->otc_as);

}

Expand Down Expand Up @@ -1588,6 +1593,8 @@ static void table_line_announce(struct prefix *prefix,int count,BGPDUMP_ENTRY *e
}
printf("|");

printf("%u|", entry->attr->otc_as);

if (show_unknown_attributes) {
append_compact_unknown_attributes(entry->attr);
}
Expand Down Expand Up @@ -1747,6 +1754,8 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
}
printf("|");

printf("%u|", entry->attr->otc_as);

if (show_unknown_attributes) {
append_compact_unknown_attributes(entry->attr);
}
Expand Down Expand Up @@ -1866,6 +1875,8 @@ static void table_line_announce6(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
}
printf("|");

printf("%u|", entry->attr->otc_as);

if (show_unknown_attributes) {
append_compact_unknown_attributes(entry->attr);
}
Expand Down Expand Up @@ -1988,6 +1999,8 @@ static void table_line_mrtd_route(BGPDUMP_MRTD_TABLE_DUMP *route,BGPDUMP_ENTRY *
}
printf("|");

printf("%u|", entry->attr->otc_as);

if (show_unknown_attributes) {
append_compact_unknown_attributes(entry->attr);
}
Expand Down Expand Up @@ -2122,6 +2135,8 @@ static void table_line_dump_v2_prefix(BGPDUMP_TABLE_DUMP_V2_PREFIX *e,BGPDUMP_EN
}
printf("|");

printf("%u|", attr->otc_as);

if (show_unknown_attributes) {
append_compact_unknown_attributes(attr);
}
Expand Down
4 changes: 4 additions & 0 deletions bgpdump_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Original Author: Dan Ardelean (dan@ripe.net)
#define BGP_ATTR_NEW_AS_PATH 17
#define BGP_ATTR_NEW_AGGREGATOR 18
#define BGP_ATTR_LARGE_COMMUNITIES 32
#define BGP_ATTR_OTC 35

/* Flag macro */
#define ATTR_FLAG_BIT(X) (1 << ((X) - 1))
Expand Down Expand Up @@ -149,6 +150,9 @@ struct attr
as_t old_aggregator_as;
struct in_addr new_aggregator_addr;
struct in_addr old_aggregator_addr;

/* RFC 9234: Only to Customer (OTC) attribute */
as_t otc_as;
};

struct community
Expand Down
12 changes: 12 additions & 0 deletions bgpdump_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ static attributes_t *attr_init(struct mstream *s, int len) {
attr->old_aspath = NULL;
attr->new_aggregator_as = -1;
attr->new_aggregator_addr.s_addr = INADDR_NONE;
attr->otc_as = 0;

return attr;
}
Expand Down Expand Up @@ -1216,6 +1217,17 @@ static void process_one_attr(struct mstream *outer_stream, attributes_t *attr, u
for (i = 0; i < attr->cluster->length; i++)
attr->cluster->list[i] = mstream_get_ipv4(s);
break;
case BGP_ATTR_OTC:
/* RFC 9234: Only to Customer (OTC) attribute
* Type Code: 35, Length: 4 octets, Value: ASN */
if(len != 4) {
warn("process_one_attr: OTC attribute has invalid length %d (expected 4)", len);
process_unknown_attr(s, attr, flag, type, len);
break;
}
assert(0 == attr->otc_as);
attr->otc_as = read_asn(s, ASN32_LEN);
break;
default:
process_unknown_attr(s, attr, flag, type, len);
}
Expand Down