-/* $OpenBSD: pf_ioctl.c,v 1.374 2022/03/23 09:01:59 sashan Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.375 2022/03/23 17:36:09 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
/* save state to not run over them all each time? */
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
memcpy(&pq->queue, qs, sizeof(pq->queue));
PF_UNLOCK();
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
nbytes = pq->nbytes;
nr = 0;
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
memcpy(&pq->queue, qs, sizeof(pq->queue));
/* It's a root flow queue but is not an HFSC root class */
qs = pool_get(&pf_queue_pl, PR_WAITOK|PR_LIMITFAIL|PR_ZERO);
if (qs == NULL) {
error = ENOMEM;
- break;
+ goto fail;
}
NET_LOCK();
PF_UNLOCK();
NET_UNLOCK();
pool_put(&pf_queue_pl, qs);
- break;
+ goto fail;
}
memcpy(qs, &q->queue, sizeof(*qs));
qs->qid = pf_qname2qid(qs->qname, 1);
PF_UNLOCK();
NET_UNLOCK();
pool_put(&pf_queue_pl, qs);
- break;
+ goto fail;
}
if (qs->parent[0] && (qs->parent_qid =
pf_qname2qid(qs->parent, 0)) == 0) {
PF_UNLOCK();
NET_UNLOCK();
pool_put(&pf_queue_pl, qs);
- break;
+ goto fail;
}
qs->kif = pfi_kif_get(qs->ifname, NULL);
if (qs->kif == NULL) {
PF_UNLOCK();
NET_UNLOCK();
pool_put(&pf_queue_pl, qs);
- break;
+ goto fail;
}
/* XXX resolve bw percentage specs */
pfi_kif_ref(qs->kif, PFI_KIF_REF_RULE);
rule = pool_get(&pf_rule_pl, PR_WAITOK|PR_LIMITFAIL|PR_ZERO);
if (rule == NULL) {
error = ENOMEM;
- break;
+ goto fail;
}
if ((error = pf_rule_copyin(&pr->rule, rule))) {
pf_rule_free(rule);
rule = NULL;
- break;
+ goto fail;
}
if (pr->rule.return_icmp >> 8 > ICMP_MAXTYPE) {
error = EINVAL;
pf_rule_free(rule);
rule = NULL;
- break;
+ goto fail;
}
if ((error = pf_rule_checkaf(rule))) {
pf_rule_free(rule);
error = EINVAL;
pf_rule_free(rule);
rule = NULL;
- break;
+ goto fail;
}
if (rule->rt && !rule->direction) {
error = EINVAL;
pf_rule_free(rule);
rule = NULL;
- break;
+ goto fail;
}
NET_LOCK();
PF_UNLOCK();
NET_UNLOCK();
pf_rule_free(rule);
- break;
+ goto fail;
}
if (pr->ticket != ruleset->rules.inactive.ticket) {
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
pf_rule_free(rule);
- break;
+ goto fail;
}
rule->cuid = p->p_ucred->cr_ruid;
rule->cpid = p->p_p->ps_pid;
pf_rm_rule(NULL, rule);
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
TAILQ_INSERT_TAIL(ruleset->rules.inactive.ptr,
rule, entries);
error = EINVAL;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
tail = TAILQ_LAST(ruleset->rules.active.ptr, pf_rulequeue);
if (tail)
error = EINVAL;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
if (pr->ticket != ruleset->rules.active.ticket) {
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
rule = TAILQ_FIRST(ruleset->rules.active.ptr);
while ((rule != NULL) && (rule->nr != pr->nr))
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
memcpy(&pr->rule, rule, sizeof(struct pf_rule));
memset(&pr->rule.entries, 0, sizeof(pr->rule.entries));
error = EBUSY;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
pf_addr_copyout(&pr->rule.src.addr);
pf_addr_copyout(&pr->rule.dst.addr);
if (pcr->action < PF_CHANGE_ADD_HEAD ||
pcr->action > PF_CHANGE_GET_TICKET) {
error = EINVAL;
- break;
+ goto fail;
}
if (pcr->action == PF_CHANGE_GET_TICKET) {
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
if (pcr->action != PF_CHANGE_REMOVE) {
PR_WAITOK|PR_LIMITFAIL|PR_ZERO);
if (newrule == NULL) {
error = ENOMEM;
- break;
+ goto fail;
}
if (pcr->rule.return_icmp >> 8 > ICMP_MAXTYPE) {
error = EINVAL;
pool_put(&pf_rule_pl, newrule);
- break;
+ goto fail;
}
error = pf_rule_copyin(&pcr->rule, newrule);
if (error != 0) {
pf_rule_free(newrule);
newrule = NULL;
- break;
+ goto fail;
}
if ((error = pf_rule_checkaf(newrule))) {
pf_rule_free(newrule);
pf_rule_free(newrule);
error = EINVAL;
newrule = NULL;
- break;
+ goto fail;
}
}
PF_UNLOCK();
NET_UNLOCK();
pf_rule_free(newrule);
- break;
+ goto fail;
}
if (pcr->ticket != ruleset->rules.active.ticket) {
PF_UNLOCK();
NET_UNLOCK();
pf_rule_free(newrule);
- break;
+ goto fail;
}
if (pcr->action != PF_CHANGE_REMOVE) {
pf_rm_rule(NULL, newrule);
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
}
error = EINVAL;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
}
PF_STATE_EXIT_WRITE();
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
if (psk->psk_af && psk->psk_proto &&
PF_STATE_EXIT_WRITE();
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
NET_LOCK();
if (sp->timeout >= PFTM_MAX) {
error = EINVAL;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
NET_UNLOCK();
if (s == NULL) {
error = ENOENT;
- break;
+ goto fail;
}
pf_state_export(&ps->state, s);
memset(pf_status.ifname, 0, IFNAMSIZ);
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
strlcpy(pf_trans_set.statusif, pi->pfiio_name, IFNAMSIZ);
pf_trans_set.mask |= PF_TSET_STATUSIF;
pfi_update_status(pi->pfiio_name, NULL);
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
memset(pf_status.counters, 0, sizeof(pf_status.counters));
error = EINVAL;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
pr->nr = 0;
if (ruleset == &pf_main_ruleset) {
error = EINVAL;
PF_UNLOCK();
NET_UNLOCK();
- break;
+ goto fail;
}
pr->name[0] = '\0';
if (ruleset == &pf_main_ruleset) {
if (io->pfrio_esize != 0) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_table)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_table)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_table)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_tstats)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_table)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_table)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != 0) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
- break;
+ goto fail;
}
error = pfr_add_addrs(&io->pfrio_table, io->pfrio_buffer,
io->pfrio_size, &io->pfrio_nadd, io->pfrio_flags |
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_astats)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io->pfrio_esize != sizeof(struct pfr_addr)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
PF_UNLOCK();
NET_UNLOCK();
free(pstore, M_TEMP, sizeof(*pstore));
- break;
+ goto fail;
}
p = psn->psn_src_nodes;
if (io->pfiio_esize != sizeof(struct pfi_kif)) {
error = ENODEV;
- break;
+ goto fail;
}
NET_LOCK();
PF_LOCK();
if (io == NULL) {
error = EINVAL;
- break;
+ goto fail;
}
NET_LOCK();
if (io == NULL) {
error = EINVAL;
- break;
+ goto fail;
}
NET_LOCK();