Re: add nl(1)

2013-05-10 Thread Stuart Henderson
On 2013/05/10 13:18, Damien Miller wrote:
 On Wed, 8 May 2013, Ted Unangst wrote:
 
  On Tue, Apr 30, 2013 at 18:57, Arto Jonsson wrote:
   Taken from netbsd with minor modifications. Comments?
  
  I don't think you've received much feedback. I don't know how other
  developers feel, but the question I have is can't this be done with a
  rather simple awk script? or perl? One of the reasons we have perl in
  base is precisely so it can be used for things like this.
 
 This implementation has the benefits of being small, having existing
 maintainers (NetBSD) and already having been written and debugged. It
 seems like make-work to do it over in Perl.

If we do use this implementation, then pascal@'s version from 2011 added
some fixes from FreeBSD, http://comments.gmane.org/gmane.os.openbsd.tech/25740



Re: add nl(1)

2013-05-10 Thread Arto Jonsson
On Fri, May 10, 2013 at 08:04:57AM +0100, Stuart Henderson wrote:
 If we do use this implementation, then pascal@'s version from 2011 added
 some fixes from FreeBSD, http://comments.gmane.org/gmane.os.openbsd.tech/25740

I'll take a closer look at this and freebsd's code later today. There's
one bug I noticed: `nl -' should use stdin and not fail like it
does currently in all implementations.



Unify and document usbd_transfer(9)

2013-05-10 Thread Martin Pieuchot
So this is is one more step in my effort to merge the various code paths
to submit an USB transfer.

This diff gets rid of the two badly named functions: usbd_bulk_transfer()
 usbd_intr_transfer() and makes use of the usbd_setup_xfer(9) + 
usbd_transfer(9) combination.  These functions were badly named because
they are identical wrappers to submit a synchronous transfer.  There are
however two small functional differences with this diff:

 - previously a custom name for the wait channel was given to tlseep(9)
   while sleeping for I/O. Now it will be usbsyn for all USB
   synchronous transfers.

 - previously the priority given to tlseep(9) was PZERO. Now it will be
   PRIBIO like for all USB synchronous transfers. But this shouldn't make
   a difference in practice, because the only priority between the two,
   PVFS, is unused. 

This diff also includes a new manual for the above mentioned functions.
I'd like to document as much functions of our USB stack as possible to
make sure driver porter/writer understand how it works.

ok?

Index: sys/dev/usb/ugen.c
===
RCS file: /cvs/src/sys/dev/usb/ugen.c,v
retrieving revision 1.71
diff -u -p -r1.71 ugen.c
--- sys/dev/usb/ugen.c  15 Apr 2013 09:23:02 -  1.71
+++ sys/dev/usb/ugen.c  26 Apr 2013 15:09:55 -
@@ -478,7 +478,7 @@ ugen_do_read(struct ugen_softc *sc, int 
struct usbd_xfer *xfer;
usbd_status err;
int s;
-   int error = 0;
+   int flags, error = 0;
u_char buffer[UGEN_CHUNK];
 
DPRINTFN(5, (%s: ugenread: %d\n, sc-sc_dev.dv_xname, endpt));
@@ -546,14 +546,17 @@ ugen_do_read(struct ugen_softc *sc, int 
xfer = usbd_alloc_xfer(sc-sc_udev);
if (xfer == 0)
return (ENOMEM);
+   flags = USBD_SYNCHRONOUS;
+   if (sce-state  UGEN_SHORT_OK)
+   flags |= USBD_SHORT_XFER_OK;
+   if (sce-timeout == 0)
+   flags |= USBD_CATCH;
while ((n = min(UGEN_BBSIZE, uio-uio_resid)) != 0) {
DPRINTFN(1, (ugenread: start transfer %d bytes\n,n));
tn = n;
-   err = usbd_bulk_transfer(
- xfer, sce-pipeh,
- sce-state  UGEN_SHORT_OK ?
- USBD_SHORT_XFER_OK : 0,
- sce-timeout, buf, tn, ugenrb);
+   usbd_setup_xfer(xfer, sce-pipeh, 0, buf, tn,
+   flags, sce-timeout, NULL);
+   err = usbd_transfer(xfer);
if (err) {
if (err == USBD_INTERRUPTED)
error = EINTR;
@@ -640,7 +643,7 @@ ugen_do_write(struct ugen_softc *sc, int
 {
struct ugen_endpoint *sce = sc-sc_endpoints[endpt][OUT];
u_int32_t n;
-   int error = 0;
+   int flags, error = 0;
char buf[UGEN_BBSIZE];
struct usbd_xfer *xfer;
usbd_status err;
@@ -663,6 +666,9 @@ ugen_do_write(struct ugen_softc *sc, int
return (EIO);
}
 #endif
+   flags = USBD_SYNCHRONOUS;
+   if (sce-timeout == 0)
+   flags |= USBD_CATCH;
 
switch (sce-edesc-bmAttributes  UE_XFERTYPE) {
case UE_BULK:
@@ -674,8 +680,9 @@ ugen_do_write(struct ugen_softc *sc, int
if (error)
break;
DPRINTFN(1, (ugenwrite: transfer %d bytes\n, n));
-   err = usbd_bulk_transfer(xfer, sce-pipeh, 0,
- sce-timeout, buf, n,ugenwb);
+   usbd_setup_xfer(xfer, sce-pipeh, 0, buf, n,
+   flags, sce-timeout, NULL);
+   err = usbd_transfer(xfer);
if (err) {
if (err == USBD_INTERRUPTED)
error = EINTR;
@@ -698,8 +705,9 @@ ugen_do_write(struct ugen_softc *sc, int
if (error)
break;
DPRINTFN(1, (ugenwrite: transfer %d bytes\n, n));
-   err = usbd_intr_transfer(xfer, sce-pipeh, 0,
-   sce-timeout, buf, n, ugenwi);
+   usbd_setup_xfer(xfer, sce-pipeh, 0, buf, n,
+   flags, sce-timeout, NULL);
+   err = usbd_transfer(xfer);
if (err) {
if (err == USBD_INTERRUPTED)
error = EINTR;
Index: sys/dev/usb/uhidev.c
===
RCS file: /cvs/src/sys/dev/usb/uhidev.c,v
retrieving revision 1.43
diff -u -p -r1.43 uhidev.c
--- sys/dev/usb/uhidev.c15 Apr 2013 09:23:02 -  

Re: zskbd_device_lookup is not used anymore

2013-05-10 Thread Mike Belopuhov
Hi,

I'll commit it then, if there are no objections.

On Sat, May 04, 2013 at 14:09 +0200, Sebastian Reitenbach wrote:
  
 On Friday, May 3, 2013 17:16 CEST, Mike Belopuhov m...@belopuhov.com wrote: 
  
  hi,
  
  as far as i can tell these functions are not used anymore.
 
 my sparcbook 3gx seems to be happy with it.
 
 Sebastian
 
  
  ok?
  
  diff --git sys/arch/sparc/dev/z8530kbd.c sys/arch/sparc/dev/z8530kbd.c
  index 0a9c364..c746e56 100644
  --- sys/arch/sparc/dev/z8530kbd.c
  +++ sys/arch/sparc/dev/z8530kbd.c
  @@ -213,8 +213,6 @@ static void zs_modem(struct zskbd_softc *, int);
   static void zs_hwiflow(struct zskbd_softc *);
   static void zs_maskintr(struct zskbd_softc *);
   
  -struct zskbd_softc *zskbd_device_lookup(struct cfdriver *, int);
  -
   /* Low-level routines. */
   static void zskbd_rxint(struct zs_chanstate *);
   static void zskbd_stint(struct zs_chanstate *, int);
  @@ -240,14 +238,6 @@ struct wskbd_consops zskbd_consops = {
   
   #defineZSKBDUNIT(x)(minor(x)  0x7)
   
  -struct zskbd_softc *
  -zskbd_device_lookup(cf, unit)
  -   struct cfdriver *cf;
  -   int unit;
  -{
  -   return (struct zskbd_softc *)device_lookup(cf, unit);
  -}
  -
   /*
* zskbd_match: how is this zs channel configured?
*/
  diff --git sys/arch/sparc64/dev/z8530kbd.c sys/arch/sparc64/dev/z8530kbd.c
  index e985544..1359964 100644
  --- sys/arch/sparc64/dev/z8530kbd.c
  +++ sys/arch/sparc64/dev/z8530kbd.c
  @@ -212,8 +212,6 @@ static void zs_modem(struct zskbd_softc *, int);
   static void zs_hwiflow(struct zskbd_softc *);
   static void zs_maskintr(struct zskbd_softc *);
   
  -struct zskbd_softc *zskbd_device_lookup(struct cfdriver *, int);
  -
   /* Low-level routines. */
   static void zskbd_rxint(struct zs_chanstate *);
   static void zskbd_stint(struct zs_chanstate *, int);
  @@ -239,14 +237,6 @@ struct wskbd_consops zskbd_consops = {
   
   #defineZSKBDUNIT(x)(minor(x)  0x7)
   
  -struct zskbd_softc *
  -zskbd_device_lookup(cf, unit)
  -   struct cfdriver *cf;
  -   int unit;
  -{ 
  -   return (struct zskbd_softc *)device_lookup(cf, unit);
  -}
  -
   /*
* zskbd_match: how is this zs channel configured?
*/
  
  
  
  
  
 



Re: check for device_lookup result in vscsi

2013-05-10 Thread Mike Belopuhov
On Fri, May 03, 2013 at 16:19 +0200, Mike Belopuhov wrote:
 hi,
 
 while looking for the device_unref bugs, i found that
 vscsi doesn't check if device_lookup has returned a
 valid return value.
 
 ok?
 

anyone?

 diff --git sys/dev/vscsi.c sys/dev/vscsi.c
 index 3da371c..db65642 100644
 --- sys/dev/vscsi.c
 +++ sys/dev/vscsi.c
 @@ -296,6 +296,9 @@ vscsiioctl(dev_t dev, u_long cmd, caddr_t addr, int 
 flags, struct proc *p)
   int read = 0;
   int err = 0;
  
 + if (sc == NULL)
 + return (ENXIO);
 +
   rw_enter_write(sc-sc_ioc_lock);
  
   switch (cmd) {
 @@ -476,6 +479,9 @@ vscsipoll(dev_t dev, int events, struct proc *p)
   struct vscsi_softc  *sc = DEV2SC(dev);
   int revents = 0;
  
 + if (sc == NULL)
 + return (ENXIO);
 +
   if (events  (POLLIN | POLLRDNORM)) {
   mtx_enter(sc-sc_state_mtx);
   if (!TAILQ_EMPTY(sc-sc_ccb_i2t))
 @@ -494,9 +500,14 @@ vscsipoll(dev_t dev, int events, struct proc *p)
  
  int
  vscsikqfilter(dev_t dev, struct knote *kn)
 -{ 
 +{
   struct vscsi_softc *sc = DEV2SC(dev);
 - struct klist *klist = sc-sc_sel.si_note;
 + struct klist *klist;
 +
 + if (sc == NULL)
 + return (ENXIO);
 +
 + klist = sc-sc_sel.si_note;
  
   switch (kn-kn_filter) {
   case EVFILT_READ:



Re: check for device_lookup result in vscsi

2013-05-10 Thread Gerhard Roth
Mike,

but it does check in vscsiopen(). Hence no userland program should be
able to call vscsiioctl() for a non-existant device because the open()
already failed. At least that's true as long as vscsi devices can't
disappear during run-time.

Gerhard


On Fri, 10 May 2013 14:44:39 +0200 Mike Belopuhov m...@belopuhov.com wrote:
 On Fri, May 03, 2013 at 16:19 +0200, Mike Belopuhov wrote:
  hi,
  
  while looking for the device_unref bugs, i found that
  vscsi doesn't check if device_lookup has returned a
  valid return value.
  
  ok?
  
 
 anyone?
 
  diff --git sys/dev/vscsi.c sys/dev/vscsi.c
  index 3da371c..db65642 100644
  --- sys/dev/vscsi.c
  +++ sys/dev/vscsi.c
  @@ -296,6 +296,9 @@ vscsiioctl(dev_t dev, u_long cmd, caddr_t addr, int 
  flags, struct proc *p)
  int read = 0;
  int err = 0;
   
  +   if (sc == NULL)
  +   return (ENXIO);
  +
  rw_enter_write(sc-sc_ioc_lock);
   
  switch (cmd) {
  @@ -476,6 +479,9 @@ vscsipoll(dev_t dev, int events, struct proc *p)
  struct vscsi_softc  *sc = DEV2SC(dev);
  int revents = 0;
   
  +   if (sc == NULL)
  +   return (ENXIO);
  +
  if (events  (POLLIN | POLLRDNORM)) {
  mtx_enter(sc-sc_state_mtx);
  if (!TAILQ_EMPTY(sc-sc_ccb_i2t))
  @@ -494,9 +500,14 @@ vscsipoll(dev_t dev, int events, struct proc *p)
   
   int
   vscsikqfilter(dev_t dev, struct knote *kn)
  -{ 
  +{
  struct vscsi_softc *sc = DEV2SC(dev);
  -   struct klist *klist = sc-sc_sel.si_note;
  +   struct klist *klist;
  +
  +   if (sc == NULL)
  +   return (ENXIO);
  +
  +   klist = sc-sc_sel.si_note;
   
  switch (kn-kn_filter) {
  case EVFILT_READ:
 




Re: check for device_lookup result in vscsi

2013-05-10 Thread Mike Belopuhov
On 10 May 2013 14:57, Gerhard Roth gerhard_r...@genua.de wrote:
 Mike,

 but it does check in vscsiopen(). Hence no userland program should be
 able to call vscsiioctl() for a non-existant device because the open()
 already failed. At least that's true as long as vscsi devices can't
 disappear during run-time.

 Gerhard


my intention here is very simple: there's a way you should call
device_lookup and everyone has to fulfill it's part of the contract.
all our devices do, vscsi doesn't.  what's the reason for it to be
one of a kind?



Re: trunk(4) take MTU from first member port.

2013-05-10 Thread Stuart Henderson
On 2013/02/22 12:30, Stuart Henderson wrote:
 I thought we already had something for this after the misc@ thread
 a few months ago, but clearly not.
 
 Adapted from FreeBSD if_lagg.c r171661 (which includes capability
 setting which we already do).
 http://svnweb.freebsd.org/base/head/sys/net/if_lagg.c?r1=171603r2=171661

JJ tested this diff but I didn't hear much else. Any comments?
Currently it is not possible to use jumbo frames with trunk(4) interfaces.



Index: if_trunk.c
===
RCS file: /cvs/src/sys/net/if_trunk.c,v
retrieving revision 1.81
diff -u -p -r1.81 if_trunk.c
--- if_trunk.c  2 Apr 2013 08:54:37 -   1.81
+++ if_trunk.c  10 May 2013 13:09:49 -
@@ -313,6 +313,20 @@ trunk_port_create(struct trunk_softc *tr
if (ifp-if_type != IFT_ETHER)
return (EPROTONOSUPPORT);
 
+   /* Take MTU from the first member port */
+   if (SLIST_EMPTY(tr-tr_ports)) {
+   if (tr-tr_ifflags  IFF_DEBUG)
+   printf(%s: first port, setting trunk mtu %u\n,
+   tr-tr_ifname, ifp-if_mtu);
+   tr-tr_ac.ac_if.if_mtu = ifp-if_mtu;
+   tr-tr_ac.ac_if.if_hardmtu = ifp-if_mtu;
+   }
+   else if (tr-tr_ac.ac_if.if_mtu != ifp-if_mtu) {
+   printf(%s: adding %s failed, MTU %u != %u\n, tr-tr_ifname,
+   ifp-if_xname, ifp-if_mtu, tr-tr_ac.ac_if.if_mtu);
+   return (EINVAL);
+   }
+
if ((error = ifpromisc(ifp, 1)) != 0)
return (error);
 
@@ -508,6 +522,10 @@ trunk_port_ioctl(struct ifnet *ifp, u_lo
}
 
trunk_port2req(tp, rp);
+   break;
+   case SIOCSIFMTU:
+   /* Do not allow the MTU to be changed once joined */
+   error = EINVAL;
break;
default:
error = ENOTTY;



Re: add nl(1)

2013-05-10 Thread Arto Jonsson
On Fri, May 10, 2013 at 08:04:57AM +0100, Stuart Henderson wrote:
 On 2013/05/10 13:18, Damien Miller wrote:
  On Wed, 8 May 2013, Ted Unangst wrote:
  
   On Tue, Apr 30, 2013 at 18:57, Arto Jonsson wrote:
Taken from netbsd with minor modifications. Comments?
   
   I don't think you've received much feedback. I don't know how other
   developers feel, but the question I have is can't this be done with a
   rather simple awk script? or perl? One of the reasons we have perl in
   base is precisely so it can be used for things like this.
  
  This implementation has the benefits of being small, having existing
  maintainers (NetBSD) and already having been written and debugged. It
  seems like make-work to do it over in Perl.
 
 If we do use this implementation, then pascal@'s version from 2011 added
 some fixes from FreeBSD, http://comments.gmane.org/gmane.os.openbsd.tech/25740

Here's an updated diff. Compared to the previous diff '-' is now handled
as stdin. From the freebsd version I noticed that the previous diff also
had useless exit() call which I removed. Comments?

Index: Makefile
===
RCS file: /cvs/src/usr.bin/Makefile,v
retrieving revision 1.129
diff -u -p -r1.129 Makefile
--- Makefile15 Mar 2013 06:01:41 -  1.129
+++ Makefile10 May 2013 14:09:23 -
@@ -16,7 +16,7 @@ SUBDIR= apply apropos ar arch asa asn1_c
m4 mail make man mandoc mesg mg \
midiplay mixerctl mkdep mklocale mkstr mktemp modstat nc netstat \
newsyslog \
-   nfsstat nice nm nohup oldrdist pagesize passwd paste patch pctr \
+   nfsstat nice nm nl nohup oldrdist pagesize passwd paste patch pctr \
pkg-config pkill \
pr printenv printf quota radioctl ranlib rcs rdist rdistd \
readlink renice rev rpcgen rpcinfo rs rsh rup ruptime rusers rwall \
Index: nl/Makefile
===
RCS file: nl/Makefile
diff -N nl/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -
+++ nl/Makefile 10 May 2013 14:09:24 -
@@ -0,0 +1,6 @@
+#  $OpenBSD$
+#  $NetBSD: Makefile,v 1.4 2011/08/16 12:00:46 christos Exp $
+
+PROG=  nl
+
+.include bsd.prog.mk
Index: nl/nl.1
===
RCS file: nl/nl.1
diff -N nl/nl.1
--- /dev/null   1 Jan 1970 00:00:00 -
+++ nl/nl.1 10 May 2013 14:09:24 -
@@ -0,0 +1,212 @@
+.\$OpenBSD$
+.\$NetBSD: nl.1,v 1.12 2012/04/08 22:00:39 wiz Exp $
+.\
+.\ Copyright (c) 1999 The NetBSD Foundation, Inc.
+.\ All rights reserved.
+.\
+.\ This code is derived from software contributed to The NetBSD Foundation
+.\ by Klaus Klein.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\ POSSIBILITY OF SUCH DAMAGE.
+.\
+.Dd $Mdocdate$
+.Dt NL 1
+.Os
+.Sh NAME
+.Nm nl
+.Nd line numbering filter
+.Sh SYNOPSIS
+.Nm
+.Op Fl p
+.Op Fl b Ar type
+.Op Fl d Ar delim
+.Op Fl f Ar type
+.Op Fl h Ar type
+.Op Fl i Ar incr
+.Op Fl l Ar num
+.Op Fl n Ar format
+.Op Fl s Ar sep
+.Op Fl v Ar startnum
+.Op Fl w Ar width
+.Op Ar file
+.Sh DESCRIPTION
+The
+.Nm
+utility reads lines from the named
+.Ar file
+or the standard input if the
+.Ar file
+argument is omitted,
+applies a configurable line numbering filter operation and writes the result
+to the standard output.
+.Pp
+The
+.Nm
+utility treats the text it reads in terms of logical pages.
+Unless specified otherwise, line numbering is reset at the start of each
+logical page.
+A logical page consists of a header, a body and a footer section; empty
+sections are valid.
+Different line numbering options are independently available for header,
+body and footer sections.
+.Pp
+The starts of logical page sections are 

Re: trunk(4) take MTU from first member port.

2013-05-10 Thread Mike Belopuhov
On 10 May 2013 16:43, Chris Cappuccio ch...@nmedia.net wrote:
 Stuart Henderson [st...@openbsd.org] wrote:
 On 2013/02/22 12:30, Stuart Henderson wrote:
  I thought we already had something for this after the misc@ thread
  a few months ago, but clearly not.
 
  Adapted from FreeBSD if_lagg.c r171661 (which includes capability
  setting which we already do).
  http://svnweb.freebsd.org/base/head/sys/net/if_lagg.c?r1=171603r2=171661

 JJ tested this diff but I didn't hear much else. Any comments?

 if (tr-tr_ac.ac_if.if_mtu != ifp-if_mtu) seems wrong. what about people
 who want to use trunk between two totally different interfaces for failover?

 i think the trunk mtu should simply be the lowest common of the group.


i agree with chris.  doesn't mtu get propogated into the routing table?
what if you failover and your other trunk port can't handle packets that
big but ip_output thinks it should be fine?



Re: trunk(4) take MTU from first member port.

2013-05-10 Thread Stuart Henderson
On 2013/05/10 16:53, Mike Belopuhov wrote:
 On 10 May 2013 16:43, Chris Cappuccio ch...@nmedia.net wrote:
  Stuart Henderson [st...@openbsd.org] wrote:
  On 2013/02/22 12:30, Stuart Henderson wrote:
   I thought we already had something for this after the misc@ thread
   a few months ago, but clearly not.
  
   Adapted from FreeBSD if_lagg.c r171661 (which includes capability
   setting which we already do).
   http://svnweb.freebsd.org/base/head/sys/net/if_lagg.c?r1=171603r2=171661
 
  JJ tested this diff but I didn't hear much else. Any comments?
 
  if (tr-tr_ac.ac_if.if_mtu != ifp-if_mtu) seems wrong. what about people
  who want to use trunk between two totally different interfaces for failover?

I think that in this case, they should be doing failover at a different
layer, or choose a lowest common denominator themselves - mixing different
MTUs within a subnet doesn't work too well and there's no way to let other
machines know that your MTU has now reduced and that they should follow suit.

  i think the trunk mtu should simply be the lowest common of the group.
 
 i agree with chris.  doesn't mtu get propogated into the routing table?
 what if you failover and your other trunk port can't handle packets that
 big but ip_output thinks it should be fine?
 

That's exactly why the diff restricts things so a port can only be added
to a trunk if the MTU is the same as existing ports. Otherwise we would be
reducing an already-existing trunk's MTU to the lowest common MTU when a
new trunkport is added which would quite possibly give problems in the
routing table, and even problems pushed down to daemons (OSPF in
particular), I think it's safer to force people to think ahead and make
a decision when the trunk interface is created.



Re: trunk(4) take MTU from first member port.

2013-05-10 Thread Reyk Floeter
Hi,

the diff is needed - I was running into it quite recently when I was
trying some QinQ/svlan configurations on trunk.

Comments below, otherwise OK

reyk

On Fri, May 10, 2013 at 02:11:28PM +0100, Stuart Henderson wrote:
 Index: if_trunk.c
 ===
 RCS file: /cvs/src/sys/net/if_trunk.c,v
 retrieving revision 1.81
 diff -u -p -r1.81 if_trunk.c
 --- if_trunk.c2 Apr 2013 08:54:37 -   1.81
 +++ if_trunk.c10 May 2013 13:09:49 -
 @@ -313,6 +313,20 @@ trunk_port_create(struct trunk_softc *tr
   if (ifp-if_type != IFT_ETHER)
   return (EPROTONOSUPPORT);
  
 + /* Take MTU from the first member port */

I agree, using the MTU from the first port is the right way, at least
it matches trunk intended behaviour.

 + if (SLIST_EMPTY(tr-tr_ports)) {
 + if (tr-tr_ifflags  IFF_DEBUG)
 + printf(%s: first port, setting trunk mtu %u\n,
 + tr-tr_ifname, ifp-if_mtu);
 + tr-tr_ac.ac_if.if_mtu = ifp-if_mtu;
 + tr-tr_ac.ac_if.if_hardmtu = ifp-if_mtu;
 + }
 + else if (tr-tr_ac.ac_if.if_mtu != ifp-if_mtu) {

Just a style comment - I don't like wrapping the else if on a new line ;)

But the check is correct.

 + printf(%s: adding %s failed, MTU %u != %u\n, tr-tr_ifname,
 + ifp-if_xname, ifp-if_mtu, tr-tr_ac.ac_if.if_mtu);
 + return (EINVAL);
 + }
 +
   if ((error = ifpromisc(ifp, 1)) != 0)
   return (error);
  
 @@ -508,6 +522,10 @@ trunk_port_ioctl(struct ifnet *ifp, u_lo
   }
  
   trunk_port2req(tp, rp);
 + break;
 + case SIOCSIFMTU:
 + /* Do not allow the MTU to be changed once joined */
 + error = EINVAL;
   break;
   default:
   error = ENOTTY;
 



Re: trunk(4) take MTU from first member port.

2013-05-10 Thread Reyk Floeter
On Fri, May 10, 2013 at 04:53:18PM +0200, Mike Belopuhov wrote:
  if (tr-tr_ac.ac_if.if_mtu != ifp-if_mtu) seems wrong. what about people
  who want to use trunk between two totally different interfaces for failover?
 
  i think the trunk mtu should simply be the lowest common of the group.
 
 
 i agree with chris.  doesn't mtu get propogated into the routing table?
 what if you failover and your other trunk port can't handle packets that
 big but ip_output thinks it should be fine?
 

I disagree and I think sthen's diff is doing it right.  The order that
you add the ports always mattered, that's how I implemented it in the
first place.

The implementation will make sure that you cannot add ports with a
different configured MTU and the configured MTU if_mtu cannot be
higher than the hardware MTU if_hardmtu.  So a failover cannot cause
problems with packets that are too big.

You can still trunk two totally different interfaces with different
hardware MTUs, like the popular WLAN + LAN failover trunk, but you
have to configure the same MTU before adding them to the trunk.  This
totally makes sense!

1. if0: if_hardmtu 65535, if_mtu 9000
2. if1: if_hardmtu 9200, if_mtu 9000
3. trunk0: if_hardmtu 9000, if_mtu 9000
4. \o/

reyk



Re: ftpd log address format

2013-05-10 Thread Todd T. Fries
Penned by Ted Unangst on 20130504  0:57.40, we have:
| On Sat, May 04, 2013 at 07:26, Martijn van Duren wrote:
|  For a lot of cases this isn't a problem. But there are a couple of
|  instances where the domain name resolves to something a little to
|  generic to be useful to determine it's origin and hence I'm not able to
|  decide if it's a legit connection or not, let alone being able to place
|  it in my firewall.
|  To fix this for myself I made this minor patch to retrieve the ip
|  address instead of the the reverse lookup. This appears to be the same
|  behavior as sshd shows.
| 
| I think this is wise. Reverse lookups are not really useful imo. If
| someone cares, they can always do them later.

I always set 'UseDNS no' in my sshd_config, same argument, and if dns is
borked for any reason, it avoids needless delay getting into an afflicted
system to unbork it.

Thanks,
-- 
Todd Fries .. t...@fries.net

 
|\  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC\  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com\  1.866.792.3418 (FAX)
| PO Box 16169, Oklahoma City, OK 73113  \  sip:freedae...@ekiga.net
| ..in support of free software solutions. \  sip:4052279...@ekiga.net
 \
 
  37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
http://todd.fries.net/pgp.txt



Re: check for device_lookup result in vscsi

2013-05-10 Thread Mike Belopuhov
On Fri, May 10, 2013 at 10:35 -0700, Matthew Dempsky wrote:
 On Fri, May 10, 2013 at 6:02 AM, Mike Belopuhov m...@belopuhov.com wrote:
  my intention here is very simple: there's a way you should call
  device_lookup and everyone has to fulfill it's part of the contract.
  all our devices do, vscsi doesn't.  what's the reason for it to be
  one of a kind?
 
 I'm ok with adding a check, though I don't think it should really be
 necessary either.
 
 Just a thought: What about adding them as KASSERT()s?
 

i don't have a strong opinion about that.

 Why doesn't your diff include vscsiclose()?

missed it.

diff --git sys/dev/vscsi.c sys/dev/vscsi.c
index 3da371c..a8f2c5b 100644
--- sys/dev/vscsi.c
+++ sys/dev/vscsi.c
@@ -296,6 +296,9 @@ vscsiioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, 
struct proc *p)
int read = 0;
int err = 0;
 
+   if (sc == NULL)
+   return (ENXIO);
+
rw_enter_write(sc-sc_ioc_lock);
 
switch (cmd) {
@@ -476,6 +479,9 @@ vscsipoll(dev_t dev, int events, struct proc *p)
struct vscsi_softc  *sc = DEV2SC(dev);
int revents = 0;
 
+   if (sc == NULL)
+   return (ENXIO);
+
if (events  (POLLIN | POLLRDNORM)) {
mtx_enter(sc-sc_state_mtx);
if (!TAILQ_EMPTY(sc-sc_ccb_i2t))
@@ -494,9 +500,14 @@ vscsipoll(dev_t dev, int events, struct proc *p)
 
 int
 vscsikqfilter(dev_t dev, struct knote *kn)
-{ 
+{
struct vscsi_softc *sc = DEV2SC(dev);
-   struct klist *klist = sc-sc_sel.si_note;
+   struct klist *klist;
+
+   if (sc == NULL)
+   return (ENXIO);
+
+   klist = sc-sc_sel.si_note;
 
switch (kn-kn_filter) {
case EVFILT_READ:
@@ -548,6 +559,9 @@ vscsiclose(dev_t dev, int flags, int mode, struct proc *p)
struct vscsi_softc  *sc = DEV2SC(dev);
struct vscsi_ccb*ccb;
 
+   if (sc == NULL)
+   return (ENXIO);
+
mtx_enter(sc-sc_state_mtx);
KASSERT(sc-sc_state == VSCSI_S_RUNNING);
sc-sc_state = VSCSI_S_CONFIG;



Re: check for device_lookup result in vscsi

2013-05-10 Thread Matthew Dempsky
On Fri, May 10, 2013 at 6:02 AM, Mike Belopuhov m...@belopuhov.com wrote:
 my intention here is very simple: there's a way you should call
 device_lookup and everyone has to fulfill it's part of the contract.
 all our devices do, vscsi doesn't.  what's the reason for it to be
 one of a kind?

I'm ok with adding a check, though I don't think it should really be
necessary either.

Just a thought: What about adding them as KASSERT()s?

Why doesn't your diff include vscsiclose()?



Re: add nl(1)

2013-05-10 Thread Jérémie Courrèges-Anglas
Arto Jonsson ajons...@kapsi.fi writes:

 On Fri, May 10, 2013 at 08:04:57AM +0100, Stuart Henderson wrote:
 On 2013/05/10 13:18, Damien Miller wrote:
  On Wed, 8 May 2013, Ted Unangst wrote:
  
   On Tue, Apr 30, 2013 at 18:57, Arto Jonsson wrote:
Taken from netbsd with minor modifications. Comments?
   
   I don't think you've received much feedback. I don't know how other
   developers feel, but the question I have is can't this be done with a
   rather simple awk script? or perl? One of the reasons we have perl in
   base is precisely so it can be used for things like this.
  
  This implementation has the benefits of being small, having existing
  maintainers (NetBSD) and already having been written and debugged. It
  seems like make-work to do it over in Perl.
 
 If we do use this implementation, then pascal@'s version from 2011 added
 some fixes from FreeBSD, 
 http://comments.gmane.org/gmane.os.openbsd.tech/25740

 Here's an updated diff. Compared to the previous diff '-' is now handled
 as stdin. From the freebsd version I noticed that the previous diff also
 had useless exit() call which I removed. Comments?

Nitpicking inline...

 Index: Makefile
 ===
 RCS file: /cvs/src/usr.bin/Makefile,v
 retrieving revision 1.129
 diff -u -p -r1.129 Makefile
 --- Makefile  15 Mar 2013 06:01:41 -  1.129
 +++ Makefile  10 May 2013 14:09:23 -
 @@ -16,7 +16,7 @@ SUBDIR= apply apropos ar arch asa asn1_c
   m4 mail make man mandoc mesg mg \
   midiplay mixerctl mkdep mklocale mkstr mktemp modstat nc netstat \
   newsyslog \
 - nfsstat nice nm nohup oldrdist pagesize passwd paste patch pctr \
 + nfsstat nice nm nl nohup oldrdist pagesize passwd paste patch pctr \
   pkg-config pkill \
   pr printenv printf quota radioctl ranlib rcs rdist rdistd \
   readlink renice rev rpcgen rpcinfo rs rsh rup ruptime rusers rwall \
 Index: nl/Makefile
 ===
 RCS file: nl/Makefile
 diff -N nl/Makefile
 --- /dev/null 1 Jan 1970 00:00:00 -
 +++ nl/Makefile   10 May 2013 14:09:24 -
 @@ -0,0 +1,6 @@
 +#$OpenBSD$
 +#$NetBSD: Makefile,v 1.4 2011/08/16 12:00:46 christos Exp $
 +
 +PROG=nl
 +
 +.include bsd.prog.mk
 Index: nl/nl.1
 ===
 RCS file: nl/nl.1
 diff -N nl/nl.1
 --- /dev/null 1 Jan 1970 00:00:00 -
 +++ nl/nl.1   10 May 2013 14:09:24 -
 @@ -0,0 +1,212 @@
 +.\  $OpenBSD$
 +.\  $NetBSD: nl.1,v 1.12 2012/04/08 22:00:39 wiz Exp $
 +.\
 +.\ Copyright (c) 1999 The NetBSD Foundation, Inc.
 +.\ All rights reserved.
 +.\
 +.\ This code is derived from software contributed to The NetBSD Foundation
 +.\ by Klaus Klein.
 +.\
 +.\ Redistribution and use in source and binary forms, with or without
 +.\ modification, are permitted provided that the following conditions
 +.\ are met:
 +.\ 1. Redistributions of source code must retain the above copyright
 +.\notice, this list of conditions and the following disclaimer.
 +.\ 2. Redistributions in binary form must reproduce the above copyright
 +.\notice, this list of conditions and the following disclaimer in the
 +.\documentation and/or other materials provided with the distribution.
 +.\
 +.\ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 +.\ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 LIMITED
 +.\ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
 PARTICULAR
 +.\ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 +.\ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 +.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 +.\ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 +.\ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 +.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 +.\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
 THE
 +.\ POSSIBILITY OF SUCH DAMAGE.
 +.\
 +.Dd $Mdocdate$
 +.Dt NL 1
 +.Os
 +.Sh NAME
 +.Nm nl
 +.Nd line numbering filter
 +.Sh SYNOPSIS
 +.Nm
 +.Op Fl p
 +.Op Fl b Ar type
 +.Op Fl d Ar delim
 +.Op Fl f Ar type
 +.Op Fl h Ar type
 +.Op Fl i Ar incr
 +.Op Fl l Ar num
 +.Op Fl n Ar format
 +.Op Fl s Ar sep
 +.Op Fl v Ar startnum
 +.Op Fl w Ar width
 +.Op Ar file
 +.Sh DESCRIPTION
 +The
 +.Nm
 +utility reads lines from the named
 +.Ar file
 +or the standard input if the
 +.Ar file
 +argument is omitted,

Since the upstream version doesn't treat `-' specially, I'd add:

