Re: eeprom does not compile on current/macppc

2016-01-01 Thread a . velichinsky
On Thu, Dec 31, 2015 at 12:01:10PM -0700, Todd C. Miller wrote:
> Hmmm, should the yyparse() proto really be static?  The actual
> yyparse() generated by yacc is not static.

the yyparse() as generated by yacc may be either static or extern
depending on the user's preference -- she's free to declare it
static in the %{ %} block or in a file included from there.

that's because the first declaration dictates the storage class;
a subsequent declaration/definition should either repeat it, omit it,
or declare it as 'extern'.

ex. ok, 'func' will be static:
static int func(void);
int func(void);
int func(void){ return 17; }
extern int func(void);

ex. *NOT* ok:
int func(void);
static int func(void){ return 17; }



fuser(1): Fix pledge when `u' flag is used

2016-01-01 Thread Michael Reed
Hi,

`fuser -u -c /' doesn't seem to work for me:

fuser(28663): syscall 33 "getpw"

The patch below fixes my issue.  The pledge condition was already a bit
long, so I just switched to snprintf(3); not sure what's normally done
in such situations.

Regards,
  Michael



Index: fstat.c
===
RCS file: /cvs/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.85
diff -u -p -r1.85 fstat.c
--- fstat.c 30 Dec 2015 19:02:12 -  1.85
+++ fstat.c 2 Jan 2016 03:18:17 -
@@ -142,6 +142,7 @@ main(int argc, char *argv[])
int arg, ch, what;
char *memf, *nlistf, *optstr;
char buf[_POSIX2_LINE_MAX];
+   char promises[1024];
const char *errstr;
int cnt, flags;
 
@@ -275,18 +276,12 @@ main(int argc, char *argv[])
if ((kf = kvm_getfiles(kd, what, arg, sizeof(*kf), &cnt)) == NULL)
errx(1, "%s", kvm_geterr(kd));
 
-   if (fuser) {
-   if (sflg) { /* fuser might call kill(2) */
-   if (pledge("stdio rpath proc", NULL) == -1)
-   err(1, "pledge");
-   } else {
-   if (pledge("stdio rpath", NULL) == -1)
-   err(1, "pledge");
-   }
-   } else {
-   if (pledge("stdio rpath getpw", NULL) == -1)
-   err(1, "pledge");
-   }
+   snprintf(promises, sizeof(promises), "stdio rpath%s%s",
+   (fuser && sflg) ? " proc" : "",  /* fuser might call kill(2) */
+   (!fuser || uflg) ? " getpw" : "");
+
+   if (pledge(promises, NULL) == -1)
+   err(1, "pledge");
 
find_splices(kf, cnt);
if (!fuser)



Re: Checking MAC address of incoming unicast packets

2016-01-01 Thread Theo de Raadt
dlg writes:

> should we just do it unconditionally? is there a downside to that?

That is a very good question.  What are the downsides against having
the driver do this filtering itself, like all real hardware does?

Why risk sending packets of the wrong form further upwards into the
network stack, and then having to ensure the checks exist up there?

This flag is requesting special service to encourage a layer violation.

What is the reasoning to encourage such a flag (which someone will one
day see, misuse, and try to expand for their bizzare use case...)



Re: Checking MAC address of incoming unicast packets

2016-01-01 Thread Theo de Raadt
>This could be done with a new flag. There seem to be three possible places 
>where this flag could be put:
>
>* ifnet.if_flags
>  This is a short and there is no free bit. But the IFF_NOTRAILERS bit has
>  become unused recently and could be recycled.
>
>* ifnet.if_xflags
>  An int, lots of free bits. But comment says 'extra softnet flags'
>
>* if_data.ifi_capabilities
>  An u_int32_t, lots of free bits. 

It feels more like it should be an inate feature of the "hardware",
not terribly visible to the admin, not in their face, and certainly
not something the root in the guest can "disable".  To stop it from
being disabled, you put it into IFF_CANTCHANGE.  That should help the
latter concern.

But I do worry about whether a guest should see such a flag so visibly.

To me, ifi_capabilities feels like the right place to put this.
Nicely hidden, cannot be changed, and noone will have it in their face
when they run ifconfig.



Re: Checking MAC address of incoming unicast packets

2016-01-01 Thread David Gwynne

> On 2 Jan 2016, at 7:55 AM, Stefan Fritsch  wrote:
> 
> Hi,
> 
> by default, the ether_input() checks the destination MAC address of 
> incoming unicast packets only if the interface is in promiscous mode. If 
> not, it is assumed that the NIC filters unicast packets reliably. 
> Unfortunately, for virtio-net this is not the case. There, unicast 
> filtering is only best effort, and (depending on configuration) if the 
> bridge on the VM host does unicast flodding, unicast packets that are not 
> for the VM guest may still be delivered to the VM guest. This is a rather 
> annoying problem because it can cause pf to send RST packets to foreign 
> connections. (Kudos to mpf@ for debugging this).
> 
> There are two possible approaches to fix this problem. Either make the 
> vio(4) driver filter out unicast packets that are not for the local MAC, 
> which would involve duplicating quite a bit of code from ether_input() in 
> vio(4). Or, and I would prefer this, allow the driver to tell 
> ether_input() that it needs to check the MAC always, and not only if the 
> interface is in promiscous mode.
> 
> This could be done with a new flag. There seem to be three possible places 
> where this flag could be put:
> 
> * ifnet.if_flags
>  This is a short and there is no free bit. But the IFF_NOTRAILERS bit has
>  become unused recently and could be recycled.
> 
> * ifnet.if_xflags
>  An int, lots of free bits. But comment says 'extra softnet flags'
> 
> * if_data.ifi_capabilities
>  An u_int32_t, lots of free bits. 
> 
> 
> In the diff below, I went with the first choice because the new 
> IFF_NOMACFILTER
> is somewhat similar to IFF_SIMPLEX and because the the check can then be 
> nicely folded into the existing check for IFF_PROMISC.
> 
> I would welcome any comments, suggestions for a better flag name, OKs, ...

