From d8060072d1c3c7524d479041d0b27e86668a0fe9 Mon Sep 17 00:00:00 2001 From: glebius Date: Thu, 8 Mar 2012 09:20:00 +0000 Subject: Merge from OpenBSD: revision 1.146 date: 2010/05/12 08:11:11; author: claudio; state: Exp; lines: +2 -3 bzero() the full compressed update struct before setting the values. This is needed because pf_state_peer_hton() skips some fields in certain situations which could result in garbage beeing sent to the other peer. This seems to fix the pfsync storms seen by stephan@ and so dlg owes me a whiskey. I didn't see any storms, but this definitely fixes a useless memory allocation on the receiving side, due to non zero scrub_flags field in a pfsync_state_peer structure. --- sys/contrib/pf/net/if_pfsync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/contrib/pf/net/if_pfsync.c b/sys/contrib/pf/net/if_pfsync.c index 0f3f5cc..f4d296d 100644 --- a/sys/contrib/pf/net/if_pfsync.c +++ b/sys/contrib/pf/net/if_pfsync.c @@ -48,6 +48,7 @@ * 1.120, 1.175 - use monotonic time_uptime * 1.122 - reduce number of updates for non-TCP sessions * 1.128 - cleanups + * 1.146 - bzero() mbuf before sparsely filling it with data * 1.170 - SIOCSIFMTU checks */ @@ -2011,6 +2012,7 @@ pfsync_out_upd_c(struct pf_state *st, struct mbuf *m, int offset) { struct pfsync_upd_c *up = (struct pfsync_upd_c *)(m->m_data + offset); + bzero(up, sizeof(*up)); up->id = st->id; pf_state_peer_hton(&st->src, &up->src); pf_state_peer_hton(&st->dst, &up->dst); @@ -2023,8 +2025,6 @@ pfsync_out_upd_c(struct pf_state *st, struct mbuf *m, int offset) up->expire = htonl(up->expire - time_second); up->timeout = st->timeout; - bzero(up->_pad, sizeof(up->_pad)); /* XXX */ - return (sizeof(*up)); } -- cgit v1.1