df(1) - variable width columns

2016-02-03 Thread Michal Mazurek
Currently df(1) has fixed width columns. With bigger filesystems the
output can become unaligned. On a 100GB filesystem that I have the number
of free inodes is over 10,000,000, which breaks alignment. On another
filesystem that is 3TB in size the number of available 512-blocks is over
5,000,000,000 which also breaks alignment. This is shown in the daily
output email.

I rewrote the display parts of df to first populate an array with
values, and then output it in a way that ensures alignment. A diff is
attached. This is a draft, it needs refinement. Is this something that
would be accepted?

An alternative would be to port FreeBSD's df. Some modifications are
needed though, most significantly it uses Juniper's libxo for output.


Index: df.c
===
RCS file: /cvs/src/bin/df/df.c,v
retrieving revision 1.54
diff -u -p -r1.54 df.c
--- df.c9 Oct 2015 01:37:06 -   1.54
+++ df.c3 Feb 2016 10:55:20 -
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,14 @@
 
 extern char *__progname;
 
+struct col {
+   char*c_label;
+   int  c_width;
+   char**c_vals;
+};
+
+#define COLS 9
+
 char   *getmntpt(char *);
 int selected(const char *);
 voidmaketypelist(char *);
@@ -62,6 +71,10 @@ void  usage(void);
 voidprthumanval(long long);
 voidprthuman(struct statfs *sfsp, unsigned long long);
 
+static void fill_table(struct col *, struct statfs *, int);
+static void print_table(struct col *, int);
+static char *df_getbsize(long *);
+
 intraw_df(char *, struct statfs *);
 extern int ffs_df(int, char *, struct statfs *);
 extern int e2fs_df(int, char *, struct statfs *);
@@ -78,6 +91,7 @@ main(int argc, char *argv[])
int ch, i;
int width, maxwidth;
char *mntpt;
+   struct col cols[COLS];
 
if (pledge("stdio rpath", NULL) == -1)
err(1, "pledge");
@@ -161,22 +175,8 @@ main(int argc, char *argv[])
}
}
 
-   if (mntsize) {
-   maxwidth = 0;
-   for (i = 0; i < mntsize; i++) {
-   width = strlen(mntbuf[i].f_mntfromname);
-   if (width > maxwidth)
-   maxwidth = width;
-   }
-
-   if (maxwidth < 11)
-   maxwidth = 11;
-
-   if (Pflag)
-   posixprint(mntbuf, mntsize, maxwidth);
-   else
-   bsdprint(mntbuf, mntsize, maxwidth);
-   }
+   fill_table(cols, mntbuf, mntsize);
+   print_table(cols, mntsize);
 
exit(mntsize ? 0 : 1);
 }
@@ -277,151 +277,6 @@ regetmntinfo(struct statfs **mntbufp, lo
return (j);
 }
 
