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.
This commit is contained in:
Gleb Smirnoff 2012-03-08 09:20:00 +00:00
parent b733be57cc
commit 0e2fe5f990

View file

@ -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));
}