-/* $OpenBSD: if_pfsync.c,v 1.315 2023/05/18 12:10:04 sashan Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.316 2023/05/26 12:13:26 kn Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
switch (bus->status) {
case PFSYNC_BUS_START:
+ PF_LOCK();
timeout_add(&sc->sc_bulkfail_tmo, 4 * hz +
pf_pool_limits[PF_LIMIT_STATES].limit /
((sc->sc_if.if_mtu - PFSYNC_MINPKT) /
sizeof(struct pfsync_state)));
+ PF_UNLOCK();
DPFPRINTF(LOG_INFO, "received bulk update start");
break;
#endif
pfsync_sync_ok = 0;
DPFPRINTF(LOG_INFO, "requesting bulk update");
+ PF_LOCK();
timeout_add(&sc->sc_bulkfail_tmo, 4 * hz +
pf_pool_limits[PF_LIMIT_STATES].limit /
((sc->sc_if.if_mtu - PFSYNC_MINPKT) /
sizeof(struct pfsync_state)));
+ PF_UNLOCK();
pfsync_request_update(0, 0);
}
}
-/* $OpenBSD: pf_ioctl.c,v 1.404 2023/05/11 12:36:22 kn Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.405 2023/05/26 12:13:26 kn Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
error = EINVAL;
goto fail;
}
- NET_LOCK();
PF_LOCK();
pl->limit = pf_pool_limits[pl->index].limit;
PF_UNLOCK();
- NET_UNLOCK();
break;
}
case DIOCSETLIMIT: {
struct pfioc_limit *pl = (struct pfioc_limit *)addr;
- NET_LOCK();
PF_LOCK();
if (pl->index < 0 || pl->index >= PF_LIMIT_MAX) {
error = EINVAL;
PF_UNLOCK();
- NET_UNLOCK();
goto fail;
}
if (((struct pool *)pf_pool_limits[pl->index].pp)->pr_nout >
pl->limit) {
error = EBUSY;
PF_UNLOCK();
- NET_UNLOCK();
goto fail;
}
/* Fragments reference mbuf clusters. */
if (pl->index == PF_LIMIT_FRAGS && pl->limit > nmbclust) {
error = EINVAL;
PF_UNLOCK();
- NET_UNLOCK();
goto fail;
}
pf_pool_limits[pl->index].limit_new = pl->limit;
pl->limit = pf_pool_limits[pl->index].limit;
PF_UNLOCK();
- NET_UNLOCK();
break;
}
-/* $OpenBSD: pfvar.h,v 1.530 2023/04/28 14:08:38 sashan Exp $ */
+/* $OpenBSD: pfvar.h,v 1.531 2023/05/26 12:13:26 kn Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
extern struct pf_status pf_status;
extern struct pool pf_frent_pl, pf_frag_pl;
+/*
+ * Protection/ownership of pf_pool_limit:
+ * I immutable after pfattach()
+ * p pf_lock
+ */
+
struct pf_pool_limit {
- void *pp;
- unsigned limit;
- unsigned limit_new;
+ void *pp; /* [I] */
+ unsigned limit; /* [p] */
+ unsigned limit_new; /* [p] */
};
extern struct pf_pool_limit pf_pool_limits[PF_LIMIT_MAX];