summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frantzen <frantzen@cvs.openbsd.org>2003-08-27 16:13:22 +0000
committerMike Frantzen <frantzen@cvs.openbsd.org>2003-08-27 16:13:22 +0000
commit94541b8379325b625efd9ea532daed507127a6fd (patch)
tree13e95549250f527fbc291588094930fcc6bfe9f1
parent3bed8e9c367a29708af9fd6c3a66c5333fc5febb (diff)
it is supprisingly common (>4%) for some NAT and DSL routers to tweak MSS
by setting it to whatever is suitable for the link type. so we try a guessed 1460 MTU and 1500 MSS if the primary check fails. algorithm tweak from Michal Zalewski name a few constants too while I'm in there
-rw-r--r--sys/net/pf_osfp.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/sys/net/pf_osfp.c b/sys/net/pf_osfp.c
index c72914aaba1..b7c72daa63c 100644
--- a/sys/net/pf_osfp.c
+++ b/sys/net/pf_osfp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_osfp.c,v 1.1 2003/08/21 19:12:08 frantzen Exp $ */
+/* $OpenBSD: pf_osfp.c,v 1.2 2003/08/27 16:13:21 frantzen Exp $ */
/*
* Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org>
@@ -372,16 +372,32 @@ pf_osfp_find(struct pf_osfp_list *list, struct pf_os_fingerprint *find,
MATCH_INT(PF_OSFP_WSCALE_MOD, PF_OSFP_WSCALE_DC, fp_wscale)
if ((f->fp_flags & PF_OSFP_WSIZE_DC) == 0) {
if (f->fp_flags & PF_OSFP_WSIZE_MSS) {
- if (find->fp_mss == 0 ||
- find->fp_wsize % find->fp_mss ||
+ if (find->fp_mss == 0)
+ continue;
+
+/* Some "smart" NAT devices and DSL routers will tweak the MSS size and
+ * will set it to whatever is suitable for the link type.
+ */
+#define SMART_MSS 1460
+ if ((find->fp_wsize % find->fp_mss ||
find->fp_wsize / find->fp_mss !=
- f->fp_wsize)
+ f->fp_wsize) &&
+ (find->fp_wsize % SMART_MSS ||
+ find->fp_wsize / SMART_MSS !=
+ f->fp_wsize))
continue;
} else if (f->fp_flags & PF_OSFP_WSIZE_MTU) {
- if (find->fp_mss == 0 ||
- find->fp_wsize % (find->fp_mss + 40) ||
- find->fp_wsize / (find->fp_mss + 40) !=
- f->fp_wsize)
+ if (find->fp_mss == 0)
+ continue;
+
+#define MTUOFF (sizeof(struct ip) + sizeof(struct tcphdr))
+#define SMART_MTU (SMART_MSS + MTUOFF)
+ if ((find->fp_wsize % (find->fp_mss + MTUOFF) ||
+ find->fp_wsize / (find->fp_mss + MTUOFF) !=
+ f->fp_wsize) &&
+ (find->fp_wsize % SMART_MTU ||
+ find->fp_wsize / SMART_MTU !=
+ f->fp_wsize))
continue;
} else if (f->fp_flags & PF_OSFP_WSIZE_MOD) {
if (f->fp_wsize == 0 || find->fp_wsize %