diff options
author | harti <harti@FreeBSD.org> | 2003-03-13 12:44:06 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2003-03-13 12:44:06 +0000 |
commit | 928f52e38a8aec1a91cd52ec7a2cc4836cc13ea4 (patch) | |
tree | 5f5f42dd1599d5fb9757e97ae85f60c6a65be5ee /sys/net | |
parent | b90d854c5fb6c36b8eda669f20407dcf5436de9d (diff) | |
download | FreeBSD-src-928f52e38a8aec1a91cd52ec7a2cc4836cc13ea4.zip FreeBSD-src-928f52e38a8aec1a91cd52ec7a2cc4836cc13ea4.tar.gz |
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@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_atm.h | 4 | ||||
-rw-r--r-- | sys/net/if_atmsubr.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/sys/net/if_atm.h b/sys/net/if_atm.h index cafe5a7..f09f7a6 100644 --- a/sys/net/if_atm.h +++ b/sys/net/if_atm.h @@ -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 diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 782ed88..7fbf1e8 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -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)); |