sync with OpenBSD -current
This commit is contained in:
parent
8f3269c13c
commit
da785accdf
@ -1,4 +1,4 @@
|
|||||||
# $OpenBSD: Makefile,v 1.1.1.1 2023/04/23 13:43:46 tb Exp $
|
# $OpenBSD: Makefile,v 1.2 2023/12/17 08:32:26 tb Exp $
|
||||||
|
|
||||||
C2SP_TESTVECTORS = /usr/local/share/c2sp-testvectors/
|
C2SP_TESTVECTORS = /usr/local/share/c2sp-testvectors/
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ cctv: cctv.go
|
|||||||
OSSL_LIB = /usr/local/lib/eopenssl
|
OSSL_LIB = /usr/local/lib/eopenssl
|
||||||
OSSL_INC = /usr/local/include/eopenssl
|
OSSL_INC = /usr/local/include/eopenssl
|
||||||
|
|
||||||
. for V in 11 30 31
|
. for V in 11 31 32
|
||||||
. if exists(/usr/local/bin/eopenssl$V)
|
. if exists(/usr/local/bin/eopenssl$V)
|
||||||
PROGS += cctv-openssl$V
|
PROGS += cctv-openssl$V
|
||||||
SRCS_cctv-openssl$V =
|
SRCS_cctv-openssl$V =
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: fuse_device.c,v 1.39 2023/09/08 20:00:28 mvs Exp $ */
|
/* $OpenBSD: fuse_device.c,v 1.40 2023/12/16 22:17:08 mvs Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
|
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
|
||||||
*
|
*
|
||||||
@ -19,13 +19,14 @@
|
|||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/event.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
#include <sys/rwlock.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
#include <sys/fusebuf.h>
|
#include <sys/fusebuf.h>
|
||||||
#include <sys/selinfo.h>
|
|
||||||
|
|
||||||
#include "fusefs_node.h"
|
#include "fusefs_node.h"
|
||||||
#include "fusefs.h"
|
#include "fusefs.h"
|
||||||
@ -36,18 +37,24 @@
|
|||||||
#define DPRINTF(fmt, arg...)
|
#define DPRINTF(fmt, arg...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Locks used to protect struct members and global data
|
||||||
|
* l fd_lock
|
||||||
|
*/
|
||||||
|
|
||||||
SIMPLEQ_HEAD(fusebuf_head, fusebuf);
|
SIMPLEQ_HEAD(fusebuf_head, fusebuf);
|
||||||
|
|
||||||
struct fuse_d {
|
struct fuse_d {
|
||||||
|
struct rwlock fd_lock;
|
||||||
struct fusefs_mnt *fd_fmp;
|
struct fusefs_mnt *fd_fmp;
|
||||||
int fd_unit;
|
int fd_unit;
|
||||||
|
|
||||||
/*fusebufs queues*/
|
/*fusebufs queues*/
|
||||||
struct fusebuf_head fd_fbufs_in;
|
struct fusebuf_head fd_fbufs_in; /* [l] */
|
||||||
struct fusebuf_head fd_fbufs_wait;
|
struct fusebuf_head fd_fbufs_wait;
|
||||||
|
|
||||||
/* kq fields */
|
/* kq fields */
|
||||||
struct selinfo fd_rsel;
|
struct klist fd_rklist; /* [l] */
|
||||||
LIST_ENTRY(fuse_d) fd_list;
|
LIST_ENTRY(fuse_d) fd_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,12 +74,16 @@ int fusewrite(dev_t, struct uio *, int);
|
|||||||
int fusekqfilter(dev_t dev, struct knote *kn);
|
int fusekqfilter(dev_t dev, struct knote *kn);
|
||||||
int filt_fuse_read(struct knote *, long);
|
int filt_fuse_read(struct knote *, long);
|
||||||
void filt_fuse_rdetach(struct knote *);
|
void filt_fuse_rdetach(struct knote *);
|
||||||
|
int filt_fuse_modify(struct kevent *, struct knote *);
|
||||||
|
int filt_fuse_process(struct knote *, struct kevent *);
|
||||||
|
|
||||||
static const struct filterops fuse_rd_filtops = {
|
static const struct filterops fuse_rd_filtops = {
|
||||||
.f_flags = FILTEROP_ISFD,
|
.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
|
||||||
.f_attach = NULL,
|
.f_attach = NULL,
|
||||||
.f_detach = filt_fuse_rdetach,
|
.f_detach = filt_fuse_rdetach,
|
||||||
.f_event = filt_fuse_read,
|
.f_event = filt_fuse_read,
|
||||||
|
.f_modify = filt_fuse_modify,
|
||||||
|
.f_process = filt_fuse_process,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef FUSE_DEBUG
|
#ifdef FUSE_DEBUG
|
||||||
@ -142,6 +153,7 @@ fuse_device_cleanup(dev_t dev)
|
|||||||
|
|
||||||
/* clear FIFO IN */
|
/* clear FIFO IN */
|
||||||
lprev = NULL;
|
lprev = NULL;
|
||||||
|
rw_enter_write(&fd->fd_lock);
|
||||||
SIMPLEQ_FOREACH_SAFE(f, &fd->fd_fbufs_in, fb_next, ftmp) {
|
SIMPLEQ_FOREACH_SAFE(f, &fd->fd_fbufs_in, fb_next, ftmp) {
|
||||||
DPRINTF("cleanup unprocessed msg in sc_fbufs_in\n");
|
DPRINTF("cleanup unprocessed msg in sc_fbufs_in\n");
|
||||||
if (lprev == NULL)
|
if (lprev == NULL)
|
||||||
@ -155,6 +167,7 @@ fuse_device_cleanup(dev_t dev)
|
|||||||
wakeup(f);
|
wakeup(f);
|
||||||
lprev = f;
|
lprev = f;
|
||||||
}
|
}
|
||||||
|
rw_exit_write(&fd->fd_lock);
|
||||||
|
|
||||||
/* clear FIFO WAIT*/
|
/* clear FIFO WAIT*/
|
||||||
lprev = NULL;
|
lprev = NULL;
|
||||||
@ -182,9 +195,11 @@ fuse_device_queue_fbuf(dev_t dev, struct fusebuf *fbuf)
|
|||||||
if (fd == NULL)
|
if (fd == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
rw_enter_write(&fd->fd_lock);
|
||||||
SIMPLEQ_INSERT_TAIL(&fd->fd_fbufs_in, fbuf, fb_next);
|
SIMPLEQ_INSERT_TAIL(&fd->fd_fbufs_in, fbuf, fb_next);
|
||||||
|
knote_locked(&fd->fd_rklist, 0);
|
||||||
|
rw_exit_write(&fd->fd_lock);
|
||||||
stat_fbufs_in++;
|
stat_fbufs_in++;
|
||||||
selwakeup(&fd->fd_rsel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -221,6 +236,9 @@ fuseopen(dev_t dev, int flags, int fmt, struct proc * p)
|
|||||||
fd->fd_unit = unit;
|
fd->fd_unit = unit;
|
||||||
SIMPLEQ_INIT(&fd->fd_fbufs_in);
|
SIMPLEQ_INIT(&fd->fd_fbufs_in);
|
||||||
SIMPLEQ_INIT(&fd->fd_fbufs_wait);
|
SIMPLEQ_INIT(&fd->fd_fbufs_wait);
|
||||||
|
rw_init(&fd->fd_lock, "fusedlk");
|
||||||
|
klist_init_rwlock(&fd->fd_rklist, &fd->fd_lock);
|
||||||
|
|
||||||
LIST_INSERT_HEAD(&fuse_d_list, fd, fd_list);
|
LIST_INSERT_HEAD(&fuse_d_list, fd, fd_list);
|
||||||
|
|
||||||
stat_opened_fusedev++;
|
stat_opened_fusedev++;
|
||||||
@ -278,6 +296,7 @@ fuseioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
|
|||||||
ioexch = (struct fb_ioctl_xch *)addr;
|
ioexch = (struct fb_ioctl_xch *)addr;
|
||||||
|
|
||||||
/* Looking for uuid in fd_fbufs_in */
|
/* Looking for uuid in fd_fbufs_in */
|
||||||
|
rw_enter_write(&fd->fd_lock);
|
||||||
SIMPLEQ_FOREACH(fbuf, &fd->fd_fbufs_in, fb_next) {
|
SIMPLEQ_FOREACH(fbuf, &fd->fd_fbufs_in, fb_next) {
|
||||||
if (fbuf->fb_uuid == ioexch->fbxch_uuid)
|
if (fbuf->fb_uuid == ioexch->fbxch_uuid)
|
||||||
break;
|
break;
|
||||||
@ -285,6 +304,7 @@ fuseioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
|
|||||||
lastfbuf = fbuf;
|
lastfbuf = fbuf;
|
||||||
}
|
}
|
||||||
if (fbuf == NULL) {
|
if (fbuf == NULL) {
|
||||||
|
rw_exit_write(&fd->fd_lock);
|
||||||
printf("fuse: Cannot find fusebuf\n");
|
printf("fuse: Cannot find fusebuf\n");
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
@ -295,6 +315,8 @@ fuseioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
|
|||||||
else
|
else
|
||||||
SIMPLEQ_REMOVE_AFTER(&fd->fd_fbufs_in, lastfbuf,
|
SIMPLEQ_REMOVE_AFTER(&fd->fd_fbufs_in, lastfbuf,
|
||||||
fb_next);
|
fb_next);
|
||||||
|
rw_exit_write(&fd->fd_lock);
|
||||||
|
|
||||||
stat_fbufs_in--;
|
stat_fbufs_in--;
|
||||||
|
|
||||||
/* Do not handle fbufs with bad len */
|
/* Do not handle fbufs with bad len */
|
||||||
@ -385,22 +407,23 @@ fuseread(dev_t dev, struct uio *uio, int ioflag)
|
|||||||
void *tmpaddr;
|
void *tmpaddr;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
|
/* We get the whole fusebuf or nothing */
|
||||||
|
if (uio->uio_resid != FUSEBUFSIZE)
|
||||||
|
return (EINVAL);
|
||||||
|
|
||||||
fd = fuse_lookup(minor(dev));
|
fd = fuse_lookup(minor(dev));
|
||||||
if (fd == NULL)
|
if (fd == NULL)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
|
|
||||||
|
rw_enter_write(&fd->fd_lock);
|
||||||
|
|
||||||
if (SIMPLEQ_EMPTY(&fd->fd_fbufs_in)) {
|
if (SIMPLEQ_EMPTY(&fd->fd_fbufs_in)) {
|
||||||
if (ioflag & O_NONBLOCK)
|
if (ioflag & O_NONBLOCK)
|
||||||
return (EAGAIN);
|
error = EAGAIN;
|
||||||
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
fbuf = SIMPLEQ_FIRST(&fd->fd_fbufs_in);
|
fbuf = SIMPLEQ_FIRST(&fd->fd_fbufs_in);
|
||||||
|
|
||||||
/* We get the whole fusebuf or nothing */
|
|
||||||
if (uio->uio_resid != FUSEBUFSIZE)
|
|
||||||
return (EINVAL);
|
|
||||||
|
|
||||||
/* Do not send kernel pointers */
|
/* Do not send kernel pointers */
|
||||||
memcpy(&hdr.fh_next, &fbuf->fb_next, sizeof(fbuf->fb_next));
|
memcpy(&hdr.fh_next, &fbuf->fb_next, sizeof(fbuf->fb_next));
|
||||||
memset(&fbuf->fb_next, 0, sizeof(fbuf->fb_next));
|
memset(&fbuf->fb_next, 0, sizeof(fbuf->fb_next));
|
||||||
@ -426,6 +449,7 @@ fuseread(dev_t dev, struct uio *uio, int ioflag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
rw_exit_write(&fd->fd_lock);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +543,7 @@ fusekqfilter(dev_t dev, struct knote *kn)
|
|||||||
|
|
||||||
switch (kn->kn_filter) {
|
switch (kn->kn_filter) {
|
||||||
case EVFILT_READ:
|
case EVFILT_READ:
|
||||||
klist = &fd->fd_rsel.si_note;
|
klist = &fd->fd_rklist;
|
||||||
kn->kn_fop = &fuse_rd_filtops;
|
kn->kn_fop = &fuse_rd_filtops;
|
||||||
break;
|
break;
|
||||||
case EVFILT_WRITE:
|
case EVFILT_WRITE:
|
||||||
@ -530,7 +554,7 @@ fusekqfilter(dev_t dev, struct knote *kn)
|
|||||||
|
|
||||||
kn->kn_hook = fd;
|
kn->kn_hook = fd;
|
||||||
|
|
||||||
klist_insert_locked(klist, kn);
|
klist_insert(klist, kn);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -539,9 +563,9 @@ void
|
|||||||
filt_fuse_rdetach(struct knote *kn)
|
filt_fuse_rdetach(struct knote *kn)
|
||||||
{
|
{
|
||||||
struct fuse_d *fd = kn->kn_hook;
|
struct fuse_d *fd = kn->kn_hook;
|
||||||
struct klist *klist = &fd->fd_rsel.si_note;
|
struct klist *klist = &fd->fd_rklist;
|
||||||
|
|
||||||
klist_remove_locked(klist, kn);
|
klist_remove(klist, kn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -550,8 +574,36 @@ filt_fuse_read(struct knote *kn, long hint)
|
|||||||
struct fuse_d *fd = kn->kn_hook;
|
struct fuse_d *fd = kn->kn_hook;
|
||||||
int event = 0;
|
int event = 0;
|
||||||
|
|
||||||
|
rw_assert_wrlock(&fd->fd_lock);
|
||||||
|
|
||||||
if (!SIMPLEQ_EMPTY(&fd->fd_fbufs_in))
|
if (!SIMPLEQ_EMPTY(&fd->fd_fbufs_in))
|
||||||
event = 1;
|
event = 1;
|
||||||
|
|
||||||
return (event);
|
return (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
filt_fuse_modify(struct kevent *kev, struct knote *kn)
|
||||||
|
{
|
||||||
|
struct fuse_d *fd = kn->kn_hook;
|
||||||
|
int active;
|
||||||
|
|
||||||
|
rw_enter_write(&fd->fd_lock);
|
||||||
|
active = knote_modify(kev, kn);
|
||||||
|
rw_exit_write(&fd->fd_lock);
|
||||||
|
|
||||||
|
return (active);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
filt_fuse_process(struct knote *kn, struct kevent *kev)
|
||||||
|
{
|
||||||
|
struct fuse_d *fd = kn->kn_hook;
|
||||||
|
int active;
|
||||||
|
|
||||||
|
rw_enter_write(&fd->fd_lock);
|
||||||
|
active = knote_process(kn, kev);
|
||||||
|
rw_exit_write(&fd->fd_lock);
|
||||||
|
|
||||||
|
return (active);
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: if_pflow.c,v 1.105 2023/12/12 12:38:52 mvs Exp $ */
|
/* $OpenBSD: if_pflow.c,v 1.106 2023/12/16 22:16:02 mvs Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Florian Obser <florian@narrans.de>
|
* Copyright (c) 2011 Florian Obser <florian@narrans.de>
|
||||||
@ -297,9 +297,9 @@ pflow_clone_destroy(struct ifnet *ifp)
|
|||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
NET_LOCK();
|
rw_enter_write(&sc->sc_lock);
|
||||||
sc->sc_dying = 1;
|
sc->sc_dying = 1;
|
||||||
NET_UNLOCK();
|
rw_exit_write(&sc->sc_lock);
|
||||||
|
|
||||||
KERNEL_ASSERT_LOCKED();
|
KERNEL_ASSERT_LOCKED();
|
||||||
SMR_SLIST_REMOVE_LOCKED(&pflowif_list, sc, pflow_softc, sc_next);
|
SMR_SLIST_REMOVE_LOCKED(&pflowif_list, sc, pflow_softc, sc_next);
|
||||||
@ -483,6 +483,7 @@ pflow_set(struct pflow_softc *sc, struct pflowreq *pflowr)
|
|||||||
sc->so = NULL;
|
sc->so = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NET_LOCK();
|
||||||
mtx_enter(&sc->sc_mtx);
|
mtx_enter(&sc->sc_mtx);
|
||||||
|
|
||||||
/* error check is above */
|
/* error check is above */
|
||||||
@ -504,6 +505,7 @@ pflow_set(struct pflow_softc *sc, struct pflowreq *pflowr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mtx_leave(&sc->sc_mtx);
|
mtx_leave(&sc->sc_mtx);
|
||||||
|
NET_UNLOCK();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -515,18 +517,33 @@ pflowioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||||||
struct pflow_softc *sc = ifp->if_softc;
|
struct pflow_softc *sc = ifp->if_softc;
|
||||||
struct ifreq *ifr = (struct ifreq *)data;
|
struct ifreq *ifr = (struct ifreq *)data;
|
||||||
struct pflowreq pflowr;
|
struct pflowreq pflowr;
|
||||||
int error;
|
int error = 0;
|
||||||
|
|
||||||
if (sc->sc_dying)
|
|
||||||
return ENXIO;
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SIOCSIFADDR:
|
case SIOCSIFADDR:
|
||||||
case SIOCSIFDSTADDR:
|
case SIOCSIFDSTADDR:
|
||||||
case SIOCSIFFLAGS:
|
case SIOCSIFFLAGS:
|
||||||
|
case SIOCSIFMTU:
|
||||||
|
case SIOCGETPFLOW:
|
||||||
|
case SIOCSETPFLOW:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return (ENOTTY);
|
||||||
|
}
|
||||||
|
|
||||||
/* XXXSMP: enforce lock order */
|
/* XXXSMP: enforce lock order */
|
||||||
NET_UNLOCK();
|
NET_UNLOCK();
|
||||||
rw_enter_read(&sc->sc_lock);
|
rw_enter_write(&sc->sc_lock);
|
||||||
|
|
||||||
|
if (sc->sc_dying) {
|
||||||
|
error = ENXIO;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SIOCSIFADDR:
|
||||||
|
case SIOCSIFDSTADDR:
|
||||||
|
case SIOCSIFFLAGS:
|
||||||
NET_LOCK();
|
NET_LOCK();
|
||||||
if ((ifp->if_flags & IFF_UP) && sc->so != NULL) {
|
if ((ifp->if_flags & IFF_UP) && sc->so != NULL) {
|
||||||
ifp->if_flags |= IFF_RUNNING;
|
ifp->if_flags |= IFF_RUNNING;
|
||||||
@ -537,60 +554,53 @@ pflowioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||||||
mtx_leave(&sc->sc_mtx);
|
mtx_leave(&sc->sc_mtx);
|
||||||
} else
|
} else
|
||||||
ifp->if_flags &= ~IFF_RUNNING;
|
ifp->if_flags &= ~IFF_RUNNING;
|
||||||
rw_exit_read(&sc->sc_lock);
|
NET_UNLOCK();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIOCSIFMTU:
|
case SIOCSIFMTU:
|
||||||
if (ifr->ifr_mtu < PFLOW_MINMTU)
|
if (ifr->ifr_mtu < PFLOW_MINMTU) {
|
||||||
return (EINVAL);
|
error = EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
if (ifr->ifr_mtu > MCLBYTES)
|
if (ifr->ifr_mtu > MCLBYTES)
|
||||||
ifr->ifr_mtu = MCLBYTES;
|
ifr->ifr_mtu = MCLBYTES;
|
||||||
|
NET_LOCK();
|
||||||
if (ifr->ifr_mtu < ifp->if_mtu)
|
if (ifr->ifr_mtu < ifp->if_mtu)
|
||||||
pflow_flush(sc);
|
pflow_flush(sc);
|
||||||
mtx_enter(&sc->sc_mtx);
|
mtx_enter(&sc->sc_mtx);
|
||||||
pflow_setmtu(sc, ifr->ifr_mtu);
|
pflow_setmtu(sc, ifr->ifr_mtu);
|
||||||
mtx_leave(&sc->sc_mtx);
|
mtx_leave(&sc->sc_mtx);
|
||||||
|
NET_UNLOCK();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIOCGETPFLOW:
|
case SIOCGETPFLOW:
|
||||||
bzero(&pflowr, sizeof(pflowr));
|
bzero(&pflowr, sizeof(pflowr));
|
||||||
|
|
||||||
/* XXXSMP: enforce lock order */
|
|
||||||
NET_UNLOCK();
|
|
||||||
rw_enter_read(&sc->sc_lock);
|
|
||||||
NET_LOCK();
|
|
||||||
if (sc->sc_flowsrc != NULL)
|
if (sc->sc_flowsrc != NULL)
|
||||||
memcpy(&pflowr.flowsrc, sc->sc_flowsrc,
|
memcpy(&pflowr.flowsrc, sc->sc_flowsrc,
|
||||||
sc->sc_flowsrc->sa_len);
|
sc->sc_flowsrc->sa_len);
|
||||||
if (sc->sc_flowdst != NULL)
|
if (sc->sc_flowdst != NULL)
|
||||||
memcpy(&pflowr.flowdst, sc->sc_flowdst,
|
memcpy(&pflowr.flowdst, sc->sc_flowdst,
|
||||||
sc->sc_flowdst->sa_len);
|
sc->sc_flowdst->sa_len);
|
||||||
rw_exit_read(&sc->sc_lock);
|
|
||||||
mtx_enter(&sc->sc_mtx);
|
mtx_enter(&sc->sc_mtx);
|
||||||
pflowr.version = sc->sc_version;
|
pflowr.version = sc->sc_version;
|
||||||
mtx_leave(&sc->sc_mtx);
|
mtx_leave(&sc->sc_mtx);
|
||||||
|
|
||||||
if ((error = copyout(&pflowr, ifr->ifr_data,
|
if ((error = copyout(&pflowr, ifr->ifr_data, sizeof(pflowr))))
|
||||||
sizeof(pflowr))))
|
goto out;
|
||||||
return (error);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIOCSETPFLOW:
|
case SIOCSETPFLOW:
|
||||||
if ((error = suser(p)) != 0)
|
if ((error = suser(p)) != 0)
|
||||||
return (error);
|
goto out;
|
||||||
if ((error = copyin(ifr->ifr_data, &pflowr,
|
if ((error = copyin(ifr->ifr_data, &pflowr, sizeof(pflowr))))
|
||||||
sizeof(pflowr))))
|
goto out;
|
||||||
return (error);
|
|
||||||
|
|
||||||
/* XXXSMP breaks atomicity */
|
|
||||||
NET_UNLOCK();
|
|
||||||
rw_enter_write(&sc->sc_lock);
|
|
||||||
error = pflow_set(sc, &pflowr);
|
error = pflow_set(sc, &pflowr);
|
||||||
NET_LOCK();
|
if (error != 0)
|
||||||
if (error != 0) {
|
goto out;
|
||||||
rw_exit_write(&sc->sc_lock);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
NET_LOCK();
|
||||||
if ((ifp->if_flags & IFF_UP) && sc->so != NULL) {
|
if ((ifp->if_flags & IFF_UP) && sc->so != NULL) {
|
||||||
ifp->if_flags |= IFF_RUNNING;
|
ifp->if_flags |= IFF_RUNNING;
|
||||||
mtx_enter(&sc->sc_mtx);
|
mtx_enter(&sc->sc_mtx);
|
||||||
@ -599,14 +609,16 @@ pflowioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||||||
mtx_leave(&sc->sc_mtx);
|
mtx_leave(&sc->sc_mtx);
|
||||||
} else
|
} else
|
||||||
ifp->if_flags &= ~IFF_RUNNING;
|
ifp->if_flags &= ~IFF_RUNNING;
|
||||||
rw_exit_write(&sc->sc_lock);
|
NET_UNLOCK();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
return (ENOTTY);
|
|
||||||
}
|
}
|
||||||
return (0);
|
|
||||||
|
out:
|
||||||
|
rw_exit_write(&sc->sc_lock);
|
||||||
|
NET_LOCK();
|
||||||
|
|
||||||
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: if_pflow.h,v 1.22 2023/12/12 00:03:31 mvs Exp $ */
|
/* $OpenBSD: if_pflow.h,v 1.23 2023/12/16 22:16:02 mvs Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Henning Brauer <henning@openbsd.org>
|
* Copyright (c) 2008 Henning Brauer <henning@openbsd.org>
|
||||||
@ -174,7 +174,6 @@ struct pflow_ipfix_flow6 {
|
|||||||
/*
|
/*
|
||||||
* Locks used to protect struct members and global data
|
* Locks used to protect struct members and global data
|
||||||
* I immutable after creation
|
* I immutable after creation
|
||||||
* N net lock
|
|
||||||
* m this pflow_softc' `sc_mtx'
|
* m this pflow_softc' `sc_mtx'
|
||||||
* p this pflow_softc' `sc_lock'
|
* p this pflow_softc' `sc_lock'
|
||||||
*/
|
*/
|
||||||
@ -183,7 +182,7 @@ struct pflow_softc {
|
|||||||
struct mutex sc_mtx;
|
struct mutex sc_mtx;
|
||||||
struct rwlock sc_lock;
|
struct rwlock sc_lock;
|
||||||
|
|
||||||
int sc_dying; /* [N] */
|
int sc_dying; /* [p] */
|
||||||
struct ifnet sc_if;
|
struct ifnet sc_if;
|
||||||
|
|
||||||
unsigned int sc_count; /* [m] */
|
unsigned int sc_count; /* [m] */
|
||||||
|
Loading…
Reference in New Issue
Block a user