Re: etherip alignment issues

2016-09-24 Thread YASUOKA Masahiko
On Sat, 24 Sep 2016 16:45:09 -0400 (EDT)
Martin Brandenburg  wrote:
> On Sun, 25 Sep 2016, YASUOKA Masahiko wrote:
> 
>> On Sat, 24 Sep 2016 13:08:18 -0400 (EDT)
>> Martin Brandenburg  wrote:
>> > On Sat, 24 Sep 2016, YASUOKA Masahiko wrote:
>> >> The problem doesn't repeat on my Octeon.
>> >>
>> >> Can you try the diff below?
>> >>
>> >>   - I assume the diff fixes the problem
>> >>   - A kernel message is added.  please let me know if it appears.
>> >
>> > I got the message, but had another panic.
>> >
>> > ip_etherip_output: leading space is small 2
>>
>> Thanks.  The diff was wrong.  I'm sorry.
>>
>> Let me update the diff.
> 
> Still panicking.

Sorry again.  Can try the diff below?

Finally I understand that any precondition about m->m_data alignment
cannot be assumed.

diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c
index ad58c52..74dba63 100644
--- a/sys/net/if_etherip.c
+++ b/sys/net/if_etherip.c
@@ -354,6 +354,8 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
struct sockaddr_in *src, *dst;
struct etherip_header *eip;
struct ip *ip;
+   struct mbuf *m1;
+   int len;
 
src = (struct sockaddr_in *)&sc->sc_src;
dst = (struct sockaddr_in *)&sc->sc_dst;
@@ -370,24 +372,27 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
 
m->m_flags &= ~(M_BCAST|M_MCAST);
 
