-/* $OpenBSD: if_pfsync.c,v 1.318 2023/07/06 04:55:05 dlg Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.319 2023/07/31 11:13:09 dlg Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
}
/* state came off the wire */
- if (ISSET(st->state_flags, PFSTATE_ACK)) {
- CLR(st->state_flags, PFSTATE_ACK);
+ if (ISSET(flags, PFSYNC_SI_PFSYNC)) {
+ if (ISSET(st->state_flags, PFSTATE_ACK)) {
+ CLR(st->state_flags, PFSTATE_ACK);
- /* peer wants an iack, not an insert */
- st->sync_state = PFSYNC_S_SYNC;
+ /* peer wants an iack, not an insert */
+ st->sync_state = PFSYNC_S_SYNC;
+ } else
+ st->sync_state = PFSYNC_S_PFSYNC;
}
}
pfsync_q_ins(s, st, PFSYNC_S_IACK);
pfsync_slice_sched(s); /* the peer is waiting */
break;
+ case PFSYNC_S_PFSYNC:
+ /* state was just inserted by pfsync */
+ st->sync_state = PFSYNC_S_NONE;
+ break;
default:
panic("%s: state %p unexpected sync_state %d",
__func__, st, st->sync_state);
continue;
}
- if (pf_state_import(sp, 0) == ENOMEM) {
+ if (pf_state_import(sp, PFSYNC_SI_PFSYNC) == ENOMEM) {
/* drop out, but process the rest of the actions */
break;
}
if (st == NULL) {
/* insert the update */
PF_LOCK();
- error = pf_state_import(sp, 0);
+ error = pf_state_import(sp, PFSYNC_SI_PFSYNC);
if (error)
pfsyncstat_inc(pfsyncs_badstate);
PF_UNLOCK();
-/* $OpenBSD: if_pfsync.h,v 1.60 2023/07/06 04:55:05 dlg Exp $ */
+/* $OpenBSD: if_pfsync.h,v 1.61 2023/07/31 11:13:10 dlg Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
#define PFSYNC_S_NONE 0xd0
#define PFSYNC_S_SYNC 0xd1
+#define PFSYNC_S_PFSYNC 0xd2
#define PFSYNC_S_DEAD 0xde
int pfsync_input4(struct mbuf **, int *, int, int);
#define PFSYNC_SI_IOCTL 0x01
#define PFSYNC_SI_CKSUM 0x02
#define PFSYNC_SI_ACK 0x04
+#define PFSYNC_SI_PFSYNC 0x08
int pfsync_state_import(struct pfsync_state *, int);
void pfsync_state_export(struct pfsync_state *,
struct pf_state *);
-/* $OpenBSD: pf.c,v 1.1183 2023/07/07 08:05:02 bluhm Exp $ */
+/* $OpenBSD: pf.c,v 1.1184 2023/07/31 11:13:09 dlg Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
sni->sn->states++;
}
+#if NPFSYNC > 0
+ pfsync_init_state(st, *skw, *sks, 0);
+#endif
+
if (pf_state_insert(BOUND_IFACE(r, pd->kif), skw, sks, st)) {
*sks = *skw = NULL;
REASON_SET(&reason, PFRES_STATEINS);