should we just do it unconditionally? is there a downside to that?

dlg

> 
> Cheers,
> Stefan
> 
> 
> 
> diff --git sys/dev/pci/if_vio.c sys/dev/pci/if_vio.c
> index 4cd80d5..22fd7cf 100644
> --- sys/dev/pci/if_vio.c
> +++ sys/dev/pci/if_vio.c
> @@ -582,21 +582,21 @@ vio_attach(struct device *parent, struct device *self, 
> void *aux)
>   virtio_start_vq_intr(vsc, &sc->sc_vq[VQCTL]);
>   vsc->sc_nvqs = 3;
>   }
>   }
> 
>   if (vio_alloc_mem(sc) < 0)
>   goto err;
> 
>   strlcpy(ifp->if_xname, self->dv_xname, IFNAMSIZ);
>   ifp->if_softc = sc;
> - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
> + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | 
> IFF_NOMACFILTER;
>   ifp->if_start = vio_start;
>   ifp->if_ioctl = vio_ioctl;
>   ifp->if_capabilities = IFCAP_VLAN_MTU;
>   if (features & VIRTIO_NET_F_CSUM)
>   ifp->if_capabilities |= IFCAP_CSUM_TCPv4|IFCAP_CSUM_UDPv4;
>   IFQ_SET_MAXLEN(&ifp->if_snd, vsc->sc_vqs[1].vq_num - 1);
>   IFQ_SET_READY(&ifp->if_snd);
>   ifmedia_init(&sc->sc_media, 0, vio_media_change, vio_media_status);
>   ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
>   ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
> diff --git sys/net/if.h sys/net/if.h
> index 8d7e390..91c6d18 100644
> --- sys/net/if.h
> +++ sys/net/if.h
> @@ -182,36 +182,37 @@ struct if_status_description {
> /*
>  * Length of interface description, including terminating '\0'.
>  */
> #define   IFDESCRSIZE 64
> 
> #define   IFF_UP  0x1 /* interface is up */
> #define   IFF_BROADCAST   0x2 /* broadcast address valid */
> #define   IFF_DEBUG   0x4 /* turn on debugging */
> #define   IFF_LOOPBACK0x8 /* is a loopback net */
> #define   IFF_POINTOPOINT 0x10/* interface is point-to-point 
> link */
> -#define  IFF_NOTRAILERS  0x20/* avoid use of trailers */
> +#define  IFF_NOMACFILTER 0x20/* Does not reliably filter 
> unicast MACs */
> #define   IFF_RUNNING 0x40/* resources allocated */
> #define   IFF_NOARP   0x80/* no address resolution 
> protocol */
> #define   IFF_PROMISC 0x100   /* receive all packets */
> #define   IFF_ALLMULTI0x200   /* receive all multicast 
> packets */
> #define   IFF_OACTIVE 0x400   /* transmission in progress */
> #define   IFF_SIMPLEX 0x800   /* can't hear own transmissions 
> */
> #define   IFF_LINK0   0x1000  /* per link layer defined bit */
> #define   IFF_LINK1   0x2000  /* per link layer defined bit */
> #define   IFF_LINK2   0x4000  /* per link layer defined bit */
> #define   IFF_MULTICAST   0x8000  /* supports multicast */
> 
> +
> /* flags set internally only: */
> #define   IFF_CANTCHANGE \
>   (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
> - IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
> +

Re: OpenBSD 5.8 on Xeon-D (1540) systems

2016-01-01 Thread Mark Kettenis
> From: Dale Ghent 
> Date: Thu, 31 Dec 2015 15:02:11 -0500
> 
> > On Dec 31, 2015, at 2:43 PM, Mark Kettenis  wrote:
> > 
> > Can you please send me a dmesg as well as the acpidump output for this
> > machine?  That will give me a chance at figuring out what is going
> > wrong.
> 
> Here you go, Mark:
> 
> http://elemental.org/xeon-d.tar.gz

Thanks.  This strange.  I don't quite understand what's happening here
as the ACPI MADT table lists the CPUs in the expected order and cpu0
attaches as the boot processor.

To rule out that the BIOS configuration changes you made somehow
resorted the table, can you try booting a GENERIC kernel?

Thanks,

Mark



Checking MAC address of incoming unicast packets

2016-01-01 Thread Stefan Fritsch
Hi,

by default, the ether_input() checks the destination MAC address of 
incoming unicast packets only if the interface is in promiscous mode. If 
not, it is assumed that the NIC filters unicast packets reliably. 
Unfortunately, for virtio-net this is not the case. There, unicast 
filtering is only best effort, and (depending on configuration) if the 
bridge on the VM host does unicast flodding, unicast packets that are not 
for the VM guest may still be delivered to the VM guest. This is a rather 
annoying problem because it can cause pf to send RST packets to foreign 
connections. (Kudos to mpf@ for debugging this).

There are two possible approaches to fix this problem. Either make the 
vio(4) driver filter out unicast packets that are not for the local MAC, 
which would involve duplicating quite a bit of code from ether_input() in 
vio(4). Or, and I would prefer this, allow the driver to tell 
ether_input() that it needs to check the MAC always, and not only if the 
interface is in promiscous mode.

This could be done with a new flag. There seem to be three possible places 
where this flag could be put:

* ifnet.if_flags
  This is a short and there is no free bit. But the IFF_NOTRAILERS bit has
  become unused recently and could be recycled.

* ifnet.if_xflags
  An int, lots of free bits. But comment says 'extra softnet flags'

* if_data.ifi_capabilities
  An u_int32_t, lots of free bits. 


In the diff below, I went with the first choice because the new IFF_NOMACFILTER
is somewhat similar to IFF_SIMPLEX and because the the check can then be 
nicely folded into the existing check for IFF_PROMISC.

I would welcome any comments, suggestions for a better flag name, OKs, ...

Cheers,
Stefan



diff --git sys/dev/pci/if_vio.c sys/dev/pci/if_vio.c
index 4cd80d5..22fd7cf 100644
--- sys/dev/pci/if_vio.c
+++ sys/dev/pci/if_vio.c
@@ -582,21 +582,21 @@ vio_attach(struct device *parent, struct device *self, 
void *aux)
virtio_start_vq_intr(vsc, &sc->sc_vq[VQCTL]);
vsc->sc_nvqs = 3;
}
}
 