-/*
- * "human-readable" output: use 3 digits max.--put unit suffixes at
- * the end.  Makes output compact and easy-to-read esp. on huge disks.
- * Code moved into libutil; this is now just a wrapper.
- */
-void
-prthumanval(long long bytes)
-{
-   char ret[FMT_SCALED_STRSIZE];
-
-   if (fmt_scaled(bytes, ret) == -1) {
-   (void)printf(" %lld", bytes);
-   return;
-   }
-   (void)printf(" %7s", ret);
-}
-
-void
-prthuman(struct statfs *sfsp, unsigned long long used)
-{
-   prthumanval(sfsp->f_blocks * sfsp->f_bsize);
-   prthumanval(used * sfsp->f_bsize);
-   prthumanval(sfsp->f_bavail * sfsp->f_bsize);
-}
-
-/*
- * Convert statfs returned filesystem size into BLOCKSIZE units.
- * Attempts to avoid overflow for large filesystems.
- */
-#define fsbtoblk(num, fsbs, bs) \
-   (((fsbs) != 0 && (fsbs) < (bs)) ? \
-   (num) / ((bs) / (fsbs)) : (num) * ((fsbs) / (bs)))
-
-/*
- * Print out status about a filesystem.
- */
-void
-prtstat(struct statfs *sfsp, int maxwidth, int headerlen, int blocksize)
-{
-   u_int64_t used, inodes;
-   int64_t availblks;
-
-   (void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname);
-   used = sfsp->f_blocks - sfsp->f_bfree;
-   availblks = sfsp->f_bavail + used;
-   if (hflag)
-   prthuman(sfsp, used);
-   else
-   (void)printf(" %*llu %9llu %9lld", headerlen,
-   fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
-   fsbtoblk(used, sfsp->f_bsize, blocksize),
-   fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
-   (void)printf(" %5.0f%%",
-   availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0);
-   if (iflag) {
-   inodes = sfsp->f_files;
-   used = inodes - sfsp->f_ffree;
-   (void)printf(" %7llu %7llu %5.0f%% ", used, sfsp->f_ffree,
-  inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0);
-   } else
-   (void)printf("  ");
-   (void)printf("  %s\n", sfsp->f_mntonname);
-}
-
-/*
- * Print in traditional BSD 

tcpdump: show 802.11 control frames

2016-02-03 Thread Stefan Sperling
Currently, tcpdump displays 802.11 control frames as "type#4" and
doesn't give more information than that.

This diff makes tcpdump show the subtype of such frames, and pretty-print
a few subtypes in verbose mode. There are more subtypes but these can
be pretty-printed later.

This can be tested with:

 ifconfig iwn0 mediaopt monitor up
 tcpdump -n -i iwn0 -y IEEE802_11_RADIO -v -s 1500 type ctl

Whether such frames can be seen depends on the driver's RX filter
settings in monitor mode. Another driver I've tested with is zyd(4).

ok?

Index: print-802_11.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-802_11.c,v
retrieving revision 1.29
diff -u -p -r1.29 print-802_11.c
--- print-802_11.c  1 Feb 2016 10:09:44 -   1.29
+++ print-802_11.c  3 Feb 2016 12:21:20 -
@@ -37,6 +37,25 @@
 #include "addrtoname.h"
 #include "interface.h"
 
+const char *ieee80211_ctl_subtype_name[] = {
+   "reserved#0",
+   "reserved#1",
+   "reserved#2",
+   "reserved#3",
+   "reserved#4",
+   "reserved#5",
+   "reserved#6",
+   "wrapper",
+   "block ack request",
+   "block ack", 
+   "ps poll", 
+   "rts", 
+   "cts", 
+   "ack", 
+   "cf-end", 
+   "cf-end-ack", 
+};
+
 const char *ieee80211_mgt_subtype_name[] = {
"association request",
"association response",
@@ -813,6 +832,69 @@ ieee80211_frame(struct ieee80211_frame *
break;
}
break;
+   case IEEE80211_FC0_TYPE_CTL: {
+   u_int8_t *t = (u_int8_t *) wh;
+
+   printf(": %s", ieee80211_ctl_subtype_name[
+   subtype >> IEEE80211_FC0_SUBTYPE_SHIFT]);
+   if (!vflag)
+   break;
+
+   /* See 802.11 2012 "8.3.1 Control frames". */
+   t += 2; /* skip Frame Control */
+   switch (subtype) {
+   case IEEE80211_FC0_SUBTYPE_RTS:
+   case IEEE80211_FC0_SUBTYPE_BAR:
+   case IEEE80211_FC0_SUBTYPE_BA:
+   TCHECK2(*t, 2); /* Duration */
+   printf(", duration %dms", (t[0] || t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* RA */
+   printf(", ra %s", etheraddr_string(t));
+   t += 6;
+   TCHECK2(*t, 6); /* TA */
+   printf(", ta %s", etheraddr_string(t));
+   if (subtype == IEEE80211_FC0_SUBTYPE_BAR ||
+   subtype == IEEE80211_FC0_SUBTYPE_BA) {
+   u_int16_t ctrl;
+
+   TCHECK2(*t, 2); /* BAR/BA control */
+   ctrl = t[0] | (t[1] << 8);
+   if (ctrl & IEEE80211_BA_ACK_POLICY)
+   printf(", no ack");
+   else
+   printf(", normal ack");
+   if ((ctrl & IEEE80211_BA_MULTI_TID) == 0 &&
+   (ctrl & IEEE80211_BA_COMPRESSED) == 0)
+   printf(", basic variant");
+   else if ((ctrl & IEEE80211_BA_MULTI_TID) &&
+   (ctrl & IEEE80211_BA_COMPRESSED))
+   printf(", multi-tid variant");
+   else if (ctrl & IEEE80211_BA_COMPRESSED)
+   printf(", compressed variant");
+   }
+   break;
+   case IEEE80211_FC0_SUBTYPE_CTS:
+   case IEEE80211_FC0_SUBTYPE_ACK:
+   TCHECK2(*t, 2); /* Duration */
+   printf(", duration %dms", (t[0] || t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* RA */
+   printf(", ra %s", etheraddr_string(t));
+   break;
+   case IEEE80211_FC0_SUBTYPE_PS_POLL:
+   TCHECK2(*t, 2); /* AID */
+   printf(", aid 0x%x", (t[0] || t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* BSSID(RA) */
+   printf(", RA %s", etheraddr_string(t));
+   t += 6;
+   TCHECK2(*t, 6); /* TA */
+   printf(", ta %s", etheraddr_string(t));
+   break;
+   }
+   break;
+   }
default:
printf(": type#%d", type);
break;



Re: sunxi: don't use sxitimer on the sun7i/A20

2016-02-03 Thread Daniel Bolgheroni
On Wed, Feb 03, 2016 at 12:31:33PM +1100, Jonathan Gray wrote:
> You'll want a kernel with the sxidog patch that was committed earlier today.

That's right. Thank you. However, stressing it out a little further, sometimes
I still get some pmap-related issues. Maybe something related to U-Boot?

I have 3 cases here. Most of the times I get what it's in case 3 (ok). However,
I occasionally get something like case 1 and case 2.

 case 1 

U-Boot SPL 2015.10-dirty (Nov 10 2015 - 21:14:20)
DRAM: 1024 MiB
CPU: 91200Hz, AXI/AHB/APB: 3/2/2


U-Boot 2015.10-dirty (Nov 10 2015 - 21:14:20 -0200) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
I2C:   ready
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:serial
Out:   serial
Err:   serial
SCSI:  SUNXI SCSI INIT
SATA link 0 timeout.
AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: ncq stag pm led clo only pmp pio slum part ccc apst
Net:   eth0: ethernet@01c5
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
USB2:   USB EHCI 1.00
USB3:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 2 for devices... 1 USB Device(s) found
Hit any key to stop autoboot:  0
=> setenv ipaddr 192.168.1.7; setenv serverip 192.168.1.5; tftpboot 
bsd.rd.SUNXI.umg; bootm
Speed: 100, full duplex
Using ethernet@01c5 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.7
Filename 'bsd.rd.SUNXI.umg'.
Load address: 0x4200
Loading: #
 #
 #
 #
 #
 #
 #
 #
 
 3.2 MiB/s
done
Bytes transferred = 8032508 (7a90fc hex)
## Booting kernel from Legacy Image at 4200 ...
   Image Name:   boot
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:8032444 Bytes = 7.7 MiB
   Load Address: 4030
   Entry Point:  4030
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...


OpenBSD/sunxi booting ...
arg0 0x0 arg1 0x10bb arg2 0x4100
atag core flags 0 pagesize 0 rootdev 0
atag serial 0x16516616:0b01944c
atag mem start 0x4000 size 0x4000
bootfile:
bootargs:
memory size derived from u-boot
bootconf.mem[0].address = 4000 pages 262144/0x4000
Allocating page tables
freestart = 0x40aaa000, free_pages = 259414 (0x0003f556)
IRQ stack: p0x40ad8000 v0xc0ad8000
ABT stack: p0x40ad9000 v0xc0ad9000
UND stack: p0x40ada000 v0xc0ada000
SVC stack: p0x40adb000 v0xc0adb000
Creating L1 page table at 0x40aac000
Mapping kernel
Constructing L2 page tables
undefined page pmap board type: 4283
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2016 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 5.9 (RAMDISK) #25: Sun Jan 31 23:07:09 BRST 2016
dbolgher...@bbb.my.domain:/usr/src/sys/arch/armv7/compile/RAMDISK
real mem  = 1073741824 (1024MB)
avail mem = 1041670144 (993MB)
mainbus0 at root
cortex0 at mainbus0
ampintc0 at cortex0 nirq 160
agtimer0 at cortex0: tick rate 24000 KHz
cpu0 at mainbus0: ARM Cortex A7 rev 4 (ARMv7 core)
cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
cpu0: 32KB(32b/l,2way) I-cache, 32KB(64b/l,4way) wr-back D-cache
sunxi0 at mainbus0: Allwinner A20
sxipio0 at sunxi0
sxiccmu0 at sunxi0
sxidog0 at sunxi0
sxirtc0 at sunxi0
sxiuart0 at sunxi0: console
sxiuart1 at sunxi0
sxiuart2 at sunxi0
sxiuart3 at sunxi0
sxiuart4 at sunxi0
sxiuart5 at sunxi0
sxiuart6 at sunxi0
sxiuart7 at sunxi0
sxie0 at sunxi0, address 02:16:0b:01:94:4c
rlphy0 at sxie0 phy 1: RTL8201L 10/100 PHY, rev. 1
ahci0 at sunxi0 AHCI 1.1
scsibus0 at ahci0: 32 targets
ehci0 at sunxi0
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Allwinner EHCI root hub" rev 2.00/1.00 addr 1
ehci1 at sunxi0
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "Allwinner EHCI root hub" rev 2.00/1.00 addr 1
gpio0 at sxipio0: 18 pins
gpio1 at sxipio0: 24 pins
gpio2 at sxipio0: 25 pins
gpio3 at sxipio0: 28 pins
gpio4 at sxipio0: 12 pins
gpio5 at sxipio0: 6 pins
gpio6 at sxipio0: 12 pins
gpio7 at sxipio0: 28 pins
gpio8 at sxipio0: 22 pins
boot device: lookup '' failed.
root on rd0a swap on rd0b dump on rd0b
WARNING: clock lost 16831 days
WARNING: CHECK AND RESET THE DATE!
erase ^?, werase ^W, kill ^U, intr ^C, status ^T

uvm_fault(0xca4a91c8, 8000, 2, 0) -> d
Fatal kernel mode data abort: 'Translation Fault (P)'
trapframe: 

Re: tcpdump: show 802.11 control frames

2016-02-03 Thread Stefan Sperling
On Wed, Feb 03, 2016 at 02:05:29PM +0100, Stefan Sperling wrote:
> On Wed, Feb 03, 2016 at 01:36:50PM +0100, Mark Kettenis wrote:
> > > Date: Wed, 3 Feb 2016 13:27:50 +0100
> > > From: Stefan Sperling 
> > > 
> > > Currently, tcpdump displays 802.11 control frames as "type#4" and
> > > doesn't give more information than that.
> > > 
> > > This diff makes tcpdump show the subtype of such frames, and pretty-print
> > > a few subtypes in verbose mode. There are more subtypes but these can
> > > be pretty-printed later.
> > > 
> > > This can be tested with:
> > > 
> > >  ifconfig iwn0 mediaopt monitor up
> > >  tcpdump -n -i iwn0 -y IEEE802_11_RADIO -v -s 1500 type ctl
> > > 
> > > Whether such frames can be seen depends on the driver's RX filter
> > > settings in monitor mode. Another driver I've tested with is zyd(4).
> > > 
> > > ok?
> > 
> > ok kettenis@
> 
> I spotted a bug in my diff. A missing t += 6 inside this if-block:
> 
> + if (subtype == IEEE80211_FC0_SUBTYPE_BAR ||
> + subtype == IEEE80211_FC0_SUBTYPE_BA) {
> 
> 
> Also, s/BA/ba/ in one printf.
> 
> Fixed version below.

David Vasek spotted another problem:
I was using boolean || where binary | was intended.

Fixed in this version.

Index: print-802_11.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-802_11.c,v
retrieving revision 1.29
diff -u -p -r1.29 print-802_11.c
--- print-802_11.c  1 Feb 2016 10:09:44 -   1.29
+++ print-802_11.c  3 Feb 2016 14:59:35 -
@@ -37,6 +37,25 @@
 #include "addrtoname.h"
 #include "interface.h"
 
+const char *ieee80211_ctl_subtype_name[] = {
+   "reserved#0",
+   "reserved#1",
+   "reserved#2",
+   "reserved#3",
+   "reserved#4",
+   "reserved#5",
+   "reserved#6",
+   "wrapper",
+   "block ack request",
+   "block ack", 
+   "ps poll", 
+   "rts", 
+   "cts", 
+   "ack", 
+   "cf-end", 
+   "cf-end-ack", 
+};
+
 const char *ieee80211_mgt_subtype_name[] = {
"association request",
"association response",
@@ -813,6 +832,70 @@ ieee80211_frame(struct ieee80211_frame *
break;
}
break;
+   case IEEE80211_FC0_TYPE_CTL: {
+   u_int8_t *t = (u_int8_t *) wh;
+
+   printf(": %s", ieee80211_ctl_subtype_name[
+   subtype >> IEEE80211_FC0_SUBTYPE_SHIFT]);
+   if (!vflag)
+   break;
+
+   /* See 802.11 2012 "8.3.1 Control frames". */
+   t += 2; /* skip Frame Control */
+   switch (subtype) {
+   case IEEE80211_FC0_SUBTYPE_RTS:
+   case IEEE80211_FC0_SUBTYPE_BAR:
+   case IEEE80211_FC0_SUBTYPE_BA:
+   TCHECK2(*t, 2); /* Duration */
+   printf(", duration %dms", (t[0] | t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* RA */
+   printf(", ra %s", etheraddr_string(t));
+   t += 6;
+   TCHECK2(*t, 6); /* TA */
+   printf(", ta %s", etheraddr_string(t));
+   if (subtype == IEEE80211_FC0_SUBTYPE_BAR ||
+   subtype == IEEE80211_FC0_SUBTYPE_BA) {
+   u_int16_t ctrl;
+
+   t += 6; 
+   TCHECK2(*t, 2); /* BAR/BA control */
+   ctrl = t[0] | (t[1] << 8);
+   if (ctrl & IEEE80211_BA_ACK_POLICY)
+   printf(", no ack");
+   else
+   printf(", normal ack");
+   if ((ctrl & IEEE80211_BA_MULTI_TID) == 0 &&
+   (ctrl & IEEE80211_BA_COMPRESSED) == 0)
+   printf(", basic variant");
+   else if ((ctrl & IEEE80211_BA_MULTI_TID) &&
+   (ctrl & IEEE80211_BA_COMPRESSED))
+   printf(", multi-tid variant");
+   else if (ctrl & IEEE80211_BA_COMPRESSED)
+   printf(", compressed variant");
+   }
+   break;
+   case IEEE80211_FC0_SUBTYPE_CTS:
+   case IEEE80211_FC0_SUBTYPE_ACK:
+   TCHECK2(*t, 2); /* Duration */
+   printf(", duration %dms", (t[0] | t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* RA */
+   printf(", ra %s", etheraddr_string(t));
+   break;
+   case IEEE80211_FC0_SUBTYPE_PS_POLL:
+   TCHECK2(*t, 2); /* AID */
+

Re: sunxi: don't use sxitimer on the sun7i/A20

2016-02-03 Thread Patrick Wildt
On Wed, Feb 03, 2016 at 01:10:57PM -0200, Daniel Bolgheroni wrote:
> On Wed, Feb 03, 2016 at 12:31:33PM +1100, Jonathan Gray wrote:
> > You'll want a kernel with the sxidog patch that was committed earlier today.
> 
> That's right. Thank you. However, stressing it out a little further, sometimes
> I still get some pmap-related issues. Maybe something related to U-Boot?
> 
> I have 3 cases here. Most of the times I get what it's in case 3 (ok). 
> However,
> I occasionally get something like case 1 and case 2.

Yes, that is known.  Here's what I told jsg@ about what it seems to be:

What happens is that for page reference emulation a page is first
inserted as not inserted.  Thus an access will fault and lead to the
fault fixup code.  The code realizes it's page referenced emulation,
hooks in the actual page and then returns.  Unfortunately the TLB seems
to not recognize the entry has changed and still remembers it as not
inserted.

The workaround I have is to invalidate the unified TLB on every PTE_SYNC
and PTE_SYNC_RANGE. PTE_SYNC is done directly after the page has
actually been inserted.

I need to get a better overview about when and how to handle the TLB
before I can propose anything.

Patrick

> 
>  case 1 
> 
> U-Boot SPL 2015.10-dirty (Nov 10 2015 - 21:14:20)
> DRAM: 1024 MiB
> CPU: 91200Hz, AXI/AHB/APB: 3/2/2
> 
> 
> U-Boot 2015.10-dirty (Nov 10 2015 - 21:14:20 -0200) Allwinner Technology
> 
> CPU:   Allwinner A20 (SUN7I)
> I2C:   ready
> DRAM:  1 GiB
> MMC:   SUNXI SD/MMC: 0
> *** Warning - bad CRC, using default environment
> 
> In:serial
> Out:   serial
> Err:   serial
> SCSI:  SUNXI SCSI INIT
> SATA link 0 timeout.
> AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
> flags: ncq stag pm led clo only pmp pio slum part ccc apst
> Net:   eth0: ethernet@01c5
> starting USB...
> USB0:   USB EHCI 1.00
> USB1:   USB OHCI 1.0
> USB2:   USB EHCI 1.00
> USB3:   USB OHCI 1.0
> scanning bus 0 for devices... 1 USB Device(s) found
> scanning bus 2 for devices... 1 USB Device(s) found
> Hit any key to stop autoboot:  0
> => setenv ipaddr 192.168.1.7; setenv serverip 192.168.1.5; tftpboot 
> bsd.rd.SUNXI.umg; bootm
> Speed: 100, full duplex
> Using ethernet@01c5 device
> TFTP from server 192.168.1.5; our IP address is 192.168.1.7
> Filename 'bsd.rd.SUNXI.umg'.
> Load address: 0x4200
> Loading: #
>  #
>  #
>  #
>  #
>  #
>  #
>  #
>  
>  3.2 MiB/s
> done
> Bytes transferred = 8032508 (7a90fc hex)
> ## Booting kernel from Legacy Image at 4200 ...
>Image Name:   boot
>Image Type:   ARM Linux Kernel Image (uncompressed)
>Data Size:8032444 Bytes = 7.7 MiB
>Load Address: 4030
>Entry Point:  4030
>Verifying Checksum ... OK
>Loading Kernel Image ... OK
> 
> Starting kernel ...
> 
> 
> OpenBSD/sunxi booting ...
> arg0 0x0 arg1 0x10bb arg2 0x4100
> atag core flags 0 pagesize 0 rootdev 0
> atag serial 0x16516616:0b01944c
> atag mem start 0x4000 size 0x4000
> bootfile:
> bootargs:
> memory size derived from u-boot
> bootconf.mem[0].address = 4000 pages 262144/0x4000
> Allocating page tables
> freestart = 0x40aaa000, free_pages = 259414 (0x0003f556)
> IRQ stack: p0x40ad8000 v0xc0ad8000
> ABT stack: p0x40ad9000 v0xc0ad9000
> UND stack: p0x40ada000 v0xc0ada000
> SVC stack: p0x40adb000 v0xc0adb000
> Creating L1 page table at 0x40aac000
> Mapping kernel
> Constructing L2 page tables
> undefined page pmap board type: 4283
> Copyright (c) 1982, 1986, 1989, 1991, 1993
> The Regents of the University of California.  All rights reserved.
> Copyright (c) 1995-2016 OpenBSD. All rights reserved.  http://www.OpenBSD.org
> 
> OpenBSD 5.9 (RAMDISK) #25: Sun Jan 31 23:07:09 BRST 2016
> dbolgher...@bbb.my.domain:/usr/src/sys/arch/armv7/compile/RAMDISK
> real mem  = 1073741824 (1024MB)
> avail mem = 1041670144 (993MB)
> mainbus0 at root
> cortex0 at mainbus0
> ampintc0 at cortex0 nirq 160
> agtimer0 at cortex0: tick rate 24000 KHz
> cpu0 at mainbus0: ARM Cortex A7 rev 4 (ARMv7 core)
> cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
> cpu0: 32KB(32b/l,2way) I-cache, 32KB(64b/l,4way) wr-back D-cache
> sunxi0 at mainbus0: Allwinner A20
> sxipio0 at sunxi0
> sxiccmu0 at sunxi0
> sxidog0 at sunxi0
> sxirtc0 at sunxi0
> sxiuart0 at sunxi0: console
> sxiuart1 at sunxi0
> sxiuart2 at 

Typo in FAQ example (faq/pf/example1.html)

2016-02-03 Thread Nils Frohberg
The FAQ explains how to set up dnscrypt-proxy (from ports) in
conjunction with unbound and pf in order to prevent information
leakage. The sample pf rule is currently broken, since the "log"
and "in" keywords are switched.

Index: faq/pf/example1.html
===
RCS file: /cvs/www/faq/pf/example1.html,v
retrieving revision 1.67
diff -u -r1.67 example1.html
--- faq/pf/example1.html24 Jan 2016 18:47:17 -  1.67
+++ faq/pf/example1.html3 Feb 2016 11:46:35 -
@@ -366,7 +366,7 @@
 http://www.openbsd.org/cgi-bin/man.cgi?query=pf.conf;>pf.conf(5)
 rule may be used as an additional safety belt:
 
-block return log in on $int_if inet proto { tcp udp } from any to ! 
192.168.1.1 port 53
+block return in log on $int_if inet proto { tcp udp } from any to ! 
192.168.1.1 port 53
 
 
 As configured in a previous section, our DHCP server will give users a default



Re: sunxi: don't use sxitimer on the sun7i/A20

2016-02-03 Thread Artturi Alm
On Tue, Feb 02, 2016 at 10:55:57AM +1100, Jonathan Gray wrote:
> 
> Thanks, both diffs committed.  Any chance you could create another to
> move the sxitimer_* globals into the softc?

I left out moving of sxitimer_iot and sxitimer_ioh on purpose, as
it would make reviewing this alot worse.
Now if this does get in somewhat as is, i wouldn't have much problems
producing diff to fix/unify armv7 timers allowing to remove some duplicate
code etc. with main reason being that afterwards all of them would be usable
with "-D_STANDALONE", being one of the ingredients to arch/armv7/stand :)
incase it does happen to be on your roadmap.

See the diff simplifying code and correcting comments in sxitimer below.

-Artturi


diff --git a/sys/arch/armv7/sunxi/sun4i.c b/sys/arch/armv7/sunxi/sun4i.c
index 6c3197a..1269b8c 100644
--- a/sys/arch/armv7/sunxi/sun4i.c
+++ b/sys/arch/armv7/sunxi/sun4i.c
@@ -44,17 +44,10 @@ struct armv7_dev sxia1x_devs[] = {
  .mem = { { INTC_ADDR, INTC_SIZE } },
},
 
-   /* Timers/Counters, resources mapped on first unit */
+   /* Timer/Counter */
{ .name = "sxitimer",
  .unit = 0,
- .mem = {  { TIMER_ADDR, TIMERx_SIZE },
-   { CPUCNTRS_ADDR, CPUCNTRS_ADDR } }
-   },
-   { .name = "sxitimer",
- .unit = 1,
-   },
-   { .name = "sxitimer",
- .unit = 2,
+ .mem = { { TIMER_ADDR, TIMERx_SIZE } }
},
 
/* Watchdog Timer */
diff --git a/sys/arch/armv7/sunxi/sunxi.c b/sys/arch/armv7/sunxi/sunxi.c
index dac0348..a8efab96 100644
--- a/sys/arch/armv7/sunxi/sunxi.c
+++ b/sys/arch/armv7/sunxi/sunxi.c
@@ -41,8 +41,6 @@ struct board_dev sun4i_devs[] = {
{ "sxiccmu",0 },
{ "a1xintc",0 },
{ "sxitimer",   0 },
-   { "sxitimer",   1 },
-   { "sxitimer",   2 },
{ "sxidog", 0 },
{ "sxirtc", 0 },
{ "sxiuart",0 },
diff --git a/sys/arch/armv7/sunxi/sunxireg.h b/sys/arch/armv7/sunxi/sunxireg.h
index 8153efa..9151669 100644
--- a/sys/arch/armv7/sunxi/sunxireg.h
+++ b/sys/arch/armv7/sunxi/sunxireg.h
@@ -60,10 +60,7 @@
 
 #defineTIMER_ADDR  0x01c20c00
 #defineTIMERx_SIZE 0x200
-#defineTIMER0_IRQ  22
-#defineTIMER1_IRQ  23
-#defineTIMER2_IRQ  24
-#defineSTATTIMER_IRQ   TIMER1_IRQ /* XXX */
+#defineTIMER_IRQNUM(x) (22 + (x))
 
 #defineWDOG_ADDR   0x01c20c90
 #defineWDOG_SIZE   0x08
diff --git a/sys/arch/armv7/sunxi/sxitimer.c b/sys/arch/armv7/sunxi/sxitimer.c
index 4062b87..a5d5dd0 100644
--- a/sys/arch/armv7/sunxi/sxitimer.c
+++ b/sys/arch/armv7/sunxi/sxitimer.c
@@ -34,7 +34,6 @@
 
 #include 
 #include 
-/* #include  */
 
 #defineTIMER_IER   0x00
 #defineTIMER_ISR   0x04
@@ -75,6 +74,13 @@
 #defineTICKTIMER   0
 #defineSTATTIMER   1
 #defineCNTRTIMER   2
+#defineTICKFREQTIMER0_FREQUENCY
+#defineSTATFREQTIMER1_FREQUENCY
+#defineCNTRFREQTIMER2_FREQUENCY
+/* timers are down-counters, from interval to 0 */
+#defineMAX_IVAL0x  /* max interval */
+
+#defineTIMER_MIN_CYCLES0x20/* 'feel good' value */
 
 void   sxitimer_attach(struct device *, struct device *, void *);
 intsxitimer_tickintr(void *);
@@ -94,27 +100,13 @@ static struct timecounter sxitimer_timecounter = {
 bus_space_tag_tsxitimer_iot;
 bus_space_handle_t sxitimer_ioh;
 
-uint32_t sxitimer_freq[] = {
-   TIMER0_FREQUENCY,
-   TIMER1_FREQUENCY,
-   TIMER2_FREQUENCY,
-   0
-};
-
-uint32_t sxitimer_irq[] = {
-   TIMER0_IRQ,
-   TIMER1_IRQ,
-   TIMER2_IRQ,
-   0
-};
-
-uint32_t sxitimer_stat_tpi, sxitimer_tick_tpi;
-uint32_t sxitimer_statvar, sxitimer_statmin;
-uint32_t sxitimer_tick_nextevt, sxitimer_stat_nextevt;
-uint32_t sxitimer_ticks_err_cnt, sxitimer_ticks_err_sum;
-
 struct sxitimer_softc {
struct device   sc_dev;
+   uint32_tstatvar, statmin;
+   uint32_tstat_tpi, stat_nextevt;
+   uint32_ttick_tpi, tick_nextevt;
+   uint32_tticks_err_cnt, ticks_err_sum;
+
 };
 
 struct cfattachsxitimer_ca = {
@@ -128,12 +120,11 @@ struct cfdriver sxitimer_cd = {
 void
 sxitimer_attach(struct device *parent, struct device *self, void *args)
 {
+   struct sxitimer_softc *sc = (struct sxitimer_softc *)self;
struct armv7_attach_args *aa = args;
-   uint32_t freq, ival, now, cr;
-   int unit = self->dv_unit;
-
-   if (unit != 0)
-   goto skip_init;
+   
+   if (self->dv_unit != 0)
+   panic("sxitimer_attach: unit = %d", self->dv_unit);
 
sxitimer_iot = aa->aa_iot;
 
@@ 

Re: Typo in FAQ example (faq/pf/example1.html)

2016-02-03 Thread Stuart Henderson
On 2016/02/03 15:03, Nils Frohberg wrote:
> The FAQ explains how to set up dnscrypt-proxy (from ports) in

BTW if you are using dnscrypt-proxy please note I have just committed a 
security fix to ports.

(and my objection which tj already knows about still stands ;)



Re: [PATCH] uname, arch/machine -> %c, %a update in PKG_PATH

2016-02-03 Thread Luke Small
I suspect that unless there is a solution that doesn't involve lazy new
users to memorize more complicated named mirrors, you are going to run into
this problem over and over again.

>>  Raf Czlonka wrote:
>> - ftp.openbsd.org is, AFAIC, overloaded

> I haven't been following this thread fully, but I agree that> ftp.openbsd.org 
>  shouldn't be used in examples. Many many people use 
> the
> default mirror whenever possible.



-Luke


Re: [PATCH] uname, arch/machine -> %c, %a update in PKG_PATH

2016-02-03 Thread Stuart Henderson
On 2016/02/03 20:48, Luke Small wrote:
> I suspect that unless there is a solution that doesn't involve lazy new
> users to memorize more complicated named mirrors, you are going to run into
> this problem over and over again.

Why would they need to memorize them? In most cases the one they picked
when they installed OpenBSD will be just fine, if not they can change
pkg.conf to point at a new one from the mirrors list.

> >>  Raf Czlonka wrote:
> >> - ftp.openbsd.org is, AFAIC, overloaded

Whenever I've checked speeds from ftp.openbsd.org they have been fairly
consistent, this isn't the usual expected behaviour of an overloaded
machine. (not super fast, but they have been consistent).



Make iwn(4) pass control frames in monitor mode

2016-02-03 Thread Stefan Sperling
This allows tcpdump to see all control frames with iwn(4).

Index: if_iwn.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.158
diff -u -p -r1.158 if_iwn.c
--- if_iwn.c25 Jan 2016 11:27:11 -  1.158
+++ if_iwn.c3 Feb 2016 16:01:58 -
@@ -2007,8 +2007,11 @@ iwn_rx_done(struct iwn_softc *sc, struct
ifp->if_ierrors++;
return;
}
-   /* Discard frames that are too short. */
-   if (len < sizeof (*wh)) {
+   /* 
+* Discard frames that are too short, unless in monitor mode where we
+* receive control frames which are shorter than regular data frames.
+*/
+   if (len < sizeof (*wh) && ic->ic_opmode != IEEE80211_M_MONITOR) {
DPRINTF(("frame too short: %d\n", len));
ic->ic_stats.is_rx_tooshort++;
ifp->if_ierrors++;



Re: Make iwn(4) pass control frames in monitor mode

2016-02-03 Thread Mark Kettenis
> Date: Wed, 3 Feb 2016 17:03:46 +0100
> From: Stefan Sperling 
> 
> This allows tcpdump to see all control frames with iwn(4).

Hmm, the code below that does look inside the frame.  How do we
guarantee it isn't looking at garbage or reading beyond the end of the
buffer?

> Index: if_iwn.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
> retrieving revision 1.158
> diff -u -p -r1.158 if_iwn.c
> --- if_iwn.c  25 Jan 2016 11:27:11 -  1.158
> +++ if_iwn.c  3 Feb 2016 16:01:58 -
> @@ -2007,8 +2007,11 @@ iwn_rx_done(struct iwn_softc *sc, struct
>   ifp->if_ierrors++;
>   return;
>   }
> - /* Discard frames that are too short. */
> - if (len < sizeof (*wh)) {
> + /* 
> +  * Discard frames that are too short, unless in monitor mode where we
> +  * receive control frames which are shorter than regular data frames.
> +  */
> + if (len < sizeof (*wh) && ic->ic_opmode != IEEE80211_M_MONITOR) {
>   DPRINTF(("frame too short: %d\n", len));
>   ic->ic_stats.is_rx_tooshort++;
>   ifp->if_ierrors++;
> 
> 



Re: [PATCH] uname, arch/machine -> %c, %a update in PKG_PATH

2016-02-03 Thread Luke Small
I didn't know about the miniroot program that edited installpath until I
had a network-assisted upgrade. Every time before, I just did it from disk.
I edited PKG_PATH to do that, from what I recall, I used a text editor and
to do that, I had to memorize the installpath to manually copy it in the
text editor. I am still unaware of a way to copy and paste to an editor
that is capable of running with root privileges.

I just took the claim that the main mirror was burdened at face value.

I wouldn't doubt that the simplest to remember is heavily burdened and the
longest is probably burdened the least.

-Luke

On Wed, Feb 3, 2016 at 9:12 PM, Stuart Henderson  wrote:

> On 2016/02/03 20:48, Luke Small wrote:
> > I suspect that unless there is a solution that doesn't involve lazy new
> > users to memorize more complicated named mirrors, you are going to run
> into
> > this problem over and over again.
>
> Why would they need to memorize them? In most cases the one they picked
> when they installed OpenBSD will be just fine, if not they can change
> pkg.conf to point at a new one from the mirrors list.
>
> > >>  Raf Czlonka wrote:
> > >> - ftp.openbsd.org is, AFAIC, overloaded
>
> Whenever I've checked speeds from ftp.openbsd.org they have been fairly
> consistent, this isn't the usual expected behaviour of an overloaded
> machine. (not super fast, but they have been consistent).
>
>


Re: [PATCH] uname, arch/machine -> %c, %a update in PKG_PATH

2016-02-03 Thread Michael McConville
Stuart Henderson wrote:
> > >>  Raf Czlonka wrote:
> > >> - ftp.openbsd.org is, AFAIC, overloaded
> 
> Whenever I've checked speeds from ftp.openbsd.org they have been
> fairly consistent, this isn't the usual expected behaviour of an
> overloaded machine. (not super fast, but they have been consistent).

At the very least, it seems like there are concerns about their
operating costs.



Re: tcpdump: show 802.11 control frames

2016-02-03 Thread Mark Kettenis
> Date: Wed, 3 Feb 2016 13:27:50 +0100
> From: Stefan Sperling 
> 
> Currently, tcpdump displays 802.11 control frames as "type#4" and
> doesn't give more information than that.
> 
> This diff makes tcpdump show the subtype of such frames, and pretty-print
> a few subtypes in verbose mode. There are more subtypes but these can
> be pretty-printed later.
> 
> This can be tested with:
> 
>  ifconfig iwn0 mediaopt monitor up
>  tcpdump -n -i iwn0 -y IEEE802_11_RADIO -v -s 1500 type ctl
> 
> Whether such frames can be seen depends on the driver's RX filter
> settings in monitor mode. Another driver I've tested with is zyd(4).
> 
> ok?

ok kettenis@

> Index: print-802_11.c
> ===
> RCS file: /cvs/src/usr.sbin/tcpdump/print-802_11.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 print-802_11.c
> --- print-802_11.c1 Feb 2016 10:09:44 -   1.29
> +++ print-802_11.c3 Feb 2016 12:21:20 -
> @@ -37,6 +37,25 @@
>  #include "addrtoname.h"
>  #include "interface.h"
>  
> +const char *ieee80211_ctl_subtype_name[] = {
> + "reserved#0",
> + "reserved#1",
> + "reserved#2",
> + "reserved#3",
> + "reserved#4",
> + "reserved#5",
> + "reserved#6",
> + "wrapper",
> + "block ack request",
> + "block ack", 
> + "ps poll", 
> + "rts", 
> + "cts", 
> + "ack", 
> + "cf-end", 
> + "cf-end-ack", 
> +};
> +
>  const char *ieee80211_mgt_subtype_name[] = {
>   "association request",
>   "association response",
> @@ -813,6 +832,69 @@ ieee80211_frame(struct ieee80211_frame *
>   break;
>   }
>   break;
> + case IEEE80211_FC0_TYPE_CTL: {
> + u_int8_t *t = (u_int8_t *) wh;
> +
> + printf(": %s", ieee80211_ctl_subtype_name[
> + subtype >> IEEE80211_FC0_SUBTYPE_SHIFT]);
> + if (!vflag)
> + break;
> +
> + /* See 802.11 2012 "8.3.1 Control frames". */
> + t += 2; /* skip Frame Control */
> + switch (subtype) {
> + case IEEE80211_FC0_SUBTYPE_RTS:
> + case IEEE80211_FC0_SUBTYPE_BAR:
> + case IEEE80211_FC0_SUBTYPE_BA:
> + TCHECK2(*t, 2); /* Duration */
> + printf(", duration %dms", (t[0] || t[1] << 8));
> + t += 2;
> + TCHECK2(*t, 6); /* RA */
> + printf(", ra %s", etheraddr_string(t));
> + t += 6;
> + TCHECK2(*t, 6); /* TA */
> + printf(", ta %s", etheraddr_string(t));
> + if (subtype == IEEE80211_FC0_SUBTYPE_BAR ||
> + subtype == IEEE80211_FC0_SUBTYPE_BA) {
> + u_int16_t ctrl;
> +
> + TCHECK2(*t, 2); /* BAR/BA control */
> + ctrl = t[0] | (t[1] << 8);
> + if (ctrl & IEEE80211_BA_ACK_POLICY)
> + printf(", no ack");
> + else
> + printf(", normal ack");
> + if ((ctrl & IEEE80211_BA_MULTI_TID) == 0 &&
> + (ctrl & IEEE80211_BA_COMPRESSED) == 0)
> + printf(", basic variant");
> + else if ((ctrl & IEEE80211_BA_MULTI_TID) &&
> + (ctrl & IEEE80211_BA_COMPRESSED))
> + printf(", multi-tid variant");
> + else if (ctrl & IEEE80211_BA_COMPRESSED)
> + printf(", compressed variant");
> + }
> + break;
> + case IEEE80211_FC0_SUBTYPE_CTS:
> + case IEEE80211_FC0_SUBTYPE_ACK:
> + TCHECK2(*t, 2); /* Duration */
> + printf(", duration %dms", (t[0] || t[1] << 8));
> + t += 2;
> + TCHECK2(*t, 6); /* RA */
> + printf(", ra %s", etheraddr_string(t));
> + break;
> + case IEEE80211_FC0_SUBTYPE_PS_POLL:
> + TCHECK2(*t, 2); /* AID */
> + printf(", aid 0x%x", (t[0] || t[1] << 8));
> + t += 2;
> + TCHECK2(*t, 6); /* BSSID(RA) */
> + printf(", RA %s", etheraddr_string(t));
> + t += 6;
> + TCHECK2(*t, 6); /* TA */
> + printf(", ta %s", etheraddr_string(t));
> + break;
> + }
> + break;
> + }
>   default:
>   printf(": type#%d", type);
>   break;
> 
> 



Re: tcpdump: show 802.11 control frames

2016-02-03 Thread Stefan Sperling
On Wed, Feb 03, 2016 at 01:36:50PM +0100, Mark Kettenis wrote:
> > Date: Wed, 3 Feb 2016 13:27:50 +0100
> > From: Stefan Sperling 
> > 
> > Currently, tcpdump displays 802.11 control frames as "type#4" and
> > doesn't give more information than that.
> > 
> > This diff makes tcpdump show the subtype of such frames, and pretty-print
> > a few subtypes in verbose mode. There are more subtypes but these can
> > be pretty-printed later.
> > 
> > This can be tested with:
> > 
> >  ifconfig iwn0 mediaopt monitor up
> >  tcpdump -n -i iwn0 -y IEEE802_11_RADIO -v -s 1500 type ctl
> > 
> > Whether such frames can be seen depends on the driver's RX filter
> > settings in monitor mode. Another driver I've tested with is zyd(4).
> > 
> > ok?
> 
> ok kettenis@

I spotted a bug in my diff. A missing t += 6 inside this if-block:

+   if (subtype == IEEE80211_FC0_SUBTYPE_BAR ||
+   subtype == IEEE80211_FC0_SUBTYPE_BA) {


Also, s/BA/ba/ in one printf.

Fixed version below.

Index: print-802_11.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-802_11.c,v
retrieving revision 1.29
diff -u -p -r1.29 print-802_11.c
--- print-802_11.c  1 Feb 2016 10:09:44 -   1.29
+++ print-802_11.c  3 Feb 2016 12:40:59 -
@@ -37,6 +37,25 @@
 #include "addrtoname.h"
 #include "interface.h"
 
+const char *ieee80211_ctl_subtype_name[] = {
+   "reserved#0",
+   "reserved#1",
+   "reserved#2",
+   "reserved#3",
+   "reserved#4",
+   "reserved#5",
+   "reserved#6",
+   "wrapper",
+   "block ack request",
+   "block ack", 
+   "ps poll", 
+   "rts", 
+   "cts", 
+   "ack", 
+   "cf-end", 
+   "cf-end-ack", 
+};
+
 const char *ieee80211_mgt_subtype_name[] = {
"association request",
"association response",
@@ -813,6 +832,70 @@ ieee80211_frame(struct ieee80211_frame *
break;
}
break;
+   case IEEE80211_FC0_TYPE_CTL: {
+   u_int8_t *t = (u_int8_t *) wh;
+
+   printf(": %s", ieee80211_ctl_subtype_name[
+   subtype >> IEEE80211_FC0_SUBTYPE_SHIFT]);
+   if (!vflag)
+   break;
+
+   /* See 802.11 2012 "8.3.1 Control frames". */
+   t += 2; /* skip Frame Control */
+   switch (subtype) {
+   case IEEE80211_FC0_SUBTYPE_RTS:
+   case IEEE80211_FC0_SUBTYPE_BAR:
+   case IEEE80211_FC0_SUBTYPE_BA:
+   TCHECK2(*t, 2); /* Duration */
+   printf(", duration %dms", (t[0] || t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* RA */
+   printf(", ra %s", etheraddr_string(t));
+   t += 6;
+   TCHECK2(*t, 6); /* TA */
+   printf(", ta %s", etheraddr_string(t));
+   if (subtype == IEEE80211_FC0_SUBTYPE_BAR ||
+   subtype == IEEE80211_FC0_SUBTYPE_BA) {
+   u_int16_t ctrl;
+
+   t += 6; 
+   TCHECK2(*t, 2); /* BAR/BA control */
+   ctrl = t[0] | (t[1] << 8);
+   if (ctrl & IEEE80211_BA_ACK_POLICY)
+   printf(", no ack");
+   else
+   printf(", normal ack");
+   if ((ctrl & IEEE80211_BA_MULTI_TID) == 0 &&
+   (ctrl & IEEE80211_BA_COMPRESSED) == 0)
+   printf(", basic variant");
+   else if ((ctrl & IEEE80211_BA_MULTI_TID) &&
+   (ctrl & IEEE80211_BA_COMPRESSED))
+   printf(", multi-tid variant");
+   else if (ctrl & IEEE80211_BA_COMPRESSED)
+   printf(", compressed variant");
+   }
+   break;
+   case IEEE80211_FC0_SUBTYPE_CTS:
+   case IEEE80211_FC0_SUBTYPE_ACK:
+   TCHECK2(*t, 2); /* Duration */
+   printf(", duration %dms", (t[0] || t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* RA */
+   printf(", ra %s", etheraddr_string(t));
+   break;
+   case IEEE80211_FC0_SUBTYPE_PS_POLL:
+   TCHECK2(*t, 2); /* AID */
+   printf(", aid 0x%x", (t[0] || t[1] << 8));
+   t += 2;
+   TCHECK2(*t, 6); /* BSSID(RA) */
+   printf(", ra %s", etheraddr_string(t));
+   t += 6;
+  

Re: Signed overflow in ufs i_modrev calculation

2016-02-03 Thread Stefan Kempf
Mike Belopuhov wrote:
> Any OKs or objections to this diff?  This looks solid to me, FWIW.

Looks good to me as well.

ok stefan@
 
> On Wed, Jan 27, 2016 at 09:52 +0100, Martin Natano wrote:
> > In ufs, the calculation of i_modrev can produce signed overflow on 32
> > bit architectures (found on i386). The tv.tv_usec * 4294 calculation is
> > designed to move the microseconds part of a struct timeval to the upper
> > bits of an unsigned(!) 32 bit value to make room for simple i_modrev
> > increments, but the calculation is performed signed, causing overflow.
> > The diff below gets rid of the overflow by casting to unsigned first.
> > 
> > While there I replaced the union _qcvt/SETHIGH/SETLOW dance with simple
> > bitshift operations.
> > 
> > Index: ufs/ext2fs/ext2fs_subr.c
> > ===
> > RCS file: /cvs/src/sys/ufs/ext2fs/ext2fs_subr.c,v
> > retrieving revision 1.33
> > diff -u -p -u -r1.33 ext2fs_subr.c
> > --- ufs/ext2fs/ext2fs_subr.c14 Mar 2015 03:38:52 -  1.33
> > +++ ufs/ext2fs/ext2fs_subr.c27 Jan 2016 08:26:05 -
> > @@ -49,25 +49,6 @@
> >  #include 
> >  #include 
> >  
> > -union _qcvt {
> > -   int64_t qcvt;
> > -   int32_t val[2];
> > -};
> > -
> > -#define SETHIGH(q, h) {\
> > -   union _qcvt tmp;\
> > -   tmp.qcvt = (q); \
> > -   tmp.val[_QUAD_HIGHWORD] = (h);  \
> > -   (q) = tmp.qcvt; \
> > -}
> > -
> > -#define SETLOW(q, l) { \
> > -   union _qcvt tmp;\
> > -   tmp.qcvt = (q); \
> > -   tmp.val[_QUAD_LOWWORD] = (l);   \
> > -   (q) = tmp.qcvt; \
> > -}
> > -
> >  #ifdef _KERNEL
> >  
> >  /*
> > @@ -220,8 +201,8 @@ ext2fs_vinit(struct mount *mp, struct vo
> >  
> > /* Initialize modrev times */
> > getmicrouptime();
> > -   SETHIGH(ip->i_modrev, tv.tv_sec);
> > -   SETLOW(ip->i_modrev, tv.tv_usec * 4294);
> > +   ip->i_modrev = (u_quad_t)tv.tv_sec << 32;
> > +   ip->i_modrev |= (u_quad_t)tv.tv_usec * 4294;
> >  
> > *vpp = vp;
> >  
> > Index: ufs/ufs/ufs_vnops.c
> > ===
> > RCS file: /cvs/src/sys/ufs/ufs/ufs_vnops.c,v
> > retrieving revision 1.123
> > diff -u -p -u -r1.123 ufs_vnops.c
> > --- ufs/ufs/ufs_vnops.c 8 Dec 2015 15:31:01 -   1.123
> > +++ ufs/ufs/ufs_vnops.c 27 Jan 2016 08:26:10 -
> > @@ -78,24 +78,6 @@ int filt_ufswrite(struct knote *, long);
> >  int filt_ufsvnode(struct knote *, long);
> >  void filt_ufsdetach(struct knote *);
> >  
> > -union _qcvt {
> > -   int64_t qcvt;
> > -   int32_t val[2];
> > -};
> > -
> > -#define SETHIGH(q, h) { \
> > -   union _qcvt tmp; \
> > -   tmp.qcvt = (q); \
> > -   tmp.val[_QUAD_HIGHWORD] = (h); \
> > -   (q) = tmp.qcvt; \
> > -}
> > -#define SETLOW(q, l) { \
> > -   union _qcvt tmp; \
> > -   tmp.qcvt = (q); \
> > -   tmp.val[_QUAD_LOWWORD] = (l); \
> > -   (q) = tmp.qcvt; \
> > -}
> > -
> >  /*
> >   * A virgin directory (no blushing please).
> >   */
> > @@ -1879,8 +1861,8 @@ ufs_vinit(struct mount *mntp, struct vop
> >  * Initialize modrev times
> >  */
> > getmicrouptime();
> > -   SETHIGH(ip->i_modrev, mtv.tv_sec);
> > -   SETLOW(ip->i_modrev, mtv.tv_usec * 4294);
> > +   ip->i_modrev = (u_quad_t)mtv.tv_sec << 32;
> > +   ip->i_modrev |= (u_quad_t)mtv.tv_usec * 4294;
> > *vpp = vp;
> > return (0);
> >  }
> > 
> > cheers,
> > natano
> > 
> 



tcpdump: fix infinite loop

2016-02-03 Thread Stefan Sperling
Fix an infinite loop when printing a country element in a management
frame in case we hit channel Tx power limits we can't pretty-print.
Also ensure we consume the last item in this list.

Index: print-802_11.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-802_11.c,v
retrieving revision 1.29
diff -u -p -r1.29 print-802_11.c
--- print-802_11.c  1 Feb 2016 10:09:44 -   1.29
+++ print-802_11.c  3 Feb 2016 15:39:58 -
@@ -276,12 +276,14 @@ ieee80211_print_country(u_int8_t *data, 
data += 3;
 
/* channels and corresponding TX power limits */
-   while (len > 3) {
+   while (len >= 3) {
/* no pretty-printing for nonsensical zero values,
 * nor for operating extension IDs (values >= 201) */
if (data[0] == 0 || data[1] == 0 ||
data[0] >= 201 || data[1] >= 201) {
printf(", %d %d %d", data[0], data[1], data[2]);
+   len -= 3;
+   data += 3;
continue;
}
 



Re: Signed overflow in ufs i_modrev calculation

2016-02-03 Thread Mike Belopuhov
Any OKs or objections to this diff?  This looks solid to me, FWIW.

On Wed, Jan 27, 2016 at 09:52 +0100, Martin Natano wrote:
> In ufs, the calculation of i_modrev can produce signed overflow on 32
> bit architectures (found on i386). The tv.tv_usec * 4294 calculation is
> designed to move the microseconds part of a struct timeval to the upper
> bits of an unsigned(!) 32 bit value to make room for simple i_modrev
> increments, but the calculation is performed signed, causing overflow.
> The diff below gets rid of the overflow by casting to unsigned first.
> 
> While there I replaced the union _qcvt/SETHIGH/SETLOW dance with simple
> bitshift operations.
> 
> Index: ufs/ext2fs/ext2fs_subr.c
> ===
> RCS file: /cvs/src/sys/ufs/ext2fs/ext2fs_subr.c,v
> retrieving revision 1.33
> diff -u -p -u -r1.33 ext2fs_subr.c
> --- ufs/ext2fs/ext2fs_subr.c  14 Mar 2015 03:38:52 -  1.33
> +++ ufs/ext2fs/ext2fs_subr.c  27 Jan 2016 08:26:05 -
> @@ -49,25 +49,6 @@
>  #include 
>  #include 
>  
> -union _qcvt {
> - int64_t qcvt;
> - int32_t val[2];
> -};
> -
> -#define SETHIGH(q, h) {  \
> - union _qcvt tmp;\
> - tmp.qcvt = (q); \
> - tmp.val[_QUAD_HIGHWORD] = (h);  \
> - (q) = tmp.qcvt; \
> -}
> -
> -#define SETLOW(q, l) {   \
> - union _qcvt tmp;\
> - tmp.qcvt = (q); \
> - tmp.val[_QUAD_LOWWORD] = (l);   \
> - (q) = tmp.qcvt; \
> -}
> -
>  #ifdef _KERNEL
>  
>  /*
> @@ -220,8 +201,8 @@ ext2fs_vinit(struct mount *mp, struct vo
>  
>   /* Initialize modrev times */
>   getmicrouptime();
> - SETHIGH(ip->i_modrev, tv.tv_sec);
> - SETLOW(ip->i_modrev, tv.tv_usec * 4294);
> + ip->i_modrev = (u_quad_t)tv.tv_sec << 32;
> + ip->i_modrev |= (u_quad_t)tv.tv_usec * 4294;
>  
>   *vpp = vp;
>  
> Index: ufs/ufs/ufs_vnops.c
> ===
> RCS file: /cvs/src/sys/ufs/ufs/ufs_vnops.c,v
> retrieving revision 1.123
> diff -u -p -u -r1.123 ufs_vnops.c
> --- ufs/ufs/ufs_vnops.c   8 Dec 2015 15:31:01 -   1.123
> +++ ufs/ufs/ufs_vnops.c   27 Jan 2016 08:26:10 -
> @@ -78,24 +78,6 @@ int filt_ufswrite(struct knote *, long);
>  int filt_ufsvnode(struct knote *, long);
>  void filt_ufsdetach(struct knote *);
>  
> -union _qcvt {
> - int64_t qcvt;
> - int32_t val[2];
> -};
> -
> -#define SETHIGH(q, h) { \
> - union _qcvt tmp; \
> - tmp.qcvt = (q); \
> - tmp.val[_QUAD_HIGHWORD] = (h); \
> - (q) = tmp.qcvt; \
> -}
> -#define SETLOW(q, l) { \
> - union _qcvt tmp; \
> - tmp.qcvt = (q); \
> - tmp.val[_QUAD_LOWWORD] = (l); \
> - (q) = tmp.qcvt; \
> -}
> -
>  /*
>   * A virgin directory (no blushing please).
>   */
> @@ -1879,8 +1861,8 @@ ufs_vinit(struct mount *mntp, struct vop
>* Initialize modrev times
>*/
>   getmicrouptime();
> - SETHIGH(ip->i_modrev, mtv.tv_sec);
> - SETLOW(ip->i_modrev, mtv.tv_usec * 4294);
> + ip->i_modrev = (u_quad_t)mtv.tv_sec << 32;
> + ip->i_modrev |= (u_quad_t)mtv.tv_usec * 4294;
>   *vpp = vp;
>   return (0);
>  }
> 
> cheers,
> natano
> 



fix A-MPDU params for iwn/iwm (fixes apple airport AP)

2016-02-03 Thread Stefan Sperling
Both drivers forgot to configure some A-MPDU parameters into the
firmware and announced the wrong A-MPDU max size in assoc responses.

Also announce that we don't support SMPS (signalled in htcaps by a value
of 3 rather than zero...)

ok?

Index: if_iwm.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v
retrieving revision 1.76
diff -u -p -r1.76 if_iwm.c
--- if_iwm.c25 Jan 2016 11:27:11 -  1.76
+++ if_iwm.c3 Feb 2016 18:23:17 -
@@ -4466,6 +4466,7 @@ iwm_mvm_sta_send_to_fw(struct iwm_softc 
struct iwm_mvm_add_sta_cmd_v6 add_sta_cmd;
int ret;
uint32_t status;
+   struct ieee80211com *ic = >sc_ic;
 
memset(_sta_cmd, 0, sizeof(add_sta_cmd));
 
@@ -4480,6 +4481,35 @@ iwm_mvm_sta_send_to_fw(struct iwm_softc 
add_sta_cmd.station_flags_msk
|= htole32(IWM_STA_FLG_FAT_EN_MSK | IWM_STA_FLG_MIMO_EN_MSK);
 
+   if (in->in_ni.ni_flags & IEEE80211_NODE_HT) {
+   add_sta_cmd.station_flags_msk
+   |= htole32(IWM_STA_FLG_MAX_AGG_SIZE_MSK |
+   IWM_STA_FLG_AGG_MPDU_DENS_MSK);
+
+   add_sta_cmd.station_flags
+   |= htole32(IWM_STA_FLG_MAX_AGG_SIZE_64K);
+   switch (ic->ic_ampdu_params & IEEE80211_AMPDU_PARAM_SS) {
+   case IEEE80211_AMPDU_PARAM_SS_2:
+   add_sta_cmd.station_flags
+   |= htole32(IWM_STA_FLG_AGG_MPDU_DENS_2US);
+   break;
+   case IEEE80211_AMPDU_PARAM_SS_4:
+   add_sta_cmd.station_flags
+   |= htole32(IWM_STA_FLG_AGG_MPDU_DENS_4US);
+   break;
+   case IEEE80211_AMPDU_PARAM_SS_8:
+   add_sta_cmd.station_flags
+   |= htole32(IWM_STA_FLG_AGG_MPDU_DENS_8US);
+   break;
+   case IEEE80211_AMPDU_PARAM_SS_16:
+   add_sta_cmd.station_flags
+   |= htole32(IWM_STA_FLG_AGG_MPDU_DENS_16US);
+   break;
+   default:
+   break;
+   }
+   }
+
status = IWM_ADD_STA_SUCCESS;
ret = iwm_mvm_send_add_sta_cmd_status(sc, _sta_cmd, );
if (ret)
@@ -6810,11 +6840,11 @@ iwm_attach(struct device *parent, struct
IEEE80211_C_SHPREAMBLE; /* short preamble supported */
 
/* No optional HT features supported for now, */
-   ic->ic_htcaps = 0;
+   ic->ic_htcaps = IEEE80211_HTCAP_SMPS_DIS;
ic->ic_htxcaps = 0;
ic->ic_txbfcaps = 0;
ic->ic_aselcaps = 0;
-   ic->ic_ampdu_params = IEEE80211_AMPDU_PARAM_SS_4;
+   ic->ic_ampdu_params = (IEEE80211_AMPDU_PARAM_SS_4 | 0x3 /* 64k */);
 
ic->ic_sup_rates[IEEE80211_MODE_11A] = ieee80211_std_rateset_11a;
ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b;
Index: if_iwn.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.158
diff -u -p -r1.158 if_iwn.c
--- if_iwn.c25 Jan 2016 11:27:11 -  1.158
+++ if_iwn.c3 Feb 2016 18:42:49 -
@@ -456,11 +456,11 @@ iwn_attach(struct device *parent, struct
IEEE80211_C_PMGT;   /* power saving supported */
 
/* No optional HT features supported for now, */
-   ic->ic_htcaps = 0;
+   ic->ic_htcaps = IEEE80211_HTCAP_SMPS_DIS;
ic->ic_htxcaps = 0;
ic->ic_txbfcaps = 0;
ic->ic_aselcaps = 0;
-   ic->ic_ampdu_params = IEEE80211_AMPDU_PARAM_SS_4;
+   ic->ic_ampdu_params = (IEEE80211_AMPDU_PARAM_SS_4 | 0x3 /* 64k */);
 
 #ifdef notyet
if (sc->sc_flags & IWN_FLAG_HAS_11N) {
@@ -4920,10 +4920,15 @@ iwn_run(struct iwn_softc *sc)
memset(, 0, sizeof node);
IEEE80211_ADDR_COPY(node.macaddr, ni->ni_macaddr);
node.id = IWN_ID_BSS;
-#ifdef notyet
-   node.htflags = htole32(IWN_AMDPU_SIZE_FACTOR(3) |
-   IWN_AMDPU_DENSITY(5));  /* 2us */
-#endif
+   if (ni->ni_flags & IEEE80211_NODE_HT) {
+   node.htmask = (IWN_AMDPU_SIZE_FACTOR_MASK |
+   IWN_AMDPU_DENSITY_MASK);
+   node.htflags = htole32(
+   IWN_AMDPU_SIZE_FACTOR(
+   (ic->ic_ampdu_params & IEEE80211_AMPDU_PARAM_LE)) |
+   IWN_AMDPU_DENSITY(
+   (ic->ic_ampdu_params & IEEE80211_AMPDU_PARAM_SS) >> 2));
+   }
DPRINTF(("adding BSS node\n"));
error = ops->add_node(sc, , 1);
if (error != 0) {
@@ -5070,10 +5075,15 @@ iwn_update_htprot(struct ieee80211com *i
memset(, 0, sizeof node);
IEEE80211_ADDR_COPY(node.macaddr, ni->ni_macaddr);
node.id = IWN_ID_BSS;
-#ifdef notyet
-   node.htflags = htole32(IWN_AMDPU_SIZE_FACTOR(3) |
-   IWN_AMDPU_DENSITY(5));  /* 2us */
-#endif
+  

Re: tmpfs uiomove() conversion

2016-02-03 Thread Stefan Kempf
Martin Natano wrote:
> Stefan Kempf wrote:
> > I'm a bit uneasy though with passing signed values as-is to uiomove().
> > Can we somehow make it explicit that we know that the uiomove() argument is
> > >= 0?
> > 
> > Changing types all over the place would be too much churn though.
> > 
> > I'm leaning towards an explicit size_t cast for signed size arguments as
> > an annotation, e.g.
> > uiomove(buf, (size_t)signed_value, uio);
> 
> I agree, a cast like that would make the intent clear to the reader. See
> the regenerated diff below.
> 
> 
> > And a check in uiomove(). If a negative value gets passed in by
> > accident, it will be caught.
> > 
> > Thoughts?
> >  
> > Index: kern_subr.c
> > ===
> > RCS file: /cvs/src/sys/kern/kern_subr.c,v
> > retrieving revision 1.45
> > diff -u -p -U10 -r1.45 kern_subr.c
> > --- kern_subr.c 11 Dec 2015 16:07:02 -  1.45
> > +++ kern_subr.c 17 Jan 2016 10:56:11 -
> > @@ -46,20 +46,23 @@
> >  #include 
> >  
> >  int
> >  uiomove(void *cp, size_t n, struct uio *uio)
> >  {
> > struct iovec *iov;
> > size_t cnt;
> > int error = 0;
> > struct proc *p;
> >  
> > +   if (n > SSIZE_MAX)
> > +   return (EINVAL);
> > +
> > p = uio->uio_procp;
> >  
> >  #ifdef DIAGNOSTIC
> > if (uio->uio_rw != UIO_READ && uio->uio_rw != UIO_WRITE)
> > panic("uiomove: mode");
> > if (uio->uio_segflg == UIO_USERSPACE && p != curproc)
> > panic("uiomove: proc");
> >  #endif
> > while (n > 0 && uio->uio_resid) {
> > iov = uio->uio_iov;
> 
> I don't think this will fix the underlying problem. It is not possible
> to detect all types of overflow inside of uiomove(). Let's take a look
> at our tmpfs example: An off_t value is passed to uimove(). On i386,
> size_t is an unsigned 32 bit integer and off_t is a signed 64 bit
> integer.  When the off_t value is truncated on conversion, the
> 'if (n > SSIZE_MAX)' condition might trigger, or not, depending on the
> exact value of the original off_t value, resulting in unreliable
> behaviour.

D'oh. Yes, you are right. It's too late for such a check in uiomove().
Let's go with your second diff then.
 
> Unfortunately, I think the best we can do is to audit and fix all
> uiomove() callers, which we already do for the purpose of the
> conversion.
> 
> cheers,
> natano
> 
> 
> Index: tmpfs_subr.c
> ===
> RCS file: /cvs/src/sys/tmpfs/tmpfs_subr.c,v
> retrieving revision 1.14
> diff -u -p -u -r1.14 tmpfs_subr.c
> --- tmpfs_subr.c  17 Apr 2015 04:43:21 -  1.14
> +++ tmpfs_subr.c  17 Jan 2016 12:05:59 -
> @@ -740,7 +740,7 @@ tmpfs_dir_getdotents(tmpfs_node_t *node,
>   return EJUSTRETURN;
>   }
>  
> - if ((error = uiomovei(dp, dp->d_reclen, uio)) != 0) {
> + if ((error = uiomove(dp, dp->d_reclen, uio)) != 0) {
>   return error;
>   }
>  
> @@ -837,7 +837,7 @@ tmpfs_dir_getdents(tmpfs_node_t *node, s
>   }
>  
>   /* Copy out the directory entry and continue. */
> - error = uiomovei(, dent.d_reclen, uio);
> + error = uiomove(, dent.d_reclen, uio);
>   if (error) {
>   break;
>   }
> @@ -1225,7 +1225,7 @@ tmpfs_uiomove(tmpfs_node_t *node, struct
>   if (pgoff + len < PAGE_SIZE) {
>   va = tmpfs_uio_lookup(node, pgnum);
>   if (va != (vaddr_t)NULL)
> - return uiomovei((void *)va + pgoff, len, uio);
> + return uiomove((void *)va + pgoff, len, uio);
>   }
>  
>   if (len >= TMPFS_UIO_MAXBYTES) {
> @@ -1249,7 +1249,7 @@ tmpfs_uiomove(tmpfs_node_t *node, struct
>   return error;
>   }
>  
> - error = uiomovei((void *)va + pgoff, sz, uio);
> + error = uiomove((void *)va + pgoff, sz, uio);
>   if (error == 0 && pgoff + sz < PAGE_SIZE)
>   tmpfs_uio_cache(node, pgnum, va);
>   else
> Index: tmpfs_vnops.c
> ===
> RCS file: /cvs/src/sys/tmpfs/tmpfs_vnops.c,v
> retrieving revision 1.23
> diff -u -p -u -r1.23 tmpfs_vnops.c
> --- tmpfs_vnops.c 8 Dec 2015 15:26:25 -   1.23
> +++ tmpfs_vnops.c 17 Jan 2016 12:06:12 -
> @@ -1017,8 +1017,8 @@ tmpfs_readlink(void *v)
>   KASSERT(vp->v_type == VLNK);
>  
>   node = VP_TO_TMPFS_NODE(vp);
> - error = uiomovei(node->tn_spec.tn_lnk.tn_link,
> - MIN(node->tn_size, uio->uio_resid), uio);
> + error = uiomove(node->tn_spec.tn_lnk.tn_link,
> + MIN((size_t)node->tn_size, uio->uio_resid), uio);
>   tmpfs_update(node, TMPFS_NODE_ACCESSED);
>  
>   return error;



Re: ntfs uiomove() conversion

2016-02-03 Thread Stefan Kempf
Martin Natano wrote:
> On Tue, Feb 02, 2016 at 07:30:08PM +0100, Stefan Kempf wrote:
> > Looks good. I agree with changing left to size_t. One small remark
> > though: size_t is defined as unsigned long. Do the DPRINTFs that print
> > the value of left have to be changed to use %zu in the format string?
> Said DDPRINTFs are in functions not touched by the diff, where 'left' is
> a cn_t. However, this got me thinking: The current code is a wild mix of
> off_t, cn_t and size_t variables for 'left' and the chunk size values
> ('tocopy', 'toread' and 'towrite').

Oh, I missed that, sorry.
 
> Please see the diff below. In addition to the uiomove() change, it also
> unifies the code in ntfs_subr.c to consistently make use of the size_t
> type for aforementioned variables. Note, that the upper bound is a
> variable called 'rsize' (a size_t) in all those cases.

Using the same type for those variables consistently sounds like a
good idea to me. Thanks for updating the diff.
 
> natano
> 
> 
> Index: ntfs/ntfs_subr.c
> ===
> RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v
> retrieving revision 1.44
> diff -u -p -u -r1.44 ntfs_subr.c
> --- ntfs/ntfs_subr.c  14 Mar 2015 03:38:52 -  1.44
> +++ ntfs/ntfs_subr.c  2 Feb 2016 20:09:53 -
> @@ -1340,7 +1340,8 @@ ntfs_writeattr_plain(struct ntfsmount *n
>  {
>   size_t  init;
>   int error = 0;
> - off_t   off = roff, left = rsize, towrite;
> + off_t   off = roff;
> + size_t  left = rsize, towrite;
>   caddr_t data = rdata;
>   struct ntvattr *vap;
>   *initp = 0;
> @@ -1351,7 +1352,7 @@ ntfs_writeattr_plain(struct ntfsmount *n
>   if (error)
>   return (error);
>   towrite = MIN(left, ntfs_cntob(vap->va_vcnend + 1) - off);
> - DDPRINTF("ntfs_writeattr_plain: o: %lld, s: %lld "
> + DDPRINTF("ntfs_writeattr_plain: o: %lld, s: %zu "
>   "(%llu - %llu)\n", off, towrite,
>   vap->va_vcnstart, vap->va_vcnend);
>   error = ntfs_writentvattr_plain(ntmp, ip, vap,
> @@ -1359,11 +1360,9 @@ ntfs_writeattr_plain(struct ntfsmount *n
>towrite, data, , uio);
>   if (error) {
>   DPRINTF("ntfs_writeattr_plain: ntfs_writentvattr_plain "
> - "failed: o: %d, s: %d\n",
> - (u_int32_t)off, (u_int32_t)towrite);
> - DPRINTF("ntfs_writeattr_plain: attrib: %d - %d\n",
> - (u_int32_t)vap->va_vcnstart,
> - (u_int32_t)vap->va_vcnend);
> + "failed: o: %lld, s: %zu\n", off, towrite);
> + DPRINTF("ntfs_writeattr_plain: attrib: %llu - %llu\n",
> + vap->va_vcnstart, vap->va_vcnend);
>   ntfs_ntvattrrele(vap);
>   break;
>   }
> @@ -1390,10 +1389,10 @@ ntfs_writentvattr_plain(struct ntfsmount
>   int error = 0;
>   off_t   off;
>   int cnt;
> - cn_tccn, ccl, cn, left, cl;
> + cn_tccn, ccl, cn, cl;
>   caddr_t data = rdata;
>   struct buf *bp;
> - size_t  tocopy;
> + size_t  left, tocopy;
>  
>   *initp = 0;
>  
> @@ -1414,7 +1413,7 @@ ntfs_writentvattr_plain(struct ntfsmount
>   ccn = vap->va_vruncn[cnt];
>   ccl = vap->va_vruncl[cnt];
>  
> - DDPRINTF("ntfs_writentvattr_plain: left %llu, cn: 0x%llx, "
> + DDPRINTF("ntfs_writentvattr_plain: left %zu, cn: 0x%llx, "
>   "cl: %llu, off: %lld\n", left, ccn, ccl, off);
>  
>   if (ntfs_cntob(ccl) < off) {
> @@ -1440,7 +1439,7 @@ ntfs_writentvattr_plain(struct ntfsmount
>   cl = ntfs_btocl(tocopy + off);
>   KASSERT(cl == 1 && tocopy <= ntfs_cntob(1));
>   DDPRINTF("ntfs_writentvattr_plain: write: cn: 0x%llx "
> - "cl: %llu, off: %lld len: %llu, left: %llu\n",
> + "cl: %llu, off: %lld len: %zu, left: %zu\n",
>   cn, cl, off, tocopy, left);
>   if ((off == 0) && (tocopy == ntfs_cntob(cl)))
>   {
> @@ -1456,7 +1455,7 @@ ntfs_writentvattr_plain(struct ntfsmount
>   }
>   }
>   if (uio) {
> - error = uiomovei(bp->b_data + off, tocopy, uio);
> + error = uiomove(bp->b_data + off, tocopy, uio);
>   if (error != 0)
>   break;
>   } else
> @@ -1495,10 +1494,10 @@ ntfs_readntvattr_plain(struct ntfsmount 
>   *initp = 0;
>   if