defer routing table updates on link state changes

2013-08-26 Thread Mike Belopuhov
hi,

in order to make our life a bit easier and prevent rogue
accesses to the routing table from the hardware interrupt
context violating all kinds of spl assumptions we would
like if_link_state_change that is called by network device
drivers in their interrupt service routines to defer its
work to the process context or thereabouts.

i did some testing here, but wouldn't mind if someone
tries this diff in gre/vlan/ospf/anything-weird setups.
making sure that hot-plugging/unplugging usb interfaces
doesn't produce any undesirable effects would be superb
as well.

please note that a token (an interface index) is passed
to the workq in order to make sure that if the interface
would be gone by the time syswq goes around to run the
task it would just fall through.

ok?

diff --git sys/net/if.c sys/net/if.c
index 6dafd0d..5b6800a 100644
--- sys/net/if.c
+++ sys/net/if.c
@@ -79,10 +79,11 @@
 #include sys/protosw.h
 #include sys/kernel.h
 #include sys/ioctl.h
 #include sys/domain.h
 #include sys/sysctl.h
+#include sys/workq.h
 
 #include net/if.h
 #include net/if_dl.h
 #include net/if_media.h
 #include net/if_types.h
@@ -151,10 +152,12 @@ int   if_clone_list(struct if_clonereq *);
 struct if_clone*if_clone_lookup(const char *, int *);
 
 void   if_congestion_clear(void *);
 intif_group_egress_build(void);
 
+void   if_link_state_change_task(void *, void *);
+
 intifai_cmp(struct ifaddr_item *,  struct ifaddr_item *);
 void   ifa_item_insert(struct sockaddr *, struct ifaddr *, struct ifnet *);
 void   ifa_item_remove(struct sockaddr *, struct ifaddr *, struct ifnet *);
 #ifndef SMALL_KERNEL
 void   ifa_print_rb(void);
@@ -1106,21 +1109,39 @@ if_up(struct ifnet *ifp)
 