-   M_PREPEND(m, sizeof(struct etherip_header), M_DONTWAIT);
-   if (m == NULL) {
-   etheripstat.etherip_adrops++;
+   len = sizeof(struct ip) + sizeof(struct etherip_header);
+   MGET(m1, M_DONTWAIT, m->m_type);
+   if (m1 == NULL) {
+   m_freem(m);
return ENOBUFS;
}
-   eip = mtod(m, struct etherip_header *);
-   eip->eip_ver = ETHERIP_VERSION;
-   eip->eip_res = 0;
-   eip->eip_pad = 0;
+   M_MOVE_PKTHDR(m1, m);
+   m1->m_next = m;
+   m = m1;
+   m->m_len = len;
+   m->m_pkthdr.len += len;
 
-   M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
-   if (m == NULL) {
-   etheripstat.etherip_adrops++;
-   return ENOBUFS;
-   }
ip = mtod(m, struct ip *);
memset(ip, 0, sizeof(struct ip));
 
+   eip = (struct etherip_header *)(ip + 1);
+
+   eip->eip_ver = ETHERIP_VERSION;
+   eip->eip_res = 0;
+   eip->eip_pad = 0;
+
ip->ip_v = IPVERSION;
ip->ip_hl = sizeof(struct ip) >> 2;
ip->ip_id = htons(ip_randomid());
@@ -514,6 +519,8 @@ ip6_etherip_output(struct ifnet *ifp, struct mbuf *m)
struct sockaddr_in6 *src, *dst;
struct etherip_header *eip;
struct ip6_hdr *ip6;
+   struct mbuf *m1;
+   int len;
 
src = (struct sockaddr_in6 *)&sc->sc_src;
dst = (struct sockaddr_in6 *)&sc->sc_dst;
@@ -530,22 +537,24 @@ ip6_etherip_output(struct ifnet *ifp, struct mbuf *m)
 
m->m_flags &= ~(M_BCAST|M_MCAST);
 
-   M_PREPEND(m, sizeof(struct etherip_header), M_DONTWAIT);
-   if (m == NULL) {
-   etheripstat.etherip_adrops++;
+   MGET(m1, M_DONTWAIT, m->m_type);
+   if (m1 == NULL) {
+   m_freem(m);
return ENOBUFS;
}
-   eip = mtod(m, struct etherip_header *);
+   M_MOVE_PKTHDR(m1, m);
+   m1->m_next = m;
+   m = m1;
+   m->m_len = len;
+   m->m_pkthdr.len += len;
+
+   ip6 = mtod(m, struct ip6_hdr *);
+   eip = (struct etherip_header *)(ip6 + 1);
+
eip->eip_ver = ETHERIP_VERSION;
eip->eip_res = 0;
eip->eip_pad = 0;
 
-   M_PREPEND(m, sizeof(struct ip6_hdr), M_DONTWAIT);
-   if (m == NULL) {
-   etheripstat.etherip_adrops++;
-   return ENOBUFS;
-   }
-   ip6 = mtod(m, struct ip6_hdr *);
ip6->ip6_flow = 0;
ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
ip6->ip6_vfc |= IPV6_VERSION;



Re: makes struct kinfo_file to provide va_nlink

2016-09-24 Thread Philip Guenther
On Sat, 24 Sep 2016, Sebastien Marie wrote:
...
> The following diff adds a `va_nlink' member in `struct kinfo_file'. The
> information become available though sysctl(3) via KERN_FILE interface,
> as some others members of `struct vattr'.

The idea seems sound, but the placement of the member in the structure is 
a problem:

> --- sys/sys/sysctl.h  21 Sep 2016 14:06:50 -  1.166
> +++ sys/sys/sysctl.h  24 Sep 2016 11:26:25 -
> @@ -697,6 +697,7 @@ struct kinfo_file {
>   uint64_tva_size;/* UINT64_T: file size in bytes */
>   uint32_tva_mode;/* MODE_T: file access mode and type */
>   uint32_tva_fsid;/* DEV_T: filesystem device */
> + uint32_tva_nlink;   /* NLINK_T: number of references to 
> file */
>   charf_mntonname[KI_MNAMELEN];

That changes the layout of the structure, changing the ABI.  If instead 
the new member is placed at the end of structure then there's no ABI 
break, as the API permits additions to the end of structure.

Also, libkvm/kvm_file2.c should be updated to match the change to 
kern_sysctl.c, so that the information is returned when debugging kernel 
crash dumps.


> Formally, for the final purpose, the information could be only partial: 
> a library dynamically linked isn't referenced via KERN_FILE interface (I 
> am unsure about the availability of the information). But as proper 
> packages will have their signature changed by any library crank, a 
> package update will make old program to be remplaced by a new one.

Yeah, mmap's hold references to files, but the KERN_FILE API doesn't see 
them.  To get that you would need to walk the maps in the uvmspace and 
pick out the non-anonymous mappings, skipping the base executable (which 
_is_ already returned by KERN_FILE).  Doing that without races in the 
kernel would be tricky, as copyout() can sleep if there's a page fault.  
Could you deadlock the kernel by asking for information about your own 
mappings, with sysctl() writing to a mapping which would need to be 
faulted in?

Perhaps better to not hold a lock over copyout() but instead just track 
the vaddr range that was being reported, and then restart the tree walk 
from there.  That guarantees progress with no locks held.


Philip Guenther



Re: /usr/share/man owner fixes for noperm builds

2016-09-24 Thread Theo Buehler
On Sun, Sep 25, 2016 at 01:14:17AM +0200, Theo Buehler wrote:
> usr/share/mandoc.db is currently installed as the build user:
> 
> -rw-r--r--   1 builder  wheel  396748 Sep 24 23:07 mandoc.db
> 
> bsd.own.mk defines MANOWN=root, MANGRP=bin, MANMODE=444 and uses these
> for installing the manpages themselves. Therefore I think we should use
> these variables rather than using BINOWN, BINGRP and hardcoded 444 for
> /usr/share/man/COPYRIGHT, and it makes more sense to me to have the
> mandoc.db owned by root:bin as well. The diff below does this.
> 
> However, the /etc/weekly script will change the ownership of mandoc.db
> to root:wheel (the current owner of the parent /usr/share/man), so I
> wonder if the entire man hierarchies should be switched to be owned by
> root:bin in the /etc/mtree/*BSD*.dist files. But that's a lot of churn
> and the benefit is unclear to me.
> 
> On the other hand, just doing 'chown root:wheel' for mandoc.db and be
> done with it would be a lot simpler...
> 

Sorry, I attached the wrong version of the diff that didn't replace -c
with ${INSTALL_COPY}. 

Index: Makefile
===
RCS file: /cvs/src/share/man/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- Makefile18 Apr 2014 10:00:48 -  1.10
+++ Makefile24 Sep 2016 23:15:20 -
@@ -4,10 +4,11 @@
 SUBDIR=man1 man3 man4 man5 man6 man7 man8 man9
 
 afterinstall:
-   ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 man0/COPYRIGHT \
-   ${DESTDIR}/usr/share/man/COPYRIGHT
+   ${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
+   man0/COPYRIGHT ${DESTDIR}/usr/share/man/COPYRIGHT
 
 makedb:
/usr/sbin/makewhatis -Qv ${DESTDIR}/usr/share/man
+   chown ${MANOWN}:${MANGRP} ${DESTDIR}/usr/share/man/mandoc.db
 
 .include 



/usr/share/man owner fixes for noperm builds

2016-09-24 Thread Theo Buehler
usr/share/mandoc.db is currently installed as the build user:

-rw-r--r--   1 builder  wheel  396748 Sep 24 23:07 mandoc.db

bsd.own.mk defines MANOWN=root, MANGRP=bin, MANMODE=444 and uses these
for installing the manpages themselves. Therefore I think we should use
these variables rather than using BINOWN, BINGRP and hardcoded 444 for
/usr/share/man/COPYRIGHT, and it makes more sense to me to have the
mandoc.db owned by root:bin as well. The diff below does this.

However, the /etc/weekly script will change the ownership of mandoc.db
to root:wheel (the current owner of the parent /usr/share/man), so I
wonder if the entire man hierarchies should be switched to be owned by
root:bin in the /etc/mtree/*BSD*.dist files. But that's a lot of churn
and the benefit is unclear to me.

On the other hand, just doing 'chown root:wheel' for mandoc.db and be
done with it would be a lot simpler...

Index: share/man/Makefile
===
RCS file: /cvs/src/share/man/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- share/man/Makefile  18 Apr 2014 10:00:48 -  1.10
+++ share/man/Makefile  24 Sep 2016 22:39:03 -
@@ -4,10 +4,11 @@
 SUBDIR=man1 man3 man4 man5 man6 man7 man8 man9
 
 afterinstall:
-   ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 man0/COPYRIGHT \
-   ${DESTDIR}/usr/share/man/COPYRIGHT
+   ${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
+   man0/COPYRIGHT ${DESTDIR}/usr/share/man/COPYRIGHT
 
 makedb:
/usr/sbin/makewhatis -Qv ${DESTDIR}/usr/share/man
+   chown ${MANOWN}:${MANGRP} ${DESTDIR}/usr/share/man/mandoc.db
 
 .include 



Boot problem with MBPro 8,2 and OSX/El Capitain and OpenBSD - and workaround

2016-09-24 Thread Sven-Volker Nowarra
Boot problem with MBPro 8,2 and OSX/El Capitain and OpenBSD - and workaround

after updating OSX with El Capitain my Linux and OpenBSD partitions wouldn’t 
boot anymore. Here is how I worked around it: 
I anyhow had to install fresh OpenBSD 6.0, I re-installed it on a partition of 
the internal hard drive. Then I had to do 2 steps: EFI and RADEON: 

1.) get EFIBOOT working 
OpenBSD can do EFI boot (no rEFInd or rEFIt required). Therefor I need to copy  
OpenBSD’s BOOTX64.EFI file to the EFI partition. My EFI partition is the second 
on my drive, so I mount it, and list the contents:

$ diskutil mount /dev/disk0s1
$ ls -l /Volumes/EFI/EFI

I have only APPLE there, looks like the El Capitain update deleted the previous 
files. So I create a new directory:

$ mkdir /Volumes/EFI/EFI/Boot

and copy the BOOTX64.EFI file into this. Perfect, now I reboot, and after the 
sound I hold left alt key, and I have the choice to boot something called „EFI 
BOOT“. Well, ok for me, OpenBSD starts. Next step:


2.) kernel hangs after loading INTELDRM
this is a known problem for me, I already mentioned this here in previous 
versions of OpenBSD: 

http://marc.info/?l=openbsd-tech&m=139161264231456&w=2

I then tried to reboot into UKC („boot -c“), just to discover that the screen 
flickers at the prompt, and the system hangs. 
—> it turns out, that the radeondrm is causing the issues, so I had to start my 
virtual OpenBSD 6.0 system, and change the kernel there:

$ config -e -o bsd.new /bsd
ukc> disable radeondrm
ukc> quit

The new file must be copied onto a USB stick, probably msdos formatted. 
I reboot my MBPro with OpenBSD 6.0 installation disk, choose to upgrade, and 
stop after the fsck was done. This way the disk was mounted readonly at /mnt. I 
need to be able to write to it, so remount r/w, mount also USB stick, and copy 
the new kernel:

$ mount -u -o rw /mnt
$ mount -o ro /dev/sd0i /mnt2
$ cp /mnt2/bsd.new /mnt/bsd
$ reboot

at this point my OpenBSD would boot properly on the MBPro 8,2. 
One observation: the temperature was quit high of the system, I could hear the 
fans running all the time. I had the impression, it was more silent in the 
previous version… Here is my dmesg:

OpenBSD 6.0 (GENERIC) #2148: Tue Jul 26 12:55:20 MDT 2016
   dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC
RTC BIOS diagnostic error 
ff
real mem = 4185079808 (3991MB)
avail mem = 4053819392 (3866MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0x8ad34000 (82 entries)
bios0: vendor Apple Inc. version "MBP81.88Z.0047.B2C.1510261540" date 10/26/15
bios0: Apple Inc. MacBookPro8,2
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP HPET APIC SBST ECDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT 
SSDT SSDT MCFG
acpi0: wakeup devices P0P2(S4) GFX0(S4) PEG1(S4) EC__(S4) GMUX(S3) HDEF(S4) 
GIGE(S4) SDXC(S3) RP01(S4) ARPT(S4) RP02(S4) RP03(S4) RP04(S4) EHC1(S3) 
EHC2(S3) ADP1(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-2675QM CPU @ 2.20GHz, 2195.29 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,NXE,LONG,LAHF,PERF,ITSC,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.1.2, IBE
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
acpiec0 at acpi0
acpimcfg0 at acpi0 addr 0xe000, bus 0-155
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (P0P2)
acpiprt2 at acpi0: bus 5 (PEG1)
acpiprt3 at acpi0: bus 2 (RP01)
acpiprt4 at acpi0: bus 3 (RP02)
acpiprt5 at acpi0: bus 4 (RP03)
acpiprt6 at acpi0: bus -1 (RP04)
acpicpu0 at acpi0: C3(200@91 mwait.1@0x30), C2(500@64 mwait.1@0x10), C1(1000@1 
mwait.1), PSS
"APP0001" at acpi0 not configured
"APP0003" at acpi0 not configured
"ACPI0008" at acpi0 not configured
"ACPI0002" at acpi0 not configured
"APP000B" at acpi0 not configured
acpibat0 at acpi0: BAT0 model "3545797981023400290" type 3545797981528607052 
oem "3545797981528673619"
acpiac0 at acpi0: AC unit online
acpibtn0 at acpi0: LID0
acpibtn1 at acpi0: PWRB
"APP0002" at acpi0 not configured
acpibtn2 at acpi0: SLPB
acpivideo0 at acpi0: IGPU
acpivout0 at acpivideo0: DD02
cpu0: Enhanced SpeedStep 2195 MHz: speeds: 2201, 2200, 2100, 2000, 1900, 1800, 
1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800 MHz
pci0 at

Re: cvs: owner of installed files

2016-09-24 Thread Theo Buehler
On Sun, Sep 18, 2016 at 12:32:17AM +0200, Martin Natano wrote:
> Next round of wrestling with install permissions. This diff adjusts the
> file owner/group for installed files of cvs(1). Ok?

The diff doesn't apply because mkinstalldirs has an odd revision:

> Index: mkinstalldirs
> ===
> RCS file: /cvs/src/gnu/usr.bin/cvs/mkinstalldirs,v
> retrieving revision 1.1.1.3
> diff -u -p -r1.1.1.3 mkinstalldirs
> --- mkinstalldirs 28 Sep 2001 22:45:35 -  1.1.1.3
> +++ mkinstalldirs 17 Sep 2016 22:25:09 -
> @@ -24,7 +24,7 @@ do
>   if test ! -d "$pathcomp"; then
>  echo "mkdir $pathcomp"
>  
> -mkdir "$pathcomp" || lasterr=$?
> +install -d -o root -g wheel "$pathcomp" || lasterr=$?
>  
>  if test ! -d "$pathcomp"; then
> errstatus=$lasterr

I think you wanted to send the diff below.

ok for this

Index: Makefile.bsd-wrapper
===
RCS file: /cvs/src/gnu/usr.bin/cvs/Makefile.bsd-wrapper,v
retrieving revision 1.54
diff -u -p -r1.54 Makefile.bsd-wrapper
--- Makefile.bsd-wrapper20 Sep 2016 18:36:57 -  1.54
+++ Makefile.bsd-wrapper24 Sep 2016 20:54:19 -
@@ -28,21 +28,23 @@ CF=
 config: .FORCE
-rm -f config.cache
PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
-   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \
-   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY}" \
-   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
-   MAKEINFO='makeinfo --no-split' \
-   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
-   --datadir=/usr/libdata ${CF}
+   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o 
${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
+   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 
${BINMODE}" \
+   INSTALL_DATA="${INSTALL} ${INSTALL_COPY} -o ${DOCOWN} -g ${DOCGRP} -m 
${DOCMODE}" \
+   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
+   MAKEINFO='makeinfo --no-split' \
+   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
+   --datadir=/usr/libdata ${CF}
 
 config.status:
PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
-   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \
-   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY}" \
-   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
-   MAKEINFO='makeinfo --no-split' \
-   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
-   --datadir=/usr/libdata ${CF}
+   INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o 
${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
+   INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 
${BINMODE}" \
+   INSTALL_DATA="${INSTALL} ${INSTALL_COPY} -o ${DOCOWN} -g ${DOCGRP} -m 
${DOCMODE}" \
+   ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \
+   MAKEINFO='makeinfo --no-split' \
+   sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \
+   --datadir=/usr/libdata ${CF}
 
 .ifdef NOMAN
 maninstall:
Index: mkinstalldirs
===
RCS file: /cvs/src/gnu/usr.bin/cvs/mkinstalldirs,v
retrieving revision 1.3
diff -u -p -r1.3 mkinstalldirs
--- mkinstalldirs   20 Sep 2016 18:36:57 -  1.3
+++ mkinstalldirs   24 Sep 2016 20:54:19 -
@@ -20,7 +20,7 @@ for file in ${1+"$@"} ; do 
 
  if test ! -d "$pathcomp"; then
 echo "mkdir $pathcomp" 1>&2
-mkdir "$pathcomp" || errstatus=$?
+install -d -o root -g wheel "$pathcomp" || errstatus=$?
  fi
 
  pathcomp="$pathcomp/"
Index: contrib/Makefile.in
===
RCS file: /cvs/src/gnu/usr.bin/cvs/contrib/Makefile.in,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile.in
--- contrib/Makefile.in 20 Sep 2016 18:36:57 -  1.15
+++ contrib/Makefile.in 24 Sep 2016 20:54:19 -
@@ -363,7 +363,8 @@ install-data-local:
echo "test ! -e $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; 
\
echo "  && cd $(DESTDIR)$(bindir) && $(LN_S) 
$(contribscriptdir)/`echo $$p|sed '$(transform)'` ."; \
(test ! -e $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'` \
-   && cd $(DESTDIR)$(bindir) && $(LN_S) $(contribscriptdir)/`echo 
$$p|sed '$(transform)'` .) \
+   && cd $(DESTDIR)$(bindir) && $(LN_S) $(contribscriptdir)/`echo 
$$p|sed '$(transform)'` . \
+   && chown root:bin `echo $$p|sed '$(transform)'`) \
  || (echo "Link creation failed" && if test -f $$p; then \
   echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo 
$$p|sed '$(transform)'`"; \
 

Re: lenovo scrollpoint mouse

2016-09-24 Thread Giannis Tsaraias
On Sat, Sep 24, 2016 at 01:29:39PM -0400, Martin Brandenburg wrote:
> The IBM/Lenovo ScrollPoint mouse is uses a TrackPoint-type mechanism
> rather than a standard mouse wheel. It appears to the system as a
> standard USB mouse with one caveat.
> 
> (http://www.ibmfiles.com/pages/scrollpoint.htm)
> 
> Where a standard USB mouse with a scrollwheel reports one click of the
> wheel as 1 unit in the z direction, this one measures force and reports
> a number from 1 to 64. It is VERY sensitive. Practically any force at
> all will send it into double-digits range. Scrolling at ten to sixty
> times normal speed is not pleasant.
> 
> IBM/Lenovo makes/made a driver for Microsoft Windows which lowered the
> scrolling speed.
> 
> This divides the reported scroll movement by 16, giving a range from 1
> to 4. I have been using this for over a year and find this comfortable.
> 
> Martin
> 

I happen to have one of these mouses, so I just tried out your diff and
it works as expected. The comment for HIDMS_FASTSCROLL is wrong, but the
rest makes sense to me. Hopefully, someone more experienced will chime in.



Re: etherip alignment issues

2016-09-24 Thread Martin Brandenburg
On Sun, 25 Sep 2016, YASUOKA Masahiko wrote:

> On Sat, 24 Sep 2016 13:08:18 -0400 (EDT)
> Martin Brandenburg  wrote:
> > On Sat, 24 Sep 2016, YASUOKA Masahiko wrote:
> >> The problem doesn't repeat on my Octeon.
> >>
> >> Can you try the diff below?
> >>
> >>   - I assume the diff fixes the problem
> >>   - A kernel message is added.  please let me know if it appears.
> >
> > I got the message, but had another panic.
> >
> > ip_etherip_output: leading space is small 2
>
> Thanks.  The diff was wrong.  I'm sorry.
>
> Let me update the diff.

Still panicking.

ddb{3}> show panic
trap type 0x34 (mem address not aligned): pc=11ffa68 npc=11ffa6c 
pstate=44820006
ddb{3}> trace
trap(4007849d370, 34, 11ffa68, 44820006, 4007849db10, 0) at trap+0x360
Lslowtrap_reenter(0, 14, 0, 4007849d566, 2, 6) at Lslowtrap_reenter+0xf8
ip_etherip_output(4000ae96000, 4001443a600, 62, 4007849dc08, 4007849db10, 0) at 
ip_etherip_output+0x130
etherip_start(4000ae96000, 62, 0, 0, 292f, 6) at etherip_start+0xc4
if_start_locked(4000ae96000, 4001443a600, 62, 4007849dc08, 4007849db10, 0) at 
if_start_locked+0x24
if_enqueue(0, 62, 0, 0, 292f, 6) at if_enqueue+0x6c
bridge_ifenqueue(4000a86, 4000ae96000, 62, 4007849dc08, 4007849db10, 0) at 
bridge_ifenqueue+0x30
bridge_output(0, 4001443a600, 0, 0, 292f, 6) at bridge_output+0x260
if_enqueue(4000ae93800, 4001443a600, 4001443a600, 4007849dc08, 4007849db10, 0) 
at if_enqueue+0x90
ether_output(37, 4001443ac00, 4007849dc08, 4001478bab0, 292f, ) at 
ether_output+0x214
ip_output(4001443ac00, 4001443ac68, 4007849dbf8, 0, 0, 0) at ip_output+0x7a0
ip_send_dispatch(0, 4007849dde0, 119bfe0, 0, 4, 2000) at 
ip_send_dispatch+0x64
taskq_thread(40008b18080, 40014bded80, 168fed8, 168fc50, 0, 3b9ac800) at 
taskq_thread+0x6c
proc_trampoline(0, 0, 0, 0, 0, 0) at proc_trampoline+0x14
ddb{3}> sc> poweroff



Re: share/: install ownership fixes

2016-09-24 Thread Theo Buehler
On Tue, Sep 20, 2016 at 08:49:24PM +0200, Martin Natano wrote:
> Ping. Ok?

ok

> On Sat, Sep 10, 2016 at 10:16:20PM +0200, Martin Natano wrote:
> > Another diff I typoed, also found by rpe@. Ok?
> > 
> > Index: share/misc/pcvtfonts/Makefile
> > ===
> > RCS file: /cvs/src/share/misc/pcvtfonts/Makefile,v
> > retrieving revision 1.6
> > diff -u -p -r1.6 Makefile
> > --- share/misc/pcvtfonts/Makefile   13 May 2002 15:27:58 -  1.6
> > +++ share/misc/pcvtfonts/Makefile   8 Sep 2016 20:54:08 -
> > @@ -16,12 +16,9 @@ FONTDIR =${BINDIR}/misc/pcvtfonts
> >  all: $(FONTS)
> >  
> >  install: ${FONTS}
> > -   @if [ ! -d ${DESTDIR}${FONTDIR} ]; then mkdir ${DESTDIR}${FONTDIR};fi
> > -   @for i in ${FONTS}; do \
> > -   echo "installing font $$i into ${DESTDIR}${FONTDIR}"; \
> > -   install -c -m ${LIBMODE} -o ${LIBOWN} -g ${LIBGRP} \
> > -   $$i ${DESTDIR}${FONTDIR}; \
> > -   done
> > +   ${INSTALL} -d -o root -g wheel ${DESTDIR}${FONTDIR}
> > +   ${INSTALL} ${INSTALL_COPY} -m ${LIBMODE} -o ${LIBOWN} -g ${LIBGRP} \
> > +   ${FONTS} ${DESTDIR}${FONTDIR}
> >  
> >  clean:
> > rm -f ${CLEANFILES}
> > Index: share/snmp/Makefile
> > ===
> > RCS file: /cvs/src/share/snmp/Makefile,v
> > retrieving revision 1.4
> > diff -u -p -r1.4 Makefile
> > --- share/snmp/Makefile 29 Jan 2016 03:06:00 -  1.4
> > +++ share/snmp/Makefile 8 Sep 2016 21:02:02 -
> > @@ -8,6 +8,7 @@ FILES+= OPENBSD-RELAYD-MIB.txt
> >  all clean cleandir depend lint obj tags: _SUBDIRUSE
> >  
> >  realinstall:
> > -   ${INSTALL} -c -m 0444 ${FILES} ${DESTDIR}${BINDIR}/snmp/mibs
> > +   ${INSTALL} ${INSTALL_COPY} -o root -g wheel -m 0444 \
> > +   ${FILES} ${DESTDIR}${BINDIR}/snmp/mibs
> >  
> >  .include 
> > Index: share/termtypes/Makefile
> > ===
> > RCS file: /cvs/src/share/termtypes/Makefile,v
> > retrieving revision 1.24
> > diff -u -p -r1.24 Makefile
> > --- share/termtypes/Makefile3 Dec 2015 11:30:46 -   1.24
> > +++ share/termtypes/Makefile10 Sep 2016 20:11:58 -
> > @@ -14,12 +14,14 @@ termcap: termtypes.master
> > @[ -s ${.TARGET} ] || exit 1
> >  
> >  realinstall:
> > +   ${INSTALL} -d -o root -g wheel ${DESTDIR}${BINDIR}/terminfo
> > find terminfo -type f -exec \
> >  ${INSTALL} -D ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
> >  {} ${DESTDIR}${BINDIR}/{} \;
> > ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 termcap \
> >  ${DESTDIR}${BINDIR}/misc/termcap
> > ln -fs ${BINDIR}/misc/termcap ${DESTDIR}/etc/termcap
> > +   chown -h root:wheel ${DESTDIR}/etc/termcap
> >  
> >  clean:
> > rm -f termcap
> 



Re: ownership fix for /usr/lib/locate/src.db

2016-09-24 Thread Theo Buehler
On Tue, Sep 20, 2016 at 10:09:28PM +0200, Martin Natano wrote:
> Without this diff src.db is installed as the build user when makeing a
> noperm release.  is required for BINOWN/BINGRP. Ok?

ok

> 
> natano
> 
> 
> Index: Makefile
> ===
> RCS file: /cvs/src/distrib/sets/Makefile,v
> retrieving revision 1.1
> diff -u -p -r1.1 Makefile
> --- Makefile  9 Jul 2014 19:23:28 -   1.1
> +++ Makefile  20 Sep 2016 19:55:10 -
> @@ -4,5 +4,8 @@ DB = /usr/lib/locate/src.db
>  
>  makedb:
>   /bin/sh ${.CURDIR}/makelocatedb ${OSrev} >${DESTDIR}${DB}
> + chown ${BINOWN}:${BINGRP} ${DESTDIR}${DB}
>  
>  .PHONY: makedb
> +
> +.include 
> 



Re: hashfree: sizes for free(9) when using hashinit.

2016-09-24 Thread Ted Unangst
Philip Guenther wrote:
> On Wed, Sep 21, 2016 at 1:30 AM, Mathieu -  wrote:
> >> > I'm introducing hashfree, a counterpart to hashinit in order to pass the
> >> > size to free(9) while hiding the implementation details.

thanks, committed.

> I don't understand the rename to hashfree() from the NetBSD name of
> hashdone().  Yes, it has different args...but so does our hashinit()!

hashfree makes sense to me. that's what it does.



Re: etherip alignment issues

2016-09-24 Thread YASUOKA Masahiko
On Sat, 24 Sep 2016 13:08:18 -0400 (EDT)
Martin Brandenburg  wrote:
> On Sat, 24 Sep 2016, YASUOKA Masahiko wrote:
>> The problem doesn't repeat on my Octeon.
>>
>> Can you try the diff below?
>>
>>   - I assume the diff fixes the problem
>>   - A kernel message is added.  please let me know if it appears.
> 
> I got the message, but had another panic.
> 
> ip_etherip_output: leading space is small 2

Thanks.  The diff was wrong.  I'm sorry.

Let me update the diff.

diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c
index ad58c52..d3b1ed6 100644
--- a/sys/net/if_etherip.c
+++ b/sys/net/if_etherip.c
@@ -352,8 +352,9 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
 {
struct etherip_softc *sc = (struct etherip_softc *)ifp->if_softc;
struct sockaddr_in *src, *dst;
-   struct etherip_header *eip;
+   struct etherip_header eip;
struct ip *ip;
+   int error;
 
src = (struct sockaddr_in *)&sc->sc_src;
dst = (struct sockaddr_in *)&sc->sc_dst;
@@ -370,21 +371,19 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
 
m->m_flags &= ~(M_BCAST|M_MCAST);
 
-   M_PREPEND(m, sizeof(struct etherip_header), M_DONTWAIT);
+   M_PREPEND(m, sizeof(struct ip) + sizeof(eip), M_DONTWAIT);
if (m == NULL) {
etheripstat.etherip_adrops++;
return ENOBUFS;
}
-   eip = mtod(m, struct etherip_header *);
-   eip->eip_ver = ETHERIP_VERSION;
-   eip->eip_res = 0;
-   eip->eip_pad = 0;
+   eip.eip_ver = ETHERIP_VERSION;
+   eip.eip_res = 0;
+   eip.eip_pad = 0;
+   error = m_copyback(m, sizeof(struct ip), sizeof(eip), (caddr_t)&eip,
+   M_DONTWAIT);
+   if (error != 0)
+   return error;
 
-   M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
-   if (m == NULL) {
-   etheripstat.etherip_adrops++;
-   return ENOBUFS;
-   }
ip = mtod(m, struct ip *);
memset(ip, 0, sizeof(struct ip));
 



Re: make rdaemon less error-prone

2016-09-24 Thread Jeremie Courreges-Anglas
j...@wxcvbn.org (Jeremie Courreges-Anglas) writes:

> Simple idiom: always initialize the pre-opened fd to -1, and within
> rdaemon() test whether the passed fd is valid.
>
> ok?

Updated diff after Theo suggested avoiding the fcntl call if possible.


Index: usr.sbin/rtadvd/rtadvd.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
retrieving revision 1.81
diff -u -p -r1.81 rtadvd.c
--- usr.sbin/rtadvd/rtadvd.c21 Sep 2016 18:54:24 -  1.81
+++ usr.sbin/rtadvd/rtadvd.c24 Sep 2016 17:56:55 -
@@ -1320,6 +1320,12 @@ ra_timer_update(struct rainfo *rai)
 int
 rdaemon(int devnull)
 {
+   if (devnull == -1) {
+   errno = EBADF;
+   return (-1);
+   }
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:
Index: usr.sbin/dhcrelay/dhcrelay.c
===
RCS file: /cvs/src/usr.sbin/dhcrelay/dhcrelay.c,v
retrieving revision 1.42
diff -u -p -r1.42 dhcrelay.c
--- usr.sbin/dhcrelay/dhcrelay.c15 Sep 2016 16:16:03 -  1.42
+++ usr.sbin/dhcrelay/dhcrelay.c24 Sep 2016 17:22:20 -
@@ -368,6 +368,12 @@ usage(void)
 int
 rdaemon(int devnull)
 {
+   if (devnull == -1) {
+   errno = EBADF;
+   return (-1);
+   }
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:
Index: usr.sbin/ftp-proxy/ftp-proxy.c
===
RCS file: /cvs/src/usr.sbin/ftp-proxy/ftp-proxy.c,v
retrieving revision 1.35
diff -u -p -r1.35 ftp-proxy.c
--- usr.sbin/ftp-proxy/ftp-proxy.c  15 Sep 2016 16:16:03 -  1.35
+++ usr.sbin/ftp-proxy/ftp-proxy.c  24 Sep 2016 17:55:37 -
@@ -633,6 +633,7 @@ main(int argc, char *argv[])
verbose = 0;
 
/* Other initialization. */
+   devnull = -1;
id_count= 1;
session_count   = 0;
 
@@ -1142,6 +1143,12 @@ usage(void)
 int
 rdaemon(int devnull)
 {
+   if (devnull == -1) {
+   errno = EBADF;
+   return (-1);
+   }
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:
Index: usr.sbin/tftpd/tftpd.c
===
RCS file: /cvs/src/usr.sbin/tftpd/tftpd.c,v
retrieving revision 1.37
diff -u -p -r1.37 tftpd.c
--- usr.sbin/tftpd/tftpd.c  4 Sep 2016 14:41:49 -   1.37
+++ usr.sbin/tftpd/tftpd.c  24 Sep 2016 17:55:58 -
@@ -1584,6 +1584,12 @@ getip(void *s)
 int
 rdaemon(int devnull)
 {
+   if (devnull == -1) {
+   errno = EBADF;
+   return (-1);
+   }
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: hashfree: sizes for free(9) when using hashinit.

2016-09-24 Thread Mathieu -
Philip Guenther wrote:
> On Wed, Sep 21, 2016 at 1:30 AM, Mathieu -  wrote:
> > Ted Unangst wrote:
> >> Mathieu - wrote:
> >> > Hello list,
> >> >
> >> > I'm introducing hashfree, a counterpart to hashinit in order to pass the
> >> > size to free(9) while hiding the implementation details.
> >> > Most of the api users are converted in the patch below, those not
> >> > included just simply do not free the memory (pid hash table etc). All,
> >> > except for one case, the input hashtbl in in_pcb, because at free time
> >> > the size is really not known, so it needs more moving of things around
> >> > and is out the scope of this patch.
> >> >
> >> > Manpage diff courtesy of natano@ on an old version of the diff!
> >>
> >> looks good
> >
> > Anyone ?
> 
> I don't understand the rename to hashfree() from the NetBSD name of
> hashdone().  Yes, it has different args...but so does our hashinit()!

It's plain and simple ignorance on my side. I usually crosscheck with
the other BSD but in this case I didn't, and came up with this name on my
own. Obviously "xxfree" was the best thing I could come up with considering
that I was tracking the sizes given to free(9).

I don't have a strong opinion on this one though and can generate
another diff with "hashdone" instead.
> 
> 
> 
> tedu, were you going to commit this?
> 
> 
> Philip Guenther
> 



Re: clang: kern/vfs_subr.c

2016-09-24 Thread Jeremie Courreges-Anglas
Mark Kettenis  writes:

> Finally a case where clang isn't entirely helpful.  Because vp->v_tag
> is an enum, clang thinks its value can't be bigger than 15 and that
> the vp->v_tag >= nitems(vtags) check is therefore always false.  But I
> think we want to prevent an out-of-bounds access here if the vnode is
> corrupted somehow.  Casting to u_int makes the compiler shut up.
>
> ok?

ok jca@

>
> Index: kern/vfs_subr.c
> ===
> RCS file: /cvs/src/sys/kern/vfs_subr.c,v
> retrieving revision 1.253
> diff -u -p -r1.253 vfs_subr.c
> --- kern/vfs_subr.c   16 Sep 2016 03:21:16 -  1.253
> +++ kern/vfs_subr.c   24 Sep 2016 17:16:52 -
> @@ -2162,8 +2162,9 @@ vfs_vnode_print(void *v, int full,
>   struct vnode *vp = v;
>  
>   (*pr)("tag %s(%d) type %s(%d) mount %p typedata %p\n",
> -   vp->v_tag >= nitems(vtags)? "":vtags[vp->v_tag], vp->v_tag,
> -   vp->v_type >= nitems(vtypes)? "":vtypes[vp->v_type],
> +   (u_int)vp->v_tag >= nitems(vtags)? "":vtags[vp->v_tag],
> +   vp->v_tag,
> +   (u_int)vp->v_type >= nitems(vtypes)? "":vtypes[vp->v_type],
> vp->v_type, vp->v_mount, vp->v_mountedhere);
>  
>   (*pr)("data %p usecount %d writecount %d holdcnt %d numoutput %d\n",
>


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: clang: dev/acpi/dsdt.c and dev/i2c/iatp.c

2016-09-24 Thread Jeremie Courreges-Anglas
Mark Kettenis  writes:

> In both cases we're comparing an array to NULL.
>
> Note that in dev/acpi/dsdt.c I changed the strcmp() condition to == 0;
> using ! for string pointer comparison always confuses me.  I can drop
> that change if people consider it controversial.

No objection.

> ok?

ok jca@

>
> Index: dev/acpi/dsdt.c
> ===
> RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
> retrieving revision 1.224
> diff -u -p -r1.224 dsdt.c
> --- dev/acpi/dsdt.c   2 Sep 2016 13:59:51 -   1.224
> +++ dev/acpi/dsdt.c   24 Sep 2016 17:13:21 -
> @@ -585,7 +585,7 @@ aml_notify_dev(const char *pnpid, int no
>   return;
>  
>   SLIST_FOREACH(pdata, &aml_notify_list, link)
> - if (pdata->pnpid && !strcmp(pdata->pnpid, pnpid))
> + if (strcmp(pdata->pnpid, pnpid) == 0)
>   pdata->cbproc(pdata->node, notify_value, pdata->cbarg);
>  }
>  
> Index: dev/i2c/iatp.c
> ===
> RCS file: /cvs/src/sys/dev/i2c/iatp.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 iatp.c
> --- dev/i2c/iatp.c4 Sep 2016 10:45:29 -   1.2
> +++ dev/i2c/iatp.c24 Sep 2016 17:13:21 -
> @@ -548,8 +548,7 @@ iatp_init(struct iatp_softc *sc)
>  
>   /* find this machine's button config */
>   sc->t19_button_bit = -1;
> - if (hw_vendor == NULL || hw_prod == NULL ||
> - sc->sc_hid == NULL)
> + if (hw_vendor == NULL || hw_prod == NULL)
>   break;
>  
>   for (m = mxt_t19_button_map_devs; m->vendor != NULL;
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: clang: warning fix for vmt.c

2016-09-24 Thread Jeremie Courreges-Anglas
Mark Kettenis  writes:

> Using a variable for the format string isn't a godd idea.
>
> ok?

ok jca@

>
> Index: dev/pv/vmt.c
> ===
> RCS file: /cvs/src/sys/dev/pv/vmt.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 vmt.c
> --- dev/pv/vmt.c  3 Feb 2016 14:24:05 -   1.9
> +++ dev/pv/vmt.c  24 Sep 2016 17:08:35 -
> @@ -419,7 +419,7 @@ vmt_kvop(void *arg, int op, char *key, c
>   goto done;
>   }
>  
> - if (vm_rpc_send_rpci_tx(sc, buf) != 0) {
> + if (vm_rpc_send_rpci_tx(sc, "%s", buf) != 0) {
>   DPRINTF("%s: error sending command: %s\n", DEVNAME(sc), buf);
>   sc->sc_rpc_error = 1;
>   error = EIO;
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: clang dev/pv/hyperv.c

2016-09-24 Thread Jeremie Courreges-Anglas
Mark Kettenis  writes:

> Another obvious mistake caught by clang.
>
> ok?

ok jca@

>
> Index: dev/pv/hyperv.c
> ===
> RCS file: /cvs/src/sys/dev/pv/hyperv.c,v
> retrieving revision 1.16
> diff -u -p -r1.16 hyperv.c
> --- dev/pv/hyperv.c   20 Sep 2016 10:27:14 -  1.16
> +++ dev/pv/hyperv.c   24 Sep 2016 17:04:24 -
> @@ -700,7 +700,7 @@ hv_vmbus_connect(struct hv_softc *sc)
>   sc->sc_revents = (u_long *)((caddr_t)sc->sc_events + (PAGE_SIZE >> 1));
>  
>   sc->sc_monitor[0] = km_alloc(PAGE_SIZE, &kv_any, &kp_zero, &kd_nowait);
> - if (sc->sc_monitor == NULL) {
> + if (sc->sc_monitor[0] == NULL) {
>   printf(": failed to allocate monitor page 1\n");
>   goto errout;
>   }
> @@ -710,7 +710,7 @@ hv_vmbus_connect(struct hv_softc *sc)
>   }
>  
>   sc->sc_monitor[1] = km_alloc(PAGE_SIZE, &kv_any, &kp_zero, &kd_nowait);
> - if (sc->sc_monitor == NULL) {
> + if (sc->sc_monitor[1] == NULL) {
>   printf(": failed to allocate monitor page 2\n");
>   goto errout;
>   }
>


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



lenovo scrollpoint mouse

2016-09-24 Thread Martin Brandenburg
The IBM/Lenovo ScrollPoint mouse is uses a TrackPoint-type mechanism
rather than a standard mouse wheel. It appears to the system as a
standard USB mouse with one caveat.

(http://www.ibmfiles.com/pages/scrollpoint.htm)

Where a standard USB mouse with a scrollwheel reports one click of the
wheel as 1 unit in the z direction, this one measures force and reports
a number from 1 to 64. It is VERY sensitive. Practically any force at
all will send it into double-digits range. Scrolling at ten to sixty
times normal speed is not pleasant.

IBM/Lenovo makes/made a driver for Microsoft Windows which lowered the
scrolling speed.

This divides the reported scroll movement by 16, giving a range from 1
to 4. I have been using this for over a year and find this comfortable.

Martin

Index: dev/hid/hidms.c
==
RCS file: /cvs/src/sys/dev/hid/hidms.c,v
retrieving revision 1.3
diff -u -p -r1.3 hidms.c
--- dev/hid/hidms.c 22 May 2016 22:06:11 -  1.3
+++ dev/hid/hidms.c 22 Sep 2016 00:55:18 -
@@ -385,6 +385,11 @@ hidms_input(struct hidms *ms, uint8_t *d
(ms->sc_tsscale.maxy - ms->sc_tsscale.miny);
}
 
+   if (ms->sc_flags & HIDMS_FASTSCROLL) {
+   dz /= 16;
+   dw /= 16;
+   }
+
for (i = 0; i < ms->sc_num_buttons; i++)
if (hid_get_data(data, len, &ms->sc_loc_btn[i]))
buttons |= (1 << HIDMS_BUT(i));
Index: dev/hid/hidmsvar.h
===
RCS file: /cvs/src/sys/dev/hid/hidmsvar.h,v
retrieving revision 1.1
diff -u -p -r1.1 hidmsvar.h
--- dev/hid/hidmsvar.h  8 Jan 2016 15:54:13 -   1.1
+++ dev/hid/hidmsvar.h  22 Sep 2016 00:55:18 -
@@ -43,18 +43,19 @@ struct tsscale {
 struct hidms {
int sc_enabled;
int sc_flags;   /* device configuration */
-#define HIDMS_SPUR_BUT_UP  0x001   /* spurious button up events */
-#define HIDMS_Z0x002   /* Z direction available */
-#define HIDMS_REVZ 0x004   /* Z-axis is reversed */
-#define HIDMS_W0x008   /* W direction available */
-#define HIDMS_REVW 0x010   /* W-axis is reversed */
-#define HIDMS_LEADINGBYTE  0x020   /* Unknown leading byte */
-#define HIDMS_ABSX 0x040   /* X-axis is absolute */
-#define HIDMS_ABSY 0x080   /* Y-axis is absolute */
-#define HIDMS_TIP  0x100   /* Tip switch on a digitiser pen */
-#define HIDMS_BARREL   0x200   /* Barrel switch on a digitiser pen */
-#define HIDMS_ERASER   0x400   /* Eraser switch on a digitiser pen */
-#define HIDMS_MS_BAD_CLASS 0x800   /* Mouse doesn't identify properly */
+#define HIDMS_SPUR_BUT_UP  0x0001  /* spurious button up events */
+#define HIDMS_Z0x0002  /* Z direction available */
+#define HIDMS_REVZ 0x0004  /* Z-axis is reversed */
+#define HIDMS_W0x0008  /* W direction available */
+#define HIDMS_REVW 0x0010  /* W-axis is reversed */
+#define HIDMS_LEADINGBYTE  0x0020  /* Unknown leading byte */
+#define HIDMS_ABSX 0x0040  /* X-axis is absolute */
+#define HIDMS_ABSY 0x0080  /* Y-axis is absolute */
+#define HIDMS_TIP  0x0100  /* Tip switch on a digitiser pen */
+#define HIDMS_BARREL   0x0200  /* Barrel switch on a digitiser pen */
+#define HIDMS_ERASER   0x0400  /* Eraser switch on a digitiser pen */
+#define HIDMS_MS_BAD_CLASS 0x0800  /* Mouse doesn't identify properly */
+#define HIDMS_FASTSCROLL   0x1000  /* Eraser switch on a digitiser pen */
 
int sc_num_buttons;
u_int32_t   sc_buttons; /* mouse button status */
Index: dev/usb/ums.c
===
RCS file: /cvs/src/sys/dev/usb/ums.c,v
retrieving revision 1.43
diff -u -p -r1.43 ums.c
--- dev/usb/ums.c   12 Jan 2016 19:16:21 -  1.43
+++ dev/usb/ums.c   22 Sep 2016 00:55:18 -
@@ -143,6 +143,8 @@ ums_attach(struct device *parent, struct
qflags |= HIDMS_MS_BAD_CLASS;
if (quirks & UQ_MS_LEADING_BYTE)
qflags |= HIDMS_LEADINGBYTE;
+   if (quirks & UQ_LENOVO_FASTSCROLL)
+   qflags |= HIDMS_FASTSCROLL;
 
if (hidms_setup(self, ms, qflags, uha->reportid, desc, size) != 0)
return;
Index: dev/usb/usb_quirks.c
===
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.74
diff -u -p -r1.74 usb_quirks.c
--- dev/usb/usb_quirks.c27 Nov 2015 10:59:32 -  1.74
+++ dev/usb/usb_quirks.c22 Sep 2016 00:55:18 -
@@ -150,6 +150,9 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLNOTEBOOK2,
ANY, { UQ_MS_BAD_CLA

clang: kern/vfs_subr.c

2016-09-24 Thread Mark Kettenis
Finally a case where clang isn't entirely helpful.  Because vp->v_tag
is an enum, clang thinks its value can't be bigger than 15 and that
the vp->v_tag >= nitems(vtags) check is therefore always false.  But I
think we want to prevent an out-of-bounds access here if the vnode is
corrupted somehow.  Casting to u_int makes the compiler shut up.

ok?


Index: kern/vfs_subr.c
===
RCS file: /cvs/src/sys/kern/vfs_subr.c,v
retrieving revision 1.253
diff -u -p -r1.253 vfs_subr.c
--- kern/vfs_subr.c 16 Sep 2016 03:21:16 -  1.253
+++ kern/vfs_subr.c 24 Sep 2016 17:16:52 -
@@ -2162,8 +2162,9 @@ vfs_vnode_print(void *v, int full,
struct vnode *vp = v;
 
(*pr)("tag %s(%d) type %s(%d) mount %p typedata %p\n",
- vp->v_tag >= nitems(vtags)? "":vtags[vp->v_tag], vp->v_tag,
- vp->v_type >= nitems(vtypes)? "":vtypes[vp->v_type],
+ (u_int)vp->v_tag >= nitems(vtags)? "":vtags[vp->v_tag],
+ vp->v_tag,
+ (u_int)vp->v_type >= nitems(vtypes)? "":vtypes[vp->v_type],
  vp->v_type, vp->v_mount, vp->v_mountedhere);
 
(*pr)("data %p usecount %d writecount %d holdcnt %d numoutput %d\n",



clang: dev/acpi/dsdt.c and dev/i2c/iatp.c

2016-09-24 Thread Mark Kettenis
In both cases we're comparing an array to NULL.

Note that in dev/acpi/dsdt.c I changed the strcmp() condition to == 0;
using ! for string pointer comparison always confuses me.  I can drop
that change if people consider it controversial.

ok?


Index: dev/acpi/dsdt.c
===
RCS file: /cvs/src/sys/dev/acpi/dsdt.c,v
retrieving revision 1.224
diff -u -p -r1.224 dsdt.c
--- dev/acpi/dsdt.c 2 Sep 2016 13:59:51 -   1.224
+++ dev/acpi/dsdt.c 24 Sep 2016 17:13:21 -
@@ -585,7 +585,7 @@ aml_notify_dev(const char *pnpid, int no
return;
 
SLIST_FOREACH(pdata, &aml_notify_list, link)
-   if (pdata->pnpid && !strcmp(pdata->pnpid, pnpid))
+   if (strcmp(pdata->pnpid, pnpid) == 0)
pdata->cbproc(pdata->node, notify_value, pdata->cbarg);
 }
 
Index: dev/i2c/iatp.c
===
RCS file: /cvs/src/sys/dev/i2c/iatp.c,v
retrieving revision 1.2
diff -u -p -r1.2 iatp.c
--- dev/i2c/iatp.c  4 Sep 2016 10:45:29 -   1.2
+++ dev/i2c/iatp.c  24 Sep 2016 17:13:21 -
@@ -548,8 +548,7 @@ iatp_init(struct iatp_softc *sc)
 
/* find this machine's button config */
sc->t19_button_bit = -1;
-   if (hw_vendor == NULL || hw_prod == NULL ||
-   sc->sc_hid == NULL)
+   if (hw_vendor == NULL || hw_prod == NULL)
break;
 
for (m = mxt_t19_button_map_devs; m->vendor != NULL;



clang: warning fix for vmt.c

2016-09-24 Thread Mark Kettenis
Using a variable for the format string isn't a godd idea.

ok?


Index: dev/pv/vmt.c
===
RCS file: /cvs/src/sys/dev/pv/vmt.c,v
retrieving revision 1.9
diff -u -p -r1.9 vmt.c
--- dev/pv/vmt.c3 Feb 2016 14:24:05 -   1.9
+++ dev/pv/vmt.c24 Sep 2016 17:08:35 -
@@ -419,7 +419,7 @@ vmt_kvop(void *arg, int op, char *key, c
goto done;
}
 
-   if (vm_rpc_send_rpci_tx(sc, buf) != 0) {
+   if (vm_rpc_send_rpci_tx(sc, "%s", buf) != 0) {
DPRINTF("%s: error sending command: %s\n", DEVNAME(sc), buf);
sc->sc_rpc_error = 1;
error = EIO;



Re: clang -Wpointer-sign

2016-09-24 Thread Mark Kettenis
> From: "Theo de Raadt" 
> Date: Sat, 24 Sep 2016 10:44:19 -0600
> 
> Please add this to all arch/*/conf/conf/Makefile.* files.
> 
> We are trying to minimize differences between these files.  If
> that effort isn't made, they will eventually wander far apart from
> each other.

Sure.  I'll leave luna88k alone though as I don't think gcc3 had a
-Wpointer-sign option.



Re: etherip alignment issues

2016-09-24 Thread Martin Brandenburg
On Sat, 24 Sep 2016, YASUOKA Masahiko wrote:

> Hi,
>
> The problem doesn't repeat on my Octeon.
>
> Can you try the diff below?
>
>   - I assume the diff fixes the problem
>   - A kernel message is added.  please let me know if it appears.
>
> Thanks,
>

I got the message, but had another panic.

ip_etherip_output: leading space is small 2
panic: ip_output no HDR
Stopped at  Debugger+0x8:   nop
   TIDPIDUID PRFLAGS PFLAGS  CPU  COMMAND
 32532  32532 730x100010   0x806  syslogd
*79702  79702  0 0x14000  0x2101  softnet
ip_output(4001491c200, 0, 0, 2, 0, 0) at ip_output+0x964
ip_etherip_output(4000ae87800, 4001491cc00, 2a, 4000ae84e8f, 0, 6) at 
ip_etherip_output+0x214
etherip_start(4000ae87800, 2a, 0, 0, e1, 6) at etherip_start+0xc4
if_start_locked(4000ae87800, 4001491cc00, 2a, 4000ae84e8f, 0, 6) at 
if_start_locked+0x24
if_enqueue(0, 2a, 0, 0, e1, 6) at if_enqueue+0x6c
bridge_ifenqueue(4000a86, 4000ae87800, 2a, 4000ae84e8f, 0, 6) at 
bridge_ifenqueue+0x30
bridge_output(0, 4001491cc00, 0, 0, e1, 6) at bridge_output+0x260
if_enqueue(4000ae8a000, 4001491cc00, 2, 4000ae84e8f, 0, 6) at if_enqueue+0x90
ether_output(37, 4001491cc00, 4007849da68, 0, e1, ba) at ether_output+0x214
arpreply(4000ae8a000, 4001491cc00, 4007849db50, 4000ae84e8f, 0, 6) at 
arpreply+0x16c
in_arpinput(4000ae8a000, 4001491cc00, 119bfe0, 0, 4, 2000) at 
in_arpinput+0x2ec
arpintr(188aff8, 40014bded80, 168ff18, 168fc90, 0, 6) at arpintr+0x48
if_netisr(0, 4007849dde0, 119bfe0, 0, 4, 2000) at if_netisr+0xf0
taskq_thread(40008b18080, 40014bded80, 168ff18, 168fc90, 0, 3b9ac800) at 
taskq_thread+0x6c



clang dev/pv/hyperv.c

2016-09-24 Thread Mark Kettenis
Another obvious mistake caught by clang.

ok?


Index: dev/pv/hyperv.c
===
RCS file: /cvs/src/sys/dev/pv/hyperv.c,v
retrieving revision 1.16
diff -u -p -r1.16 hyperv.c
--- dev/pv/hyperv.c 20 Sep 2016 10:27:14 -  1.16
+++ dev/pv/hyperv.c 24 Sep 2016 17:04:24 -
@@ -700,7 +700,7 @@ hv_vmbus_connect(struct hv_softc *sc)
sc->sc_revents = (u_long *)((caddr_t)sc->sc_events + (PAGE_SIZE >> 1));
 
sc->sc_monitor[0] = km_alloc(PAGE_SIZE, &kv_any, &kp_zero, &kd_nowait);
-   if (sc->sc_monitor == NULL) {
+   if (sc->sc_monitor[0] == NULL) {
printf(": failed to allocate monitor page 1\n");
goto errout;
}
@@ -710,7 +710,7 @@ hv_vmbus_connect(struct hv_softc *sc)
}
 
sc->sc_monitor[1] = km_alloc(PAGE_SIZE, &kv_any, &kp_zero, &kd_nowait);
-   if (sc->sc_monitor == NULL) {
+   if (sc->sc_monitor[1] == NULL) {
printf(": failed to allocate monitor page 2\n");
goto errout;
}



Re: clang -Wpointer-sign

2016-09-24 Thread Theo de Raadt
Please add this to all arch/*/conf/conf/Makefile.* files.

We are trying to minimize differences between these files.  If
that effort isn't made, they will eventually wander far apart from
each other.

> So clang has this warning turned on by default.  And our codebase is
> not clean.  I don't think we intend to fix that anytime soon.  In
> fact, I think we deliberately convert between signed and unsigned char
> pointers in places.  So I propose to turn this warning off.  Since gcc
> recognizes the option we can just unconditionally add -Wno-pointer-sign.
> 
> ok?
> 
> 
> Index: arch/armv7/conf/Makefile.armv7
> ===
> RCS file: /cvs/src/sys/arch/armv7/conf/Makefile.armv7,v
> retrieving revision 1.13
> diff -u -p -r1.13 Makefile.armv7
> --- arch/armv7/conf/Makefile.armv729 Apr 2016 12:44:52 -  1.13
> +++ arch/armv7/conf/Makefile.armv724 Sep 2016 13:31:55 -
> @@ -24,7 +24,7 @@ _archdir?=  $S/arch/${_arch}
>  INCLUDES=-nostdinc -I$S -I. -I$S/arch
>  CPPFLAGS=${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP
>  CWARNFLAGS=  -Werror -Wall -Wimplicit-function-declaration \
> - -Wno-main -Wno-uninitialized \
> + -Wno-main -Wno-uninitialized -Wno-pointer-sign \
>   -Wframe-larger-than=2047
>  
>  CMACHFLAGS=  -ffreestanding -msoft-float -march=armv6 -Wa,-march=armv7a
> 



rc.securelevel example

2016-09-24 Thread Jeremie Courreges-Anglas

Looks like it's not completely obvious how to set a custom securelevel,
at least one user went the /etc/sysctl.conf way, which has the nasty
side-effect of preventing the use of /etc/pf.conf.

Should we add more belts and suspenders?


Index: rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.486
diff -u -p -r1.486 rc
--- rc  10 Jul 2016 09:08:18 -  1.486
+++ rc  24 Sep 2016 15:31:10 -
@@ -52,6 +52,12 @@ update_limit() {
 sysctl_conf() {
stripcom /etc/sysctl.conf |
while read _line; do
+   case $_line in
+   kern.securelevel=*)
+   echo "$_line ignored in /etc/sysctl.conf"
+   continue;;
+   esac
+
sysctl "$_line"
 
case $_line in
Index: examples/rc.securelevel
===
RCS file: /cvs/src/etc/examples/rc.securelevel,v
retrieving revision 1.3
diff -u -p -r1.3 rc.securelevel
--- examples/rc.securelevel 14 Jul 2014 10:15:33 -  1.3
+++ examples/rc.securelevel 24 Sep 2016 15:24:13 -
@@ -7,3 +7,7 @@
 # which should be done AFTER your system has gone into securemode
 # please see /etc/rc.local.
 #
+
+
+# If you want to set a custom securelevel, do so here.
+#sysctl kern.securelevel=2


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



clang and

2016-09-24 Thread Mark Kettenis
clang warns by default about static functions that are unused.  It
does this even for static inline functions, except when those
functions are defined in a header file.  The RBT code in 
has macros that define static inline functions.  Unfortunately that
means that the inline functions generated by those macros trigger the
warning when they're not used.  The diff below marks them as __unused,
to suppress this warning.  With this change, both gcc and clang only
emit the functions that are actually used.

ok?


Index: sys/tree.h
===
RCS file: /cvs/src/sys/sys/tree.h,v
retrieving revision 1.24
diff -u -p -r1.24 tree.h
--- sys/tree.h  15 Sep 2016 06:07:22 -  1.24
+++ sys/tree.h  24 Sep 2016 15:26:41 -
@@ -823,97 +823,97 @@ int_rb_check(const struct rb_type *, v
 #define RBT_PROTOTYPE(_name, _type, _field, _cmp)  \
 extern const struct rb_type *const _name##_RBT_TYPE;   \
\
-static inline void \
+__unused static inline void\
 _name##_RBT_INIT(struct _name *head)   \
 {  \
_rb_init(&head->rbh_root);  \
 }  \
\
-static inline struct _type *   \
+__unused static inline struct _type *  \
 _name##_RBT_INSERT(struct _name *head, struct _type *elm)  \
 {  \
return _rb_insert(_name##_RBT_TYPE, &head->rbh_root, elm);  \
 }  \
\
-static inline struct _type *   \
+__unused static inline struct _type *  \
 _name##_RBT_REMOVE(struct _name *head, struct _type *elm)  \
 {  \
return _rb_remove(_name##_RBT_TYPE, &head->rbh_root, elm);  \
 }  \
\
-static inline struct _type *   \
+__unused static inline struct _type *  \
 _name##_RBT_FIND(struct _name *head, const struct _type *key)  \
 {  \
return _rb_find(_name##_RBT_TYPE, &head->rbh_root, key);\
 }  \
\
-static inline struct _type *   \
+__unused static inline struct _type *  \
 _name##_RBT_NFIND(struct _name *head, const struct _type *key) \
 {  \
return _rb_nfind(_name##_RBT_TYPE, &head->rbh_root, key);   \
 }  \
\
-static inline struct _type *   \
+__unused static inline struct _type *  \
 _name##_RBT_ROOT(struct _name *head)   \
 {  \
return _rb_root(_name##_RBT_TYPE, &head->rbh_root); \
 }  \
\
-static inline int  \
+__unused static inline int \
 _name##_RBT_EMPTY(struct _name *head)  \
 {  \
return _rb_empty(&head->rbh_root);  \
 }  \
\
-static inline struct _type *   \
+__unused static inline struct _type *  \
 _name##_RBT_MIN(struct _name *head)\
 {  \
   

make rdaemon less error-prone

2016-09-24 Thread Jeremie Courreges-Anglas

Simple idiom: always initialize the pre-opened fd to -1, and within
rdaemon() test whether the passed fd is valid.

ok?


Index: usr.sbin/dhcrelay/dhcrelay.c
===
RCS file: /cvs/src/usr.sbin/dhcrelay/dhcrelay.c,v
retrieving revision 1.42
diff -u -p -r1.42 dhcrelay.c
--- usr.sbin/dhcrelay/dhcrelay.c15 Sep 2016 16:16:03 -  1.42
+++ usr.sbin/dhcrelay/dhcrelay.c24 Sep 2016 14:32:44 -
@@ -368,6 +368,8 @@ usage(void)
 int
 rdaemon(int devnull)
 {
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:
Index: usr.sbin/ftp-proxy/ftp-proxy.c
===
RCS file: /cvs/src/usr.sbin/ftp-proxy/ftp-proxy.c,v
retrieving revision 1.35
diff -u -p -r1.35 ftp-proxy.c
--- usr.sbin/ftp-proxy/ftp-proxy.c  15 Sep 2016 16:16:03 -  1.35
+++ usr.sbin/ftp-proxy/ftp-proxy.c  24 Sep 2016 14:32:44 -
@@ -633,6 +633,7 @@ main(int argc, char *argv[])
verbose = 0;
 
/* Other initialization. */
+   devnull = -1;
id_count= 1;
session_count   = 0;
 
@@ -1142,6 +1143,8 @@ usage(void)
 int
 rdaemon(int devnull)
 {
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:
Index: usr.sbin/rtadvd/rtadvd.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
retrieving revision 1.81
diff -u -p -r1.81 rtadvd.c
--- usr.sbin/rtadvd/rtadvd.c21 Sep 2016 18:54:24 -  1.81
+++ usr.sbin/rtadvd/rtadvd.c24 Sep 2016 14:32:44 -
@@ -1320,6 +1320,8 @@ ra_timer_update(struct rainfo *rai)
 int
 rdaemon(int devnull)
 {
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:
Index: usr.sbin/tftpd/tftpd.c
===
RCS file: /cvs/src/usr.sbin/tftpd/tftpd.c,v
retrieving revision 1.37
diff -u -p -r1.37 tftpd.c
--- usr.sbin/tftpd/tftpd.c  4 Sep 2016 14:41:49 -   1.37
+++ usr.sbin/tftpd/tftpd.c  24 Sep 2016 14:32:44 -
@@ -1584,6 +1584,8 @@ getip(void *s)
 int
 rdaemon(int devnull)
 {
+   if (fcntl(devnull, F_GETFL) == -1)
+   return (-1);
 
switch (fork()) {
case -1:

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



More clang warnings in the kernel

2016-09-24 Thread Mark Kettenis
Compiling sys/dev/athn.c fails with:

../../../../dev/ic/athn.c:2182:9: error: shifting a negative signed value is
  undefined [-Werror,-Wshift-negative-value]
reg = RW(reg, AR_AES_MUTE_MASK1_FC1_MGMT,
  ^~~
../../../../dev/ic/athnreg.h:1483:26: note: expanded from macro 'RW'
(((var) & ~field##_M) | SM(field, val))
^~
../../../../dev/ic/athnreg.h:1479:10: note: expanded from macro 'SM'
(((val) << field##_S) & field##_M)
  ~ ^

The whole statement is:

reg = RW(reg, AR_AES_MUTE_MASK1_FC1_MGMT,
~(IEEE80211_FC1_RETRY | IEEE80211_FC1_PWR_MGT |
  IEEE80211_FC1_MORE_DATA));

and the issue is that the IEEE80211_FC1_XXX values are signed
integers, so the bitwise complement of that ends up being a negative
value.  Possible the solution below.  Alternative would be to define
te IEEE80211_FC1_XXX values as unsigned.

Thoughts?


Index: dev/ic/athnreg.h
===
RCS file: /cvs/src/sys/dev/ic/athnreg.h,v
retrieving revision 1.18
diff -u -p -r1.18 athnreg.h
--- dev/ic/athnreg.h10 Jun 2012 21:23:36 -  1.18
+++ dev/ic/athnreg.h24 Sep 2016 14:28:41 -
@@ -1472,11 +1472,11 @@
  */
 /* Mask and Shift (getter). */
 #define MS(val, field) \
-   (((val) & field##_M) >> field##_S)
+   (((uint32_t)(val) & field##_M) >> field##_S)
 
 /* Shift and Mask (setter). */
 #define SM(field, val) \
-   (((val) << field##_S) & field##_M)
+   (((uint32_t)(val) << field##_S) & field##_M)
 
 /* Rewrite. */
 #define RW(var, field, val)\



Re: etherip alignment issues

2016-09-24 Thread YASUOKA Masahiko
Hi,

The problem doesn't repeat on my Octeon.

Can you try the diff below?

  - I assume the diff fixes the problem
  - A kernel message is added.  please let me know if it appears.

Thanks,

diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c
index ad58c52..c0af82e 100644
--- a/sys/net/if_etherip.c
+++ b/sys/net/if_etherip.c
@@ -354,6 +354,8 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
struct sockaddr_in *src, *dst;
struct etherip_header *eip;
struct ip *ip;
+   struct mbuf *m1;
+   int len;
 
src = (struct sockaddr_in *)&sc->sc_src;
dst = (struct sockaddr_in *)&sc->sc_dst;
@@ -370,22 +372,31 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
 
m->m_flags &= ~(M_BCAST|M_MCAST);
 
-   M_PREPEND(m, sizeof(struct etherip_header), M_DONTWAIT);
-   if (m == NULL) {
+   len = sizeof(*eip) + sizeof(*ip);
+   KASSERT(MHLEN >= len + 3);
+#if 1
+   if (M_LEADINGSPACE(m) < len)
+   printf("%s: leading space is small %d\n",
+   __func__, M_LEADINGSPACE(m));
+#endif
+
+   MGET(m1, M_DONTWAIT, m->m_type);
+   if (m1 == NULL) {
+   m_freem(m);
etheripstat.etherip_adrops++;
return ENOBUFS;
}
+   m1->m_data += ETHER_ALIGN;
+   m1->m_len = len;
+   m1->m_next = m;
+   m = m1;
+
eip = mtod(m, struct etherip_header *);
eip->eip_ver = ETHERIP_VERSION;
eip->eip_res = 0;
eip->eip_pad = 0;
 
-   M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
-   if (m == NULL) {
-   etheripstat.etherip_adrops++;
-   return ENOBUFS;
-   }
-   ip = mtod(m, struct ip *);
+   ip = (struct ip *)(eip + 1);
memset(ip, 0, sizeof(struct ip));
 
ip->ip_v = IPVERSION;



clang -Wpointer-sign

2016-09-24 Thread Mark Kettenis
So clang has this warning turned on by default.  And our codebase is
not clean.  I don't think we intend to fix that anytime soon.  In
fact, I think we deliberately convert between signed and unsigned char
pointers in places.  So I propose to turn this warning off.  Since gcc
recognizes the option we can just unconditionally add -Wno-pointer-sign.

ok?


Index: arch/armv7/conf/Makefile.armv7
===
RCS file: /cvs/src/sys/arch/armv7/conf/Makefile.armv7,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile.armv7
--- arch/armv7/conf/Makefile.armv7  29 Apr 2016 12:44:52 -  1.13
+++ arch/armv7/conf/Makefile.armv7  24 Sep 2016 13:31:55 -
@@ -24,7 +24,7 @@ _archdir?=$S/arch/${_arch}
 INCLUDES=  -nostdinc -I$S -I. -I$S/arch
 CPPFLAGS=  ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP
 CWARNFLAGS=-Werror -Wall -Wimplicit-function-declaration \
-   -Wno-main -Wno-uninitialized \
+   -Wno-main -Wno-uninitialized -Wno-pointer-sign \
-Wframe-larger-than=2047
 
 CMACHFLAGS=-ffreestanding -msoft-float -march=armv6 -Wa,-march=armv7a



Re: Some arm cleanups suggested by clang

2016-09-24 Thread Mark Kettenis
> Date: Sat, 24 Sep 2016 14:07:00 +1000
> From: Jonathan Gray 
> 
> On Fri, Sep 23, 2016 at 01:43:04PM +0200, Mark Kettenis wrote:
> > Index: arch/arm/arm/cpu.c
> > ===
> > RCS file: /cvs/src/sys/arch/arm/arm/cpu.c,v
> > retrieving revision 1.32
> > diff -u -p -r1.32 cpu.c
> > --- arch/arm/arm/cpu.c  14 Aug 2016 11:30:54 -  1.32
> > +++ arch/arm/arm/cpu.c  23 Sep 2016 11:32:51 -
> > @@ -103,16 +103,6 @@ static const char * const pxa2x0_steppin
> > "rev 12",   "rev 13",   "rev 14",   "rev 15"
> >  };
> >  
> > -/* Steppings for PXA255/26x.
> > - * rev 5: PXA26x B0, rev 6: PXA255 A0
> > - */
> > -static const char * const pxa255_steppings[16] = {
> > -   "rev 0","rev 1","rev 2","step A-0",
> > -   "rev 4","step B-0", "step A-0", "rev 7",
> > -   "rev 8","rev 9","rev 10",   "rev 11",
> > -   "rev 12",   "rev 13",   "rev 14",   "rev 15"
> > -};
> 
> Why not just remove all the pxa/xscale bits from cpu/cpufunc?

I committed the previous diff.  So here is a diff that removes the
pxa/xscale bits.  As a bonus I added an ARMv8 CPU class, such that we
don't misidentify those as ARMv7.

ok?


Index: arch/arm/arm/cpu.c
===
RCS file: /cvs/src/sys/arch/arm/arm/cpu.c,v
retrieving revision 1.33
diff -u -p -r1.33 cpu.c
--- arch/arm/arm/cpu.c  24 Sep 2016 13:03:47 -  1.33
+++ arch/arm/arm/cpu.c  24 Sep 2016 13:27:05 -
@@ -84,8 +84,8 @@ cpu_attach(struct device *dv)
 
 enum cpu_class {
CPU_CLASS_NONE,
-   CPU_CLASS_XSCALE,
-   CPU_CLASS_ARMv7
+   CPU_CLASS_ARMv7,
+   CPU_CLASS_ARMv8
 };
 
 static const char * const generic_steppings[16] = {
@@ -95,22 +95,6 @@ static const char * const generic_steppi
"rev 12",   "rev 13",   "rev 14",   "rev 15"
 };
 
-/* Steppings for PXA2[15]0 */
-static const char * const pxa2x0_steppings[16] = {
-   "step A-0", "step A-1", "step B-0", "step B-1",
-   "step B-2", "step C-0", "rev 6","rev 7",
-   "rev 8","rev 9","rev 10",   "rev 11",
-   "rev 12",   "rev 13",   "rev 14",   "rev 15"
-};
-
-/* Steppings for PXA270 */
-static const char * const pxa27x_steppings[16] = {
-   "step A-0", "step A-1", "step B-0", "step B-1",
-   "step C-0", "step ?",   "step ?",   "step C-5",
-   "rev 8","rev 9","rev 10",   "rev 11",
-   "rev 12",   "rev 13",   "rev 14",   "rev 15"
-};
-
 struct cpuidtab {
u_int32_t   cpuid;
enumcpu_class cpu_class;
@@ -119,21 +103,6 @@ struct cpuidtab {
 };
 
 const struct cpuidtab cpuids[] = {
-   { CPU_ID_PXA250A,   CPU_CLASS_XSCALE,   "PXA250",
- pxa2x0_steppings },
-   { CPU_ID_PXA210A,   CPU_CLASS_XSCALE,   "PXA210",
- pxa2x0_steppings },
-   { CPU_ID_PXA250B,   CPU_CLASS_XSCALE,   "PXA250",
- pxa2x0_steppings },
-   { CPU_ID_PXA210B,   CPU_CLASS_XSCALE,   "PXA210",
- pxa2x0_steppings },
-   { CPU_ID_PXA250C,   CPU_CLASS_XSCALE,   "PXA250",
- pxa2x0_steppings },
-   { CPU_ID_PXA27X,CPU_CLASS_XSCALE,   "PXA27x",
- pxa27x_steppings },
-   { CPU_ID_PXA210C,   CPU_CLASS_XSCALE,   "PXA210",
- pxa2x0_steppings },
-
{ CPU_ID_CORTEX_A5, CPU_CLASS_ARMv7,"ARM Cortex A5",
  generic_steppings },
{ CPU_ID_CORTEX_A7, CPU_CLASS_ARMv7,"ARM Cortex A7",
@@ -171,21 +140,21 @@ const struct cpuidtab cpuids[] = {
{ CPU_ID_CORTEX_A17_R1, CPU_CLASS_ARMv7,"ARM Cortex A17 R1",
  generic_steppings },
 
-   { CPU_ID_CORTEX_A35,CPU_CLASS_ARMv7,"ARM Cortex A35",
+   { CPU_ID_CORTEX_A35,CPU_CLASS_ARMv8,"ARM Cortex A35",
  generic_steppings },
-   { CPU_ID_CORTEX_A53,CPU_CLASS_ARMv7,"ARM Cortex A53",
+   { CPU_ID_CORTEX_A53,CPU_CLASS_ARMv8,"ARM Cortex A53",
  generic_steppings },
-   { CPU_ID_CORTEX_A53_R1, CPU_CLASS_ARMv7,"ARM Cortex A53 R1",
+   { CPU_ID_CORTEX_A53_R1, CPU_CLASS_ARMv8,"ARM Cortex A53 R1",
  generic_steppings },
-   { CPU_ID_CORTEX_A57,CPU_CLASS_ARMv7,"ARM Cortex A57",
+   { CPU_ID_CORTEX_A57,CPU_CLASS_ARMv8,"ARM Cortex A57",
  generic_steppings },
-   { CPU_ID_CORTEX_A57_R1, CPU_CLASS_ARMv7,"ARM Cortex A57 R1",
+   { CPU_ID_CORTEX_A57_R1, CPU_CLASS_ARMv8,"ARM Cortex A57 R1",
  generic_steppings },
-   { CPU_ID_CORTEX_A72,CPU_CLASS_ARMv7,"ARM Cortex A72",
+   { CPU_ID_CORTEX_A72,CPU_CLASS_ARMv8,"ARM Cortex A72",
  generic_steppings },
-   { CPU_ID_CORTEX_A72_R1, CPU_CLASS_ARMv7,"ARM C

Re: innetgr(3): fix matching when user, host and domain are specified

2016-09-24 Thread Todd C. Miller
On Sat, 24 Sep 2016 00:49:07 -0700, Philip Guenther wrote:

> Hmm, but then in the strdup() fails you need to call
>   _ng_sl_free(sl, 1);
> no?

Yes, fixed.

> (Speaking of, _ng_sl_free() is now static and its second argument is 
> always 1, so maybe it should lose that...)

That arg can be 0 in netgroup_mkdb but it has a separate copy of
the code in question.  It might be useful to keep the two copies
in sync.

 - todd



makes struct kinfo_file to provide va_nlink

2016-09-24 Thread Sebastien Marie
Hi,

I would like access to `va_nlink' information in struct vattr. The
purpose is to know when VTEXT node of a running process is "detached"
from filesystem (read: the running process isn't the same anymore than
the file on disk, maybe due to upgrade).

`va_nlink' is the number of references of the vnode. When it is zero, it
means, if I correctly understood, that underling file is dangle. The
file has been unlinked.

Currently, in order to access to this information from userland, I need
to copte with kvm, which is bad (from my perspective). I implemented it
for my personal use (https://github.com/semarie/checkrestart), but I
would prefer a better approch, and if it is available from base, it
would be wonderful.

The following diff adds a `va_nlink' member in `struct kinfo_file'. The
information become available though sysctl(3) via KERN_FILE interface,
as some others members of `struct vattr'.

In order to illustrate the use of the va_nlink information, I also makes
a diff for fstat(1): the inode number will be followed by `*' when it
is unlinked from disk.

For me, this information is highlty desirable as it could permit to
easily found processes that would need restart after packages upgrades
(rcctl restart ...).

Formally, for the final purpose, the information could be only partial:
a library dynamically linked isn't referenced via KERN_FILE interface (I
am unsure about the availability of the information). But as proper
packages will have their signature changed by any library crank, a
package update will make old program to be remplaced by a new one.


