Skip to content

Commit bc700c4

Browse files
committed
BGP: Print LARGE_COMMUNITY Path Attribute
Moreover: Delete redundant empty lines
1 parent 90dc6cb commit bc700c4

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

print-bgp.c

+19-7
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct bgp_route_refresh {
139139
#define BGPTYPE_AIGP 26 /* RFC7311 */
140140
#define BGPTYPE_PE_DISTINGUISHER_LABEL 27 /* RFC6514 */
141141
#define BGPTYPE_ENTROPY_LABEL 28 /* RFC6790 */
142+
#define BGPTYPE_LARGE_COMMUNITY 30 /* draft-ietf-idr-large-community-02 */
142143
#define BGPTYPE_ATTR_SET 128 /* RFC6368 */
143144

144145
#define BGP_MP_NLRI_MINSIZE 3 /* End of RIB Marker detection */
@@ -169,6 +170,7 @@ static const struct tok bgp_attr_values[] = {
169170
{ BGPTYPE_AIGP, "Accumulated IGP Metric"},
170171
{ BGPTYPE_PE_DISTINGUISHER_LABEL, "PE Distinguisher Label"},
171172
{ BGPTYPE_ENTROPY_LABEL, "Entropy Label"},
173+
{ BGPTYPE_LARGE_COMMUNITY, "Large Community"},
172174
{ BGPTYPE_ATTR_SET, "Attribute Set"},
173175
{ 255, "Reserved for development"},
174176
{ 0, NULL}
@@ -201,7 +203,6 @@ static const struct tok bgp_as_path_segment_close_values[] = {
201203
#define BGP_OPT_AUTH 1
202204
#define BGP_OPT_CAP 2
203205

204-
205206
static const struct tok bgp_opt_values[] = {
206207
{ BGP_OPT_AUTH, "Authentication Information"},
207208
{ BGP_OPT_CAP, "Capabilities Advertisement"},
@@ -355,7 +356,6 @@ static const struct tok bgp_aigp_values[] = {
355356
{ 0, NULL}
356357
};
357358

358-
359359
/* Subsequent address family identifier, RFC2283 section 7 */
360360
#define SAFNUM_RES 0
361361
#define SAFNUM_UNICAST 1
@@ -430,7 +430,6 @@ static const struct tok bgp_safi_values[] = {
430430
#define BGP_EXT_COM_L2VPN_RT_0 0x000a /* L2VPN Identifier,Format AS(2bytes):AN(4bytes) */
431431
#define BGP_EXT_COM_L2VPN_RT_1 0xF10a /* L2VPN Identifier,Format IP address:AN(2bytes) */
432432

433-
434433
/* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml */
435434
#define BGP_EXT_COM_EIGRP_GEN 0x8800
436435
#define BGP_EXT_COM_EIGRP_METRIC_AS_DELAY 0x8801
@@ -707,7 +706,6 @@ bgp_vpn_sg_print(netdissect_options *ndo,
707706
return (total_length);
708707
}
709708

710-
711709
/* RDs and RTs share the same semantics
712710
* we use bgp_vpn_rd_print for
713711
* printing route targets inside a NLRI */
@@ -1374,7 +1372,6 @@ bgp_attr_print(netdissect_options *ndo,
13741372
}
13751373
break;
13761374

1377-
13781375
/*
13791376
* Process AS4 byte path and AS2 byte path attributes here.
13801377
*/
@@ -2191,7 +2188,6 @@ bgp_attr_print(netdissect_options *ndo,
21912188
tok2str(bgp_aigp_values, "Unknown", type),
21922189
type, length));
21932190

2194-
21952191
/*
21962192
* Check if we can read the TLV data.
21972193
*/
@@ -2267,7 +2263,23 @@ bgp_attr_print(netdissect_options *ndo,
22672263
}
22682264
break;
22692265

2270-
2266+
case BGPTYPE_LARGE_COMMUNITY:
2267+
if (len == 0 || len % 12) {
2268+
ND_PRINT((ndo, "invalid len"));
2269+
break;
2270+
}
2271+
ND_PRINT((ndo, "\n\t "));
2272+
while (len > 0) {
2273+
ND_TCHECK2(*tptr, 12);
2274+
ND_PRINT((ndo, "%u:%u:%u%s",
2275+
EXTRACT_32BITS(tptr),
2276+
EXTRACT_32BITS(tptr + 4),
2277+
EXTRACT_32BITS(tptr + 8),
2278+
(len > 12) ? ", " : ""));
2279+
tptr += 12;
2280+
len -= 12;
2281+
}
2282+
break;
22712283
default:
22722284
ND_TCHECK2(*pptr,len);
22732285
ND_PRINT((ndo, "\n\t no Attribute %u decoder", atype)); /* we have no decoder for the attribute */

0 commit comments

Comments
 (0)