]> The Tcpdump Group git mirrors - tcpdump/commitdiff
OpenFlow 1.0: Get snapend right for nested frames.
authorDenis Ovsienko <[email protected]>
Fri, 22 Jan 2021 12:51:15 +0000 (12:51 +0000)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 27 Feb 2021 18:19:10 +0000 (19:19 +0100)
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.

(cherry picked from commits f39bd6851f0e4150377ce8a1f0136b8aad821ce8
 and 6c982c49c695e958f6e881874b7ba1cc447588a0)

CHANGES
print-openflow-1.0.c

diff --git a/CHANGES b/CHANGES
index d76897ae8236e7dd7c0c5a151e1457f32cd106e1..279b3c04f58f6a4c700277558105e7ef82389b78 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@ Monthday, Month DD, YYYY by gharris
       Rebuild configure script when building release
       ICMP: Update the snapend for some nested IP packets.
       MACsec: Update the snapend thus the ICV field is not payload for the caller.
+      OpenFlow 1.0: Get snapend right for nested frames.
     Solaris:
       Fix a compile error with Sun C
 
index d2cc5b9e9cf3fd43225105c9cd17faf6d911ccd1..1d7f2474875e9c3c4fed72e729b0393b894a792e 100644 (file)
@@ -1018,7 +1018,18 @@ of10_packet_data_print(netdissect_options *ndo,
        }
        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.
+        */
+       const u_char *snapend_save = ndo->ndo_snapend;
+       ndo->ndo_snapend = ND_MIN(cp + len, ndo->ndo_snapend);
        ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
+       ndo->ndo_snapend = snapend_save;
        ndo->ndo_vflag += 3;
 }