if (vio_alloc_mem(sc) < 0)
goto err;
 
strlcpy(ifp->if_xname, self->dv_xname, IFNAMSIZ);
ifp->if_softc = sc;
-   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+   ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | 
IFF_NOMACFILTER;
ifp->if_start = vio_start;
ifp->if_ioctl = vio_ioctl;
ifp->if_capabilities = IFCAP_VLAN_MTU;
if (features & VIRTIO_NET_F_CSUM)
ifp->if_capabilities |= IFCAP_CSUM_TCPv4|IFCAP_CSUM_UDPv4;
IFQ_SET_MAXLEN(&ifp->if_snd, vsc->sc_vqs[1].vq_num - 1);
IFQ_SET_READY(&ifp->if_snd);
ifmedia_init(&sc->sc_media, 0, vio_media_change, vio_media_status);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
diff --git sys/net/if.h sys/net/if.h
index 8d7e390..91c6d18 100644
--- sys/net/if.h
+++ sys/net/if.h
@@ -182,36 +182,37 @@ struct if_status_description {
 /*
  * Length of interface description, including terminating '\0'.
  */
 #defineIFDESCRSIZE 64
 
 #defineIFF_UP  0x1 /* interface is up */
 #defineIFF_BROADCAST   0x2 /* broadcast address valid */
 #defineIFF_DEBUG   0x4 /* turn on debugging */
 #defineIFF_LOOPBACK0x8 /* is a loopback net */
 #defineIFF_POINTOPOINT 0x10/* interface is point-to-point 
link */
-#defineIFF_NOTRAILERS  0x20/* avoid use of trailers */
+#defineIFF_NOMACFILTER 0x20/* Does not reliably filter 
unicast MACs */
 #defineIFF_RUNNING 0x40/* resources allocated */
 #defineIFF_NOARP   0x80/* no address resolution 
protocol */
 #defineIFF_PROMISC 0x100   /* receive all packets */
 #defineIFF_ALLMULTI0x200   /* receive all multicast 
packets */
 #defineIFF_OACTIVE 0x400   /* transmission in progress */
 #defineIFF_SIMPLEX 0x800   /* can't hear own transmissions 
*/
 #defineIFF_LINK0   0x1000  /* per link layer defined bit */
 #defineIFF_LINK1   0x2000  /* per link layer defined bit */
 #defineIFF_LINK2   0x4000  /* per link layer defined bit */
 #defineIFF_MULTICAST   0x8000  /* supports multicast */
 
+
 /* flags set internally only: */
 #defineIFF_CANTCHANGE \
(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
-   IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
+   IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_NOMACFILTER)
 
 #define IFXF_MPSAFE0x1 /* if_start is mpsafe */
 #defineIFXF_INET6_NOPRIVACY0x4 /* don't autoconf 
privacy */
 #defineIFXF_MPLS  

Re: sed(1): Fix incomplete error message

2016-01-01 Thread Theo Buehler
On Fri, Jan 01, 2016 at 08:47:09PM +0100, Theo Buehler wrote:
> On Fri, Jan 01, 2016 at 02:19:16PM -0500, Michael Reed wrote:
> > Hi,
> > 
> > I noticed that when doing `sed -i` on a file you don't have
> > permission to read, the error message printed isn't very helpful:
> > 
> >   $ sed -i '/test/d' /var/log/Xorg.1.log.old
> >   sed: /var/log/Xorg.1.log.old
> > 
> > The patch below seems to fix the issue for me:
> > 
> >   $ ./sed -i '/test/d' /var/log/Xorg.1.log.old
> >   sed: /var/log/Xorg.1.log.old: Permission denied
> > 
> > Regards,
> >   Michael
> > 

Please disregard my previous mail.  Michael's patch is correct.  Whoever
wants to commit has my ok.



Re: sed(1): Fix incomplete error message

2016-01-01 Thread Theo Buehler
On Fri, Jan 01, 2016 at 02:19:16PM -0500, Michael Reed wrote:
> Hi,
> 
> I noticed that when doing `sed -i` on a file you don't have
> permission to read, the error message printed isn't very helpful:
> 
>   $ sed -i '/test/d' /var/log/Xorg.1.log.old
>   sed: /var/log/Xorg.1.log.old
> 
> The patch below seems to fix the issue for me:
> 
>   $ ./sed -i '/test/d' /var/log/Xorg.1.log.old
>   sed: /var/log/Xorg.1.log.old: Permission denied
> 
> Regards,
>   Michael
> 

I think you're right.  There's also an error message for unlink right
below the message you fixed that would also benefit from strerror.
I couldn't find any others.

How about:

Index: main.c
===
RCS file: /cvs/src/usr.bin/sed/main.c,v
retrieving revision 1.30
diff -u -p -r1.30 main.c
--- main.c  26 Oct 2015 22:22:56 -  1.30
+++ main.c  1 Jan 2016 19:46:05 -
@@ -374,10 +374,10 @@ mf_fgets(SPACE *sp, enum e_spflag spflag
if (len >= sizeof(tmpfname))
error(FATAL, "%s: name too long", fname);
if ((fd = mkstemp(tmpfname)) == -1)
-   error(FATAL, "%s", fname);
+   error(FATAL, "%s: %s", fname, strerror(errno));
if ((outfile = fdopen(fd, "w")) == NULL) {
unlink(tmpfname);
-   error(FATAL, "%s", fname);
+   error(FATAL, "%s: %s", fname, strerror(errno));
}
fchown(fileno(outfile), sb.st_uid, sb.st_gid);
fchmod(fileno(outfile), sb.st_mode & ALLPERMS);



sed(1): Fix incomplete error message

2016-01-01 Thread Michael Reed
Hi,

I noticed that when doing `sed -i` on a file you don't have
permission to read, the error message printed isn't very helpful:

  $ sed -i '/test/d' /var/log/Xorg.1.log.old
  sed: /var/log/Xorg.1.log.old

The patch below seems to fix the issue for me:

  $ ./sed -i '/test/d' /var/log/Xorg.1.log.old
  sed: /var/log/Xorg.1.log.old: Permission denied

Regards,
  Michael



Index: main.c
===
RCS file: /cvs/src/usr.bin/sed/main.c,v
retrieving revision 1.30
diff -u -p -r1.30 main.c
--- main.c  26 Oct 2015 22:22:56 -  1.30
+++ main.c  1 Jan 2016 19:17:16 -
@@ -374,7 +374,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag
if (len >= sizeof(tmpfname))
error(FATAL, "%s: name too long", fname);
if ((fd = mkstemp(tmpfname)) == -1)
-   error(FATAL, "%s", fname);
+   error(FATAL, "%s: %s", fname, strerror(errno));
if ((outfile = fdopen(fd, "w")) == NULL) {
unlink(tmpfname);
error(FATAL, "%s", fname);



Re: npppd: simplify and lock down priv_open()

2016-01-01 Thread Philip Guenther
On Fri, 4 Dec 2015, Todd C. Miller wrote:
> On Fri, 04 Dec 2015 09:47:46 -0800, Philip Guenther wrote:
> > We should fix open(2); please try the diff below.  Are you sure pppx
> > is affected?  pppxioctl()'s FIONBIO case appears to be a no-op.  I
> > certainly agree that bpf and tun are affected.
> 
> Shouldn't the device open function check for FNONBLOCK and handle
> it as needed?

Finally got back to this; this diff should fix open(O_NONBLOCK) of bpf, 
tun, and tap devices.  The bikeshed question is whether this should use 
O_NONBLOCK or FNONBLOCK...

ok?


Index: net/bpf.c
===
RCS file: /data/src/openbsd/src/sys/net/bpf.c,v
retrieving revision 1.131
diff -u -p -r1.131 bpf.c
--- net/bpf.c   5 Dec 2015 10:07:55 -   1.131
+++ net/bpf.c   1 Jan 2016 18:47:42 -
@@ -341,6 +341,9 @@ bpfopen(dev_t dev, int flag, int mode, s
d->bd_bufsize = bpf_bufsize;
d->bd_sig = SIGIO;
 
+   if (flag & O_NONBLOCK)
+   d->bd_rtout = -1;
+
D_GET(d);
 
return (0);
Index: net/if_tun.c
===
RCS file: /data/src/openbsd/src/sys/net/if_tun.c,v
retrieving revision 1.164
diff -u -p -r1.164 if_tun.c
--- net/if_tun.c5 Dec 2015 16:09:09 -   1.164
+++ net/if_tun.c1 Jan 2016 18:47:30 -
@@ -361,6 +361,8 @@ tun_dev_open(struct tun_softc *tp, int f
 
ifp = &tp->tun_if;
tp->tun_flags |= TUN_OPEN;
+   if (flag & O_NONBLOCK)
+   tp->tun_flags |= TUN_NBIO;
 
/* automatically mark the interface running on open */
s = splnet();



Re: hash ports in trunk?

2016-01-01 Thread Stuart Henderson
On 2016/01/01 11:30, Ted Unangst wrote:
> If you're trying to utilize multiple links for aggregation, etc., you have to
> ensure that the packets get hashed differently. Currently we use MAC address
> and IP address, but not port numbers.

These days we're basing the decision on the pf state ID (if present), so in most
cases I'd expect these to already be balanced..



Re: hash ports in trunk?

2016-01-01 Thread Martin Pieuchot
On 01/01/16(Fri) 11:30, Ted Unangst wrote:
> If you're trying to utilize multiple links for aggregation, etc., you have to
> ensure that the packets get hashed differently. Currently we use MAC address
> and IP address, but not port numbers. This makes it challenging to connect two
> servers unless you jump through some hoops and assign multiple IPs, and
> you're still left with the challenge of balancing across IPs, which will not
> be the default behavior for most clients. Adding the port numbers into the mix
> means each connection still goes over a single link, but at least if I use ftp
> to download two files, there's a chance they will be on separate links.
> 
> As far as I know, this is mostly within spec. There's some question of how it
> handles fragments, but practically speaking I expect fragments to be rare? I
> didn't find previous discussion of adding this to trunk, so I thought I'd
> bring it up. Diff below is poc, could also do udp/ipv6/etc.

I don't think it makes sense to continue tweaking the trunk hash logic
until somebody really investigate the performance cost of this function,
especially since it has been converted to use SipHash24.



Adapt video.4 for recent videoio.h change

2016-01-01 Thread Ingo Feinerer
Hi,

video.4 manual page diff to cope with recent videoio.h change. OK?

Best regards,
Ingo

Index: video.4
===
RCS file: /cvs/src/share/man/man4/video.4,v
retrieving revision 1.12
diff -u -p -r1.12 video.4
--- video.4 18 Oct 2014 08:01:34 -  1.12
+++ video.4 1 Jan 2016 16:29:35 -
@@ -54,31 +54,34 @@ struct v4l2_capability {
u_int8_tbus_info[32];
u_int32_t   version;
u_int32_t   capabilities;
-   u_int32_t   reserved[4];
+   u_int32_t   device_caps;
+   u_int32_t   reserved[3];
 };
 .Ed
 .It Dv VIDIOC_ENUM_FMT Fa "struct v4l2_fmtdesc *"
 Enumerate image formats.
 .Bd -literal
 struct v4l2_fmtdesc {
-   u_int32_t   index;
-   enum v4l2_buf_type  type;
-   u_int32_t   flags;
-   u_int8_tdescription[32];
-   u_int32_t   pixelformat;
-   u_int32_t   reserved[4];
+   u_int32_t   index;
+   u_int32_t   type;
+   u_int32_t   flags;
+   u_int8_tdescription[32];
+   u_int32_t   pixelformat;
+   u_int32_t   reserved[4];
 };
 .Ed
 .It Dv VIDIOC_S_FMT Fa "struct v4l2_format *"
 Set the data format.
 .Bd -literal
 struct v4l2_format {
-   enum v4l2_buf_type  type;
+   u_int32_t   type;
union {
struct v4l2_pix_format  pix;
+   struct v4l2_pix_format_mplane   pix_mp;
struct v4l2_window  win;
struct v4l2_vbi_format  vbi;
struct v4l2_sliced_vbi_format   sliced;
+   struct v4l2_sdr_format  sdr;
u_int8_traw_data[200];
 } fmt;
 };
@@ -99,7 +102,8 @@ struct v4l2_input {
u_int32_t   tuner;
v4l2_std_id std;
u_int32_t   status;
-   u_int32_t   reserved[32];
+   u_int32_t   capabilities;
+   u_int32_t   reserved[3];
 };
 .Ed
 .It Dv VIDIOC_G_INPUT Fa "int *"
@@ -110,10 +114,10 @@ Select the current video input.
 Initiate memory mapping or user pointer I/O.
 .Bd -literal
 struct v4l2_requestbuffers {
-   u_int32_t   count;
-   enum v4l2_buf_type  type;
-   enum v4l2_memorymemory;
-   u_int32_t   reserved[2];
+   u_int32_t   count;
+   u_int32_t   type;
+   u_int32_t   memory;
+   u_int32_t   reserved[2];
 };
 .Ed
 .It Dv VIDIOC_QUERYBUF Fa "struct v4l2_buffer *"
@@ -121,20 +125,22 @@ Query the status of a buffer.
 .Bd -literal
 struct v4l2_buffer {
u_int32_t   index;
-   enum v4l2_buf_type  type;
+   u_int32_t   type;
u_int32_t   bytesused;
u_int32_t   flags;
-   enum v4l2_field field;
+   u_int32_t   field;
struct timeval  timestamp;
struct v4l2_timecodetimecode;
u_int32_t   sequence;
-   enum v4l2_memorymemory;
+   u_int32_t   memory;
union {
-   u_int32_t   offset;
-   unsigned long   userptr;
+   u_int32_t   offset;
+   unsigned long   userptr;
+   struct v4l2_plane   *planes;
+   int32_t fd;
} m;
u_int32_t   length;
-   u_int32_t   input;
+   u_int32_t   reserved2;
u_int32_t   reserved;
 };
 .Ed
@@ -169,7 +175,7 @@ struct v4l2_frmivalemun {
union {
struct v4l2_fract   discrete;
struct v4l2_frmival_stepwisestepwise;
-   } un;
+   };
u_int32_t   reserved[2];
 };
 
@@ -183,7 +189,7 @@ struct v4l2_frmival_stepwise {
 Set streaming parameters.
 .Bd -literal
 struct v4l2_streamparm {
-   enum v4l2_buf_type  type;
+   u_int32_t   type;
union {
struct v4l2_captureparm capture;
struct v4l2_outputparm  output;
@@ -218,15 +224,15 @@ Same structures as for
 Enumerate control items.
 .Bd -literal
 struct v4l2_queryctrl {
-   u_int32_t   id;
-   enum v4l2_ctrl_type type;
-   u_int8_tname[32];
-   int32_t minimum;
-   int32_t maximum;
-   int32_t step;
-   int32_t default_value;
-   u_int32_t   flags;
-   u_int32_t   reserved[2];
+   u_int32_t   id;
+   u_int32_t   type;
+   u_int8_tname[32];
+   int32_t minimum;
+   int32_t maximum;
+   int32_t step;
+   int32_t default_value;
+   u_int32_t   flags;
+   u_int32_t   reserved[2];
 };
 .Ed
 .El
@@ -242,6 +248

hash ports in trunk?

2016-01-01 Thread Ted Unangst
If you're trying to utilize multiple links for aggregation, etc., you have to
ensure that the packets get hashed differently. Currently we use MAC address
and IP address, but not port numbers. This makes it challenging to connect two
servers unless you jump through some hoops and assign multiple IPs, and
you're still left with the challenge of balancing across IPs, which will not
be the default behavior for most clients. Adding the port numbers into the mix
means each connection still goes over a single link, but at least if I use ftp
to download two files, there's a chance they will be on separate links.

As far as I know, this is mostly within spec. There's some question of how it
handles fragments, but practically speaking I expect fragments to be rare? I
didn't find previous discussion of adding this to trunk, so I thought I'd
bring it up. Diff below is poc, could also do udp/ipv6/etc.


Index: if_trunk.c
===
RCS file: /cvs/src/sys/net/if_trunk.c,v
retrieving revision 1.125
diff -u -p -r1.125 if_trunk.c
--- if_trunk.c  21 Nov 2015 11:02:23 -  1.125
+++ if_trunk.c  1 Jan 2016 16:15:21 -
@@ -994,6 +994,16 @@ trunk_hashmbuf(struct mbuf *m, SIPHASH_K
return (p);
SipHash24_Update(&ctx, &ip->ip_src, sizeof(struct in_addr));
SipHash24_Update(&ctx, &ip->ip_dst, sizeof(struct in_addr));
+   if (ip->ip_p == IPPROTO_TCP) {
+   struct tcpiphdr *tp, tcpbuf;
+   if ((tp = (struct tcpiphdr *)
+   trunk_gethdr(m, off, sizeof(*tp), &tcpbuf))) {
+   SipHash24_Update(&ctx, &tp->ti_sport,
+   sizeof(uint16_t));
+   SipHash24_Update(&ctx, &tp->ti_dport,
+   sizeof(uint16_t));
+   }
+   }
break;
 #ifdef INET6
case ETHERTYPE_IPV6:



Re: OpenBSDVMM58 -> OpenBSDVMM59 in vmmvar.h

2016-01-01 Thread Ted Unangst

unless something has actually changed, it should not be necessary to increment
this number. the vmm in 5.9 will still speak the same protocol as the vmm that
appeared after 5.8.

Michal Mazurek wrote:
> Index: vmmvar.h
> ===
> RCS file: /cvs/src/sys/arch/amd64/include/vmmvar.h,v
> retrieving revision 1.6
> diff -u -p -r1.6 vmmvar.h
> --- vmmvar.h  17 Dec 2015 09:29:28 -  1.6
> +++ vmmvar.h  1 Jan 2016 16:06:10 -
> @@ -21,7 +21,7 @@
>  #ifndef _MACHINE_VMMVAR_H_
>  #define _MACHINE_VMMVAR_H_
>  
> -#define VMM_HV_SIGNATURE "OpenBSDVMM58"
> +#define VMM_HV_SIGNATURE "OpenBSDVMM59"
>  
>  #define VMM_MAX_DISKS_PER_VM 2
>  #define VMM_MAX_PATH_DISK128
>  
> 
> -- 
> Michal Mazurek
> 



OpenBSDVMM58 -> OpenBSDVMM59 in vmmvar.h

2016-01-01 Thread Michal Mazurek
Index: vmmvar.h
===
RCS file: /cvs/src/sys/arch/amd64/include/vmmvar.h,v
retrieving revision 1.6
diff -u -p -r1.6 vmmvar.h
--- vmmvar.h17 Dec 2015 09:29:28 -  1.6
+++ vmmvar.h1 Jan 2016 16:06:10 -
@@ -21,7 +21,7 @@
 #ifndef _MACHINE_VMMVAR_H_
 #define _MACHINE_VMMVAR_H_
 
-#define VMM_HV_SIGNATURE   "OpenBSDVMM58"
+#define VMM_HV_SIGNATURE   "OpenBSDVMM59"
 
 #define VMM_MAX_DISKS_PER_VM   2
 #define VMM_MAX_PATH_DISK  128
 

-- 
Michal Mazurek



Don't declare main() in pax, adventure, battlestar

2016-01-01 Thread Michal Mazurek
main() does not need to be declared.

Index: bin/pax/extern.h
===
RCS file: /cvs/src/bin/pax/extern.h,v
retrieving revision 1.53
diff -u -p -r1.53 extern.h
--- bin/pax/extern.h19 Mar 2015 05:14:24 -  1.53
+++ bin/pax/extern.h1 Jan 2016 15:27:58 -
@@ -246,7 +246,6 @@ extern char *tempfile;
 extern char *tempbase;
 extern int havechd;
 
-int main(int, char **);
 void sig_cleanup(int);
 
 /*
Index: games/adventure/extern.h
===
RCS file: /cvs/src/games/adventure/extern.h,v
retrieving revision 1.8
diff -u -p -r1.8 extern.h
--- games/adventure/extern.h26 Dec 2015 00:26:39 -  1.8
+++ games/adventure/extern.h1 Jan 2016 15:28:07 -
@@ -72,9 +72,6 @@ struct text;
 void speak(const struct text *);
 void pspeak(int, int);
 
-/* main.c */
-int main(int, char **);
-
 /* save.c */
 int save(const char *);
 int restore(const char *);
Index: games/battlestar/battlestar.c
===
RCS file: /cvs/src/games/battlestar/battlestar.c,v
retrieving revision 1.18
diff -u -p -r1.18 battlestar.c
--- games/battlestar/battlestar.c   4 Dec 2015 17:34:40 -   1.18
+++ games/battlestar/battlestar.c   1 Jan 2016 15:28:07 -
@@ -40,8 +40,6 @@
 #include "extern.h"
 #include "pathnames.h"
 
-int main(int, char *[]);
-
 int
 main(int argc, char *argv[])
 {
 

-- 
Michal Mazurek



Mark some functions as static in vmd.c

2016-01-01 Thread Michal Mazurek
Mark some functions as static.

Don't declare vmd_reload() in vmd.h, do it in vmd.c.

Don't declare main() - we don't have to.

Don't declare vmd_control_run() - it doesn't exist.

Sort declarations by function name.

Index: vmd.c
===
RCS file: /cvs/src/usr.sbin/vmd/vmd.c,v
retrieving revision 1.25
diff -u -p -r1.25 vmd.c
--- vmd.c   11 Dec 2015 10:16:53 -  1.25
+++ vmd.c   1 Jan 2016 14:44:29 -
@@ -36,15 +36,14 @@
 #include "proc.h"
 #include "vmd.h"
 
-__dead void usage(void);
+static __dead void usage(void);
 
-int main(int, char **);
-int vmd_configure(void);
-voidvmd_sighdlr(int sig, short event, void *arg);
-voidvmd_shutdown(void);
-int vmd_control_run(void);
-int vmd_dispatch_control(int, struct privsep_proc *, struct imsg *);
-int vmd_dispatch_vmm(int, struct privsep_proc *, struct imsg *);
+static int  vmd_configure(void);
+static int  vmd_dispatch_control(int, struct privsep_proc *, struct imsg 
*);
+static int  vmd_dispatch_vmm(int, struct privsep_proc *, struct imsg *);
+static void vmd_reload(int, const char *);
+static void vmd_shutdown(void);
+static void vmd_sighdlr(int sig, short event, void *arg);
 
 struct vmd *env;
 
@@ -53,7 +52,7 @@ static struct privsep_proc procs[] = {
{ "vmm",PROC_VMM,   vmd_dispatch_vmm, vmm },
 };
 
-int
+static int
 vmd_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
 {
struct privsep  *ps = p->p_ps;
@@ -132,7 +131,7 @@ vmd_dispatch_control(int fd, struct priv
return (0);
 }
 
-int
+static int
 vmd_dispatch_vmm(int fd, struct privsep_proc *p, struct imsg *imsg)
 {
struct vmop_result   vmr;
@@ -206,7 +205,7 @@ vmd_dispatch_vmm(int fd, struct privsep_
return (0);
 }
 
-void
+static void
 vmd_sighdlr(int sig, short event, void *arg)
 {
struct privsep  *ps = arg;
@@ -285,7 +284,7 @@ vmd_sighdlr(int sig, short event, void *
}
 }
 
-__dead void
+static __dead void
 usage(void)
 {
extern char *__progname;
@@ -406,7 +405,7 @@ main(int argc, char **argv)
return (0);
 }
 
-int
+static int
 vmd_configure(void)
 {
/*
@@ -435,7 +434,7 @@ vmd_configure(void)
return (0);
 }
 
-void
+static void
 vmd_reload(int reset, const char *filename)
 {
/* Switch back to the default config file */
@@ -453,7 +452,7 @@ vmd_reload(int reset, const char *filena
}
 }
 
-void
+static void
 vmd_shutdown(void)
 {
proc_kill(&env->vmd_ps);
Index: vmd.h
===
RCS file: /cvs/src/usr.sbin/vmd/vmd.h,v
retrieving revision 1.16
diff -u -p -r1.16 vmd.h
--- vmd.h   11 Dec 2015 10:16:53 -  1.16
+++ vmd.h   1 Jan 2016 14:44:29 -
@@ -105,7 +105,6 @@ struct vmd {
 };
 
 /* vmd.c */
-voidvmd_reload(int, const char *);
 struct vmd_vm *vm_getbyvmid(uint32_t);
 struct vmd_vm *vm_getbyid(uint32_t);
 struct vmd_vm *vm_getbyname(const char *);
 

-- 
Michal Mazurek



Re: ifconfig: rm not need variable noprint

2016-01-01 Thread Joerg Jung
On Wed, Dec 30, 2015 at 05:24:27PM +0100, Fabian Raetz wrote:
> Hi tech@,
> 
> this patch removes the 'noprint' variable which was added to ifconfig.c in 
> rev 1.216
> and is not in use since rev. 1.220.

Committed, thanks!
 
> Cheers,
> Fabian
> 
> 
> Index: sbin/ifconfig/ifconfig.c
> ===
> --- sbin/ifconfig/ifconfig.c.orig
> +++ sbin/ifconfig/ifconfig.c
> @@ -604,7 +604,6 @@ main(int argc, char *argv[])
>   int Cflag = 0;
>   int gflag = 0;
>   int i;
> - int noprint = 0;
>  
>   /* If no args at all, print all interfaces.  */
>   if (argc < 2) {
> @@ -760,7 +759,7 @@ nextarg:
>   argc--, argv++;
>   }
>  
> - if (argc == 0 && actions == 0 && !noprint) {
> + if (argc == 0 && actions == 0) {
>   printif(ifr.ifr_name, aflag ? ifaliases : 1);
>   exit(0);
>   }
> 



Re: integer truncation in soreceive()

2016-01-01 Thread Stefan Kempf
Thanks. A similar diff was discussed privately with a few
developers during the last few days and is about to be
committed soon.

Martin Natano wrote:
> Another integer overflow: A recv() call with a size of 2^32 bytes causes
> soreceive() to spin in an endless loop, resulting in a system freeze.
> The diff below prevents this behaviour by establishing an upper bound
> for uio_resid before assigning the value to an integer variable with
> smaller width. Also the 'offset' and 'resid' variables are converted to
> use the correct integer types.
> 
> cheers,
> natano
> 
> Index: kern/uipc_socket.c
> ===
> RCS file: /cvs/src/sys/kern/uipc_socket.c,v
> retrieving revision 1.144
> diff -u -p -u -r1.144 uipc_socket.c
> --- kern/uipc_socket.c5 Dec 2015 10:11:53 -   1.144
> +++ kern/uipc_socket.c31 Dec 2015 21:26:01 -
> @@ -613,13 +613,14 @@ soreceive(struct socket *so, struct mbuf
>  {
>   struct mbuf *m, **mp;
>   struct mbuf *cm;
> - int flags, len, error, s, offset;
> + int flags, len, error, s;
> + u_long offset;
>   struct protosw *pr = so->so_proto;
>   struct mbuf *nextrecord;
>   int moff, type = 0;
>   size_t orig_resid = uio->uio_resid;
>   int uio_error = 0;
> - int resid;
> + size_t resid;
>  
>   mp = mp0;
>   if (paddr)
> @@ -639,8 +640,8 @@ soreceive(struct socket *so, struct mbuf
>   if (error)
>   goto bad;
>   do {
> - error = uiomovei(mtod(m, caddr_t),
> - (int) min(uio->uio_resid, m->m_len), uio);
> + error = uiomove(mtod(m, caddr_t),
> + ulmin(uio->uio_resid, m->m_len), uio);
>   m = m_free(m);
>   } while (uio->uio_resid && error == 0 && m);
>  bad:
> @@ -833,11 +834,9 @@ dontblock:
>   panic("receive 3");
>  #endif
>   so->so_state &= ~SS_RCVATMARK;
> - len = uio->uio_resid;
> + len = ulmin(uio->uio_resid, m->m_len - moff);
>   if (so->so_oobmark && len > so->so_oobmark - offset)
>   len = so->so_oobmark - offset;
> - if (len > m->m_len - moff)
> - len = m->m_len - moff;
>   /*
>* If mp is set, just pass back the mbufs.
>* Otherwise copy them out via the uio, then free.
>