Re: splassert: rtrequest1: want 5 have 0

2015-02-19 Thread Alexander Bluhm
On Wed, Feb 18, 2015 at 12:14:15PM +0100, Matthieu Herrb wrote:
 Feb 18 12:09:59 castor /bsd: splassert: rtrequest1: want 5 have 0
 Feb 18 12:09:59 castor /bsd: Starting stack trace...
 Feb 18 12:09:59 castor /bsd: splassert_check() at splassert_check+0x78
 Feb 18 12:09:59 castor /bsd: rtrequest1() at rtrequest1+0x5e
 Feb 18 12:09:59 castor /bsd: nd6_prefix_offlink() at
 nd6_prefix_offlink+0x1bf
 Feb 18 12:09:59 castor /bsd: pfxlist_onlink_check() at
 pfxlist_onlink_check+0x25e
 Feb 18 12:09:59 castor /bsd: in6_control() at in6_control+0x894
 Feb 18 12:09:59 castor /bsd: ifioctl() at ifioctl+0x175
 Feb 18 12:09:59 castor /bsd: sys_ioctl() at sys_ioctl+0x169
 Feb 18 12:09:59 castor /bsd: syscall() at syscall+0x297
 Feb 18 12:09:59 castor /bsd: --- syscall (number 54) ---
 Feb 18 12:09:59 castor /bsd: end of kernel
 Feb 18 12:09:59 castor /bsd: end trace frame: 0xc8115948400, count:
 249
 Feb 18 12:09:59 castor /bsd: 0xc8115715cda:
 Feb 18 12:09:59 castor /bsd: End of stack trace.
 Feb 18 12:10:00 castor /bsd: carp0: state transition: BACKUP - MASTER

Most calls to pfxlist_onlink_check() are protected by splsoftnet.
Only the path in your trace does not set it.  So I suggest to set
splsoftnet() in in6_control().  I have included the dohooks() as
this is done in IPv4.  While there I have moved some splsoftnet()
hiding in the declarations to the beginning of the code.

ok?

bluhm

Index: netinet6/in6.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.152
diff -u -p -r1.152 in6.c
--- netinet6/in6.c  27 Jan 2015 10:34:27 -  1.152
+++ netinet6/in6.c  19 Feb 2015 18:47:06 -
@@ -552,6 +552,7 @@ in6_control(struct socket *so, u_long cm
pr-ndpr_refcnt++;
}
 