argument is a single dash
.Pq Sq \-
or absent,

- as in cat(1) - to make that clear.

 +applies a configurable line numbering filter operation and writes the result
 +to the standard output.
 +.Pp
 +The
 +.Nm
 +utility treats the text it reads in terms of logical pages.
 +Unless specified otherwise, 

Re: emacs fails to build after switching to 5.3

2013-05-10 Thread Jérémie Courrèges-Anglas
Han Boetes h...@boetes.org writes:

 Hi,

Hi (again),

 I noticed emacs failed to build after switching to 5.3. I
 discussed the matter with the emacs devs and they added some debug
 code which is triggered by CFLAGS='-g3 -DUNEXELF_DEBUG' So when
 it's building the main binary at Dumping under the name emacs I
 get this output:

Does that mean that *only* building with -DUNEXELF_DEBUG fails?  If so,
the problem is perhaps not that important...

 old_bss_index 25
 old_bss_addr 0x63fca0
 old_bss_size 0x73fd8
 old_bss_offset 0x53fca0
 new_bss_addr 0x4d313aa9000
 new_data2_addr 0x63fca0
 new_data2_size 0x13469360
 new_data2_offset 0x53fca0
 new_data2_incr 0x13469360
 old_file_h-e_shoff 0x9a4258
 Old section count 38
 new_file_h-e_shoff 0x13e0d5b8
 New section count 39
 Segmentation fault
 gmake[1]: *** [bootstrap-emacs] Error 1


 After which I got this comment back by email from the developer:
  new_bss_addr 0x4d313aa9000

 That looks like the problem: OpenBSD's sbrk(0) is returning a
 huge value.  src/unexelf.c isn't set up for that.

 Fixing this will require someone who knows ELF and OpenBSD
 fairly well, which alas is not me.

 He is refering to this file:

 http://bzr.savannah.gnu.org/lh/emacs/trunk/annotate/head:/src/unexelf.c

 What needs to be done to fix this problem?

I don't have a 64 bits host to repeat it.  Please make it clear that the
very last version of this file doesn't solve the issue.

(Commit message: unexelf.c: Don't assume ElfW (Half) fits in int.)

 # Han

-- 
Jérémie Courrèges-Anglas
PGP Key fingerprint: 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494



Re: emacs fails to build after switching to 5.3

2013-05-10 Thread Han Boetes
Han Boetes wrote:
 I noticed emacs failed to build after switching to 5.3. I
 discussed the matter with the emacs devs and they added some
 debug code which is triggered by CFLAGS='-g3 -DUNEXELF_DEBUG' So
 when it's building the main binary at Dumping under the name
 emacs I get this output:

Incase anyone missed it: I'm always using the latest code from BZR.


# Han