]> The Tcpdump Group git mirrors - tcpdump/commitdiff
OpenFlow 1.0: enable decoding of nested frames
authorDenis Ovsienko <[email protected]>
Mon, 9 Sep 2013 09:48:11 +0000 (13:48 +0400)
committerDenis Ovsienko <[email protected]>
Mon, 9 Sep 2013 09:48:11 +0000 (13:48 +0400)
The packet that may be contained in an OFPT_PACKET_IN or OFPT_PACKET_OUT
OpenFlow message is a plain Ethernet frame. Make it possible to have
ether_print() process that frame, with a controlled verbosity level (see
a comment in print-openflow-1.0.c for details). Update an existing test
case to employ the new feature.

print-openflow-1.0.c
tests/TESTLIST
tests/of10_s4810-vvvv.out [moved from tests/of10_s4810-vv.out with 98% similarity]

index f4bd977bfefa6c58552672f127202397e176fa6e..95a93a99e21e2b654c8c2f2dc3cd869ec541bc6f 100644 (file)
@@ -8,6 +8,13 @@
  *
  * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf
  *
  *
  * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf
  *
+ * Decoding of Ethernet frames nested in OFPT_PACKET_IN and OFPT_PACKET_OUT
+ * messages is done only when the verbosity level set by command-line argument
+ * is "-vvv" or higher. In that case the verbosity level is temporarily
+ * decremented by 3 during the nested frame decoding. For example, running
+ * tcpdump with "-vvvv" will do full decoding of OpenFlow and "-v" decoding of
+ * the nested frames.
+ *
  *
  * Copyright (c) 2013 The TCPDUMP project
  * All rights reserved.
  *
  * Copyright (c) 2013 The TCPDUMP project
  * All rights reserved.
@@ -641,6 +648,26 @@ trunc:
        return ep;
 }
 
        return ep;
 }
 
