summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_tcpmss.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2010-04-01 10:41:01 +0000
committermav <mav@FreeBSD.org>2010-04-01 10:41:01 +0000
commit648144045d4aa71db14153ad891b5e3563af8de7 (patch)
treecf0726b82703b8cd7fc87252165328b7188c2487 /sys/netgraph/ng_tcpmss.c
parent452876c6d97da27a17468d815ddd602fc0a14ba3 (diff)
downloadFreeBSD-src-648144045d4aa71db14153ad891b5e3563af8de7.zip
FreeBSD-src-648144045d4aa71db14153ad891b5e3563af8de7.tar.gz
Remove alignment constraints.
Diffstat (limited to 'sys/netgraph/ng_tcpmss.c')
-rw-r--r--sys/netgraph/ng_tcpmss.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/netgraph/ng_tcpmss.c b/sys/netgraph/ng_tcpmss.c
index bcc421a..19f9edc 100644
--- a/sys/netgraph/ng_tcpmss.c
+++ b/sys/netgraph/ng_tcpmss.c
@@ -47,6 +47,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/endian.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@@ -410,9 +411,9 @@ correct_mss(struct tcphdr *tc, int hlen, uint16_t maxmss, int flags)
{
int olen, optlen;
u_char *opt;
- uint16_t *mss;
int accumulate;
int res = 0;
+ uint16_t sum;
for (olen = hlen - sizeof(struct tcphdr), opt = (u_char *)(tc + 1);
olen > 0; olen -= optlen, opt += optlen) {
@@ -427,13 +428,15 @@ correct_mss(struct tcphdr *tc, int hlen, uint16_t maxmss, int flags)
if (*opt == TCPOPT_MAXSEG) {
if (optlen != TCPOLEN_MAXSEG)
continue;
- mss = (uint16_t *)(opt + 2);
- if (ntohs(*mss) > maxmss) {
- accumulate = *mss;
- *mss = htons(maxmss);
- accumulate -= *mss;
- if ((flags & CSUM_TCP) == 0)
- TCPMSS_ADJUST_CHECKSUM(accumulate, tc->th_sum);
+ accumulate = be16dec(opt + 2);
+ if (accumulate > maxmss) {
+ if ((flags & CSUM_TCP) == 0) {
+ accumulate -= maxmss;
+ sum = be16dec(&tc->th_sum);
+ TCPMSS_ADJUST_CHECKSUM(accumulate, sum);
+ be16enc(&tc->th_sum, sum);
+ }
+ be16enc(opt + 2, maxmss);
res = 1;
}
}
OpenPOWER on IntegriCloud