]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add BGP encap ext community 796/head
authorckishimo <[email protected]>
Thu, 29 Aug 2019 15:44:41 +0000 (17:44 +0200)
committerckishimo <[email protected]>
Tue, 3 Sep 2019 07:49:40 +0000 (09:49 +0200)
print-bgp.c
tests/TESTLIST
tests/bgp-encap.out [new file with mode: 0644]
tests/bgp-encap.pcap [new file with mode: 0644]

index 97f3bbee2daf042c1e9b6a67977433b613181b91..841e496b4d6a33a97ac8a526b501ccde67c2abf0 100644 (file)
@@ -433,6 +433,7 @@ static const struct tok bgp_safi_values[] = {
 
 #define BGP_EXT_COM_OSPF_RTYPE  0x0306  /* OSPF Route Type,Format Area(4B):RouteType(1B):Options(1B) */
 #define BGP_EXT_COM_OSPF_RTYPE2 0x8000  /* duplicate - keep for backwards compatibility */
+#define BGP_EXT_COM_ENCAP       0x030c  /* rfc5512 */
 
 #define BGP_EXT_COM_OSPF_RID    0x0107  /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
 #define BGP_EXT_COM_OSPF_RID2   0x8001  /* duplicate - keep for backwards compatibility */
@@ -472,6 +473,7 @@ static const struct tok bgp_extd_comm_subtype_values[] = {
     { BGP_EXT_COM_VPN_ORIGIN4, "ospf-domain"},
     { BGP_EXT_COM_OSPF_RTYPE,  "ospf-route-type"},
     { BGP_EXT_COM_OSPF_RTYPE2, "ospf-route-type"},
+    { BGP_EXT_COM_ENCAP,       "encapsulation"},
     { BGP_EXT_COM_OSPF_RID,    "ospf-router-id"},
     { BGP_EXT_COM_OSPF_RID2,   "ospf-router-id"},
     { BGP_EXT_COM_L2INFO,      "layer2-info"},
@@ -488,6 +490,46 @@ static const struct tok bgp_extd_comm_subtype_values[] = {
     { 0, NULL},
 };
 
+/* RFC RFC5512 BGP Tunnel Encapsulation Attribute Tunnel Types */
+#define BGP_ENCAP_TUNNEL_L2TPV3_IP  1
+#define BGP_ENCAP_TUNNEL_GRE        2
+#define BGP_ENCAP_TUNNEL_TRANSMIT   3
+#define BGP_ENCAP_TUNNEL_IPSEC      4
+#define BGP_ENCAP_TUNNEL_IP_IPSEC   5
+#define BGP_ENCAP_TUNNEL_MPLS_IP    6
+#define BGP_ENCAP_TUNNEL_IP_IP      7
+#define BGP_ENCAP_TUNNEL_VXLAN      8
+#define BGP_ENCAP_TUNNEL_NVGRE      9
+#define BGP_ENCAP_TUNNEL_MPLS       10
+#define BGP_ENCAP_TUNNEL_MPLS_GRE   11
+#define BGP_ENCAP_TUNNEL_VXLAN_GPE  12
+#define BGP_ENCAP_TUNNEL_MPLS_UDP   13
+#define BGP_ENCAP_TUNNEL_IPV6       14
+#define BGP_ENCAP_TUNNEL_SR_TE      15
+#define BGP_ENCAP_TUNNEL_BARE       16
+#define BGP_ENCAP_TUNNEL_SR         17
+
+static const struct tok bgp_extd_comm_encap_tunnel_values[] = {
+    { BGP_ENCAP_TUNNEL_L2TPV3_IP,    "L2TPv3 over IP"},
+    { BGP_ENCAP_TUNNEL_GRE,          "GRE"},
+    { BGP_ENCAP_TUNNEL_TRANSMIT,     "Transmit Tunnel"},
+    { BGP_ENCAP_TUNNEL_IPSEC,        "IPsec"},
+    { BGP_ENCAP_TUNNEL_IP_IPSEC,     "IP in IP with IPsec"},
+    { BGP_ENCAP_TUNNEL_MPLS_IP,      "MPLS in IP with IPsec"},
+    { BGP_ENCAP_TUNNEL_IP_IP,        "IP in IP"},
+    { BGP_ENCAP_TUNNEL_VXLAN,        "VXLAN"},
+    { BGP_ENCAP_TUNNEL_NVGRE,        "NVGRE"},
+    { BGP_ENCAP_TUNNEL_MPLS,         "MPLS"},
+    { BGP_ENCAP_TUNNEL_MPLS_GRE,     "MPLS in GRE"},
+    { BGP_ENCAP_TUNNEL_VXLAN_GPE,    "VXLAN GPE"},
+    { BGP_ENCAP_TUNNEL_MPLS_UDP,     "MPLS in UDP"},
+    { BGP_ENCAP_TUNNEL_IPV6,         "IPv6"},
+    { BGP_ENCAP_TUNNEL_SR_TE,        "SR TE"},
+    { BGP_ENCAP_TUNNEL_BARE,         "Bare"},
+    { BGP_ENCAP_TUNNEL_SR,           "SR"},
+    { 0, NULL},
+};
+
 /* OSPF codes for  BGP_EXT_COM_OSPF_RTYPE draft-rosen-vpns-ospf-bgp-mpls  */
 #define BGP_OSPF_RTYPE_RTR      1 /* OSPF Router LSA */
 #define BGP_OSPF_RTYPE_NET      2 /* OSPF Network LSA */
@@ -845,6 +887,12 @@ bgp_extended_community_print(netdissect_options *ndo,
         ND_PRINT("AS %u", GET_BE_U_2(pptr + 2));
         break;
 
+    case BGP_EXT_COM_ENCAP:
+        ND_PRINT("Tunnel type: %s", tok2str(bgp_extd_comm_encap_tunnel_values,
+                                           "unknown encaps",
+                                           GET_BE_U_2(pptr + 6)));
+        break;
+
     default:
         ND_PRINT("%02x%02x%02x%02x%02x%02x",
                  GET_U_1(pptr + 2),
index 300be7fd6dbd30cf8d9a47a5b3e6ed5acaf31226..f9b358031351746b9b557a7bccccd11a11beaf49 100644 (file)
@@ -32,6 +32,7 @@ bgp-4byte-asdot       bgp-4byte-asn.pcap      bgp-4byte-asdot.out     -vb
 bgp-lu-multiple-labels bgp-lu-multiple-labels.pcap bgp-lu-multiple-labels.out -v
 bgp-evpn       bgp-evpn.pcap           bgp-evpn.out            -v
 bgp-llgr       bgp-evpn.pcap           bgp-llgr.out            -v
+bgp-encap      bgp-encap.pcap          bgp-encap.out           -v
 
 # Broadcom tag tests
 brcmtag                brcm-tag.pcap           brcm-tag.out
diff --git a/tests/bgp-encap.out b/tests/bgp-encap.out
new file mode 100644 (file)
index 0000000..e76948a
--- /dev/null
@@ -0,0 +1,15 @@
+    1  12:59:23.482812 IP (tos 0xc0, ttl 255, id 48945, offset 0, flags [none], proto TCP (6), length 156)
+    10.0.14.4.179 > 10.0.14.1.63656: Flags [P.], cksum 0xa26f (correct), seq 123918763:123918867, ack 3762271638, win 16384, options [nop,nop,TS val 2163155192 ecr 2226825164], length 104: BGP
+       Update Message (2), length: 104
+         Origin (1), length: 1, Flags [T]: IGP
+         AS Path (2), length: 0, Flags [T]: empty
+         Local Preference (5), length: 4, Flags [T]: 100
+         Extended Community (16), length: 16, Flags [OT]: 
+           target (0x0002), Flags [none]: 65000:101 (= 0.0.0.101)
+           encapsulation (0x030c), Flags [none]: Tunnel type: VXLAN
+         Multi-Protocol Reach NLRI (14), length: 44, Flags [OE]: 
+           AFI: VPLS (25), SAFI: EVPN (70)
+           no AFI 25 / SAFI 70 decoder
+           0x0000:  0019 4604 0404 0404 0002 2100 0104 0404
+           0x0010:  0400 0400 0000 0000 0000 0000 0000 0000
+           0x0020:  0030 0206 0a0e faf3 0000 0065
diff --git a/tests/bgp-encap.pcap b/tests/bgp-encap.pcap
new file mode 100644 (file)
index 0000000..6fa0d25
Binary files /dev/null and b/tests/bgp-encap.pcap differ