Skip to content

Commit 482813e

Browse files
authored
Leave it up to the caller to process the data after the MACsec header.
Don't do it ourselves - it's not part of the MACsec header.
1 parent 734a7e0 commit 482813e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

print-macsec.c

+19-15
Original file line numberDiff line numberDiff line change
@@ -163,25 +163,29 @@ int macsec_print(netdissect_options *ndo, const u_char **bp,
163163
}
164164

165165
len = ieee8021ae_sectag_len(ndo, sectag);
166-
*length_type = GET_BE_U_2(*bp + len);
167-
if (ndo->ndo_eflag && *length_type > ETHERMTU && !(GET_U_1(sectag->tci_an) & MACSEC_TCI_E))
168-
ND_PRINT("ethertype %s, ", tok2str(ethertype_values,"0x%04x", *length_type));
169166

170-
if ((GET_U_1(sectag->tci_an) & MACSEC_TCI_CONFID)) {
171-
*bp += len;
172-
*hdrlenp += len;
167+
/* Skip the MACsec header. */
168+
*bp += len;
169+
*hdrlenp += len;
170+
171+
/* Remove it from the lengths, as it's been processed. */
172+
*lengthp -= len;
173+
*caplenp -= len;
173174

174-
*lengthp -= len;
175-
*caplenp -= len;
175+
if ((GET_U_1(sectag->tci_an) & MACSEC_TCI_CONFID)) {
176+
/*
177+
* The payload is encrypted. Tell our
178+
* caller it can't be dissected.
179+
*/
176180
return 0;
177181
} else {
178-
len += 2;
179-
*bp += len;
180-
*hdrlenp += len;
181-
182-
len += MACSEC_DEFAULT_ICV_LEN;
183-
*lengthp -= len;
184-
*caplenp -= len;
182+
/*
183+
* The payload isn't encrypted; remove the
184+
* ICV length from the lengths, so our caller
185+
* doesn't treat it as payload.
186+
*/
187+
*lengthp -= MACSEC_DEFAULT_ICV_LEN;
188+
*caplenp -= MACSEC_DEFAULT_ICV_LEN;
185189
return -1;
186190
}
187191
}

0 commit comments

Comments
 (0)