Here a concret example with fstat(1):

# get the inode of the file sndiod

$ ls -i /usr/bin/sndiod
2754462 /usr/bin/sndiod

# check the inode of the running sndiod process

$ fstat | grep 'sndio.*text'
_sndio   sndiod 56390 text /usr  2754462  -r-xr-xr-x   r80160
_sndiop  sndiod 27240 text /usr  2754462  -r-xr-xr-x   r80160

# recompile sndiod program, and install it: inode 2754462 will be
# removed, and a new file installed.

$ cd /usr/src/usr.bin/sndiod && make clean && make && doas make install
...

# get the new inode

$ ls -i /usr/bin/sndiod
2754467 /usr/bin/sndiod

# check that the running sndiod process is still the "old" one:
# the inode 2754462 is suffixed with `*'

$ fstat | grep 'sndio.*text'
_sndio   sndiod 56390 text /usr  2754462* -r-xr-xr-x   r80160
_sndiop  sndiod 27240 text /usr  2754462* -r-xr-xr-x   r80160

# restart sndiod, as the running copy isn't in sync with filesystem

$ doas rcctl restart sndiod
sndiod(ok)
sndiod(ok)

# check that now, the running process use the new inode.

$ fstat | grep 'sndio.*text'
_sndio   sndiod 79950 text /usr  2754467  -r-xr-xr-x   r80160
_sndiop  sndiod  1725 text /usr  2754467  -r-xr-xr-x   r80160