+   s = splsoftnet();
/*
 * this might affect the status of autoconfigured addresses,
 * that is, this address might make other addresses detached.
@@ -559,6 +560,7 @@ in6_control(struct socket *so, u_long cm
pfxlist_onlink_check();
 
dohooks(ifp-if_addrhooks, 0);
+   splx(s);
break;
}
 
Index: netinet6/nd6_rtr.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6_rtr.c,v
retrieving revision 1.97
diff -u -p -r1.97 nd6_rtr.c
--- netinet6/nd6_rtr.c  27 Jan 2015 03:17:36 -  1.97
+++ netinet6/nd6_rtr.c  19 Feb 2015 17:39:18 -
@@ -707,10 +707,10 @@ defrouter_reset(void)
 void
 defrouter_select(void)
 {
-   int s = splsoftnet();
struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL;
struct rtentry *rt = NULL;
struct llinfo_nd6 *ln = NULL;
+   int s = splsoftnet();
 
/*
 * This function should be called only when acting as an autoconfigured
@@ -1139,12 +1139,13 @@ prelist_update(struct nd_prefix *new, st
struct ifaddr *ifa;
struct ifnet *ifp = new-ndpr_ifp;
struct nd_prefix *pr;
-   int s = splsoftnet();
-   int error = 0;
+   int s, error = 0;
int tempaddr_preferred = 0, autoconf = 0, statique = 0;
int auth;
struct in6_addrlifetime lt6_tmp;
char addr[INET6_ADDRSTRLEN];
+
+   s = splsoftnet();
 
auth = 0;
if (m) {



Re: splassert: rtrequest1: want 5 have 0

2015-02-19 Thread Mike Belopuhov
On 19 February 2015 at 21:30, Alexander Bluhm alexander.bl...@gmx.net wrote:
 On Wed, Feb 18, 2015 at 12:14:15PM +0100, Matthieu Herrb wrote:
 Feb 18 12:09:59 castor /bsd: splassert: rtrequest1: want 5 have 0
 Feb 18 12:09:59 castor /bsd: Starting stack trace...
 Feb 18 12:09:59 castor /bsd: splassert_check() at splassert_check+0x78
 Feb 18 12:09:59 castor /bsd: rtrequest1() at rtrequest1+0x5e
 Feb 18 12:09:59 castor /bsd: nd6_prefix_offlink() at
 nd6_prefix_offlink+0x1bf
 Feb 18 12:09:59 castor /bsd: pfxlist_onlink_check() at
 pfxlist_onlink_check+0x25e
 Feb 18 12:09:59 castor /bsd: in6_control() at in6_control+0x894
 Feb 18 12:09:59 castor /bsd: ifioctl() at ifioctl+0x175
 Feb 18 12:09:59 castor /bsd: sys_ioctl() at sys_ioctl+0x169
 Feb 18 12:09:59 castor /bsd: syscall() at syscall+0x297
 Feb 18 12:09:59 castor /bsd: --- syscall (number 54) ---
 Feb 18 12:09:59 castor /bsd: end of kernel
 Feb 18 12:09:59 castor /bsd: end trace frame: 0xc8115948400, count:
 249
 Feb 18 12:09:59 castor /bsd: 0xc8115715cda:
 Feb 18 12:09:59 castor /bsd: End of stack trace.
 Feb 18 12:10:00 castor /bsd: carp0: state transition: BACKUP - MASTER

 Most calls to pfxlist_onlink_check() are protected by splsoftnet.
 Only the path in your trace does not set it.  So I suggest to set
 splsoftnet() in in6_control().  I have included the dohooks() as
 this is done in IPv4.  While there I have moved some splsoftnet()
 hiding in the declarations to the beginning of the code.

 ok?

 bluhm


OK, thanks for taking a look!



Re: splassert: rtrequest1: want 5 have 0

2015-02-19 Thread Matthieu Herrb
On Thu, Feb 19, 2015 at 09:30:40PM +0100, Alexander Bluhm wrote:
 On Wed, Feb 18, 2015 at 12:14:15PM +0100, Matthieu Herrb wrote:
  Feb 18 12:09:59 castor /bsd: splassert: rtrequest1: want 5 have 0
  Feb 18 12:09:59 castor /bsd: Starting stack trace...
  Feb 18 12:09:59 castor /bsd: splassert_check() at splassert_check+0x78
  Feb 18 12:09:59 castor /bsd: rtrequest1() at rtrequest1+0x5e
  Feb 18 12:09:59 castor /bsd: nd6_prefix_offlink() at
  nd6_prefix_offlink+0x1bf
  Feb 18 12:09:59 castor /bsd: pfxlist_onlink_check() at
  pfxlist_onlink_check+0x25e
  Feb 18 12:09:59 castor /bsd: in6_control() at in6_control+0x894
  Feb 18 12:09:59 castor /bsd: ifioctl() at ifioctl+0x175
  Feb 18 12:09:59 castor /bsd: sys_ioctl() at sys_ioctl+0x169
  Feb 18 12:09:59 castor /bsd: syscall() at syscall+0x297
  Feb 18 12:09:59 castor /bsd: --- syscall (number 54) ---
  Feb 18 12:09:59 castor /bsd: end of kernel
  Feb 18 12:09:59 castor /bsd: end trace frame: 0xc8115948400, count:
  249
  Feb 18 12:09:59 castor /bsd: 0xc8115715cda:
  Feb 18 12:09:59 castor /bsd: End of stack trace.
  Feb 18 12:10:00 castor /bsd: carp0: state transition: BACKUP - MASTER
 
 Most calls to pfxlist_onlink_check() are protected by splsoftnet.
 Only the path in your trace does not set it.  So I suggest to set
 splsoftnet() in in6_control().  I have included the dohooks() as
 this is done in IPv4.  While there I have moved some splsoftnet()
 hiding in the declarations to the beginning of the code.
 
 ok?

This fixes the issue (which was reproducible) for me. so ok as far as
I understand the issue.

 
 bluhm
 
 Index: netinet6/in6.c
 ===
 RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6.c,v
 retrieving revision 1.152
 diff -u -p -r1.152 in6.c
 --- netinet6/in6.c27 Jan 2015 10:34:27 -  1.152
 +++ netinet6/in6.c19 Feb 2015 18:47:06 -
 @@ -552,6 +552,7 @@ in6_control(struct socket *so, u_long cm
   pr-ndpr_refcnt++;
   }
  
 + s = splsoftnet();
   /*
* this might affect the status of autoconfigured addresses,
* that is, this address might make other addresses detached.
 @@ -559,6 +560,7 @@ in6_control(struct socket *so, u_long cm
   pfxlist_onlink_check();
  
   dohooks(ifp-if_addrhooks, 0);
 + splx(s);
   break;
   }
  
 Index: netinet6/nd6_rtr.c
 ===
 RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6_rtr.c,v
 retrieving revision 1.97
 diff -u -p -r1.97 nd6_rtr.c
 --- netinet6/nd6_rtr.c27 Jan 2015 03:17:36 -  1.97
 +++ netinet6/nd6_rtr.c19 Feb 2015 17:39:18 -
 @@ -707,10 +707,10 @@ defrouter_reset(void)
  void
  defrouter_select(void)
  {
 - int s = splsoftnet();
   struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL;
   struct rtentry *rt = NULL;
   struct llinfo_nd6 *ln = NULL;
 + int s = splsoftnet();
  
   /*
* This function should be called only when acting as an autoconfigured
 @@ -1139,12 +1139,13 @@ prelist_update(struct nd_prefix *new, st
   struct ifaddr *ifa;
   struct ifnet *ifp = new-ndpr_ifp;
   struct nd_prefix *pr;
 - int s = splsoftnet();
 - int error = 0;
 + int s, error = 0;
   int tempaddr_preferred = 0, autoconf = 0, statique = 0;
   int auth;
   struct in6_addrlifetime lt6_tmp;
   char addr[INET6_ADDRSTRLEN];
 +
 + s = splsoftnet();
  
   auth = 0;
   if (m) {
 

-- 
Matthieu Herrb



splassert: rtrequest1: want 5 have 0

2015-02-18 Thread Matthieu Herrb
Hi,

I'm setting up a new pair of firewalls, running -current. When I bring
up the carp0 interface, I get (running with kern.splassert=2):

Feb 18 12:09:59 castor /bsd: splassert: rtrequest1: want 5 have 0
Feb 18 12:09:59 castor /bsd: Starting stack trace...
Feb 18 12:09:59 castor /bsd: splassert_check() at splassert_check+0x78
Feb 18 12:09:59 castor /bsd: rtrequest1() at rtrequest1+0x5e
Feb 18 12:09:59 castor /bsd: nd6_prefix_offlink() at
nd6_prefix_offlink+0x1bf
Feb 18 12:09:59 castor /bsd: pfxlist_onlink_check() at
pfxlist_onlink_check+0x25e
Feb 18 12:09:59 castor /bsd: in6_control() at in6_control+0x894
Feb 18 12:09:59 castor /bsd: ifioctl() at ifioctl+0x175
Feb 18 12:09:59 castor /bsd: sys_ioctl() at sys_ioctl+0x169
Feb 18 12:09:59 castor /bsd: syscall() at syscall+0x297
Feb 18 12:09:59 castor /bsd: --- syscall (number 54) ---
Feb 18 12:09:59 castor /bsd: end of kernel
Feb 18 12:09:59 castor /bsd: end trace frame: 0xc8115948400, count:
249
Feb 18 12:09:59 castor /bsd: 0xc8115715cda:
Feb 18 12:09:59 castor /bsd: End of stack trace.
Feb 18 12:10:00 castor /bsd: carp0: state transition: BACKUP - MASTER

I do have an IPv6 address configured on carp0: 

castor$ cat /etc/hostname.carp0 
vhid 100 carpdev em0 pass suppressed0
inet 140.93.56.3 255.255.248.0
inet6 2001:660:6602:13::3 64

OpenBSD 5.7-beta (GENERIC.MP) #3: Tue Feb 17 11:03:09 CET 2015
matthieu@castor:/share/OpenBSD/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 17115840512 (16322MB)
avail mem = 16656306176 (15884MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xcf42c000 (77 entries)
bios0: vendor Dell Inc. version 2.3.3 date 07/10/2014
bios0: Dell Inc. PowerEdge R420
acpi0 at bios0: rev 2
acpi0: sleep states S0 S4 S5
acpi0: tables DSDT FACP APIC SPCR HPET DMAR MCFG WD__ SLIC ERST HEST BERT EINJ 
TCPA PC__ SRAT SSDT
acpi0: wakeup devices PCI0(S5) EHC1(S3) EHC2(S3) PCI1(S5)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Xeon(R) CPU E5-2407 v2 @ 2.40GHz, 2400.34 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,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS
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 100MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.1.0, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Xeon(R) CPU E5-2407 v2 @ 2.40GHz, 2400.01 MHz
cpu1: 
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,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Xeon(R) CPU E5-2407 v2 @ 2.40GHz, 2400.01 MHz
cpu2: 
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,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 6 (application processor)
cpu3: Intel(R) Xeon(R) CPU E5-2407 v2 @ 2.40GHz, 2400.01 MHz
cpu3: 
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,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 0, core 3, package 0
ioapic0 at mainbus0: apid 0 pa 0xfec0, version 20, 24 pins
ioapic1 at mainbus0: apid 1 pa 0xfec3f000, version 20, 24 pins
ioapic1: misconfigured as apic 15, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpimcfg0 at acpi0 addr 0xe000, bus 0-255
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (PEX1)
acpiprt2 at acpi0: bus -1 (PEX2)
acpiprt3 at acpi0: bus 8 (PEX3)
acpiprt4 at acpi0: bus -1 (PEX4)
acpiprt5 at acpi0: bus -1 (PEX5)
acpiprt6 at acpi0: bus 10 (PEX6)
acpiprt7 at acpi0: bus 2 (PEX7)
acpiprt8 at acpi0: bus -1 (PEX8)
acpiprt9 at acpi0: bus 3 (PEX9)
acpicpu0 at acpi0
acpicpu1 at acpi0
acpicpu2 at acpi0
acpicpu3 at acpi0
ipmi at mainbus0 not configured
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 Intel E5 v2 Host rev 0x04
ppb0 at pci0 dev 1 function 0 Intel E5 v2 PCIE rev 0x04
pci1 at ppb0 bus 1
mfi0 at pci1