]> The Tcpdump Group git mirrors - tcpdump/commitdiff
OpenFlow 1.0: Get snapend right for nested frames. [skip ci]
authorDenis Ovsienko <[email protected]>
Fri, 22 Jan 2021 12:51:15 +0000 (12:51 +0000)
committerDenis Ovsienko <[email protected]>
Fri, 22 Jan 2021 13:16:02 +0000 (13:16 +0000)
The current and the nested packets can and do have different snapend,
implement and comment that in of10_packet_data_print() to fix an issue
discovered by Francois-Xavier Le Bail.

CHANGES
print-openflow-1.0.c

diff --git a/CHANGES b/CHANGES
index de07436e4468af12c998b909d4103f097735bc6f..75de7b715de0eeaff7a2ecf118b0e6a2f6355d0a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -14,6 +14,7 @@ Monthday, Month DD, YYYY by gharris and denis
       AppleTalk: Declutter appletalk.h.
       Introduce new ND_LCHECK*() macros to deduplicate more code.
       IEEE 802.11: Simplify handle_action().
       AppleTalk: Declutter appletalk.h.
       Introduce new ND_LCHECK*() macros to deduplicate more code.
       IEEE 802.11: Simplify handle_action().
+      OpenFlow 1.0: Get snapend right for nested frames.
 
 Monthday, Month DD, YYYY by gharris
   Summary for 4.99.1 tcpdump release (so far!)
 
 Monthday, Month DD, YYYY by gharris
   Summary for 4.99.1 tcpdump release (so far!)
index df57a09a38aa401fc4724c17837e0a5ff029efae..7751f2d90ead0ef24bdf2870359f3fe11932b943 100644 (file)
@@ -1017,7 +1017,19 @@ of10_packet_data_print(netdissect_options *ndo,
        }
        ndo->ndo_vflag -= 3;
        ND_PRINT(", frame decoding below\n");
        }
        ndo->ndo_vflag -= 3;
        ND_PRINT(", frame decoding below\n");
+       /*
+        * The encapsulated Ethernet frame is not necessarily the last
+        * data of this packet (i.e. there may be more OpenFlow messages
+        * after the current OFPT_PACKET_IN/OFPT_PACKET_OUT message, in
+        * which case the current (outer) packet's snapshot end is not
+        * what ether_print() needs to decode an Ethernet frame nested in
+        * the middle of a TCP payload.
+        */
+       if (!nd_push_snapend(ndo, cp + len))
+               (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
+                                 "%s: failed to adjust snapend", __func__);
        ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
        ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
+       nd_pop_packet_info(ndo);
        ndo->ndo_vflag += 3;
 }
 
        ndo->ndo_vflag += 3;
 }