+static const u_char *
+of10_packet_data_print(const u_char *cp, const u_char *ep, const u_int len) {
+       if (len == 0)
+               return cp;
+       /* data */
+       printf("\n\t data (%u octets)", len);
+       if (vflag < 3)
+               return cp + len;
+       TCHECK2(*cp, len);
+       vflag -= 3;
+       printf(", frame decoding below\n");
+       ether_print(gndo, cp, len, snapend - cp, NULL, NULL);
+       vflag += 3;
+       return cp + len;
+
+trunc:
+       printf(" [|openflow]");
+       return ep;
+}
+
 /* [OF10] Section 5.2.1 */
 static const u_char *
 of10_phy_ports_print(const u_char *cp, const u_char *ep, u_int len) {
 /* [OF10] Section 5.2.1 */
 static const u_char *
 of10_phy_ports_print(const u_char *cp, const u_char *ep, u_int len) {
@@ -1714,7 +1741,7 @@ of10_packet_out_print(const u_char *cp, const u_char *ep, const u_int len) {
        if (ep == (cp = of10_actions_print("\n\t ", cp, ep, actions_len)))
                return ep; /* end of snapshot */
        /* data */
        if (ep == (cp = of10_actions_print("\n\t ", cp, ep, actions_len)))
                return ep; /* end of snapshot */
        /* data */
-       return of10_data_print(cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
+       return of10_packet_data_print(cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
 
 corrupt: /* skip the rest of the message body */
        printf(" (corrupt)");
 
 corrupt: /* skip the rest of the message body */
        printf(" (corrupt)");
@@ -1749,7 +1776,7 @@ of10_packet_in_print(const u_char *cp, const u_char *ep, const u_int len) {
        cp += 1;
        /* data */
        /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
        cp += 1;
        /* data */
        /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
-       return of10_data_print(cp, ep, len - (OF_PACKET_IN_LEN - 2));
+       return of10_packet_data_print(cp, ep, len - (OF_PACKET_IN_LEN - 2));
 
 trunc:
        printf(" [|openflow]");
 
 trunc:
        printf(" [|openflow]");
index c7e473c13741f1d12fd4c44909f2f5f59d003b00..271d7b1c85cde21689e3524186d6b097ba19b916 100644 (file)
@@ -129,7 +129,7 @@ mptcp-fclose        mptcp-fclose.pcap       mptcp-fclose.out        -t
 
 # OpenFlow tests
 of10_p3295-vv  of10_p3295.pcap         of10_p3295-vv.out       -t -vv
 
 # OpenFlow tests
 of10_p3295-vv  of10_p3295.pcap         of10_p3295-vv.out       -t -vv
-of10_s4810-vv  of10_s4810.pcap         of10_s4810-vv.out       -t -vv
+of10_s4810-vvvv        of10_s4810.pcap         of10_s4810-vvvv.out     -t -vvvv
 of10_pf5240-vv of10_pf5240.pcap        of10_pf5240-vv.out      -t -vv
 
 # GeoNetworking and CALM FAST tests
 of10_pf5240-vv of10_pf5240.pcap        of10_pf5240-vv.out      -t -vv
 
 # GeoNetworking and CALM FAST tests
similarity index 98%
rename from tests/of10_s4810-vv.out
rename to tests/of10_s4810-vvvv.out
index 8c7f9d46a0433eefdf1a51bdd1e5deca8b6e6a21..dabc2f2be3994f117ba41976d64b206a1e844b0e 100644 (file)
@@ -884,15 +884,14 @@ IP (tos 0x0, ttl 64, id 53604, offset 0, flags [DF], proto TCP (6), length 189)
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0x03e7 (correct), seq 10213:10350, ack 4641, win 1035, options [nop,nop,TS val 3 ecr 47837000], length 137: OpenFlow
        version 1.0, type PACKET_IN, length 137, xid 0x00000000
         buffer_id NONE, total_len 119, in_port 1, reason ACTION
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0x03e7 (correct), seq 10213:10350, ack 4641, win 1035, options [nop,nop,TS val 3 ecr 47837000], length 137: OpenFlow
        version 1.0, type PACKET_IN, length 137, xid 0x00000000
         buffer_id NONE, total_len 119, in_port 1, reason ACTION
-        data (119 octets)
-         0x0000:  0180 c200 0000 089e 0162 d5f4 0069 4242  .........b...iBB
-         0x0010:  0300 0003 027e 8000 089e 0162 d5f4 0000  .....~.....b....
-         0x0020:  0000 8000 089e 0162 d5f4 8034 0000 1400  .......b...4....
-         0x0030:  0200 0f00 0000 4000 7069 6361 3800 0000  [email protected]...
-         0x0040:  0000 0000 0000 0000 0000 0000 0000 0000  ................
-         0x0050:  0000 0000 0000 0000 0000 ac36 177f 5028  ...........6..P(
-         0x0060:  3cd4 b838 21d8 ab26 de62 0000 0000 8000  <..8!..&.b......
-         0x0070:  089e 0162 d5f4 14                        ...b...
+        data (119 octets), frame decoding below
+STP 802.1s, Rapid STP, CIST Flags [Proposal, Learn, Forward, Agreement], length 102
+       port-role Designated, CIST root-id 8000.08:9e:01:62:d5:f4, CIST ext-pathcost 0 
+       CIST regional-root-id 8000.08:9e:01:62:d5:f4, CIST port-id 8034, 
+       message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+       v3len 64, MCID Name pica8, rev 0, 
+               digest ac36177f50283cd4b83821d8ab26de62, CIST int-root-pathcost 0, 
+       CIST bridge-id 8000.08:9e:01:62:d5:f4, CIST remaining-hops 20
 IP (tos 0x0, ttl 64, id 53605, offset 0, flags [DF], proto TCP (6), length 168)
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0x4a03 (correct), seq 10350:10466, ack 4641, win 1035, options [nop,nop,TS val 3 ecr 47837000], length 116: OpenFlow
        version 1.0, type STATS_REPLY, length 116, xid 0x0000003f
 IP (tos 0x0, ttl 64, id 53605, offset 0, flags [DF], proto TCP (6), length 168)
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0x4a03 (correct), seq 10350:10466, ack 4641, win 1035, options [nop,nop,TS val 3 ecr 47837000], length 116: OpenFlow
        version 1.0, type STATS_REPLY, length 116, xid 0x0000003f
@@ -1235,11 +1234,8 @@ IP (tos 0x0, ttl 64, id 53123, offset 0, flags [DF], proto TCP (6), length 144)
        version 1.0, type PACKET_OUT, length 84, xid 0x00000044
         buffer_id 0xffffffff, in_port CONTROLLER
         action type OUTPUT, len 8, port 1
        version 1.0, type PACKET_OUT, length 84, xid 0x00000044
         buffer_id 0xffffffff, in_port CONTROLLER
         action type OUTPUT, len 8, port 1
-        data (60 octets)
-         0x0000:  6162 6364 6566 6768 0000 0000 0000 0000  abcdefgh........
-         0x0010:  0000 0000 0000 0000 0000 0000 0000 0000  ................
-         0x0020:  0000 0000 0000 0000 0000 0000 0000 0000  ................
-         0x0030:  0000 0000 0000 0000 0000 0000            ............
+        data (60 octets), frame decoding below
+67:68:00:00:00:00 > 61:62:63:64:65:66 Null Information, send seq 0, rcv seq 0, Flags [Command], length 46
        version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000045
 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0xb6f1 (correct), seq 14734:14742, ack 4821, win 1035, options [nop,nop,TS val 3 ecr 47837403], length 8: OpenFlow
        version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000045
 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0xb6f1 (correct), seq 14734:14742, ack 4821, win 1035, options [nop,nop,TS val 3 ecr 47837403], length 8: OpenFlow
@@ -1317,15 +1313,14 @@ IP (tos 0x0, ttl 64, id 53775, offset 0, flags [DF], proto TCP (6), length 189)
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0xf083 (correct), seq 14766:14903, ack 4857, win 1035, options [nop,nop,TS val 6 ecr 47837447], length 137: OpenFlow
        version 1.0, type PACKET_IN, length 137, xid 0x00000000
         buffer_id NONE, total_len 119, in_port 1, reason NO_MATCH
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0xf083 (correct), seq 14766:14903, ack 4857, win 1035, options [nop,nop,TS val 6 ecr 47837447], length 137: OpenFlow
        version 1.0, type PACKET_IN, length 137, xid 0x00000000
         buffer_id NONE, total_len 119, in_port 1, reason NO_MATCH
-        data (119 octets)
-         0x0000:  0180 c200 0000 089e 0162 d5f4 0069 4242  .........b...iBB
-         0x0010:  0300 0003 027e 8000 089e 0162 d5f4 0000  .....~.....b....
-         0x0020:  0000 8000 089e 0162 d5f4 8034 0000 1400  .......b...4....
-         0x0030:  0200 0f00 0000 4000 7069 6361 3800 0000  [email protected]...
-         0x0040:  0000 0000 0000 0000 0000 0000 0000 0000  ................
-         0x0050:  0000 0000 0000 0000 0000 ac36 177f 5028  ...........6..P(
-         0x0060:  3cd4 b838 21d8 ab26 de62 0000 0000 8000  <..8!..&.b......
-         0x0070:  089e 0162 d5f4 14                        ...b...
+        data (119 octets), frame decoding below
+STP 802.1s, Rapid STP, CIST Flags [Proposal, Learn, Forward, Agreement], length 102
+       port-role Designated, CIST root-id 8000.08:9e:01:62:d5:f4, CIST ext-pathcost 0 
+       CIST regional-root-id 8000.08:9e:01:62:d5:f4, CIST port-id 8034, 
+       message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+       v3len 64, MCID Name pica8, rev 0, 
+               digest ac36177f50283cd4b83821d8ab26de62, CIST int-root-pathcost 0, 
+       CIST bridge-id 8000.08:9e:01:62:d5:f4, CIST remaining-hops 20
 IP (tos 0x0, ttl 64, id 53128, offset 0, flags [DF], proto TCP (6), length 52)
     10.0.0.20.6633 > 10.0.0.81.56068: Flags [.], cksum 0x148b (incorrect -> 0xb3e0), seq 4857, ack 14903, win 331, options [nop,nop,TS val 47839052 ecr 6], length 0
 IP (tos 0x0, ttl 64, id 53129, offset 0, flags [DF], proto TCP (6), length 52)
 IP (tos 0x0, ttl 64, id 53128, offset 0, flags [DF], proto TCP (6), length 52)
     10.0.0.20.6633 > 10.0.0.81.56068: Flags [.], cksum 0x148b (incorrect -> 0xb3e0), seq 4857, ack 14903, win 331, options [nop,nop,TS val 47839052 ecr 6], length 0
 IP (tos 0x0, ttl 64, id 53129, offset 0, flags [DF], proto TCP (6), length 52)