summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2010-01-10 23:54:21 +0000
committerdlg <dlg@openbsd.org>2010-01-10 23:54:21 +0000
commit4efe3db76e8ef36e372fa5336e892089734d1349 (patch)
treefc3dd627581a363adcf84a8cc040478e7ffb805c
parentlex <=, >=, and != into a single token for correctness and to reduce the (diff)
downloadwireguard-openbsd-4efe3db76e8ef36e372fa5336e892089734d1349.tar.xz
wireguard-openbsd-4efe3db76e8ef36e372fa5336e892089734d1349.zip
replace a pad in the pfsync subheader with a length field. it stores the
length of its message in dwords. multiply that by the count of the messages to figure out how to skip to the next subheader. "old" code still thinks the len field is a pad, which it doesnt look at, so new messages with a filled in len are still parsed correctly by "old" code. input and ok mcbride@ sounds good! Simon Perreault
-rw-r--r--sys/net/if_pfsync.c8
-rw-r--r--sys/net/if_pfsync.h6
2 files changed, 10 insertions, 4 deletions
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index 3f19771e2e8..ebfe8f27640 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.135 2009/12/14 12:31:45 henning Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.136 2010/01/10 23:54:21 dlg Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -1668,6 +1668,7 @@ pfsync_sendout(void)
}
bzero(subh, sizeof(*subh));
+ subh->len = sizeof(ur->ur_msg) >> 2;
subh->action = PFSYNC_ACT_UPD_REQ;
subh->count = htons(count);
}
@@ -1696,6 +1697,7 @@ pfsync_sendout(void)
bzero(subh, sizeof(*subh));
subh->action = PFSYNC_ACT_TDB;
+ subh->len = sizeof(struct pfsync_tdb) >> 2;
subh->count = htons(count);
}
@@ -1722,6 +1724,7 @@ pfsync_sendout(void)
bzero(subh, sizeof(*subh));
subh->action = pfsync_qs[q].action;
+ subh->len = pfsync_qs[q].len >> 2;
subh->count = htons(count);
}
@@ -1730,6 +1733,7 @@ pfsync_sendout(void)
bzero(subh, sizeof(*subh));
subh->action = PFSYNC_ACT_EOF;
+ subh->len = 0 >> 2;
subh->count = htons(1);
/* we're done, let's put it on the wire */
@@ -2082,6 +2086,7 @@ pfsync_clear_states(u_int32_t creatorid, const char *ifname)
bzero(&r, sizeof(r));
r.subh.action = PFSYNC_ACT_CLR;
+ r.subh.len = sizeof(struct pfsync_clr) >> 2;
r.subh.count = htons(1);
strlcpy(r.clr.ifname, ifname, sizeof(r.clr.ifname));
@@ -2286,6 +2291,7 @@ pfsync_bulk_status(u_int8_t status)
bzero(&r, sizeof(r));
r.subh.action = PFSYNC_ACT_BUS;
+ r.subh.len = sizeof(struct pfsync_bus) >> 2;
r.subh.count = htons(1);
r.bus.creatorid = pf_status.hostid;
diff --git a/sys/net/if_pfsync.h b/sys/net/if_pfsync.h
index 108dc47a341..6a6e024a3d5 100644
--- a/sys/net/if_pfsync.h
+++ b/sys/net/if_pfsync.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.h,v 1.40 2009/11/09 23:46:38 dlg Exp $ */
+/* $OpenBSD: if_pfsync.h,v 1.41 2010/01/10 23:54:21 dlg Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -114,7 +114,7 @@
struct pfsync_header {
u_int8_t version;
u_int8_t _pad;
- u_int16_t len;
+ u_int16_t len; /* in bytes */
u_int8_t pfcksum[PF_MD5_DIGEST_LENGTH];
} __packed;
@@ -124,7 +124,7 @@ struct pfsync_header {
struct pfsync_subheader {
u_int8_t action;
- u_int8_t _pad;
+ u_int8_t len; /* in dwords */
u_int16_t count;
} __packed;