Does it make any interest ?

Thanks.
-- 
Sebastien Marie


Index: sys/kern/kern_sysctl.c
===
RCS file: /cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.311
diff -u -p -r1.311 kern_sysctl.c
--- sys/kern/kern_sysctl.c  21 Sep 2016 14:06:50 -  1.311
+++ sys/kern/kern_sysctl.c  24 Sep 2016 11:26:24 -
@@ -1057,6 +1057,7 @@ fill_file(struct kinfo_file *kf, struct 
kf->va_size = va.va_size;
kf->va_rdev = va.va_rdev;
kf->va_fsid = va.va_fsid & 0x;
+   kf->va_nlink = va.va_nlink;
}
break;
 
Index: sys/sys/sysctl.h
===
RCS file: /cvs/src/sys/sys/sysctl.h,v
retrieving revision 1.166
diff -u -p -r1.166 sysctl.h
--- sys/sys/sysctl.h21 Sep 2016 14:06:50 -  1.166
+++ sys/sys/sysctl.h24 Sep 2016 11:26:25 -
@@ -697,6 +697,7 @@ struct kinfo_file {
uint64_tva_size;/* UINT64_T: file size in bytes */
uint32_tva_mode;/* MODE_T: file access mode and type */
uint32_tva_fsid;/* DEV_T: filesystem device */
+   uint32_tva_nlink;   /* NLINK_T: number of references to 
file */
charf_mntonname[KI_MNAMELEN];
 
/* socket information */
Index: usr.bin/fstat/fstat.1
===
RCS file: /cvs/src/usr.bin/fstat/fstat.1,v
retrieving revision 1.52
diff -u -p -r1.52 fstat.1
--- usr.bin/fstat/fstat.1   25 Apr 2016 19:18:41 -  1.52
+++ usr.bin/fstat/fstat.1   24 Sep 2016 11:26:25 -
@@ -146,6 +146,9 @@ flag is specified, this header is presen
 major/minor number of the device that this file resides in.
 .It Li INUM
 The inode number of the file.
+It will be followed by an asterisk
+.Pq Ql *
+if the inode is unlinked from disk.
 .It Li MODE
 The mode of the file.
 If the
Index: usr.bin/fstat/fstat.c
===
RCS file: /cvs/sr

Re: timeout_set_proc(9)

2016-09-24 Thread Christiano F. Haesbaert
Am Samstag, 24. September 2016 schrieb David Gwynne :

> On Fri, Sep 23, 2016 at 10:16:34PM -0700, Philip Guenther wrote:
> > On Fri, 23 Sep 2016, Christiano F. Haesbaert wrote:
> > ...
> > > The diff as it is will deadlock against SCHED_LOCK.
> > > tsleep() calls sleep_setup(), which grabs SCHED_LOCK,
> > > Then sleep_setup_timeout() will grab timeout_mutex in timeout_add()
> > >
> > > On softclock() you have the opposite:
> > > Grabs timeout_mutex then does a wakeup, which grabs SCHED_LOCK.
>
> nice.
>
> >
> > Hmm, yes. And softclock_thread() has the same problem: msleep() needs to
> > grab SCHED_LOCK while the passed in mutex is held, so it'll hold
> > timeout_mutex while grabbing SCHED_LOCK too.
> >
> > I just played around with using a separate mutex for protecting
> > timeout_proc, a mutex which would be 'outside' SCHED_LOCK, unlike
> > timeout_mutex which is 'inside' SCHED_LOCK.  The catch is that supporting
> > all the functionality of timeout_add() and timeout_del() becomes ugly and
> > fragile: they would need to check whether the mutex has
> > TIMEOUT_NEEDPROCCTX set and, if so, grab the new mutex before grabbing
> > timeout_mutex. ??That's "safe" from being a lock loop from tsleep()
> because
> > the thread's p_sleep_to *can't* have that flag set, so the 'outside'
> mutex
> > wouldn't be neededbut geez is this ugly.  I'm also unsure what
> defined
> > semantics, if any, timeout_triggered() should have for NEEDPROCCTX
> > timeouts.  Should it return true once the timeout has been dequeued from
> > the timeout wheel, or should it only be set once softclock_thread is
> > actually going to run it?
> >
> >
> > ...or maybe this makes people think we should toss this out and go
> > directly to dlg@'s proposal...
>
> let's not go crazy.
>
> i believe the deadlock can be fixed by moving the wakeup outside
> the hold of timeout_mutex in timeout_add. you only need to wake up
> the thread once even if you queued multiple timeouts, cos the thread
> will loop until it completes all pending work. think of this as
> interrupt mitigation.


Yes, that was my solution as well, i don't have access to the code right
now, but I think this won't fix the msleep case guenther pointed out.



>
> it is worth noting that sleep_setup_timeout doesnt timeout_add if
> the wait is 0, so the thread doesnt recurse.
>
> Index: kern/kern_timeout.c
> ===
> RCS file: /cvs/src/sys/kern/kern_timeout.c,v
> retrieving revision 1.49
> diff -u -p -r1.49 kern_timeout.c
> --- kern/kern_timeout.c 22 Sep 2016 12:55:24 -  1.49
> +++ kern/kern_timeout.c 24 Sep 2016 09:45:09 -
> @@ -375,6 +375,7 @@ softclock(void *arg)
> int delta;
> struct circq *bucket;
> struct timeout *to;
> +   int needsproc = 0;
>
> mtx_enter(&timeout_mutex);
> while (!CIRCQ_EMPTY(&timeout_todo)) {
> @@ -391,7 +392,7 @@ softclock(void *arg)
> CIRCQ_INSERT(&to->to_list, bucket);
> } else if (to->to_flags & TIMEOUT_NEEDPROCCTX) {
> CIRCQ_INSERT(&to->to_list, &timeout_proc);
> -   wakeup(&timeout_proc);
> +   needsproc = 1;
> } else {
>  #ifdef DEBUG
> if (delta < 0)
> @@ -401,6 +402,9 @@ softclock(void *arg)
> }
> }
> mtx_leave(&timeout_mutex);
> +
> +   if (needsproc)
> +   wakeup(&timeout_proc);
>  }
>
>  void
>


