Re: pr_usrreq and splsoftnet
On Wed, Nov 16, 2016 at 11:38:06AM +0100, Martin Pieuchot wrote: > I'd like to enforce that pr_usrreq functions are always called at > IPL_SOFTNET. This will allow us to keep locking simple as soon as > we trade splsoftnet() for a rwlock. > > Most of the PRU_* actions are already called under splsoftnet() and > the ones that are not are relatively small, so it should not really > matter since processes are already serialized by the KERNEL_LOCK(). > > I'd even argue that this is a step forward removing the KERNEL_LOCK > from the socket layer. > > Comments, oks? Agreed and OK > Index: kern/sys_socket.c > === > RCS file: /cvs/src/sys/kern/sys_socket.c,v > retrieving revision 1.22 > diff -u -p -r1.22 sys_socket.c > --- kern/sys_socket.c 6 Oct 2016 17:02:10 - 1.22 > +++ kern/sys_socket.c 16 Nov 2016 09:58:54 - > @@ -73,6 +73,7 @@ int > soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p) > { > struct socket *so = (struct socket *)fp->f_data; > + int s, error = 0; > > switch (cmd) { > > @@ -122,8 +123,12 @@ soo_ioctl(struct file *fp, u_long cmd, c > return (ifioctl(so, cmd, data, p)); > if (IOCGROUP(cmd) == 'r') > return (rtioctl(cmd, data, p)); > - return ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, > + s = splsoftnet(); > + error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, > (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)NULL, p)); > + splx(s); > + > + return (error); > } > > int > @@ -167,6 +172,7 @@ int > soo_stat(struct file *fp, struct stat *ub, struct proc *p) > { > struct socket *so = fp->f_data; > + int s; > > memset(ub, 0, sizeof (*ub)); > ub->st_mode = S_IFSOCK; > @@ -177,8 +183,10 @@ soo_stat(struct file *fp, struct stat *u > ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; > ub->st_uid = so->so_euid; > ub->st_gid = so->so_egid; > + s = splsoftnet(); > (void) ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, > (struct mbuf *)ub, NULL, NULL, p)); > + splx(s); > return (0); > } > > Index: kern/uipc_socket.c > === > RCS file: /cvs/src/sys/kern/uipc_socket.c,v > retrieving revision 1.164 > diff -u -p -r1.164 uipc_socket.c > --- kern/uipc_socket.c14 Nov 2016 08:45:30 - 1.164 > +++ kern/uipc_socket.c16 Nov 2016 10:14:05 - > @@ -652,8 +652,10 @@ soreceive(struct socket *so, struct mbuf > flags |= MSG_DONTWAIT; > if (flags & MSG_OOB) { > m = m_get(M_WAIT, MT_DATA); > + s = splsoftnet(); > error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, > (struct mbuf *)(long)(flags & MSG_PEEK), NULL, curproc); > + splx(s); > if (error) > goto bad; > do { > Index: kern/uipc_syscalls.c > === > RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v > retrieving revision 1.139 > diff -u -p -r1.139 uipc_syscalls.c > --- kern/uipc_syscalls.c 9 Nov 2016 09:39:43 - 1.139 > +++ kern/uipc_syscalls.c 16 Nov 2016 10:17:08 - > @@ -1066,7 +1066,7 @@ sys_getsockname(struct proc *p, void *v, > struct socket *so; > struct mbuf *m = NULL; > socklen_t len; > - int error; > + int error, s; > > if ((error = getsock(p, SCARG(uap, fdes), &fp)) != 0) > return (error); > @@ -1078,14 +1078,15 @@ sys_getsockname(struct proc *p, void *v, > if (error) > goto bad; > m = m_getclr(M_WAIT, MT_SONAME); > + s = splsoftnet(); > error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0, p); > + splx(s); > if (error) > goto bad; > error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); > bad: > FRELE(fp, p); > - if (m) > - m_freem(m); > + m_freem(m); > return (error); > } > > @@ -1104,7 +1105,7 @@ sys_getpeername(struct proc *p, void *v, > struct socket *so; > struct mbuf *m = NULL; > socklen_t len; > - int error; > + int error, s; > > if ((error = getsock(p, SCARG(uap, fdes), &fp)) != 0) > return (error); > @@ -1120,7 +1121,9 @@ sys_getpeername(struct proc *p, void *v, > if (error) > goto bad; > m = m_getclr(M_WAIT, MT_SONAME); > + s = splsoftnet(); > error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0, p); > + splx(s); > if (error) > goto bad; > error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); > Index: net/if.c > === > RCS file: /cvs/src/sys/net/if.c,v > retrieving revision 1.461 > diff -u -p -r1.461 if.c > --- net/if.c 14
Re: cwm ptrmove keybindings
Fri, 11 Nov 2016 20:47:49 +0200 li...@wrant.com > Fri, 11 Nov 2016 10:42:42 -0500 Okan Demirmen > > Hi, > > > > mpi@ recently alerted me to the fact that cwm(1)'s default keybindings for > > ptrmove actions conflict with emacs users' uses, namely all the > > control-[arrow] > > bindings that cwm(1) grabs. It has actually been like this since > > keyboard-based > > pointer movements were added, almost exactly 9 years ago. (what have people > > done > > since??) > > > > In any case, I'm happy to remove the keybindings for the 8 pointer movement > > actions, however I'm curious what the usage pattern is for even keeping this > > feature. I don't use keyboard-based ptr movements, and find it odd, but it's > > here, so I'll ask - anyone use it, or object to it's removal? > > > > I realize what asking for opinions means :) > > > > Regardless, if it stays, the current bindings will be removed - There are > > way > > more emacs users (including those using emacs mode in ksh for example) than > > cwm(1) ones for sure...those default bindings should win. > > > > Thanks, > > Okan > > > > Hi Okan, tech@, > > Thank you for opening up this topic. I would have done the same a long > time ago and with a different aspect to it. Precisely, as we are here, > would many users object to aligning the default key bindings for cwm(1) > with several other programs in addition to Emacs? Assuming most modern > keyboards have the Mod4 (with a variation of a window / OS symbol) key, > would that be fine to consider moving cwm's defaults around the 4- key? > > I myself (very likely many others) also use tmux(1), xterm(1), ksh(1) & > Emacs (especially the Org-Mode structure editing) & there're conflicts. > So far, I've been happily managing it pretty well with a heavy modified > cwm config file to remap C-, CS- to 4-, 4S- and M-, MS- to 4M, 4MS- and > CM-, CMS- to 4C-, 4CS- and some other specifically application related. > > This is to say, I would please ask you to not remove the keyboard based > pointer movement functionality, it is very useful to me and is possible > to both keep it, and resolve the conflicts with the above applications. > > I would be happy to provide my .cwmrc file in my next post, if there is > any interest in this direction. Thank you for improving cwm over time. > > Kind regards, > Anton Hi Okan, fellows, Let me decipher that nuisance map above.. The logic is simple: hold the 4- key and arrows to move the pointer, add the M- key to move the window, or the C- key to resize the window, for an extra boost use the S- key on. Still not interested presumably, but please let me know is it the 4- or?? Kind regards, Anton
Re: pr_usrreq and splsoftnet
On Wed, Nov 16, 2016 at 11:38:06AM +0100, Martin Pieuchot wrote: > I'd like to enforce that pr_usrreq functions are always called at > IPL_SOFTNET. This will allow us to keep locking simple as soon as > we trade splsoftnet() for a rwlock. > > Most of the PRU_* actions are already called under splsoftnet() and > the ones that are not are relatively small, so it should not really > matter since processes are already serialized by the KERNEL_LOCK(). > > I'd even argue that this is a step forward removing the KERNEL_LOCK > from the socket layer. > > Comments, oks? OK bluhm@ > > Index: kern/sys_socket.c > === > RCS file: /cvs/src/sys/kern/sys_socket.c,v > retrieving revision 1.22 > diff -u -p -r1.22 sys_socket.c > --- kern/sys_socket.c 6 Oct 2016 17:02:10 - 1.22 > +++ kern/sys_socket.c 16 Nov 2016 09:58:54 - > @@ -73,6 +73,7 @@ int > soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p) > { > struct socket *so = (struct socket *)fp->f_data; > + int s, error = 0; > > switch (cmd) { > > @@ -122,8 +123,12 @@ soo_ioctl(struct file *fp, u_long cmd, c > return (ifioctl(so, cmd, data, p)); > if (IOCGROUP(cmd) == 'r') > return (rtioctl(cmd, data, p)); > - return ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, > + s = splsoftnet(); > + error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, > (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)NULL, p)); > + splx(s); > + > + return (error); > } > > int > @@ -167,6 +172,7 @@ int > soo_stat(struct file *fp, struct stat *ub, struct proc *p) > { > struct socket *so = fp->f_data; > + int s; > > memset(ub, 0, sizeof (*ub)); > ub->st_mode = S_IFSOCK; > @@ -177,8 +183,10 @@ soo_stat(struct file *fp, struct stat *u > ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; > ub->st_uid = so->so_euid; > ub->st_gid = so->so_egid; > + s = splsoftnet(); > (void) ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, > (struct mbuf *)ub, NULL, NULL, p)); > + splx(s); > return (0); > } > > Index: kern/uipc_socket.c > === > RCS file: /cvs/src/sys/kern/uipc_socket.c,v > retrieving revision 1.164 > diff -u -p -r1.164 uipc_socket.c > --- kern/uipc_socket.c14 Nov 2016 08:45:30 - 1.164 > +++ kern/uipc_socket.c16 Nov 2016 10:14:05 - > @@ -652,8 +652,10 @@ soreceive(struct socket *so, struct mbuf > flags |= MSG_DONTWAIT; > if (flags & MSG_OOB) { > m = m_get(M_WAIT, MT_DATA); > + s = splsoftnet(); > error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, > (struct mbuf *)(long)(flags & MSG_PEEK), NULL, curproc); > + splx(s); > if (error) > goto bad; > do { > Index: kern/uipc_syscalls.c > === > RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v > retrieving revision 1.139 > diff -u -p -r1.139 uipc_syscalls.c > --- kern/uipc_syscalls.c 9 Nov 2016 09:39:43 - 1.139 > +++ kern/uipc_syscalls.c 16 Nov 2016 10:17:08 - > @@ -1066,7 +1066,7 @@ sys_getsockname(struct proc *p, void *v, > struct socket *so; > struct mbuf *m = NULL; > socklen_t len; > - int error; > + int error, s; > > if ((error = getsock(p, SCARG(uap, fdes), &fp)) != 0) > return (error); > @@ -1078,14 +1078,15 @@ sys_getsockname(struct proc *p, void *v, > if (error) > goto bad; > m = m_getclr(M_WAIT, MT_SONAME); > + s = splsoftnet(); > error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0, p); > + splx(s); > if (error) > goto bad; > error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); > bad: > FRELE(fp, p); > - if (m) > - m_freem(m); > + m_freem(m); > return (error); > } > > @@ -1104,7 +1105,7 @@ sys_getpeername(struct proc *p, void *v, > struct socket *so; > struct mbuf *m = NULL; > socklen_t len; > - int error; > + int error, s; > > if ((error = getsock(p, SCARG(uap, fdes), &fp)) != 0) > return (error); > @@ -1120,7 +1121,9 @@ sys_getpeername(struct proc *p, void *v, > if (error) > goto bad; > m = m_getclr(M_WAIT, MT_SONAME); > + s = splsoftnet(); > error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0, p); > + splx(s); > if (error) > goto bad; > error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); > Index: net/if.c > === > RCS file: /cvs/src/sys/net/if.c,v > retrieving revision 1.461 > diff -u -p -r1.461 if.c > --- net/if.c 14 N
Re: smtpd: internal cleanups, part 2
On Wed, Nov 16, 2016 at 11:09:43PM +0100, Eric Faurot wrote: > This diff removes the IO_TLSVERIFIED which is not a io event, and > inlines the necessary code where the callback functions are called > for this event. > yes, it was confusing too ok > Index: ioev.c > === > RCS file: /cvs/src/usr.sbin/smtpd/ioev.c,v > retrieving revision 1.27 > diff -u -p -r1.27 ioev.c > --- ioev.c16 Nov 2016 21:30:37 - 1.27 > +++ ioev.c16 Nov 2016 21:56:25 - > @@ -118,7 +118,6 @@ io_strevent(int evt) > switch (evt) { > CASE(IO_CONNECTED); > CASE(IO_TLSREADY); > - CASE(IO_TLSVERIFIED); > CASE(IO_DATAIN); > CASE(IO_LOWAT); > CASE(IO_DISCONNECTED); > Index: ioev.h > === > RCS file: /cvs/src/usr.sbin/smtpd/ioev.h,v > retrieving revision 1.7 > diff -u -p -r1.7 ioev.h > --- ioev.h16 Nov 2016 21:30:37 - 1.7 > +++ ioev.h16 Nov 2016 21:56:25 - > @@ -20,7 +20,6 @@ > enum { > IO_CONNECTED = 0, /* connection successful*/ > IO_TLSREADY,/* TLS started successfully */ > - IO_TLSVERIFIED, /* XXX - needs more work*/ > IO_TLSERROR,/* XXX - needs more work*/ > IO_DATAIN, /* new data in input buffer */ > IO_LOWAT, /* output queue running low */ > Index: mta_session.c > === > RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v > retrieving revision 1.84 > diff -u -p -r1.84 mta_session.c > --- mta_session.c 16 Nov 2016 21:30:37 - 1.84 > +++ mta_session.c 16 Nov 2016 21:56:25 - > @@ -259,6 +259,7 @@ mta_session_imsg(struct mproc *p, struct > const char *name; > void*ssl; > int dnserror, status; > + X509*x; > > switch (imsg->hdr.type) { > > @@ -363,7 +364,22 @@ mta_session_imsg(struct mproc *p, struct > return; > } > > - mta_io(&s->io, IO_TLSVERIFIED, s->io.arg); > + x = SSL_get_peer_certificate(s->io.ssl); > + if (x) { > + log_info("smtp-out: Server certificate verification %s " > + "on session %016"PRIx64, > + (s->flags & MTA_VERIFIED) ? "succeeded" : "failed", > + s->id); > + X509_free(x); > + } > + > + if (s->use_smtps) { > + mta_enter_state(s, MTA_BANNER); > + io_set_read(&s->io); > + } > + else > + mta_enter_state(s, MTA_EHLO); > + > io_resume(&s->io, IO_PAUSE_IN); > io_reload(&s->io); > return; > @@ -1141,7 +1157,6 @@ mta_io(struct io *io, int evt, void *arg > size_t len; > const char *error; > int cont; > - X509*x; > > log_trace(TRACE_IO, "mta: %p: %s %s", s, io_strevent(evt), > io_strio(io)); > @@ -1170,24 +1185,6 @@ mta_io(struct io *io, int evt, void *arg > io_pause(&s->io, IO_PAUSE_IN); > break; > } > - > - case IO_TLSVERIFIED: > - x = SSL_get_peer_certificate(s->io.ssl); > - if (x) { > - log_info("smtp-out: Server certificate verification %s " > - "on session %016"PRIx64, > - (s->flags & MTA_VERIFIED) ? "succeeded" : "failed", > - s->id); > - X509_free(x); > - } > - > - if (s->use_smtps) { > - mta_enter_state(s, MTA_BANNER); > - io_set_read(io); > - } > - else > - mta_enter_state(s, MTA_EHLO); > - break; > > case IO_DATAIN: > nextline: > Index: smtp_session.c > === > RCS file: /cvs/src/usr.sbin/smtpd/smtp_session.c,v > retrieving revision 1.290 > diff -u -p -r1.290 smtp_session.c > --- smtp_session.c16 Nov 2016 21:30:37 - 1.290 > +++ smtp_session.c16 Nov 2016 21:56:26 - > @@ -698,6 +698,7 @@ smtp_session_imsg(struct mproc *p, struc > uint32_t msgid; > int status, success, dnserror; > void*ssl_ctx; > + X509*x; > > switch (imsg->hdr.type) { > case IMSG_SMTP_DNS_PTR: > @@ -993,7 +994,26 @@ smtp_session_imsg(struct mproc *p, struc > smtp_free(s, "SSL certificate check failed"); >
smtpd: internal cleanups, part 2
This diff removes the IO_TLSVERIFIED which is not a io event, and inlines the necessary code where the callback functions are called for this event. Eric. Index: ioev.c === RCS file: /cvs/src/usr.sbin/smtpd/ioev.c,v retrieving revision 1.27 diff -u -p -r1.27 ioev.c --- ioev.c 16 Nov 2016 21:30:37 - 1.27 +++ ioev.c 16 Nov 2016 21:56:25 - @@ -118,7 +118,6 @@ io_strevent(int evt) switch (evt) { CASE(IO_CONNECTED); CASE(IO_TLSREADY); - CASE(IO_TLSVERIFIED); CASE(IO_DATAIN); CASE(IO_LOWAT); CASE(IO_DISCONNECTED); Index: ioev.h === RCS file: /cvs/src/usr.sbin/smtpd/ioev.h,v retrieving revision 1.7 diff -u -p -r1.7 ioev.h --- ioev.h 16 Nov 2016 21:30:37 - 1.7 +++ ioev.h 16 Nov 2016 21:56:25 - @@ -20,7 +20,6 @@ enum { IO_CONNECTED = 0, /* connection successful*/ IO_TLSREADY,/* TLS started successfully */ - IO_TLSVERIFIED, /* XXX - needs more work*/ IO_TLSERROR,/* XXX - needs more work*/ IO_DATAIN, /* new data in input buffer */ IO_LOWAT, /* output queue running low */ Index: mta_session.c === RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v retrieving revision 1.84 diff -u -p -r1.84 mta_session.c --- mta_session.c 16 Nov 2016 21:30:37 - 1.84 +++ mta_session.c 16 Nov 2016 21:56:25 - @@ -259,6 +259,7 @@ mta_session_imsg(struct mproc *p, struct const char *name; void*ssl; int dnserror, status; + X509*x; switch (imsg->hdr.type) { @@ -363,7 +364,22 @@ mta_session_imsg(struct mproc *p, struct return; } - mta_io(&s->io, IO_TLSVERIFIED, s->io.arg); + x = SSL_get_peer_certificate(s->io.ssl); + if (x) { + log_info("smtp-out: Server certificate verification %s " + "on session %016"PRIx64, + (s->flags & MTA_VERIFIED) ? "succeeded" : "failed", + s->id); + X509_free(x); + } + + if (s->use_smtps) { + mta_enter_state(s, MTA_BANNER); + io_set_read(&s->io); + } + else + mta_enter_state(s, MTA_EHLO); + io_resume(&s->io, IO_PAUSE_IN); io_reload(&s->io); return; @@ -1141,7 +1157,6 @@ mta_io(struct io *io, int evt, void *arg size_t len; const char *error; int cont; - X509*x; log_trace(TRACE_IO, "mta: %p: %s %s", s, io_strevent(evt), io_strio(io)); @@ -1170,24 +1185,6 @@ mta_io(struct io *io, int evt, void *arg io_pause(&s->io, IO_PAUSE_IN); break; } - - case IO_TLSVERIFIED: - x = SSL_get_peer_certificate(s->io.ssl); - if (x) { - log_info("smtp-out: Server certificate verification %s " - "on session %016"PRIx64, - (s->flags & MTA_VERIFIED) ? "succeeded" : "failed", - s->id); - X509_free(x); - } - - if (s->use_smtps) { - mta_enter_state(s, MTA_BANNER); - io_set_read(io); - } - else - mta_enter_state(s, MTA_EHLO); - break; case IO_DATAIN: nextline: Index: smtp_session.c === RCS file: /cvs/src/usr.sbin/smtpd/smtp_session.c,v retrieving revision 1.290 diff -u -p -r1.290 smtp_session.c --- smtp_session.c 16 Nov 2016 21:30:37 - 1.290 +++ smtp_session.c 16 Nov 2016 21:56:26 - @@ -698,6 +698,7 @@ smtp_session_imsg(struct mproc *p, struc uint32_t msgid; int status, success, dnserror; void*ssl_ctx; + X509*x; switch (imsg->hdr.type) { case IMSG_SMTP_DNS_PTR: @@ -993,7 +994,26 @@ smtp_session_imsg(struct mproc *p, struc smtp_free(s, "SSL certificate check failed"); return; } - smtp_io(&s->io, IO_TLSVERIFIED, s->io.arg); + + x = SSL_get_peer_certificate(s->io.ssl); + if (x
Intel 10GbE (ix) driver update - Looking for tests
Hi, I've done a massive update of our ix(4) driver that brings support for X550 family of controllers including those integrated into new Xeon chips as well as QSFP support for X520 (82599) but this needs thorough testing. If you're using Intel 10Gb controllers, please make sure that you either (or both!) test the complete diff found at this URL: http://gir.theapt.org/~mike/ixgbe.diff or next few snapshots that will (hopefully) contain bits of this monster diff. To test the monster diff, make sure that you are running a recent snapshot and your kernel source code is up-to-date, then reset a few files to the specified revisions and remove the support file for X550: % pwd /usr/src % cvs up -r1.326 sys/dev/pci/files.pci % cvs up -r1.133 sys/dev/pci/if_ix.c % cvs up -r1.14 sys/dev/pci/ixgbe.c % cvs up -r1.23 sys/dev/pci/ixgbe.h % cvs up -r1.11 sys/dev/pci/ixgbe_82598.c % cvs up -r1.12 sys/dev/pci/ixgbe_82599.c % cvs up -r1.13 sys/dev/pci/ixgbe_phy.c % cvs up -r1.22 sys/dev/pci/ixgbe_type.h % cvs up -r1.4 sys/dev/pci/ixgbe_x540.c % rm -f sys/dev/pci/ixgbe_x550.c To verify that files have been reset: % pwd /usr/src % fgrep "//T1" sys/dev/pci/CVS/Entries /files.pci/1.326/Mon Sep 12 09:45:53 2016//T1.326 /if_ix.c/1.133/Thu Oct 27 05:00:50 2016//T1.133 /ixgbe.c/1.14/Wed Nov 26 17:03:52 2014//T1.14 /ixgbe.h/1.23/Tue Oct 4 09:24:02 2016//T1.23 /ixgbe_82598.c/1.11/Mon Aug 5 19:58:06 2013//T1.11 /ixgbe_82599.c/1.12/Fri May 1 04:15:00 2015//T1.12 /ixgbe_phy.c/1.13/Fri May 1 04:15:00 2015//T1.13 /ixgbe_type.h/1.22/Wed Nov 16 21:53:57 2016//T1.22 /ixgbe_x540.c/1.4/Wed May 20 14:34:27 2015//T1.4 And then test and apply the diff: % pwd /usr/src % patch -Csp0
pf IPv6 hop-by-hop after fragment header
Hi, I found the link http://www.secfu.net/ in one of sthen@'s mails. There the author mentions that we accept IPv6 hop-by-hop headers after fragment headers. In fact this is a result of my pf fragment reassembly, so add an extra check there. ok? bluhm Index: net/pf.c === RCS file: /data/mirror/openbsd/cvs/src/sys/net/pf.c,v retrieving revision 1.998 diff -u -p -r1.998 pf.c --- net/pf.c14 Nov 2016 13:25:00 - 1.998 +++ net/pf.c16 Nov 2016 20:39:38 - @@ -6207,13 +6207,14 @@ pf_walk_header6(struct pf_pdesc *pd, str struct ip6_ext ext; struct ip6_rthdr rthdr; u_int32_tend; - int fraghdr_cnt = 0, rthdr_cnt = 0; + int hdr_cnt = 0, fraghdr_cnt = 0, rthdr_cnt = 0; pd->off += sizeof(struct ip6_hdr); end = pd->off + ntohs(h->ip6_plen); pd->fragoff = pd->extoff = pd->jumbolen = 0; pd->proto = h->ip6_nxt; for (;;) { + hdr_cnt++; switch (pd->proto) { case IPPROTO_FRAGMENT: if (fraghdr_cnt++) { @@ -6266,8 +6267,15 @@ pf_walk_header6(struct pf_pdesc *pd, str return (PF_DROP); } /* FALLTHROUGH */ - case IPPROTO_AH: case IPPROTO_HOPOPTS: + /* RFC2460 4.1: Hop-by-Hop only after IPv6 header */ + if (pd->proto == IPPROTO_HOPOPTS && hdr_cnt > 1) { + DPFPRINTF(LOG_NOTICE, "IPv6 hopopts not first"); + REASON_SET(reason, PFRES_IPOPTIONS); + return (PF_DROP); + } + /* FALLTHROUGH */ + case IPPROTO_AH: case IPPROTO_DSTOPTS: /* fragments may be short */ if (pd->fragoff != 0 && end < pd->off + sizeof(ext)) {
Re: smtpd: internal cleanups
On Wed, Nov 16, 2016 at 09:13:40PM +0100, Eric Faurot wrote: > Hi, > > I'm working on improving the async io interface in smtpd, make it simpler > to use and less error-prone. > > The short-term goal is to make the io structure opaque. > > With this first diff, the user pointer is passed as parameter to the io > callback instead of having the user dereference the io structure. There > are places where the callback function is triggered outside of the io > layer. It's not desirable, and it needs to be fixed in a separate diff. > ok gilles@ > Index: bounce.c > === > RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v > retrieving revision 1.72 > diff -u -p -r1.72 bounce.c > --- bounce.c 3 Feb 2016 05:57:09 - 1.72 > +++ bounce.c 16 Nov 2016 19:35:54 - > @@ -97,7 +97,7 @@ static int bounce_next_message(struct b > static int bounce_next(struct bounce_session *); > static void bounce_delivery(struct bounce_message *, int, const char *); > static void bounce_status(struct bounce_session *, const char *, ...); > -static void bounce_io(struct io *, int); > +static void bounce_io(struct io *, int, void *); > static void bounce_timeout(int, short, void *); > static void bounce_free(struct bounce_session *); > static const char *action_str(const struct delivery_bounce *); > @@ -712,9 +712,9 @@ bounce_free(struct bounce_session *s) > } > > static void > -bounce_io(struct io *io, int evt) > +bounce_io(struct io *io, int evt, void *arg) > { > - struct bounce_session *s = io->arg; > + struct bounce_session *s = arg; > const char *error; > char*line, *msg; > int cont; > Index: filter.c > === > RCS file: /cvs/src/usr.sbin/smtpd/filter.c,v > retrieving revision 1.19 > diff -u -p -r1.19 filter.c > --- filter.c 29 Jun 2016 06:46:06 - 1.19 > +++ filter.c 16 Nov 2016 19:35:54 - > @@ -114,7 +114,7 @@ static void filter_run_query(struct filt > static void filter_end_query(struct filter_query *); > static void filter_set_sink(struct filter_session *, int); > static int filter_tx(struct filter_session *, int); > -static void filter_tx_io(struct io *, int); > +static void filter_tx_io(struct io *, int, void *); > > static TAILQ_HEAD(, filter_proc) procs; > struct dict chains; > @@ -678,9 +678,9 @@ filter_tx(struct filter_session *s, int > } > > static void > -filter_tx_io(struct io *io, int evt) > +filter_tx_io(struct io *io, int evt, void *arg) > { > - struct filter_session *s = io->arg; > + struct filter_session *s = arg; > size_t len, n; > char*data; > > Index: ioev.c > === > RCS file: /cvs/src/usr.sbin/smtpd/ioev.c,v > retrieving revision 1.26 > diff -u -p -r1.26 ioev.c > --- ioev.c16 May 2016 21:43:16 - 1.26 > +++ ioev.c16 Nov 2016 19:35:54 - > @@ -226,7 +226,7 @@ _io_init() > > void > io_init(struct io *io, int sock, void *arg, > - void(*cb)(struct io*, int), struct iobuf *iobuf) > + void(*cb)(struct io*, int, void *), struct iobuf *iobuf) > { > _io_init(); > > @@ -580,7 +580,7 @@ leave: > void > io_callback(struct io *io, int evt) > { > - io->cb(io, evt); > + io->cb(io, evt, io->arg); > } > > int > Index: ioev.h > === > RCS file: /cvs/src/usr.sbin/smtpd/ioev.h,v > retrieving revision 1.6 > diff -u -p -r1.6 ioev.h > --- ioev.h25 Mar 2016 15:06:58 - 1.6 > +++ ioev.h16 Nov 2016 19:35:54 - > @@ -41,7 +41,7 @@ struct iobuf; > struct io { > int sock; > void*arg; > - void(*cb)(struct io*, int); > + void(*cb)(struct io*, int, void *); > struct iobuf*iobuf; > size_t lowat; > int timeout; > @@ -55,7 +55,8 @@ struct io { > void io_set_nonblocking(int); > void io_set_nolinger(int); > > -void io_init(struct io*, int, void*, void(*)(struct io*, int), struct > iobuf*); > +void io_init(struct io*, int, void*, void(*)(struct io*, int, void *), > +struct iobuf*); > void io_clear(struct io*); > void io_set_read(struct io *); > void io_set_write(struct io *); > Index: mda.c > === > RCS file: /cvs/src/usr.sbin/smtpd/mda.c,v > retrieving revision 1.120 > diff -u -p -r1.120 mda.c > --- mda.c 1 Sep 2016 15:12:45 - 1.120 > +++ mda.c 16 Nov 2016 19:35:55 - > @@ -84,7 +84,7 @@ struct mda_session { > FILE*datafp; > }; > > -static void mda_io(struct io *, int); > +static void mda_io(struct io *, int, void *); > static int mda_check_loop(FILE *, struct mda_enve
Re: texinfo: /usr/share/info/dir permissions
On Wed, Nov 09, 2016 at 02:52:24PM +0100, Theo Buehler wrote: > This is the last installed file whose permissions are dependent on the > umask. ok? > > Index: gnu/usr.bin/texinfo/Makefile.bsd-wrapper > === > RCS file: /var/cvs/src/gnu/usr.bin/texinfo/Makefile.bsd-wrapper,v > retrieving revision 1.44 > diff -u -p -r1.44 Makefile.bsd-wrapper > --- gnu/usr.bin/texinfo/Makefile.bsd-wrapper 3 Oct 2016 21:24:40 - > 1.44 > +++ gnu/usr.bin/texinfo/Makefile.bsd-wrapper 8 Nov 2016 23:11:10 - > @@ -60,6 +60,7 @@ install:maninstall > sh ${.CURDIR}/util/gen-dir-node ${DESTDIR}/usr/share/info > \ > ${DESTDIR}/usr/share/info/dir > chown ${MANOWN}:${MANGRP} ${DESTDIR}/usr/share/info/dir > + chmod ${MANMODE} ${DESTDIR}/usr/share/info/dir > > clean cleandir: > rm -f ${CLEANFILES} >
Re: smtpd: internal cleanups
On Wed, 16 Nov 2016 21:13:40 +0100, Eric Faurot wrote: > With this first diff, the user pointer is passed as parameter to the io > callback instead of having the user dereference the io structure. There > are places where the callback function is triggered outside of the io > layer. It's not desirable, and it needs to be fixed in a separate diff. This looks like an improvement. OK millert@ - todd
socket splicing with large mbufs
Hi, I have seen a hang in my socket splicing test on loopback with large mbufs and reduced buffer size. If the send buffer size is less than the size of a single mbuf, it will never fit. So if the send buffer is empty, split the large mbuf and move only a part. ok? bluhm Index: kern/uipc_socket.c === RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.164 diff -u -p -r1.164 uipc_socket.c --- kern/uipc_socket.c 14 Nov 2016 08:45:30 - 1.164 +++ kern/uipc_socket.c 16 Nov 2016 19:01:35 - @@ -1365,8 +1365,16 @@ somove(struct socket *so, int wait) "m_type %d", so, so->so_type, *mp, (*mp)->m_type); #endif if ((*mp)->m_len > size) { - if (!maxreached || (*mp = m_copym( - so->so_rcv.sb_mb, 0, size, wait)) == NULL) { + /* +* Move only a partial mbuf at maximum splice lenght or +* if the drain buffer is too small for this large mbuf. +*/ + if (!maxreached && so->so_snd.sb_datacc > 0) { + len -= size; + break; + } + *mp = m_copym(so->so_rcv.sb_mb, 0, size, wait); + if (*mp == NULL) { len -= size; break; }
smtpd: internal cleanups
Hi, I'm working on improving the async io interface in smtpd, make it simpler to use and less error-prone. The short-term goal is to make the io structure opaque. With this first diff, the user pointer is passed as parameter to the io callback instead of having the user dereference the io structure. There are places where the callback function is triggered outside of the io layer. It's not desirable, and it needs to be fixed in a separate diff. Eric. Index: bounce.c === RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v retrieving revision 1.72 diff -u -p -r1.72 bounce.c --- bounce.c3 Feb 2016 05:57:09 - 1.72 +++ bounce.c16 Nov 2016 19:35:54 - @@ -97,7 +97,7 @@ static int bounce_next_message(struct b static int bounce_next(struct bounce_session *); static void bounce_delivery(struct bounce_message *, int, const char *); static void bounce_status(struct bounce_session *, const char *, ...); -static void bounce_io(struct io *, int); +static void bounce_io(struct io *, int, void *); static void bounce_timeout(int, short, void *); static void bounce_free(struct bounce_session *); static const char *action_str(const struct delivery_bounce *); @@ -712,9 +712,9 @@ bounce_free(struct bounce_session *s) } static void -bounce_io(struct io *io, int evt) +bounce_io(struct io *io, int evt, void *arg) { - struct bounce_session *s = io->arg; + struct bounce_session *s = arg; const char *error; char*line, *msg; int cont; Index: filter.c === RCS file: /cvs/src/usr.sbin/smtpd/filter.c,v retrieving revision 1.19 diff -u -p -r1.19 filter.c --- filter.c29 Jun 2016 06:46:06 - 1.19 +++ filter.c16 Nov 2016 19:35:54 - @@ -114,7 +114,7 @@ static void filter_run_query(struct filt static void filter_end_query(struct filter_query *); static void filter_set_sink(struct filter_session *, int); static int filter_tx(struct filter_session *, int); -static void filter_tx_io(struct io *, int); +static void filter_tx_io(struct io *, int, void *); static TAILQ_HEAD(, filter_proc) procs; struct dictchains; @@ -678,9 +678,9 @@ filter_tx(struct filter_session *s, int } static void -filter_tx_io(struct io *io, int evt) +filter_tx_io(struct io *io, int evt, void *arg) { - struct filter_session *s = io->arg; + struct filter_session *s = arg; size_t len, n; char*data; Index: ioev.c === RCS file: /cvs/src/usr.sbin/smtpd/ioev.c,v retrieving revision 1.26 diff -u -p -r1.26 ioev.c --- ioev.c 16 May 2016 21:43:16 - 1.26 +++ ioev.c 16 Nov 2016 19:35:54 - @@ -226,7 +226,7 @@ _io_init() void io_init(struct io *io, int sock, void *arg, - void(*cb)(struct io*, int), struct iobuf *iobuf) + void(*cb)(struct io*, int, void *), struct iobuf *iobuf) { _io_init(); @@ -580,7 +580,7 @@ leave: void io_callback(struct io *io, int evt) { - io->cb(io, evt); + io->cb(io, evt, io->arg); } int Index: ioev.h === RCS file: /cvs/src/usr.sbin/smtpd/ioev.h,v retrieving revision 1.6 diff -u -p -r1.6 ioev.h --- ioev.h 25 Mar 2016 15:06:58 - 1.6 +++ ioev.h 16 Nov 2016 19:35:54 - @@ -41,7 +41,7 @@ struct iobuf; struct io { int sock; void*arg; - void(*cb)(struct io*, int); + void(*cb)(struct io*, int, void *); struct iobuf*iobuf; size_t lowat; int timeout; @@ -55,7 +55,8 @@ struct io { void io_set_nonblocking(int); void io_set_nolinger(int); -void io_init(struct io*, int, void*, void(*)(struct io*, int), struct iobuf*); +void io_init(struct io*, int, void*, void(*)(struct io*, int, void *), +struct iobuf*); void io_clear(struct io*); void io_set_read(struct io *); void io_set_write(struct io *); Index: mda.c === RCS file: /cvs/src/usr.sbin/smtpd/mda.c,v retrieving revision 1.120 diff -u -p -r1.120 mda.c --- mda.c 1 Sep 2016 15:12:45 - 1.120 +++ mda.c 16 Nov 2016 19:35:55 - @@ -84,7 +84,7 @@ struct mda_session { FILE*datafp; }; -static void mda_io(struct io *, int); +static void mda_io(struct io *, int, void *); static int mda_check_loop(FILE *, struct mda_envelope *); static int mda_getlastline(int, char *, size_t); static void mda_done(struct mda_session *); @@ -496,9 +496,9 @@ mda_postprivdrop() } static void -mda_io(struct io *io, int evt) +mda_io(struct io *io, int evt, void *arg) { - struct mda_session
Re: bpf_mtap(9) w/o KERNEL_LOCK
On Wed, Nov 16, 2016 at 12:18:48PM +0100, Martin Pieuchot wrote: > Here's another extracted diff: Use goto in read & write and always > increment the reference count in write. > > ok? OK bluhm@ > > Index: net/bpf.c > === > RCS file: /cvs/src/sys/net/bpf.c,v > retrieving revision 1.151 > diff -u -p -r1.151 bpf.c > --- net/bpf.c 16 Nov 2016 09:00:01 - 1.151 > +++ net/bpf.c 16 Nov 2016 11:08:25 - > @@ -406,16 +406,17 @@ bpfread(dev_t dev, struct uio *uio, int > if (d->bd_bif == NULL) > return (ENXIO); > > + s = splnet(); > + bpf_get(d); > + > /* >* Restrict application to use a buffer the same size as >* as kernel buffers. >*/ > - if (uio->uio_resid != d->bd_bufsize) > - return (EINVAL); > - > - s = splnet(); > - > - bpf_get(d); > + if (uio->uio_resid != d->bd_bufsize) { > + error = EINVAL; > + goto out; > + } > > /* >* If there's a timeout, bd_rdStart is tagged when we start the read. > @@ -431,13 +432,12 @@ bpfread(dev_t dev, struct uio *uio, int >* ends when the timeout expires or when enough packets >* have arrived to fill the store buffer. >*/ > - while (d->bd_hbuf == 0) { > + while (d->bd_hbuf == NULL) { > if (d->bd_bif == NULL) { > /* interface is gone */ > if (d->bd_slen == 0) { > - bpf_put(d); > - splx(s); > - return (EIO); > + error = EIO; > + goto out; > } > ROTATE_BUFFERS(d); > break; > @@ -461,18 +461,15 @@ bpfread(dev_t dev, struct uio *uio, int > } else > error = EWOULDBLOCK; > } > - if (error == EINTR || error == ERESTART) { > - bpf_put(d); > - splx(s); > - return (error); > - } > + if (error == EINTR || error == ERESTART) > + goto out; > if (error == EWOULDBLOCK) { > /* >* On a timeout, return what's in the buffer, >* which may be nothing. If there is something >* in the store buffer, we can rotate the buffers. >*/ > - if (d->bd_hbuf) > + if (d->bd_hbuf != NULL) > /* >* We filled up the buffer in between >* getting the timeout and arriving > @@ -481,9 +478,8 @@ bpfread(dev_t dev, struct uio *uio, int > break; > > if (d->bd_slen == 0) { > - bpf_put(d); > - splx(s); > - return (0); > + error = 0; > + goto out; > } > ROTATE_BUFFERS(d); > break; > @@ -505,7 +501,7 @@ bpfread(dev_t dev, struct uio *uio, int > d->bd_fbuf = d->bd_hbuf; > d->bd_hbuf = NULL; > d->bd_hlen = 0; > - > +out: > bpf_put(d); > splx(s); > > @@ -554,32 +550,40 @@ bpfwrite(dev_t dev, struct uio *uio, int > struct bpf_insn *fcode = NULL; > int error, s; > struct sockaddr_storage dst; > + u_int dlt; > > d = bpfilter_lookup(minor(dev)); > if (d->bd_bif == NULL) > return (ENXIO); > > + bpf_get(d); > ifp = d->bd_bif->bif_ifp; > > - if ((ifp->if_flags & IFF_UP) == 0) > - return (ENETDOWN); > + if ((ifp->if_flags & IFF_UP) == 0) { > + error = ENETDOWN; > + goto out; > + } > > - if (uio->uio_resid == 0) > - return (0); > + if (uio->uio_resid == 0) { > + error = 0; > + goto out; > + } > > KERNEL_ASSERT_LOCKED(); /* for accessing bd_wfilter */ > bf = srp_get_locked(&d->bd_wfilter); > if (bf != NULL) > fcode = bf->bf_insns; > > - error = bpf_movein(uio, d->bd_bif->bif_dlt, &m, > - (struct sockaddr *)&dst, fcode); > + dlt = d->bd_bif->bif_dlt; > + > + error = bpf_movein(uio, dlt, &m, (struct sockaddr *)&dst, fcode); > if (error) > - return (error); > + goto out; > > if (m->m_pkthdr.len > ifp->if_mtu) { > m_freem(m); > - return (EMSGSIZE); > + error = EMSGSIZE; > + goto out; > } > > m->m_pkthdr.ph_rtableid = ifp->if_rdomain; > @@ -591,9 +595,9 @@ bpfwrite(dev_t dev, struct uio *uio, int >
Re: tcp_input.c: recursive splsoftnet()
On Wed, Nov 16, 2016 at 09:58:00AM +0100, Martin Pieuchot wrote: > On 15/11/16(Tue) 16:36, Alexander Bluhm wrote: > > [...] > > You are a bit inconsistent wether you remove the {} from one line > > if blocks. > > That should fix my inconsistencies. OK bluhm@ > > Index: netinet/tcp_input.c > === > RCS file: /cvs/src/sys/netinet/tcp_input.c,v > retrieving revision 1.332 > diff -u -p -r1.332 tcp_input.c > --- netinet/tcp_input.c 16 Nov 2016 08:50:32 - 1.332 > +++ netinet/tcp_input.c 16 Nov 2016 08:57:03 - > @@ -3678,10 +3678,9 @@ syn_cache_get(struct sockaddr *src, stru > > splsoftassert(IPL_SOFTNET); > > - if ((sc = syn_cache_lookup(src, dst, &scp, > - sotoinpcb(so)->inp_rtableid)) == NULL) { > + sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rtableid); > + if (sc == NULL) > return (NULL); > - } > > /* >* Verify the sequence and ack numbers. Try getting the correct > @@ -3910,9 +3909,8 @@ syn_cache_reset(struct sockaddr *src, st > if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) > return; > if (SEQ_LT(th->th_seq, sc->sc_irs) || > - SEQ_GT(th->th_seq, sc->sc_irs+1)) { > + SEQ_GT(th->th_seq, sc->sc_irs + 1)) > return; > - } > syn_cache_rm(sc); > tcpstat.tcps_sc_reset++; > syn_cache_put(sc); > @@ -3927,9 +3925,8 @@ syn_cache_unreach(struct sockaddr *src, > > splsoftassert(IPL_SOFTNET); > > - if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) { > + if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) > return; > - } > /* If the sequence number != sc_iss, then it's a bogus ICMP msg */ > if (ntohl (th->th_seq) != sc->sc_iss) { > return; > @@ -4030,8 +4027,8 @@ syn_cache_add(struct sockaddr *src, stru >* If we do, resend the SYN,ACK. We do not count this >* as a retransmission (XXX though maybe we should). >*/ > - if ((sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rtableid)) > - != NULL) { > + sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rtableid); > + if (sc != NULL) { > tcpstat.tcps_sc_dupesyn++; > if (ipopts) { > /*
Re: bpf_mtap(9) w/o KERNEL_LOCK
On 13/09/16(Tue) 12:23, Martin Pieuchot wrote: > Here's the big scary diff I've been using for some months now to stop > grabbing the KERNEL_LOCK() in bpf_mtap(9). This has been originally > written to prevent lock ordering inside pf_test(). Now that we're > heading toward using a rwlock, we won't have this problem, but fewer > usages of KERNEL_LOCK() is still interesting. > > I'm going to split this diff in small chunks to ease the review. But > I'd appreciate if people could try to break it, test & report back. > > Some notes: > > - Now that selwakeup() is called in a thread context (task) we only > rely on the KERNEL_LOCK() to serialize access to kqueue(9) data. > > - The reference counting is here to make sure a descriptor is not > freed during a sleep. That's why the KERNEL_LOCK() is still > necessary in the slow path. On the other hand bpf_catchpacket() > relies on the reference guaranteed by the SRP list. > > - A mutex now protects the rotating buffers and their associated > fields. It is dropped before calling ifpromisc() because USB > devices sleep. > > - The dance around uiomove(9) is here to check that buffers aren't > rotated while data is copied to userland. Setting ``b->bd_fbuf'' > to NULL should be enough to let bpf_catchpacket() to drop the > patcket. But I added ``__in_uiomove'' to be able to have usable > panic if something weird happen. Here's another extracted diff: Use goto in read & write and always increment the reference count in write. ok? Index: net/bpf.c === RCS file: /cvs/src/sys/net/bpf.c,v retrieving revision 1.151 diff -u -p -r1.151 bpf.c --- net/bpf.c 16 Nov 2016 09:00:01 - 1.151 +++ net/bpf.c 16 Nov 2016 11:08:25 - @@ -406,16 +406,17 @@ bpfread(dev_t dev, struct uio *uio, int if (d->bd_bif == NULL) return (ENXIO); + s = splnet(); + bpf_get(d); + /* * Restrict application to use a buffer the same size as * as kernel buffers. */ - if (uio->uio_resid != d->bd_bufsize) - return (EINVAL); - - s = splnet(); - - bpf_get(d); + if (uio->uio_resid != d->bd_bufsize) { + error = EINVAL; + goto out; + } /* * If there's a timeout, bd_rdStart is tagged when we start the read. @@ -431,13 +432,12 @@ bpfread(dev_t dev, struct uio *uio, int * ends when the timeout expires or when enough packets * have arrived to fill the store buffer. */ - while (d->bd_hbuf == 0) { + while (d->bd_hbuf == NULL) { if (d->bd_bif == NULL) { /* interface is gone */ if (d->bd_slen == 0) { - bpf_put(d); - splx(s); - return (EIO); + error = EIO; + goto out; } ROTATE_BUFFERS(d); break; @@ -461,18 +461,15 @@ bpfread(dev_t dev, struct uio *uio, int } else error = EWOULDBLOCK; } - if (error == EINTR || error == ERESTART) { - bpf_put(d); - splx(s); - return (error); - } + if (error == EINTR || error == ERESTART) + goto out; if (error == EWOULDBLOCK) { /* * On a timeout, return what's in the buffer, * which may be nothing. If there is something * in the store buffer, we can rotate the buffers. */ - if (d->bd_hbuf) + if (d->bd_hbuf != NULL) /* * We filled up the buffer in between * getting the timeout and arriving @@ -481,9 +478,8 @@ bpfread(dev_t dev, struct uio *uio, int break; if (d->bd_slen == 0) { - bpf_put(d); - splx(s); - return (0); + error = 0; + goto out; } ROTATE_BUFFERS(d); break; @@ -505,7 +501,7 @@ bpfread(dev_t dev, struct uio *uio, int d->bd_fbuf = d->bd_hbuf; d->bd_hbuf = NULL; d->bd_hlen = 0; - +out: bpf_put(d); splx(s); @@ -554,32 +550,40 @@ bpfwrite(dev_t dev, struct uio *uio, int struct bpf_insn *fcode = NULL; int error, s; struct sockaddr_storage dst; +
pr_usrreq and splsoftnet
I'd like to enforce that pr_usrreq functions are always called at IPL_SOFTNET. This will allow us to keep locking simple as soon as we trade splsoftnet() for a rwlock. Most of the PRU_* actions are already called under splsoftnet() and the ones that are not are relatively small, so it should not really matter since processes are already serialized by the KERNEL_LOCK(). I'd even argue that this is a step forward removing the KERNEL_LOCK from the socket layer. Comments, oks? Index: kern/sys_socket.c === RCS file: /cvs/src/sys/kern/sys_socket.c,v retrieving revision 1.22 diff -u -p -r1.22 sys_socket.c --- kern/sys_socket.c 6 Oct 2016 17:02:10 - 1.22 +++ kern/sys_socket.c 16 Nov 2016 09:58:54 - @@ -73,6 +73,7 @@ int soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p) { struct socket *so = (struct socket *)fp->f_data; + int s, error = 0; switch (cmd) { @@ -122,8 +123,12 @@ soo_ioctl(struct file *fp, u_long cmd, c return (ifioctl(so, cmd, data, p)); if (IOCGROUP(cmd) == 'r') return (rtioctl(cmd, data, p)); - return ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, + s = splsoftnet(); + error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)NULL, p)); + splx(s); + + return (error); } int @@ -167,6 +172,7 @@ int soo_stat(struct file *fp, struct stat *ub, struct proc *p) { struct socket *so = fp->f_data; + int s; memset(ub, 0, sizeof (*ub)); ub->st_mode = S_IFSOCK; @@ -177,8 +183,10 @@ soo_stat(struct file *fp, struct stat *u ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; ub->st_uid = so->so_euid; ub->st_gid = so->so_egid; + s = splsoftnet(); (void) ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, (struct mbuf *)ub, NULL, NULL, p)); + splx(s); return (0); } Index: kern/uipc_socket.c === RCS file: /cvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.164 diff -u -p -r1.164 uipc_socket.c --- kern/uipc_socket.c 14 Nov 2016 08:45:30 - 1.164 +++ kern/uipc_socket.c 16 Nov 2016 10:14:05 - @@ -652,8 +652,10 @@ soreceive(struct socket *so, struct mbuf flags |= MSG_DONTWAIT; if (flags & MSG_OOB) { m = m_get(M_WAIT, MT_DATA); + s = splsoftnet(); error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, (struct mbuf *)(long)(flags & MSG_PEEK), NULL, curproc); + splx(s); if (error) goto bad; do { Index: kern/uipc_syscalls.c === RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.139 diff -u -p -r1.139 uipc_syscalls.c --- kern/uipc_syscalls.c9 Nov 2016 09:39:43 - 1.139 +++ kern/uipc_syscalls.c16 Nov 2016 10:17:08 - @@ -1066,7 +1066,7 @@ sys_getsockname(struct proc *p, void *v, struct socket *so; struct mbuf *m = NULL; socklen_t len; - int error; + int error, s; if ((error = getsock(p, SCARG(uap, fdes), &fp)) != 0) return (error); @@ -1078,14 +1078,15 @@ sys_getsockname(struct proc *p, void *v, if (error) goto bad; m = m_getclr(M_WAIT, MT_SONAME); + s = splsoftnet(); error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0, p); + splx(s); if (error) goto bad; error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); bad: FRELE(fp, p); - if (m) - m_freem(m); + m_freem(m); return (error); } @@ -1104,7 +1105,7 @@ sys_getpeername(struct proc *p, void *v, struct socket *so; struct mbuf *m = NULL; socklen_t len; - int error; + int error, s; if ((error = getsock(p, SCARG(uap, fdes), &fp)) != 0) return (error); @@ -1120,7 +1121,9 @@ sys_getpeername(struct proc *p, void *v, if (error) goto bad; m = m_getclr(M_WAIT, MT_SONAME); + s = splsoftnet(); error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0, p); + splx(s); if (error) goto bad; error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); Index: net/if.c === RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.461 diff -u -p -r1.461 if.c --- net/if.c14 Nov 2016 10:52:04 - 1.461 +++ net/if.c16 Nov 2016 09:58:54 - @@ -2046,9 +2046,11 @@ ifioctl(struct socket *so, u_long cmd, c default: if (so->so_proto == 0)
FCC Auth patch for umb(4)
Some MBIM devices need a FCC Authentication before they're willing to turn on the radio. This has to be done by sending a QMI command inside an MBIM message. This patch is based on an earlier patch by Stuart Henderson. One crucial thing was missing in sthen@'s patch: first a client-id (CID) has to be allocated and this CID must then be patched into the right field of the FCC-Auth. Sending the FCC-Auth is limited to a list of devices known to require this. Currently, this is only the Sierra Wireless EM7455. This patch was possible thanks to a lot of testing by Bryan Vyhmeister. Gerhard Index: sys/dev/usb/if_umb.c === RCS file: /cvs/src/sys/dev/usb/if_umb.c,v retrieving revision 1.6 diff -u -p -u -p -r1.6 if_umb.c --- sys/dev/usb/if_umb.c14 Nov 2016 12:55:56 - 1.6 +++ sys/dev/usb/if_umb.c16 Nov 2016 08:42:44 - @@ -170,6 +170,8 @@ int umb_setpin(struct umb_softc *, int int); voidumb_setdataclass(struct umb_softc *); voidumb_radio(struct umb_softc *, int); +voidumb_allocate_cid(struct umb_softc *); +voidumb_send_fcc_auth(struct umb_softc *); voidumb_packet_service(struct umb_softc *, int); voidumb_connect(struct umb_softc *); voidumb_disconnect(struct umb_softc *); @@ -177,8 +179,10 @@ voidumb_send_connect(struct umb_softc voidumb_qry_ipconfig(struct umb_softc *); voidumb_cmd(struct umb_softc *, int, int, void *, int); +voidumb_cmd1(struct umb_softc *, int, int, void *, int, uint8_t *); voidumb_command_done(struct umb_softc *, void *, int); voidumb_decode_cid(struct umb_softc *, uint32_t, void *, int); +voidumb_decode_qmi(struct umb_softc *, uint8_t *, int); voidumb_intr(struct usbd_xfer *, void *, usbd_status); @@ -188,6 +192,7 @@ int umb_xfer_tout = USBD_DEFAULT_TIMEO uint8_t umb_uuid_basic_connect[] = MBIM_UUID_BASIC_CONNECT; uint8_t umb_uuid_context_internet[] = MBIM_UUID_CONTEXT_INTERNET; +uint8_t umb_uuid_qmi_mbim[] = MBIM_UUID_QMI_MBIM; uint32_tumb_session_id = 0; struct cfdriver umb_cd = { @@ -204,6 +209,39 @@ const struct cfattach umb_ca = { int umb_delay = 4000; +/* + * These devices require an "FCC Authentication" command. + */ +const struct usb_devno umb_fccauth_devs[] = { + { USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_EM7455 }, +}; + +uint8_t umb_qmi_alloc_cid[] = { + 0x01, + 0x0f, 0x00, /* len */ + 0x00, /* QMUX flags */ + 0x00, /* service "ctl" */ + 0x00, /* CID */ + 0x00, /* QMI flags */ + 0x01, /* transaction */ + 0x22, 0x00, /* msg "Allocate CID" */ + 0x04, 0x00, /* TLV len */ + 0x01, 0x01, 0x00, 0x02 /* TLV */ +}; + +uint8_t umb_qmi_fcc_auth[] = { + 0x01, + 0x0c, 0x00, /* len */ + 0x00, /* QMUX flags */ + 0x02, /* service "dms" */ +#define UMB_QMI_CID_OFFS 5 + 0x00, /* CID (filled in later) */ + 0x00, /* QMI flags */ + 0x01, 0x00, /* transaction */ + 0x5f, 0x55, /* msg "Send FCC Authentication" */ + 0x00, 0x00 /* TLV len */ +}; + int umb_match(struct device *parent, void *match, void *aux) { @@ -328,6 +366,10 @@ umb_attach(struct device *parent, struct printf("%s: missing MBIM descriptor\n", DEVNAM(sc)); goto fail; } + if (usb_lookup(umb_fccauth_devs, uaa->vendor, uaa->product)) { + sc->sc_flags |= UMBFLG_FCC_AUTH_REQUIRED; + sc->sc_cid = -1; + } for (i = 0; i < uaa->nifaces; i++) { if (usbd_iface_claimed(sc->sc_udev, i)) @@ -783,7 +825,14 @@ umb_statechg_timeout(void *arg) { struct umb_softc *sc = arg; - printf("%s: state change timeout\n",DEVNAM(sc)); + if (sc->sc_info.regstate == MBIM_REGSTATE_ROAMING && !sc->sc_roaming) { + /* +* Query the registration state until we're with the home +* network again. +*/ + umb_cmd(sc, MBIM_CID_REGISTER_STATE, MBIM_CMDOP_QRY, NULL, 0); + } else + printf("%s: state change timeout\n",DEVNAM(sc)); usb_add_task(sc->sc_udev, &sc->sc_umb_task); } @@ -863,8 +912,23 @@ umb_up(struct umb_softc *sc) umb_open(sc); break; case UMB_S_OPEN: - DPRINTF("%s: init: turning radio on ...\n", DEVNAM(sc)); - umb_radio(sc, 1); + if (sc->sc_flags & UMBFLG_FCC_AUTH_REQUIRED) { + i
Re: tcp_input.c: recursive splsoftnet()
On 15/11/16(Tue) 16:36, Alexander Bluhm wrote: > [...] > You are a bit inconsistent wether you remove the {} from one line > if blocks. That should fix my inconsistencies. Index: netinet/tcp_input.c === RCS file: /cvs/src/sys/netinet/tcp_input.c,v retrieving revision 1.332 diff -u -p -r1.332 tcp_input.c --- netinet/tcp_input.c 16 Nov 2016 08:50:32 - 1.332 +++ netinet/tcp_input.c 16 Nov 2016 08:57:03 - @@ -3678,10 +3678,9 @@ syn_cache_get(struct sockaddr *src, stru splsoftassert(IPL_SOFTNET); - if ((sc = syn_cache_lookup(src, dst, &scp, - sotoinpcb(so)->inp_rtableid)) == NULL) { + sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rtableid); + if (sc == NULL) return (NULL); - } /* * Verify the sequence and ack numbers. Try getting the correct @@ -3910,9 +3909,8 @@ syn_cache_reset(struct sockaddr *src, st if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) return; if (SEQ_LT(th->th_seq, sc->sc_irs) || - SEQ_GT(th->th_seq, sc->sc_irs+1)) { + SEQ_GT(th->th_seq, sc->sc_irs + 1)) return; - } syn_cache_rm(sc); tcpstat.tcps_sc_reset++; syn_cache_put(sc); @@ -3927,9 +3925,8 @@ syn_cache_unreach(struct sockaddr *src, splsoftassert(IPL_SOFTNET); - if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) { + if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) return; - } /* If the sequence number != sc_iss, then it's a bogus ICMP msg */ if (ntohl (th->th_seq) != sc->sc_iss) { return; @@ -4030,8 +4027,8 @@ syn_cache_add(struct sockaddr *src, stru * If we do, resend the SYN,ACK. We do not count this * as a retransmission (XXX though maybe we should). */ - if ((sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rtableid)) - != NULL) { + sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rtableid); + if (sc != NULL) { tcpstat.tcps_sc_dupesyn++; if (ipopts) { /*
Re: [PATCH] usbdevs for Sierra Wireless EM7455
On Tue, 15 Nov 2016 08:11:01 -0800 Bryan Vyhmeister wrote: > This patch adds the Sierra Wireless EM7455 umb(4) device to usbdevs in > preparation for another patch to if_umb.c which adds full support for > the EM7455. > > Bryan > > > Index: sys/dev/usb/usbdevs > === > RCS file: /cvs/src/sys/dev/usb/usbdevs,v > retrieving revision 1.670 > diff -u -p -r1.670 usbdevs > --- sys/dev/usb/usbdevs 23 Sep 2016 08:18:00 - 1.670 > +++ sys/dev/usb/usbdevs 10 Nov 2016 17:13:34 - > @@ -3840,6 +3840,7 @@ product SIERRA MC8355 0x9013 MC8355 > product SIERRA AIRCARD_340U 0x9051 Aircard 340U > product SIERRA AIRCARD_770S 0x9053 Aircard 770S > product SIERRA MC74550x9071 MC7455 > +product SIERRA EM74550x9079 EM7455 > > /* Sigmatel products */ > product SIGMATEL IRDA0x4200 IrDA Thanks, committed. Gerhard