summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authormaxv <maxv@NetBSD.org>2018-04-06 14:50:55 +0000
committermaxv <maxv@NetBSD.org>2018-04-06 14:50:55 +0000
commit2dd9f544b767ac6ca35c19690f5538245dfe8df6 (patch)
treee4e8bafde727325f031d8ca62521df16817bb125 /sys/net
parent4a64e6dac613d93698f37974d90a71ce259cbaa4 (diff)
If we're trying to read the mss on a packet that for some reason has two
MAXSEG options, we find ourselves patching the second option with the value of the first one. Fix that by using a local variable.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/npf/npf_inet.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/net/npf/npf_inet.c b/sys/net/npf/npf_inet.c
index a3a8a0b786d..ddac55dc3fc 100644
--- a/sys/net/npf/npf_inet.c
+++ b/sys/net/npf/npf_inet.c
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_inet.c,v 1.47 2018/03/23 08:28:54 maxv Exp $ */
+/* $NetBSD: npf_inet.c,v 1.48 2018/04/06 14:50:55 maxv Exp $ */
/*-
* Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.47 2018/03/23 08:28:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.48 2018/04/06 14:50:55 maxv Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -230,6 +230,7 @@ npf_fetch_tcpopts(npf_cache_t *npc, uint16_t *mss, int *wscale)
nbuf_t *nbuf = npc->npc_nbuf;
const struct tcphdr *th = npc->npc_l4.tcp;
int topts_len, step;
+ bool setmss = false;
uint8_t *nptr;
uint8_t val;
bool ok;
@@ -245,6 +246,11 @@ npf_fetch_tcpopts(npf_cache_t *npc, uint16_t *mss, int *wscale)
}
KASSERT(topts_len <= MAX_TCPOPTLEN);
+ /* Determine if we want to set or get the mss. */
+ if (mss) {
+ setmss = (*mss != 0);
+ }
+
/* First step: IP and TCP header up to options. */
step = npc->npc_hlen + sizeof(struct tcphdr);
nbuf_reset(nbuf);
@@ -270,7 +276,7 @@ next:
goto done;
}
if (mss) {
- if (*mss) {
+ if (setmss) {
memcpy(nptr + 2, mss, sizeof(uint16_t));
} else {
memcpy(mss, nptr + 2, sizeof(uint16_t));