pf.conf.5 patch

2016-09-24 Thread Peter J. Philipp
Hi,

Please consider this patch for the pf.conf.5 manpage, it took me hours to
figure out what went wrong with my network after parts stopped working due
to this example.  Changing it to what I have now makes it work right.

Symptoms without this fix caused IPv6 neighbours to stop pinging/being 
available and even the NAT64 did not work anymore.

Thank you,

-peter


Index: pf.conf.5
===
RCS file: /cvs/src/share/man/man5/pf.conf.5,v
retrieving revision 1.552
diff -u -p -u -r1.552 pf.conf.5
--- pf.conf.5   14 May 2016 08:21:40 -  1.552
+++ pf.conf.5   24 Sep 2016 09:55:23 -
@@ -863,8 +863,8 @@ translated to 2001:db8::c633:6464.
 .Pp
 In the reverse case the following rules are identical:
 .Bd -literal -offset indent
-pass in inet6 af-to inet from 198.51.100.1 to 0.0.0.0/0
-pass in inet6 af-to inet from 198.51.100.1
+pass in inet6 from any to 64:ff9b::/96 af-to inet from 198.51.100.1 to 
0.0.0.0/0
+pass in inet6 from any to 64:ff9b::/96 af-to inet from 198.51.100.1
 .Ed
 .Pp
 The destination IPv4 address is assumed to be embedded inside the



