-/* $OpenBSD: mib.c,v 1.3 2023/04/19 12:58:15 jsg Exp $ */
+/* $OpenBSD: mib.c,v 1.4 2023/07/04 11:34:19 sashan Exp $ */
/*
* Copyright (c) 2022 Martijn van Duren <martijn@openbsd.org>
struct kif kif;
};
+void mib_close_pftrans(struct agentx_varbind *, u_int32_t);
+
void mib_pfinfo(struct agentx_varbind *);
void mib_pfcounters(struct agentx_varbind *);
void mib_pfscounters(struct agentx_varbind *);
fatal("%s: Unexpected object", __func__);
}
+void
+mib_close_pftrans(struct agentx_varbind *vb, u_int32_t ticket)
+{
+ extern int devpf;
+
+ if (ioctl(devpf, DIOCXEND, &ticket) == -1) {
+ log_warn("DIOCXEND");
+ agentx_varbind_error(vb);
+ }
+}
+
void
mib_pflabelnum(struct agentx_varbind *vb)
{
if (ioctl(devpf, DIOCGETRULE, &pr) == -1) {
log_warn("DIOCGETRULE");
agentx_varbind_error(vb);
+ mib_close_pftrans(vb, pr.ticket);
return;
}
}
agentx_varbind_integer(vb, lnr);
+
+ mib_close_pftrans(vb, pr.ticket);
}
void
if (ioctl(devpf, DIOCGETRULE, &pr) == -1) {
log_warn("DIOCGETRULE");
agentx_varbind_error(vb);
+ mib_close_pftrans(vb, pr.ticket);
return;
}
}
}
+ mib_close_pftrans(vb, pr.ticket);
+
if (r == NULL) {
agentx_varbind_notfound(vb);
return;
-/* $OpenBSD: pf_ioctl.c,v 1.412 2023/07/04 02:01:55 jsg Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.413 2023/07/04 11:34:19 sashan Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
case DIOCGETSRCNODES:
case DIOCIGETIFACES:
case DIOCGETSYNFLWATS:
+ case DIOCXEND:
break;
case DIOCRCLRTABLES:
case DIOCRADDTABLES:
break;
}
+ case DIOCXEND: {
+ u_int32_t *ticket = (u_int32_t *)addr;
+ struct pf_trans *t;
+
+ t = pf_find_trans(minor(dev), *ticket);
+ if (t != NULL)
+ pf_rollback_trans(t);
+ else
+ error = ENXIO;
+ break;
+ }
+
case DIOCGETSRCNODES: {
struct pfioc_src_nodes *psn = (struct pfioc_src_nodes *)addr;
struct pf_src_node *n, *p, *pstore;
-/* $OpenBSD: pfvar.h,v 1.531 2023/05/26 12:13:26 kn Exp $ */
+/* $OpenBSD: pfvar.h,v 1.532 2023/07/04 11:34:19 sashan Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
#define DIOCSETSYNFLWATS _IOWR('D', 97, struct pfioc_synflwats)
#define DIOCSETSYNCOOKIES _IOWR('D', 98, u_int8_t)
#define DIOCGETSYNFLWATS _IOWR('D', 99, struct pfioc_synflwats)
+#define DIOCXEND _IOWR('D', 100, u_int32_t)
#ifdef _KERNEL
-/* $OpenBSD: pftop.c,v 1.45 2019/10/17 21:54:29 millert Exp $ */
+/* $OpenBSD: pftop.c,v 1.46 2023/07/04 11:34:19 sashan Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar
* Copyright (c) 2001 Daniel Hartmeier
int label_length;
+void
+close_pf_trans(u_int32_t ticket)
+{
+ if (ioctl(pf_dev, DIOCXEND, &ticket) == -1)
+ error("DIOCXEND: %s", strerror(errno));
+}
+
int
read_anchor_rules(char *anchor)
{
pr.nr = nr;
if (ioctl(pf_dev, DIOCGETRULE, &pr) == -1) {
error("DIOCGETRULE: %s", strerror(errno));
+ close_pf_trans(pr.ticket);
return (-1);
}
/* XXX overload pr.anchor, to store a pointer to
rules[off + nr] = pr.rule;
}
+ close_pf_trans(pr.ticket);
+
return (num);
}