]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add support for ethernet IP protocol
authorAhmed Abdelsalam <[email protected]>
Fri, 7 Aug 2020 15:02:16 +0000 (15:02 +0000)
committerfxlb <[email protected]>
Fri, 7 Aug 2020 16:11:20 +0000 (16:11 +0000)
The SRv6 network programming defines a new IP protocol number [1].

The new protocol number is used in the Next Header field of an IPv6 header
or any extension header indicates that the payload is an Ethernet.

IANA has assigned 143 as the protocol number of ethernet [2].

The SRv6 packet has the following format:
IPv6 HDR + SRH + Ethernet HDR + IPv4/IPv6 packet

This patch allows TCPDUMP to dissect such SRv6 packets.

[1] https://tools.ietf.org/html/draft-ietf-spring-srv6-network-programming-16#section-9.1
[2] https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

Signed-off-by: Ahmed Abdelsalam <[email protected]>
ipproto.c
ipproto.h
print-ip-demux.c
tests/TESTLIST
tests/ipv6-srh-ipproto-ether.out [new file with mode: 0644]
tests/ipv6-srh-ipproto-ether.pcap [new file with mode: 0644]

index 58ceeeba445055618ffa30b823cf8252fc8356c8..a3b0714a5a3431c5858e4b45e19db2b089a8e156 100644 (file)
--- a/ipproto.c
+++ b/ipproto.c
@@ -50,6 +50,7 @@ const struct tok ipproto_values[] = {
     { IPPROTO_PGM, "PGM" },
     { IPPROTO_SCTP, "SCTP" },
     { IPPROTO_MOBILITY, "Mobility" },
+    { IPPROTO_ETHERNET, "Ethernet" },
     { 0, NULL }
 };
 
index 845cf00805897693409bd43642c10e15708e8dbd..baec4bdc246d59a90db9d723a0a9dc28bea21057 100644 (file)
--- a/ipproto.h
+++ b/ipproto.h
@@ -140,3 +140,6 @@ extern const char *netdb_protoname (const uint8_t);
 #ifndef IPPROTO_MOBILITY
 #define IPPROTO_MOBILITY       135
 #endif
+#ifndef IPPROTO_ETHERNET
+#define IPPROTO_ETHERNET       143 /* TEMPORARY - registered 2020-01-31, expires 2021-01-31 */
+#endif
index 7df0f7095d72b0a8fb61d6c44120cff49c151a7d..8b53187cc29172e65daec8b91d00742e5e20d54d 100644 (file)
@@ -208,6 +208,16 @@ again:
                pgm_print(ndo, bp, length, iph);
                break;
 
+       case IPPROTO_ETHERNET:
+               if (ver == 6)
+                       ether_print(ndo, bp, length, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
+               else {
+                       ND_PRINT("[%s requires IPv6]",
+                                tok2str(ipproto_values,"unknown",nh));
+                       nd_print_invalid(ndo);
+               }
+               break;
+
        case IPPROTO_NONE:
                ND_PRINT("no next header");
                break;
index 90fc31d24738ed8057ffd8cf059d356126d936c4..8da3626906b701203eacce00b1140ec83fa79257 100644 (file)
@@ -285,6 +285,7 @@ ipv6-bad-version    ipv6-bad-version.pcap   ipv6-bad-version.out
 ipv6-routing-header    ipv6-routing-header.pcap        ipv6-routing-header.out -v
 ipv6-srh-ext-header    ipv6-srh-ext-header.pcap        ipv6-srh-ext-header.out -v
 ipv6-srh-insert-cksum  ipv6-srh-insert-cksum.pcap      ipv6-srh-insert-cksum.out -v
+ipv6-srh-ipproto-ether ipv6-srh-ipproto-ether.pcap     ipv6-srh-ipproto-ether.out -ev
 # Loopback/CTP test case
 loopback       loopback.pcap           loopback.out
 
diff --git a/tests/ipv6-srh-ipproto-ether.out b/tests/ipv6-srh-ipproto-ether.out
new file mode 100644 (file)
index 0000000..96a99bc
--- /dev/null
@@ -0,0 +1 @@
+    1  15:07:04.802036 be:f5:06:09:44:74 > d6:67:19:4e:0f:4f, ethertype IPv6 (0x86dd), length 196: (flowlabel 0xde027, hlim 63, next-header Routing (43) payload length: 142) a::1 > c::2: srcrt (len=2, type=4, segleft=0, last-entry=0, flags=0x0, tag=0, [0]c::2) ae:64:42:3b:5b:9a > 1e:1d:df:cd:54:7a, ethertype IPv6 (0x86dd), length 118: (flowlabel 0xde027, hlim 64, next-header ICMPv6 (58) payload length: 64) a::2 > e::2: [icmp6 sum ok] ICMP6, echo request, id 18516, seq 1339
diff --git a/tests/ipv6-srh-ipproto-ether.pcap b/tests/ipv6-srh-ipproto-ether.pcap
new file mode 100644 (file)
index 0000000..30181e4
Binary files /dev/null and b/tests/ipv6-srh-ipproto-ether.pcap differ