Re: timeout_set_proc(9)

2016-09-24 Thread David Gwynne
On Fri, Sep 23, 2016 at 10:16:34PM -0700, Philip Guenther wrote:
> On Fri, 23 Sep 2016, Christiano F. Haesbaert wrote:
> ...
> > The diff as it is will deadlock against SCHED_LOCK.
> > tsleep() calls sleep_setup(), which grabs SCHED_LOCK,
> > Then sleep_setup_timeout() will grab timeout_mutex in timeout_add()
> > 
> > On softclock() you have the opposite:
> > Grabs timeout_mutex then does a wakeup, which grabs SCHED_LOCK.

nice.

> 
> Hmm, yes. And softclock_thread() has the same problem: msleep() needs to 
> grab SCHED_LOCK while the passed in mutex is held, so it'll hold 
> timeout_mutex while grabbing SCHED_LOCK too.
> 
> I just played around with using a separate mutex for protecting 
> timeout_proc, a mutex which would be 'outside' SCHED_LOCK, unlike 
> timeout_mutex which is 'inside' SCHED_LOCK.  The catch is that supporting 
> all the functionality of timeout_add() and timeout_del() becomes ugly and 
> fragile: they would need to check whether the mutex has 
> TIMEOUT_NEEDPROCCTX set and, if so, grab the new mutex before grabbing 
> timeout_mutex. ??That's "safe" from being a lock loop from tsleep() because 
> the thread's p_sleep_to *can't* have that flag set, so the 'outside' mutex 
> wouldn't be neededbut geez is this ugly.  I'm also unsure what defined 
> semantics, if any, timeout_triggered() should have for NEEDPROCCTX 
> timeouts.  Should it return true once the timeout has been dequeued from 
> the timeout wheel, or should it only be set once softclock_thread is 
> actually going to run it?
> 
> 
> ...or maybe this makes people think we should toss this out and go 
> directly to dlg@'s proposal...

