]> The Tcpdump Group git mirrors - tcpdump/commitdiff
BGP: Add support for the AIGP attribute (RFC7311)
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 22 May 2015 10:41:40 +0000 (12:41 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 22 May 2015 10:41:40 +0000 (12:41 +0200)
Based on a patch from Hannes Gredler

print-bgp.c
tests/TESTLIST
tests/bgp-aigp.out [new file with mode: 0644]
tests/bgp-aigp.pcap [new file with mode: 0644]

index 6a4fa2c0ff50e3f0c92befe8cb81516152a0c458..8429ae922be06e67e853b47fe52ac0ecb06d454b 100644 (file)
@@ -131,6 +131,7 @@ struct bgp_route_refresh {
 #define BGPTYPE_AS4_PATH               17      /* RFC4893 */
 #define BGPTYPE_AGGREGATOR4            18      /* RFC4893 */
 #define BGPTYPE_PMSI_TUNNEL             22      /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */
+#define BGPTYPE_AIGP                    26      /* RFC7311 */
 #define BGPTYPE_ATTR_SET               128      /* draft-marques-ppvpn-ibgp */
 
 #define BGP_MP_NLRI_MINSIZE              3       /* End of RIB Marker detection */
@@ -155,6 +156,7 @@ static const struct tok bgp_attr_values[] = {
     { BGPTYPE_MP_UNREACH_NLRI,  "Multi-Protocol Unreach NLRI"},
     { BGPTYPE_EXTD_COMMUNITIES, "Extended Community"},
     { BGPTYPE_PMSI_TUNNEL,      "PMSI Tunnel"},
+    { BGPTYPE_AIGP,             "Accumulated IGP Metric"},
     { BGPTYPE_ATTR_SET,         "Attribute Set"},
     { 255,                      "Reserved for development"},
     { 0, NULL}
@@ -317,6 +319,13 @@ static const struct tok bgp_pmsi_flag_values[] = {
     { 0, NULL}
 };
 
+#define BGP_AIGP_TLV 1
+
+static const struct tok bgp_aigp_values[] = {
+    { BGP_AIGP_TLV, "AIGP"},
+    { 0, NULL}
+};
+
 
 /* Subsequent address family identifier, RFC2283 section 7 */
 #define SAFNUM_RES                      0
@@ -2150,6 +2159,55 @@ bgp_attr_print(netdissect_options *ndo,
                 }
                 break;
         }
+       case BGPTYPE_AIGP:
+       {
+               u_int8_t type;
+               u_int16_t length;
+
+               ND_TCHECK2(tptr[0], 3);
+
+               tlen = len;
+
+               while (tlen >= 3) {
+
+                   type = *tptr;
+                   length = EXTRACT_16BITS(tptr+1);
+
+                   printf("\n\t    %s TLV (%u), length %u",
+                          tok2str(bgp_aigp_values, "Unknown", type),
+                          type, length);
+
+
+                   /*
+                    * Check if we can read the TLV data.
+                    */
+                   ND_TCHECK2(tptr[3], length - 3);
+
+                   switch (type) {
+
+                   case BGP_AIGP_TLV:
+                       ND_TCHECK2(tptr[3], 8);
+                       printf(", metric %" PRIu64, EXTRACT_64BITS(tptr+3));
+                       break;
+
+                   default:
+                       if (ndo->ndo_vflag <= 1) {
+                           print_unknown_data(ndo, tptr+3,"\n\t      ", length-3);
+                       }
+                   }
+
+                   /*
+                    * Header length includes TLV overhead.
+                    */
+                   if (length < 3) {
+                       break;
+                   }
+
+                   tptr += length;
+                   tlen -= length;
+               }
+               break;
+       }
         case BGPTYPE_ATTR_SET:
                 ND_TCHECK2(tptr[0], 4);
                 if (len < 4)
index b0bf5ee56f3e9ddb4f0151e1380ccee3d811ccc3..c28bec81f5c1678a76ef3c3687714300f4797f21 100644 (file)
@@ -20,6 +20,7 @@ print-AA      print-flags.pcap        print-AA.out    -t -AA
 bgp_vpn_attrset bgp_vpn_attrset.pcap bgp_vpn_attrset.out -t -v
 mpbgp-linklocal-nexthop mpbgp-linklocal-nexthop.pcap mpbgp-linklocal-nexthop.out -t -v
 bgp_infloop-v          bgp-infinite-loop.pcap          bgp_infloop-v.out       -t -v
+bgp-aigp       bgp-aigp.pcap   bgp-aigp.out    -t -v
 
 # EAP tests
 eapon1 eapon1.pcap eapon1.out -t
diff --git a/tests/bgp-aigp.out b/tests/bgp-aigp.out
new file mode 100644 (file)
index 0000000..3fd6678
--- /dev/null
@@ -0,0 +1,20 @@
+IP (tos 0xc0, ttl 64, id 35063, offset 0, flags [none], proto TCP (6), length 182)
+    172.16.20.5.59631 > 172.16.20.3.179: Flags [P.], cksum 0xe112 (correct), seq 3923783171:3923783301, ack 3341773693, win 16384, options [nop,nop,TS val 32734022 ecr 32695671], length 130: BGP
+       Update Message (2), length: 100
+         Origin (1), length: 1, Flags [T]: Incomplete
+         AS Path (2), length: 0, Flags [T]: empty
+         Multi Exit Discriminator (4), length: 4, Flags [O]: 0
+         Local Preference (5), length: 4, Flags [T]: 100
+         Community (8), length: 4, Flags [OT]: 65000:11201
+         Originator ID (9), length: 4, Flags [O]: 172.16.21.4
+         Cluster List (10), length: 4, Flags [O]: 172.16.20.5
+         Accumulated IGP Metric (26), length: 11, Flags [O]: 
+           AIGP TLV (1), length 11, metric 2000
+         Multi-Protocol Reach NLRI (14), length: 17, Flags [OE]: 
+           AFI: IPv4 (1), SAFI: labeled Unicast (4)
+           nexthop: 172.16.20.5, nh-length: 4, no SNPA
+             172.16.21.4/32, label:300096 (bottom)
+       Update Message (2), length: 30
+         Multi-Protocol Unreach NLRI (15), length: 3, Flags [OE]: 
+           AFI: IPv4 (1), SAFI: labeled Unicast (4)
+             End-of-Rib Marker (empty NLRI)
diff --git a/tests/bgp-aigp.pcap b/tests/bgp-aigp.pcap
new file mode 100644 (file)
index 0000000..1e55e19
Binary files /dev/null and b/tests/bgp-aigp.pcap differ