m_clinitifp(ifp);
 }
 
 /*
- * Process a link state change.
- * NOTE: must be called at splsoftnet or equivalent.
+ * Schedule a link state change task.
  */
 void
 if_link_state_change(struct ifnet *ifp)
 {
-   rt_ifmsg(ifp);
+   /* try to put the routing table update task on syswq */
+   workq_add_task(NULL, 0, if_link_state_change_task,
+   (void *)((unsigned long)ifp-if_index), NULL);
+}
+
+/*
+ * Process a link state change.
+ */
+void
+if_link_state_change_task(void *arg, void *unused)
+{
+   unsigned int index = (unsigned long)arg;
+   struct ifnet *ifp;
+   int s;
+
+   s = splsoftnet();
+   if ((ifp = if_get(index)) != NULL) {
+   rt_ifmsg(ifp);
 #ifndef SMALL_KERNEL
-   rt_if_track(ifp);
+   rt_if_track(ifp);
 #endif
-   dohooks(ifp-if_linkstatehooks, 0);
+   dohooks(ifp-if_linkstatehooks, 0);
+   }
+   splx(s);
 }
 
 /*
  * Handle interface watchdog timer routines.  Called
  * from softclock, we decrement timers (if set) and



Wrong word used in make(1) manpage.

2013-08-26 Thread Christian Schulte
Patch correcting a wrong word in the make(1) manpage.

Index: usr.bin/make/make.1
===
RCS file: /cvs/src/usr.bin/make/make.1,v
retrieving revision 1.106
diff -r1.106 make.1
500c500
 Redefining the corresponding suffix (or suffixes) will re-active the rule.
---
 Redefining the corresponding suffix (or suffixes) will re-activate the rule.



AIGLX error: dlopen of /usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)

2013-08-26 Thread Alexis de BRUYN
Hi tech@,

In my /var/log/Xorg.0.log, I saw this error :
[14.671] (EE) AIGLX error: dlopen of
/usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)

After trying to build swarstg manually in
/usr/xenocara/lib/libGL/dri/swrastg/, make failed :

cc: ../../mesa/libmesagallium/libmesagallium_pic.a: No such file or
directory
cc: ../../glsl/libglsl/libglsl_pic.a: No such file or directory
cc: ../../gallium/drivers/trace/libtrace_pic.a: No such file or directory
cc: ../../gallium/drivers/rbug/librbug_pic.a: No such file or directory
cc: ../../gallium/drivers/softpipe/libsoftpipe_pic.a: No such file or
directory
cc: ../../gallium/libgallium/libgallium_pic.a: No such file or directory
*** Error 1 in /usr/xenocara/lib/libGL/dri/swrastg (../Makefile.inc:81
'swrastg_dri.so')

It seems that the paths are wrong in the Makefile:

--- Makefile.iniSun Aug 25 05:51:56 2013
+++ MakefileSun Aug 25 05:59:20 2013
@@ -11,9 +11,9 @@
-DHAVE_POSIX_MEMALIGN
 
 SWRAST_DRIVERS= \
-   ../../gallium/drivers/trace/libtrace_pic.a \
-   ../../gallium/drivers/rbug/librbug_pic.a \
-   ../../gallium/drivers/softpipe/libsoftpipe_pic.a
+   ../../../../../xobj/lib/libGL/gallium/drivers/trace/libtrace_pic.a \
+   ../../../../../xobj/lib/libGL/gallium/drivers/rbug/librbug_pic.a \
+  
../../../../../xobj/lib/libGL/gallium/drivers/softpipe/libsoftpipe_pic.a
 
 DRIVER_DEFINES = \
-D__NOT_HAVE_DRM_H \
@@ -44,12 +44,12 @@
${SWRAST_COMMON_SOURCES} \
${DRIVER_SOURCES}
 
-LDADD= ../../mesa/libmesagallium/libmesagallium_pic.a \
-   ../../glsl/libglsl/libglsl_pic.a \
+LDADD=
../../../../../xobj/lib/libGL/mesa/libmesagallium/libmesagallium_pic.a \
+   ../../../../../xobj/lib/libGL/glsl/libglsl/libglsl_pic.a \
${SWRAST_DRIVERS} \
-   ../../gallium/libgallium/libgallium_pic.a \
+   ../../../../../xobj/lib/libGL/gallium/libgallium/libgallium_pic.a \
-L${X11BASE}/lib -lexpat -lm -lstdc++ -lc
-DPADD= ../../mesa/libmesagallium/libmesagallium_pic.a
+DPADD=
../../../../../xobj/lib/libGL/mesa/libmesagallium/libmesagallium_pic.a
 
 .include ../../gallium/Makefile.inc
 .include bsd.xorg.mk

Build works for me and there is no longer the error in Xorg.0.log. Not
sure if it is the proper way to correct this.

Regards,

-- 
Alexis de BRUYN



Re: Wrong word used in make(1) manpage.

2013-08-26 Thread Jason McIntyre
On Mon, Aug 26, 2013 at 03:21:56PM +0200, Christian Schulte wrote:
 Patch correcting a wrong word in the make(1) manpage.
 
 Index: usr.bin/make/make.1
 ===
 RCS file: /cvs/src/usr.bin/make/make.1,v
 retrieving revision 1.106
 diff -r1.106 make.1
 500c500
  Redefining the corresponding suffix (or suffixes) will re-active the rule.
 ---
  Redefining the corresponding suffix (or suffixes) will re-activate the rule.
 

fixed, thanks!
jmc



Re: AIGLX error: dlopen of /usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)

2013-08-26 Thread Jonathan Gray
On Mon, Aug 26, 2013 at 06:34:53PM +0200, Alexis de BRUYN wrote:
 Hi tech@,
 
 In my /var/log/Xorg.0.log, I saw this error :
 [14.671] (EE) AIGLX error: dlopen of
 /usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)

That is a result of a patch that was added to fallback
to a different swrast, your problem is somewhere else.  Include
your full Xorg.0.log and dmesg



Re: AIGLX error: dlopen of /usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)

2013-08-26 Thread Matthieu Herrb
On Mon, Aug 26, 2013 at 06:34:53PM +0200, Alexis de BRUYN wrote:
 Hi tech@,
 
 In my /var/log/Xorg.0.log, I saw this error :
 [14.671] (EE) AIGLX error: dlopen of
 /usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)
 
 After trying to build swarstg manually in
 /usr/xenocara/lib/libGL/dri/swrastg/, make failed :
 
 cc: ../../mesa/libmesagallium/libmesagallium_pic.a: No such file or
 directory
 cc: ../../glsl/libglsl/libglsl_pic.a: No such file or directory
 cc: ../../gallium/drivers/trace/libtrace_pic.a: No such file or directory
 cc: ../../gallium/drivers/rbug/librbug_pic.a: No such file or directory
 cc: ../../gallium/drivers/softpipe/libsoftpipe_pic.a: No such file or
 directory
 cc: ../../gallium/libgallium/libgallium_pic.a: No such file or directory
 *** Error 1 in /usr/xenocara/lib/libGL/dri/swrastg (../Makefile.inc:81
 'swrastg_dri.so')
 
 It seems that the paths are wrong in the Makefile:

No. If you want to build the gallium llvmpipe driver (swrastg_dri.so),
please see detailed infos in /usr/xenocara/README.
_
 
 --- Makefile.iniSun Aug 25 05:51:56 2013
 +++ MakefileSun Aug 25 05:59:20 2013
 @@ -11,9 +11,9 @@
 -DHAVE_POSIX_MEMALIGN
  
  SWRAST_DRIVERS= \
 -   ../../gallium/drivers/trace/libtrace_pic.a \
 -   ../../gallium/drivers/rbug/librbug_pic.a \
 -   ../../gallium/drivers/softpipe/libsoftpipe_pic.a
 +   ../../../../../xobj/lib/libGL/gallium/drivers/trace/libtrace_pic.a \
 +   ../../../../../xobj/lib/libGL/gallium/drivers/rbug/librbug_pic.a \
 +  
 ../../../../../xobj/lib/libGL/gallium/drivers/softpipe/libsoftpipe_pic.a
  
  DRIVER_DEFINES = \
 -D__NOT_HAVE_DRM_H \
 @@ -44,12 +44,12 @@
 ${SWRAST_COMMON_SOURCES} \
 ${DRIVER_SOURCES}
  
 -LDADD= ../../mesa/libmesagallium/libmesagallium_pic.a \
 -   ../../glsl/libglsl/libglsl_pic.a \
 +LDADD=
 ../../../../../xobj/lib/libGL/mesa/libmesagallium/libmesagallium_pic.a \
 +   ../../../../../xobj/lib/libGL/glsl/libglsl/libglsl_pic.a \
 ${SWRAST_DRIVERS} \
 -   ../../gallium/libgallium/libgallium_pic.a \
 +   ../../../../../xobj/lib/libGL/gallium/libgallium/libgallium_pic.a \
 -L${X11BASE}/lib -lexpat -lm -lstdc++ -lc
 -DPADD= ../../mesa/libmesagallium/libmesagallium_pic.a
 +DPADD=
 ../../../../../xobj/lib/libGL/mesa/libmesagallium/libmesagallium_pic.a
  
  .include ../../gallium/Makefile.inc
  .include bsd.xorg.mk
 
 Build works for me and there is no longer the error in Xorg.0.log. Not
 sure if it is the proper way to correct this.
 
 Regards,
 
 -- 
 Alexis de BRUYN
 

-- 
Matthieu Herrb



Working on PXE automated installation

2013-08-26 Thread Loïc BLOT
Hello @tech.
I want to share you my work to make OpenBSD automated installation
possible.

My approach is to load a configuration file based on DHCP option 225
(thanks to Nick's work). If this file is present and available (HTTP,FTP
and TFTP are currently supported) the parser load variables to
installation environment (pxe_*).
If an error occurs at this time, installer comes back to normal mode.

The configuration file designed variables on this patern:
define_aiv pxe_myvar=value

or (for multiple values):
define_aiv pxe_mymultivar=value1 value2

(AIV is for automated installation value)

Then, the installation process begins.

To answers all questions i have added an extra argument to (_)ask*()
functions which is the automated variables. It's the better approach for
minimal changes.

At this time i don't answers all questions, but all classic questions
for an automated install by ethernet are answered. (for example if
didn't have answers to WiFi or VLAN questions, but this is possible by
adding a variable name !

Instead of Nick's work i don't patch the kernel itself because netboot
interface is tagged and i can get it with regexp.

The only thing is missing to get choice between a PXE automated install
or a PXE manual install is, maybe, a boot.conf variable to set
installation in an automatic mode. In my case automated install is
forced by launching install pxe in the dot.profile.

You'll find my patch here (based on 5.3)
http://www.unix-experience.fr/wp-content/uploads/2013/08/OpenBSD-PXE-automatedinstall-0826131920GMT.diff

A working configuration:
http://www.unix-experience.fr/wp-content/uploads/2013/08/OpenBSD-PXE-autoinstall.conf

And here is the PoC via a Youtube Video (5min30, sorry my Internet
connection is slow):

https://www.youtube.com/watch?v=rdcdcHhWtVQ

Comments and review are welcome !

-- 
Best regards,
Loïc BLOT, 
UNIX systems, security and network expert
http://www.unix-experience.fr




signature.asc
Description: This is a digitally signed message part


Fix error code for ELF

2013-08-26 Thread Maxime Villard
Hi,
after playing with some ELF binaries, I figured out that error
codes received in errno do not always match with what is expected
in the kernel.

Actually, this function should return (error) instead of (ENOEXEC):


Index: exec_elf.c
===
RCS file: /cvs/src/sys/kern/exec_elf.c,v
retrieving revision 1.93
diff -u -p -r1.93 exec_elf.c
--- exec_elf.c  4 Jul 2013 17:37:05 -   1.93
+++ exec_elf.c  26 Aug 2013 15:26:06 -
@@ -552,8 +552,10 @@ ELFNAME2(exec,makecmds)(struct proc *p, 
 
for (i = 0, pp = ph; i  eh-e_phnum; i++, pp++) {
if (pp-p_type == PT_INTERP  !interp) {
-   if (pp-p_filesz = MAXPATHLEN)
+   if (pp-p_filesz = MAXPATHLEN) {
+   error = ENOEXEC;
goto bad;
+   }
interp = pool_get(namei_pool, PR_WAITOK);
if ((error = ELFNAME(read_from)(p, epp-ep_vp,
pp-p_offset, interp, pp-p_filesz)) != 0) {
@@ -567,8 +569,10 @@ ELFNAME2(exec,makecmds)(struct proc *p, 
 
if (eh-e_type == ET_DYN) {
/* need an interpreter and load sections for PIE */
-   if (interp == NULL || base_ph == NULL)
+   if (interp == NULL || base_ph == NULL) {
+   error = ENOEXEC;
goto bad;
+   }
/* randomize exe_base for PIE */
exe_base = uvm_map_pie(base_ph-p_align);
}
@@ -589,9 +593,9 @@ ELFNAME2(exec,makecmds)(struct proc *p, 
 * *interp with a changed path (/emul/xxx/path), and also
 * set the ep_emul field in the exec package structure.
 */
-   error = ENOEXEC;
if (eh-e_ident[EI_OSABI] != ELFOSABI_OPENBSD 
ELFNAME(os_pt_note)(p, epp, epp-ep_hdr, OpenBSD, 8, 4) != 0) {
+   error = ENOEXEC;
for (i = 0; ELFNAME(probes)[i].func != NULL  error; i++)
error = (*ELFNAME(probes)[i].func)(p, epp, interp, 
pos);
if (error)
@@ -760,7 +764,7 @@ bad:
pool_put(namei_pool, interp);
free(ph, M_TEMP);
kill_vmcmds(epp-ep_vmcmds);
-   return (ENOEXEC);
+   return (error);
 }
 
 /*


Ok/Comments?



Re: AIGLX error: dlopen of /usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)

2013-08-26 Thread Alexis de BRUYN


On 26.08.2013 20:27, Matthieu Herrb wrote:
 On Mon, Aug 26, 2013 at 06:34:53PM +0200, Alexis de BRUYN wrote:
 Hi tech@,

 In my /var/log/Xorg.0.log, I saw this error :
 [14.671] (EE) AIGLX error: dlopen of
 /usr/X11R6/lib/modules/dri/swrastg_dri.so failed (File not found)

 After trying to build swarstg manually in
 /usr/xenocara/lib/libGL/dri/swrastg/, make failed :

 cc: ../../mesa/libmesagallium/libmesagallium_pic.a: No such file or
 directory
 cc: ../../glsl/libglsl/libglsl_pic.a: No such file or directory
 cc: ../../gallium/drivers/trace/libtrace_pic.a: No such file or directory
 cc: ../../gallium/drivers/rbug/librbug_pic.a: No such file or directory
 cc: ../../gallium/drivers/softpipe/libsoftpipe_pic.a: No such file or
 directory
 cc: ../../gallium/libgallium/libgallium_pic.a: No such file or directory
 *** Error 1 in /usr/xenocara/lib/libGL/dri/swrastg (../Makefile.inc:81
 'swrastg_dri.so')

 It seems that the paths are wrong in the Makefile:
 
 No. If you want to build the gallium llvmpipe driver (swrastg_dri.so),
 please see detailed infos in /usr/xenocara/README.
Indeed, build ok.

 Thanks Matthieu.

 _

 --- Makefile.iniSun Aug 25 05:51:56 2013
 +++ MakefileSun Aug 25 05:59:20 2013
 @@ -11,9 +11,9 @@
 -DHAVE_POSIX_MEMALIGN
  
  SWRAST_DRIVERS= \
 -   ../../gallium/drivers/trace/libtrace_pic.a \
 -   ../../gallium/drivers/rbug/librbug_pic.a \
 -   ../../gallium/drivers/softpipe/libsoftpipe_pic.a
 +   ../../../../../xobj/lib/libGL/gallium/drivers/trace/libtrace_pic.a \
 +   ../../../../../xobj/lib/libGL/gallium/drivers/rbug/librbug_pic.a \
 +  
 ../../../../../xobj/lib/libGL/gallium/drivers/softpipe/libsoftpipe_pic.a
  
  DRIVER_DEFINES = \
 -D__NOT_HAVE_DRM_H \
 @@ -44,12 +44,12 @@
 ${SWRAST_COMMON_SOURCES} \
 ${DRIVER_SOURCES}
  
 -LDADD= ../../mesa/libmesagallium/libmesagallium_pic.a \
 -   ../../glsl/libglsl/libglsl_pic.a \
 +LDADD=
 ../../../../../xobj/lib/libGL/mesa/libmesagallium/libmesagallium_pic.a \
 +   ../../../../../xobj/lib/libGL/glsl/libglsl/libglsl_pic.a \
 ${SWRAST_DRIVERS} \
 -   ../../gallium/libgallium/libgallium_pic.a \
 +   ../../../../../xobj/lib/libGL/gallium/libgallium/libgallium_pic.a \
 -L${X11BASE}/lib -lexpat -lm -lstdc++ -lc
 -DPADD= ../../mesa/libmesagallium/libmesagallium_pic.a
 +DPADD=
 ../../../../../xobj/lib/libGL/mesa/libmesagallium/libmesagallium_pic.a
  
  .include ../../gallium/Makefile.inc
  .include bsd.xorg.mk

 Build works for me and there is no longer the error in Xorg.0.log. Not
 sure if it is the proper way to correct this.

 Regards,

 -- 
 Alexis de BRUYN

 

-- 
Alexis de BRUYN