let's not go crazy.

i believe the deadlock can be fixed by moving the wakeup outside
the hold of timeout_mutex in timeout_add. you only need to wake up
the thread once even if you queued multiple timeouts, cos the thread
will loop until it completes all pending work. think of this as
interrupt mitigation.

it is worth noting that sleep_setup_timeout doesnt timeout_add if
the wait is 0, so the thread doesnt recurse.

Index: kern/kern_timeout.c
===
RCS file: /cvs/src/sys/kern/kern_timeout.c,v
retrieving revision 1.49
diff -u -p -r1.49 kern_timeout.c
--- kern/kern_timeout.c 22 Sep 2016 12:55:24 -  1.49
+++ kern/kern_timeout.c 24 Sep 2016 09:45:09 -
@@ -375,6 +375,7 @@ softclock(void *arg)
int delta;
struct circq *bucket;
struct timeout *to;
+   int needsproc = 0;
 
mtx_enter(&timeout_mutex);
while (!CIRCQ_EMPTY(&timeout_todo)) {
@@ -391,7 +392,7 @@ softclock(void *arg)
CIRCQ_INSERT(&to->to_list, bucket);
} else if (to->to_flags & TIMEOUT_NEEDPROCCTX) {
CIRCQ_INSERT(&to->to_list, &timeout_proc);
-   wakeup(&timeout_proc);
+   needsproc = 1;
} else {
 #ifdef DEBUG
if (delta < 0)
@@ -401,6 +402,9 @@ softclock(void *arg)
}
}
mtx_leave(&timeout_mutex);
+
+   if (needsproc)
+   wakeup(&timeout_proc);
 }
 
 void



add in6 multicast support to vxlan(4) ; question on mbufs

2016-09-24 Thread Vincent Gross
Hi,

As said in Subject:.

I would like to get comments on the m_adj/m_pullup dance at the end of
vxlan_lookup() ; I do this because ether_input() access the ethernet header
with mtod(), and under some conditions the mbuf handled would have its
first data chunk empty (mh_len == 0). What is the rule of thumb
regarding m_pullup/mtod use versus m_copydata ?

Aside from the mbuf issue, is this Ok ?

Index: net/if_vxlan.c
===
RCS file: /cvs/src/sys/net/if_vxlan.c,v
retrieving revision 1.44
diff -u -p -r1.44 if_vxlan.c
--- net/if_vxlan.c  4 Sep 2016 11:14:44 -   1.44
+++ net/if_vxlan.c  24 Sep 2016 08:37:22 -
@@ -47,6 +47,8 @@
 #include 
 #include 
 
+#include 
+
 #if NPF > 0
 #include 
 #endif
