Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/pf_syncookies.c
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | if (nv->size == 0) { | ||||
ERROUT(ENOSPC); | ERROUT(ENOSPC); | ||||
} | } | ||||
error = copyout(nvlpacked, nv->data, nv->len); | error = copyout(nvlpacked, nv->data, nv->len); | ||||
#undef ERROUT | #undef ERROUT | ||||
errout: | errout: | ||||
nvlist_destroy(nvl); | nvlist_destroy(nvl); | ||||
free(nvlpacked, M_TEMP); | free(nvlpacked, M_NVLIST); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
pf_set_syncookies(struct pfioc_nv *nv) | pf_set_syncookies(struct pfioc_nv *nv) | ||||
{ | { | ||||
nvlist_t *nvl = NULL; | nvlist_t *nvl = NULL; | ||||
void *nvlpacked = NULL; | void *nvlpacked = NULL; | ||||
int error; | int error; | ||||
bool enabled, adaptive; | bool enabled, adaptive; | ||||
uint32_t hiwat, lowat; | uint32_t hiwat, lowat; | ||||
uint8_t newmode; | uint8_t newmode; | ||||
#define ERROUT(x) ERROUT_FUNCTION(errout, x) | #define ERROUT(x) ERROUT_FUNCTION(errout, x) | ||||
if (nv->len > pf_ioctl_maxcount) | if (nv->len > pf_ioctl_maxcount) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
nvlpacked = malloc(nv->len, M_TEMP, M_WAITOK); | nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK); | ||||
if (nvlpacked == NULL) | if (nvlpacked == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
error = copyin(nv->data, nvlpacked, nv->len); | error = copyin(nv->data, nvlpacked, nv->len); | ||||
if (error) | if (error) | ||||
ERROUT(error); | ERROUT(error); | ||||
nvl = nvlist_unpack(nvlpacked, nv->len, 0); | nvl = nvlist_unpack(nvlpacked, nv->len, 0); | ||||
Show All 24 Lines | #define ERROUT(x) ERROUT_FUNCTION(errout, x) | ||||
V_pf_syncookie_status.lowat = lowat; | V_pf_syncookie_status.lowat = lowat; | ||||
V_pf_syncookie_status.hiwat = hiwat; | V_pf_syncookie_status.hiwat = hiwat; | ||||
PF_RULES_WUNLOCK(); | PF_RULES_WUNLOCK(); | ||||
#undef ERROUT | #undef ERROUT | ||||
errout: | errout: | ||||
nvlist_destroy(nvl); | nvlist_destroy(nvl); | ||||
free(nvlpacked, M_TEMP); | free(nvlpacked, M_NVLIST); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
pf_syncookies_setmode(u_int8_t mode) | pf_syncookies_setmode(u_int8_t mode) | ||||
{ | { | ||||
if (mode > PF_SYNCOOKIES_MODE_MAX) | if (mode > PF_SYNCOOKIES_MODE_MAX) | ||||
▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines |