This corrects a longstanding endian bug in processing LLC/SNAP encoded
frames. A comment in if_atm.h suggests that both macros, that for extracting the ethertype and that for inserting it, handle their argument in host byte order. In fact, the inserting macro treated its argument as an opposite host order short and the calling code feeds it the result of htons(). This happens to work on i386, but fails on sparc. Make the macro use real host endianess. Reviewed by: kjc, atm@
This commit is contained in:
parent
82c7cf3159
commit
57648f8aae
@ -93,8 +93,8 @@ struct atmllc {
|
||||
/* ATM_LLC macros: note type code in host byte order */
|
||||
#define ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1]))
|
||||
#define ATM_LLC_SETTYPE(X,V) { \
|
||||
(X)->type[1] = ((V) >> 8) & 0xff; \
|
||||
(X)->type[0] = ((V) & 0xff); \
|
||||
(X)->type[0] = ((V) >> 8) & 0xff; \
|
||||
(X)->type[1] = ((V) & 0xff); \
|
||||
}
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
@ -130,9 +130,9 @@ atm_output(ifp, m0, dst, rt0)
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
if (dst->sa_family == AF_INET6)
|
||||
etype = htons(ETHERTYPE_IPV6);
|
||||
etype = ETHERTYPE_IPV6;
|
||||
else
|
||||
etype = htons(ETHERTYPE_IP);
|
||||
etype = ETHERTYPE_IP;
|
||||
if (!atmresolve(rt, m, dst, &atmdst)) {
|
||||
m = NULL;
|
||||
/* XXX: atmresolve already free'd it */
|
||||
@ -180,7 +180,7 @@ atm_output(ifp, m0, dst, rt0)
|
||||
bcopy(ATMLLC_HDR, atmllc->llchdr,
|
||||
sizeof(atmllc->llchdr));
|
||||
ATM_LLC_SETTYPE(atmllc, etype);
|
||||
/* note: already in network order */
|
||||
/* note: in host order */
|
||||
}
|
||||
else
|
||||
bcopy(llc_hdr, atmllc, sizeof(struct atmllc));
|
||||
|
Loading…
Reference in New Issue
Block a user