@@ -61,7 +63,12 @@ struct vxlan_softc {
struct arpcomsc_ac;
struct ifmedia   sc_media;
 
-   struct ip_moptions   sc_imo;
+   union {
+   struct ip_moptions   u_imo;
+   struct ip6_moptions  u_imo6;
+   } sc_imu;
+#define sc_imo sc_imu.u_imo
+#define sc_im6osc_imu.u_imo6
void*sc_ahcookie;
void*sc_lhcookie;
void*sc_dhcookie;
@@ -129,10 +136,6 @@ vxlan_clone_create(struct if_clone *ifc,
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
return (ENOMEM);
 
-   sc->sc_imo.imo_membership = malloc(
-   (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
-   M_WAITOK|M_ZERO);
-   sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS;
sc->sc_dstport = htons(VXLAN_PORT);
sc->sc_vnetid = VXLAN_VNI_UNSET;
 
@@ -190,7 +193,6 @@ vxlan_clone_destroy(struct ifnet *ifp)
ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
ether_ifdetach(ifp);
if_detach(ifp);
-   free(sc->sc_imo.imo_membership, M_IPMOPTS, 0);
free(sc, M_DEVBUF, sizeof(*sc));
 
return (0);
@@ -199,11 +201,33 @@ vxlan_clone_destroy(struct ifnet *ifp)
 void
 vxlan_multicast_cleanup(struct ifnet *ifp)
 {
-   struct vxlan_softc  *sc = (struct vxlan_softc *)ifp->if_softc;
-   struct ip_moptions  *imo = &sc->sc_imo;
-   struct ifnet*mifp;
+   struct vxlan_softc   *sc = (struct vxlan_softc *)ifp->if_softc;
+   struct ip_moptions   *imo;
+   struct in_multi **imm;
+   struct ip6_moptions  *im6o;
+   struct in6_multi_mship   *im6m, *im6m_next;
+   struct ifnet *mifp = NULL;
+
+   switch (sc->sc_dst.ss_family) {
+   case AF_INET:
+   imo = &sc->sc_imo;
+   mifp = if_get(imo->imo_ifidx);
+   imm = imo->imo_membership;
+   while (imo->imo_num_memberships > 0)
+   in_delmulti(imm[--imo->imo_num_memberships]);
+   free(imm, M_IPMOPTS,
+   sizeof(struct in_multi *) * imo->imo_num_memberships);
+   break;
+   case AF_INET6:
+   im6o = &sc->sc_im6o;
+   mifp = if_get(im6o->im6o_ifidx);
+   LIST_FOREACH_SAFE(im6m, &im6o->im6o_memberships, i6mm_chain,
+   im6m_next)
+   in6_leavegroup(im6m);
+   break;
+   }
+   bzero(&sc->sc_imu, sizeof(sc->sc_imu));
 
-   mifp = if_get(imo->imo_ifidx);
if (mifp != NULL) {
if (sc->sc_ahcookie != NULL) {
hook_disestablish(mifp->if_addrhooks, sc->sc_ahcookie);
@@ -219,14 +243,9 @@ vxlan_multicast_cleanup(struct ifnet *if
sc->sc_dhcookie);
sc->sc_dhcookie = NULL;
}
-
-   if_put(mifp);
}
 
-   if (imo->imo_num_memberships > 0) {
-   in_delmulti(imo->imo_membership[--imo->imo_num_memberships]);
-   imo->imo_ifidx = 0;
-   }
+   if_put(mifp);
 }
 
 int
@@ -234,47 +253,136 @@ vxlan_multicast_join(struct ifnet *ifp, 
 struct sockaddr *dst)
 {
struct vxlan_softc  *sc = ifp->if_softc;
-   struct ip_moptions  *imo = &sc->sc_imo;
+   struct ip_moptions  *imo;
+   struct ip6_moptions *im6o;
+   struct in6_multi_mship  *imm;
struct sockaddr_in  *src4, *dst4;
-   struct sockaddr_in6 *dst6;
+   struct sockaddr_in6 *src6, *dst6;
struct ifaddr   *ifa;
-   struct ifnet*mifp;
+   struct ifnet*mifp = NULL;
+   struct rtentry  *rt;
+   int  error;
 
-   if (dst->sa_family == AF_INET) {
+   switch (dst->sa_family) {
+   case AF_INET:
dst4 = satosin(dst);
+   src4 = satosin(src);
if (!IN_MULTICAST(dst4->sin_addr.s_addr))
return (0);
-   } else if (dst->sa_family == AF_INET6) {
+   if (src4->s

Re: correct option listing in switchd(8)

2016-09-24 Thread lists
Sat, 24 Sep 2016 12:12:03 +1000 Jonathan Gray 
> Sync the option list with reality.  Don't document the internal
> -I and -P options that set the instance number and title on
> purpose.

Hi Jonathan,

I think undocumented and/or intentionally non synchronised options
contradicts with the idea of "correct option" definition anywhere.

Kind regards,
Anton

> Index: switchd.8
> ===
> RCS file: /cvs/src/usr.sbin/switchd/switchd.8,v
> retrieving revision 1.1
> diff -u -p -r1.1 switchd.8
> --- switchd.8 19 Jul 2016 16:54:26 -  1.1
> +++ switchd.8 16 Sep 2016 11:01:27 -
> @@ -22,13 +22,52 @@
>  .Nd software-defined networking (SDN) sflow controller
>  .Sh SYNOPSIS
>  .Nm switchd
> -.Op Fl 6dnSTtv
> +.Op Fl dnv
> +.Op Fl c Ar cachesize
>  .Op Fl D Ar macro Ns = Ns Ar value
>  .Op Fl f Ar file
> +.Op Fl t Ar timeout
>  .Sh DESCRIPTION
>  .Nm
>  is an controller for software-defined networking (SDN) and is
>  compatible with the OpenFlow protocol.
> +.Pp
> +The options are as follows:
> +.Bl -tag -width Dssmacro=value
> +.It Fl D Ar macro Ns = Ns Ar value
> +Set a
> +.Ar macro
> +to a
> +.Ar value .
> +Macros can be referenced in the configuration files.
> +.It Fl c Ar cachesize
> +Number of MAC addresses to cache.
> +The default is 4096.
> +.It Fl d
> +Debug mode.
> +Don't detach or become a daemon.
> +This allows for easy monitoring of
> +.Nm .
> +.It Fl f Ar file
> +Specifies the configuration file.
> +The default is
> +.Pa /etc/switchd.conf .
> +.It Fl n
> +Check that the configuration is valid, but don't start the daemon.
> +.It Fl t Ar timeout
> +Timeout in seconds for learned MAC addresses.
> +The default is 240 seconds.
> +.It Fl v
> +Verbose mode.
> +Multiple
> +.Fl v
> +options increase the verbosity.
> +.El
> +.Sh FILES
> +.Bl -tag -width "/etc/switchd.conf" -compact
> +.It Pa /etc/switchd.conf
> +Default configuration file.
> +.El
>  .Sh STANDARDS
>  .Rs
>  .%A Open Networking Foundation (ONF)
> 



Re: innetgr(3): fix matching when user, host and domain are specified

2016-09-24 Thread Philip Guenther
On Tue, 13 Sep 2016, Todd C. Miller wrote:
> Currently, innetgr(3) will return false if all of user, host and domain 
> are specified, even if the tuple would otherwise match.
> 
> The commented assumption "If a domainname is given, we would have found 
> a match" is simply not true.

Sure.

> I also moved the strdup after the "Too bad need the slow recursive way" 
> comment for readability.

Hmm, but then in the strdup() fails you need to call
_ng_sl_free(sl, 1);
no?


(Speaking of, _ng_sl_free() is now static and its second argument is 
always 1, so maybe it should lose that...)


Philip Guenther



Re: let openbgpd announce rtlabels

2016-09-24 Thread Peter Hessler
On 2016 Sep 14 (Wed) at 16:41:53 +0200 (+0200), Peter Hessler wrote:
:It is quite common to want to do a cross-protocol readvertisement from
:IGP->EGP.  We can add rtlabels in bgpd and ospfd, but only advertise
:in ospfd.
:
:This diff lets bgpd announce routes based on rtlabels.  The existing
:"cannot announce routes that point to localhost" and "cannot announce
:defaults" still apply.  Should they?
:
:OK?
:

Updated diff, with fixed man page.

I also talked to Henning, and we agree that the syntax should include
the the address family.

network inet6 rtlabel "humppa"

OK?


Index: usr.sbin/bgpd/bgpd.conf.5
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpd/bgpd.conf.5,v
retrieving revision 1.146
diff -u -p -u -p -r1.146 bgpd.conf.5
--- usr.sbin/bgpd/bgpd.conf.5   17 Aug 2016 08:14:40 -  1.146
+++ usr.sbin/bgpd/bgpd.conf.5   24 Sep 2016 06:57:33 -
@@ -268,6 +268,11 @@ Log received and sent updates.
 .Pq Ic inet Ns | Ns Ic inet6
 .Ic connected Op Ic set ...\&
 .Xc
+.It Xo
+.Ic network
+.Pq Ic inet Ns | Ns Ic inet6
+.Ic rtlabel Ar label Op Ic set ...\&
+.Xc
 Announce the specified network as belonging to our AS.
 If set to
 .Ic connected ,
@@ -275,6 +280,11 @@ routes to directly attached networks wil
 If set to
 .Ic static ,
 all static routes will be announced.
+If set to
+.Ic rtlabel ,
+routes with the specified
+.Ar label
+will be announced.
 .Bd -literal -offset indent
 network 192.168.7.0/24
 .Ed
Index: usr.sbin/bgpd/bgpd.h
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpd/bgpd.h,v
retrieving revision 1.295
diff -u -p -u -p -r1.295 bgpd.h
--- usr.sbin/bgpd/bgpd.h2 Sep 2016 14:00:29 -   1.295
+++ usr.sbin/bgpd/bgpd.h24 Sep 2016 06:56:39 -
@@ -85,6 +85,7 @@
 #defineF_CTL_ADJ_IN0x2000
 #defineF_CTL_ADJ_OUT   0x4000
 #defineF_CTL_ACTIVE0x8000
+#defineF_RTLABEL   0x1
 
 /*
  * Limit the number of control messages generated by the RDE and queued in
@@ -334,6 +335,7 @@ enum network_type {
NETWORK_DEFAULT,
NETWORK_STATIC,
NETWORK_CONNECTED,
+   NETWORK_RTLABEL,
NETWORK_MRTCLONE
 };
 
@@ -342,6 +344,7 @@ struct network_config {
struct filter_set_head   attrset;
struct rde_aspath   *asp;
u_intrtableid;
+   u_int16_trtlabel;
enum network_typetype;
u_int8_t prefixlen;
u_int8_t old;   /* used for reloading */
@@ -507,6 +510,7 @@ struct kroute_full {
struct bgpd_addrprefix;
struct bgpd_addrnexthop;
charlabel[RTLABEL_LEN];
+   u_int16_t   labelid;
u_int16_t   flags;
u_short ifindex;
u_int8_tprefixlen;
Index: usr.sbin/bgpd/kroute.c
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpd/kroute.c,v
retrieving revision 1.209
diff -u -p -u -p -r1.209 kroute.c
--- usr.sbin/bgpd/kroute.c  8 Apr 2016 12:27:05 -   1.209
+++ usr.sbin/bgpd/kroute.c  24 Sep 2016 06:56:39 -
@@ -,6 +,10 @@ kr_net_match(struct ktable *kt, struct k
if (kr->flags & F_CONNECTED)
return (xn);
break;
+   case NETWORK_RTLABEL:
+   if (kr->labelid == xn->net.rtlabel)
+   return (xn);
+   break;
case NETWORK_MRTCLONE:
/* can not happen */
break;
@@ -1143,6 +1147,10 @@ kr_net_match6(struct ktable *kt, struct 
if (kr6->flags & F_CONNECTED)
return (xn);
break;
+   case NETWORK_RTLABEL:
+   if (kr6->labelid == xn->net.rtlabel)
+   return (xn);
+   break;
case NETWORK_MRTCLONE:
/* can not happen */
break;
@@ -1269,6 +1277,7 @@ sendit:
net.prefix.aid = AID_INET;
net.prefix.v4.s_addr = kr->prefix.s_addr;
net.prefixlen = kr->prefixlen;
+   net.rtlabel = kr->labelid;
net.rtableid = kt->rtableid;
 
return (send_network(type, &net, match ? &match->net.attrset : NULL));
@@ -1337,6 +1346,7 @@ sendit:
net.prefix.aid = AID_INET6;
memcpy(&net.prefix.v6, &kr6->prefix, sizeof(struct in6_addr));
net.prefixlen = kr6->prefixlen;
+   net.rtlabel = kr6->labelid;
net.rtableid = kt->rtableid;
 
return (send_network(type, &net, match ? &match->net.attrset : NULL));
@@ -1392,6 +1402,7 @@ kr_tofull(struct kroute *kr)
kf.nexthop.

Re: Two more arm aeabi functions for the kernel

2016-09-24 Thread Philip Guenther
On Thu, Sep 22, 2016 at 1:09 PM, Mark Kettenis  wrote:
> These functions are necessary to build our kernel with clang.  I
> picked these from NetBSD as I didn't quite like the way FreeBSD
> implemented them.  I stripped all the unecessary bits from the NetBSD
> implementation (which is shared with userland).
>
> Do the file names with the leading underscores bother people?  I could
> rename the files ldivmod.S and uldivmod.S.

There are other leading underbar filenames under libkern.  Leave the
names the way they are, IMO.


> ok?

They look basically sane.  ok guenther@
If you want a review of numerical correctness, poke martynas@.