skip = 1;
}
if (skip) {
- ND_TCHECK_LEN(cp, plen - 4);
- cp += plen - 4;
+ /*
+ * plen >= OF_QUEUE_PROP_HEADER_LEN
+ * cp is OF_QUEUE_PROP_HEADER_LEN bytes in
+ */
+ ND_TCHECK_LEN(cp, plen - OF_QUEUE_PROP_HEADER_LEN);
+ cp += plen - OF_QUEUE_PROP_HEADER_LEN;
goto next_property;
}
if (property == OFPQT_MIN_RATE) { /* the only case of property decoding */
alen = GET_BE_U_2(cp);
cp += 2;
ND_PRINT(", len %u", alen);
+ /*
+ * The 4-byte "pad" in the specification is not a field of the
+ * action header, but a placeholder to illustrate the 64-bit
+ * alignment requirement. Action type specific case blocks
+ * below fetch these 4 bytes.
+ */
+
/* On action size underrun/overrun skip the rest of the action list. */
if (alen < OF_ACTION_HEADER_LEN || alen > len)
goto invalid;
- /* On action size inappropriate for the given type or invalid type just skip
- * the current action, as the basic length constraint has been met. */
+ /*
+ * After validating the basic length constraint it will be safe
+ * to skip the current action if the action size is not valid
+ * for the type or the type is invalid.
+ */
switch (type) {
case OFPAT_OUTPUT:
case OFPAT_SET_VLAN_VID:
skip = 1;
}
if (skip) {
+ /*
+ * alen >= OF_ACTION_HEADER_LEN
+ * cp is 4 bytes in
+ */
ND_TCHECK_LEN(cp, alen - 4);
cp += alen - 4;
goto next_action;
* the basic header. A message length underrun fails decoding of the rest of
* the current packet. At the same time, try decoding as much of the current
* message as possible even when it does not end within the current TCP
- * segment. */
+ * segment.
+ *
+ * That is, do NOT require the header "length" to be small enough for
+ * the full declared OpenFlow message to fit into the remainder of the
+ * declared TCP segment given to this function, same as the full declared
+ * TCP segment is not required to fit into the captured packet buffer.
+ */
if (length < OF_HEADER_LEN) {
of_header_print(ndo, version, type, length, xid);
goto invalid;