Re: Virtio drivers for OpenBSD

2012-07-12 Thread Jiri B
On Thu, Jul 12, 2012 at 11:02:54AM +0200, Stefan Fritsch wrote:
 On Wed, 11 Jul 2012, Matthew Dempsky wrote:
 There are quite a few pretendy-SCSI drivers in the tree, but most of
 them deal with fairly complicated hardware so they're not good
 reference points.
 
 sparc64's vdsk(4) driver is probably the best reference point, since
 it's also for a virtual disk driver (see sys/arch/sparc64/dev/vdsk.c).

If you would like to dig into vmware pvscsi support, I'm more than happy
to do testing :)

http://lxr.linux.no/#linux+v3.4.4/drivers/scsi/vmw_pvscsi.c

jirib



Re: Virtio drivers for OpenBSD

2012-07-12 Thread Stefan Fritsch

On Thu, 12 Jul 2012, Jiri B wrote:


On Thu, Jul 12, 2012 at 11:02:54AM +0200, Stefan Fritsch wrote:

On Wed, 11 Jul 2012, Matthew Dempsky wrote:

There are quite a few pretendy-SCSI drivers in the tree, but most of
them deal with fairly complicated hardware so they're not good
reference points.

sparc64's vdsk(4) driver is probably the best reference point, since
it's also for a virtual disk driver (see sys/arch/sparc64/dev/vdsk.c).


If you would like to dig into vmware pvscsi support, I'm more than happy
to do testing :)

http://lxr.linux.no/#linux+v3.4.4/drivers/scsi/vmw_pvscsi.c


I will leave that to other people. I am not interested in vmware ATM.



Hibernate enabled for i386

2012-07-12 Thread Mike Larkin
Hibernate (suspend-to-disk) is enabled in -current for i386+wd configurations.

You'll see a bunch of disk activity as the pages are written out after 'ZZZ'.

On resume, a full kernel boot is performed, at which point (at the very end),
the hibernated image is read back from disk (more disk I/O) followed by a 
pause (sometimes a LONG pause) while the image is unpacked on top of the
resuming environment. The machine then resumes from where it suspended
using the same resume mechanism as S3 (suspend-to-ram).

Please see my earlier mail for FAQs and other warnings...

-ml



Re: Virtio drivers for OpenBSD

2012-07-12 Thread Mark Kettenis
 Date: Wed, 11 Jul 2012 08:34:44 -0700
 From: Matthew Dempsky matt...@dempsky.org
 
 On Wed, Jul 11, 2012 at 8:28 AM, Stefan Fritsch s...@sfritsch.de wrote:
  There is a virtio-scsi device, too, but this is only supported in very
  recent versions of qemu. To attach the simpler virtio-block device as scsi,
  the driver would have to emulate the scsi commands. Is there some generic
  infrastructure to do that? Or which driver would you recommend to take the
  emulation code from? sys/dev/ata/atascsi.c seems rather complex (it is twice
  the size of sys/dev/pci/viod.c).
 
 There are quite a few pretendy-SCSI drivers in the tree, but most of
 them deal with fairly complicated hardware so they're not good
 reference points.
 
 sparc64's vdsk(4) driver is probably the best reference point, since
 it's also for a virtual disk driver (see sys/arch/sparc64/dev/vdsk.c).

Absolutely!  Although krw@ pointed out some time ago that vdsk(4)
needs to be iopoolified.



Re: Virtio drivers for OpenBSD

2012-07-12 Thread Stuart Henderson
On 2012/07/11 13:01, Matthew Dempsky wrote:
 Are you able to configure VMWare to emulate a different mpi(4) device?
  E.g., one that uses SAS or FC instead?  Do you use the 53c1030 with
 Linux too?

Yes, dmesg below from a VM with one of each type of emulated mpi(4).

Note the lack of scsibus attached to the emulated SAS controller mpi1.


OpenBSD 5.2-beta (GENERIC.MP) #301: Sun Jul  1 23:32:09 MDT 2012
dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Xeon(R) CPU 3065 @ 2.33GHz (GenuineIntel 686-class) 2.36 GHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUS
H,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,NXE,LONG,SSE3,SSSE3,CX16,LAHF
real mem  = 536342528 (511MB)
avail mem = 516718592 (492MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 09/21/11, BIOS32 rev. 0 @ 0xfd780,
SMBIOS rev. 2.4 @ 0xe0010 (268 entries)
bios0: vendor Phoenix Technologies LTD version 6.00 date 09/21/2011
bios0: VMware, Inc. VMware Virtual Platform
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S4 S5
acpi0: tables DSDT FACP BOOT APIC MCFG SRAT HPET WAET
acpi0: wakeup devices PCI0(S3) USB_(S1) P2P0(S3) S1F0(S3) S2F0(S3) S3F0(S3)
S4F0(S3) S5F0(S3) S6F0(S3) S7F0(S3) S8F0(S3) S9F0(S3) Z00S(S3) Z00T(S3)
Z00U(S3) Z00V(S3) Z00W(S3) Z00X(S3) Z00Y(S3) Z00Z(S3) Z010(S3) Z011(S3)
Z012(S3) Z013(S3) Z014(S3) Z015(S3) Z016(S3) Z017(S3) Z018(S3) Z019(S3)
Z01A(S3) Z01B(S3) Z01C(S3) Z01D(S3) Z01E(S3) P2P1(S3) S1F0(S3) S2F0(S3)
S3F0(S3) S4F0(S3) S5F0(S3) S6F0(S3) S7F0(S3) S8F0(S3) S9F0(S3) Z00S(S3)
Z00T(S3) Z00U(S3) Z00V(S3) Z00W(S3) Z00X(S3) Z00Y(S3) Z00Z(S3) Z010(S3)
Z011(S3) Z012(S3) Z013(S3) Z014(S3) Z015(S3) Z016(S3) Z017(S3) Z018(S3)
Z019(S3) Z01A(S3) Z01B(S3) Z01C(S3) Z01D(S3) Z01E(S3) P2P2(S3) S1F0(S3)
S2F0(S3) S3F0(S3) S4F0(S3) S5F0(S3) S6F0(S3) S7F0(S3) S8F0(S3) S9F0(S3)
Z00S(S3) Z00T(S3) Z00U(S3) Z00V(S3) Z00W(S3) Z00X(S3) Z00Y(S3) Z00Z(S3)
Z010(S3) Z011(S3) Z012(S3) Z013(S3) Z014(S3) Z015(S3) Z016(S3) Z017(S3)
Z018(S3) Z019(S3) Z01A(S3) Z01B(S3) Z01C(S3) Z01D(S3) Z01E(S3) P2P3(S3)
S1F0(S3) S2F0(S3) S3F0(S3) S4F0(S3) S5F0(S3) S6F0(S3) S7F0(S3) S8F0(S3)
S9F0(S3) Z00S(S3) Z00T(S3) Z00U(S3) Z00V(S3) Z00W(S3) Z00X(S3) Z00Y(S3)
Z00Z(S3) Z010(S3) Z011(S3) Z012(S3) Z013(S3) Z014(S3) Z015(S3) Z016(S3)
Z017(S3) Z018(S3) Z019(S3) Z01A(S3) Z01B(S3) Z01C(S3) Z01D(S3) Z01E(S3)
PE40(S3) S1F0(S3) PE50(S3) S1F0(S3) PE60(S3) S1F0(S3) PE70(S3) S1F0(S3)
PE80(S3) S1F0(S3) PE90(S3) S1F0(S3) PEA0(S3) S1F0(S3) PEB0(S3) S1F0(S3)
PEC0(S3) S1F0(S3) PED0(S3) S1F0(S3) PEE0(S3) S1F0(S3) PE41(S3) S1F0(S3)
PE42(S3) S1F0(S3) PE43(S3) S1F0(S3) PE44(S3) S1F0(S3) PE45(S3) S1F0(S3)
PE46(S3) S1F0(S3) PE47(S3) S1F0(S3) PE51(S3) S1F0(S3) PE52(S3) S1F0(S3)
PE53(S3) S1F0(S3) PE54(S3) S1F0(S3) PE55(S3) S1F0(S3) PE56(S3) S1F0(S3)
PE57(S3) S1F0(S3) PE61(S3) S1F0(S3) PE62(S3) S1F0(S3) PE63(S3) S1F0(S3)
PE64(S3) S1F0(S3) PE65(S3) S1F0(S3) PE66(S3) S1F0(S3) PE67(S3) S1F0(S3)
PE71(S3) S1F0(S3) PE72(S3) S1F0(S3) PE73(S3) S1F0(S3) PE74(S3) S1F0(S3)
PE75(S3) S1F0(S3) PE76(S3) S1F0(S3) PE77(S3) S1F0(S3) PE81(S3) S1F0(S3)
PE82(S3) S1F0(S3) PE83(S3) S1F0(S3) PE84(S3) S1F0(S3) PE85(S3) S1F0(S3)
PE86(S3) S1F0(S3) PE87(S3) S1F0(S3) PE91(S3) S1F0(S3) PE92(S3) S1F0(S3)
PE93(S3) S1F0(S3) PE94(S3) S1F0(S3) PE95(S3) S1F0(S3) PE96(S3) S1F0(S3)
PE97(S3) S1F0(S3) PEA1(S3) S1F0(S3) PEA2(S3) S1F0(S3) PEA3(S3) S1F0(S3)
PEA4(S3) S1F0(S3) PEA5(S3) S1F0(S3) PEA6(S3) S1F0(S3) PEA7(S3) S1F0(S3)
PEB1(S3) S1F0(S3) PEB2(S3) S1F0(S3) PEB3(S3) S1F0(S3) PEB4(S3) S1F0(S3)
PEB5(S3) S1F0(S3) PEB6(S3) S1F0(S3) PEB7(S3) S1F0(S3) SLPB(S4) LID_(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 70MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Xeon(R) CPU 3065 @ 2.33GHz (GenuineIntel 686-class) 2.54 GHz
cpu1:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUS
H,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,NXE,LONG,SSE3,SSSE3,CX16,LAHF
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 11, 24 pins
acpimcfg0 at acpi0 addr 0xe000, bus 0-255
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0
acpicpu1 at acpi0
acpibat0 at acpi0: BAT1 not present
acpibat1 at acpi0: BAT2 not present
acpiac0 at acpi0: AC unit online
acpibtn0 at acpi0: SLPB
acpibtn1 at acpi0: LID_
bios0: ROM list: 0xc/0x8000 0xc8000/0x1e00! 0xca000/0x1000 0xcb000/0x1e00!
0xdc000/0x4000! 0xe/0x4000!
vmt0 at mainbus0
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 Intel 82443BX AGP rev 0x01
ppb0 at pci0 dev 1 function 0 Intel 82443BX AGP rev 0x01
pci1 at ppb0 bus 1
piixpcib0 at pci0 dev 7 function 0 Intel 82371AB PIIX4 ISA rev 0x08
pciide0 at pci0 dev 7 function 1 Intel 82371AB IDE rev 0x01: DMA, channel 0
configured to compatibility, channel 1 configured to compatibility
pciide0: channel 0 disabled (no drives)
atapiscsi0 at pciide0 channel 1 drive 0
scsibus0 at atapiscsi0: 2 

Re: ftp mput recursiv upload diff for testing

2012-07-12 Thread Alexander Bluhm
Comments inline:

On Mon, Jul 09, 2012 at 02:04:27PM +0200, Jan Klemkow wrote:
 Index: cmds.c
 ===
 RCS file: /cvs/src/usr.bin/ftp/cmds.c,v
 retrieving revision 1.70
 diff -u -p -r1.70 cmds.c
 --- cmds.c5 May 2009 19:35:30 -   1.70
 +++ cmds.c9 Jul 2012 11:56:54 -
 @@ -229,17 +229,30 @@ void
  mput(int argc, char *argv[])
  {
   extern int optind, optreset;
 - int ch, i, restartit = 0;
 + int ch, i, restartit = 0, recursiv = 0;
s/recursiv/recursive/
And this variable is not used.

   sig_t oldintr;
   char *cmd, *tp;
 -
 + const char *errstr;
 + static int depth = 0, max_depth = 0;
Put an emtpy line after the declarations

   optind = optreset = 1;
  
 - while ((ch = getopt(argc, argv, c)) != -1) {
 + while ((ch = getopt(argc, argv, cd:r)) != -1) {
   switch(ch) {
   case 'c':
   restartit = 1;
   break;
 + case 'd':
 + max_depth = strtonum(optarg, 0, INT_MAX, errstr);
 + if (errstr != NULL) {
 + fprintf(ttyout, bad depth value, %s: %s,
\n missing

 + errstr, optarg);
 + code = -1;
 + return;
 + }
 + break;
 + case 'r':
 + depth = 1;
 + break;
   default:
   goto usage;
   }
 @@ -247,7 +260,8 @@ mput(int argc, char *argv[])
  
   if (argc - optind  1  !another(argc, argv, local-files)) {
  usage:
 - fprintf(ttyout, usage: %s [-c] local-files\n, argv[0]);
 + fprintf(ttyout, usage: %s [-cr] [-d depth] local-files\n,
 + argv[0]);
   code = -1;
   return;
   }
 @@ -318,11 +332,16 @@ usage:
   mflag = 0;
   return;
   }
 +
 + if (depth)
 + depth++;
 +
Should this be before getopt like in mget?
After -r depth = 1 case, depth gets incremented to 2 here and is
not reset correctly to 0 after all.  Try mput -r and mput, the
second one will still be recursive.

   for (i = 1; i  argc; i++) {
   char **cpp;
   glob_t gl;
   int flags;
  
 + /* Copy files without word expantion */
s/expantion/expansion/
Needless comments, unecessary diff.

   if (!doglob) {
   if (mflag  confirm(argv[0], argv[i])) {
   tp = (ntflag) ? dotrans(argv[i]) : argv[i];
 @@ -348,6 +367,7 @@ usage:
   continue;
   }
  
 + /* expanding file names */
Needless comments, unecessary diff.

   memset(gl, 0, sizeof(gl));
   flags = GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
   if (glob(argv[i], flags, NULL, gl) || gl.gl_pathc == 0) {
 @@ -355,8 +375,58 @@ usage:
   globfree(gl);
   continue;
   }
 +
 + /* traverse all expanded file names */
Needless comments, unecessary diff.

   for (cpp = gl.gl_pathv; cpp  *cpp != NULL; cpp++) {
 + struct stat filestat;
 +
   if (mflag  confirm(argv[0], *cpp)) {
 +
 + /* 
trailing whitespace

 +  * If file is a directory then create a new one
 +  * at the remote machine.
 +  */
 + stat(*cpp, filestat);
 +
 + if (S_ISDIR(filestat.st_mode)) {
mget() has this logic to skip on directories
if (type == 'd'  depth == max_depth)
continue;
if (!confirm(argv[0], cp))
continue;
if (type == 'd') {
Perhaps we want the same for mput()

 + char* xargv[] = {argv[0], *cpp};
terminating NULL is missing.
Make it consistent to mget() and declare at function beginning.
Then you get original argv[0], before optind has been added.

 +
 + if (depth == max_depth) {
 + continue;
 + }
no { } for one line if

 +
 + makedir(2, xargv);
These should be right before cd(), as cd() makes the error checking for
makedir().

 +
 + /*
 +  * Copy the hole directory recursivly.
 +  */
s/recursivly/recursively

 + if (chdir(*cpp) != 0) {
 + warn(local: %s, *cpp);
 + continue;
 + 

Re: mask support for ethernet bridge filtering

2012-07-12 Thread sven falempin
Inline diff

2012/7/3 sven falempin sven.falem...@gmail.com

 This diff enables the possibilty of using a mask on bridges rules.

 I have test it like this :

 $ cat /etc/hostname.bridge0


 up
 add re0
 add vether0
 rule pass out on vether0 src 78:2b:4f:00:00:00 mask ff:ff:ff:00:00:00 tag
 booz
 rule block out on vether0 src 78:2b:00:00:00:00 mask ff:ff:00:00:00:00
 $ cat /etc/hostname.vether0
 inet 172.16.0.2 255.255.0.0
 $ cat /etc/hostname.re0
 inet 10.15.0.3 255.255.0.0

 then from a machine on the 10.15/24 network i add an alias to access
 172.16/24  through bridge0

 blocking and tagging are ok.

 Unexpected result:
  - block on re0 just block everything, not just the bridging (forwarding
 to vether
  - this is not dynamic (after a flushrule i cannot block - this is not
 related to the patch)

 --

 -
 () ascii ribbon campaign - against html e-mail
 /\


Index: ./sys/net/if_bridge.c
===
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.193
diff -u -r1.193 if_bridge.c
--- ./sys/net/if_bridge.c 4 Jul 2011 06:54:49 - 1.193
+++ ./sys/net/if_bridge.c 3 Jul 2012 22:52:25 -
@@ -76,6 +76,8 @@
 #include netinet6/ip6_var.h
 #endif

+#include sys/syslog.h
+
 #if NPF  0
 #include net/pfvar.h
 #define BRIDGE_IN PF_IN
@@ -145,6 +147,8 @@
 struct ifbrlreq *, int out);
 int bridge_flushrule(struct bridge_iflist *);
 int bridge_brlconf(struct bridge_softc *, struct ifbrlconf *);
+int bridge_test_ea(struct ether_addr *, struct ether_addr *,
+struct ether_addr *);
 u_int8_t bridge_filterrule(struct brl_head *, struct ether_header *,
 struct mbuf *);
 struct mbuf *bridge_ip(struct bridge_softc *, int, struct ifnet *,
@@ -910,6 +914,8 @@
  req.ifbr_flags = n-brl_flags;
  req.ifbr_src = n-brl_src;
  req.ifbr_dst = n-brl_dst;
+ req.ifbr_src_mask = n-brl_src_mask;
+ req.ifbr_dst_mask = n-brl_dst_mask;
 #if NPF  0
  req.ifbr_tagname[0] = '\0';
  if (n-brl_tag)
@@ -933,6 +939,8 @@
  req.ifbr_flags = n-brl_flags;
  req.ifbr_src = n-brl_src;
  req.ifbr_dst = n-brl_dst;
+ req.ifbr_src_mask = n-brl_src_mask;
+ req.ifbr_dst_mask = n-brl_dst_mask;
 #if NPF  0
  req.ifbr_tagname[0] = '\0';
  if (n-brl_tag)
@@ -2204,33 +2212,36 @@
  return (1);
 }

+//inline
+int
+bridge_test_ea(struct ether_addr *ea_packet, struct ether_addr *ea_rules,
+struct ether_addr *ea_mask) {
+ int i;
+ struct ether_addr ea_cmp;
+ for (i = 0; i  ETHER_ADDR_LEN; ++i) {
+ ea_cmp.ether_addr_octet[i] = ea_mask-ether_addr_octet[i]
+  ea_packet-ether_addr_octet[i];
+ }
+ return (bcmp(ea_cmp, ea_rules, ETHER_ADDR_LEN));
+}
+
 u_int8_t
 bridge_filterrule(struct brl_head *h, struct ether_header *eh, struct mbuf
*m)
 {
  struct brl_node *n;
- u_int8_t flags;

  SIMPLEQ_FOREACH(n, h, brl_next) {
- flags = n-brl_flags  (BRL_FLAG_SRCVALID|BRL_FLAG_DSTVALID);
- if (flags == 0)
- goto return_action;
- if (flags == (BRL_FLAG_SRCVALID|BRL_FLAG_DSTVALID)) {
- if (bcmp(eh-ether_shost, n-brl_src, ETHER_ADDR_LEN))
- continue;
- if (bcmp(eh-ether_dhost, n-brl_dst, ETHER_ADDR_LEN))
- continue;
- goto return_action;
- }
- if (flags == BRL_FLAG_SRCVALID) {
- if (bcmp(eh-ether_shost, n-brl_src, ETHER_ADDR_LEN))
+ if ( n-brl_flags  BRL_FLAG_SRCVALID ) {
+ if (bridge_test_ea( (struct ether_addr *)eh-ether_shost,
+n-brl_src, n-brl_src_mask))
  continue;
- goto return_action;
  }
- if (flags == BRL_FLAG_DSTVALID) {
- if (bcmp(eh-ether_dhost, n-brl_dst, ETHER_ADDR_LEN))
+ if (n-brl_flags   BRL_FLAG_DSTVALID) {
+ if (bridge_test_ea( (struct ether_addr *)eh-ether_dhost,
+n-brl_dst, n-brl_dst_mask))
  continue;
- goto return_action;
  }
+ goto return_action;
  }
  return (BRL_ACTION_PASS);

@@ -2249,8 +2260,10 @@
  n = malloc(sizeof(*n), M_DEVBUF, M_NOWAIT);
  if (n == NULL)
  return (ENOMEM);
- bcopy(req-ifbr_src, n-brl_src, sizeof(struct ether_addr));
- bcopy(req-ifbr_dst, n-brl_dst, sizeof(struct ether_addr));
+ n-brl_src = req-ifbr_src;
+ n-brl_dst = req-ifbr_dst;
+ n-brl_src_mask = req-ifbr_src_mask;
+ n-brl_dst_mask = req-ifbr_dst_mask;
  n-brl_action = req-ifbr_action;
  n-brl_flags = req-ifbr_flags;
 #if NPF  0
Index: ./sys/net/if_bridge.h
===
RCS file: /cvs/src/sys/net/if_bridge.h,v
retrieving revision 1.34
diff -u -r1.34 if_bridge.h
--- ./sys/net/if_bridge.h 20 Nov 2010 14:23:09 - 1.34
+++ ./sys/net/if_bridge.h 3 Jul 2012 22:52:25 -
@@ -194,7 +194,9 @@
  u_int8_t ifbr_action; /* disposition */
  u_int8_t ifbr_flags; /* flags */
  struct ether_addr ifbr_src; /* source mac */
+ struct ether_addr ifbr_src_mask; /* source mac mask */
  struct ether_addr ifbr_dst; /* destination mac */
+ struct ether_addr ifbr_dst_mask; /* destination mac mask */
  char ifbr_tagname[PF_TAG_NAME_SIZE]; /* pf tagname */
 };
 #define BRL_ACTION_BLOCK 0x01 /* block frame */
@@ -257,7 +259,9 @@
 struct brl_node {
  

make net80211_input be nice to soekris

2012-07-12 Thread Stefan Sperling
 Running ifconfig ral0 debug down up can leave slow systems, such
 as edd@'s soekris, with an unusable wireless interface until reboot.

The net80211 layer will run a scan when the interface comes up.
The scan hops from channel to channel every 200msec. This hopping is
controlled via a timeout that runs at IPL_SOFTCLOCK. When the scan
reaches the last channel it terminates.

The problem with soekris is that, in noisy environments, they take so
much time printing debug messsages about received frames from
ieee80211_input() to the serial console that another RX interrupt
will run next at IPL_NET. This prevents the scan from running its 200msc
timeout handler at IPL_SOFTCLOCK, and the scan never finishes.

With the diff below, we print the message from a work queue at IPL_TTY
instead (idea from guenther@). This allows the soekris to finish the scan.
The box is still hardly responsive during the scan but at least concurrent
SSH sessions remain somewhat responsive and eventually the soekris recovers
completely.

Index: ieee80211_input.c
===
RCS file: /cvs/src/sys/net80211/ieee80211_input.c,v
retrieving revision 1.119
diff -u -p -r1.119 ieee80211_input.c
--- ieee80211_input.c   5 Apr 2011 11:48:28 -   1.119
+++ ieee80211_input.c   12 Jul 2012 15:42:24 -
@@ -42,6 +42,7 @@
 #include sys/errno.h
 #include sys/proc.h
 #include sys/sysctl.h
+#include sys/workq.h
 
 #include net/if.h
 #include net/if_dl.h
@@ -131,6 +132,9 @@ voidieee80211_recv_bar(struct ieee80211
 void   ieee80211_bar_tid(struct ieee80211com *, struct ieee80211_node *,
u_int8_t, u_int16_t);
 #endif
+void   ieee80211_input_print_frame(struct ieee80211com *,  struct ifnet *,
+   struct ieee80211_frame *, struct ieee80211_rxinfo *);
+void   ieee80211_input_print_frame_task(void *, void *);
 
 /*
  * Retrieve the length in bytes of an 802.11 header.
@@ -152,6 +156,71 @@ ieee80211_get_hdrlen(const struct ieee80
return size;
 }
 
+/* Work queue task that prints a received frame.  Avoids printf() from
+ * interrupt context at IPL_NET making slow machines unusable when many
+ * rames are received and the interface is put in debug mode. */
+void
+ieee80211_input_print_frame_task(void *arg1, void *arg2)
+{
+   char *msg = arg1;
+
+   printf(msg);
+   free(msg, M_DEVBUF);
+}
+
+void
+ieee80211_input_print_frame(struct ieee80211com *ic,  struct ifnet *ifp,
+struct ieee80211_frame *wh, struct ieee80211_rxinfo *rxi)
+{
+   int doprint, error;
+   char *msg;
+   u_int8_t subtype = wh-i_fc[0]  IEEE80211_FC0_SUBTYPE_MASK;
+
+   /* avoid to print too many frames */
+   doprint = 0;
+   switch (subtype) {
+   case IEEE80211_FC0_SUBTYPE_BEACON:
+   if (ic-ic_state == IEEE80211_S_SCAN)
+   doprint = 1;
+   break;
+#ifndef IEEE80211_STA_ONLY
+   case IEEE80211_FC0_SUBTYPE_PROBE_REQ:
+   if (ic-ic_opmode == IEEE80211_M_IBSS)
+   doprint = 1;
+   break;
+#endif
+   default:
+   doprint = 1;
+   break;
+   }
+#ifdef IEEE80211_DEBUG
+   doprint += ieee80211_debug;
+#endif
+   if (!doprint)
+   return;
+
+   msg = malloc(1024, M_DEVBUF, M_NOWAIT);
+   if (msg == NULL)
+   return;
+
+   snprintf(msg, 1024, %s: received %s from %s rssi %d mode %s\n,
+   ifp-if_xname,
+   ieee80211_mgt_subtype_name[subtype  IEEE80211_FC0_SUBTYPE_SHIFT],
+   ether_sprintf(wh-i_addr2), rxi-rxi_rssi,
+   ieee80211_phymode_name[ieee80211_chan2mode(
+   ic, ic-ic_bss-ni_chan)]);
+
+   if (ic-ic_print_workq) {
+   error = workq_add_task(ic-ic_print_workq, 0,
+   ieee80211_input_print_frame_task, msg, NULL);
+   if (error)
+   free(msg, M_DEVBUF);
+   } else {
+   printf(msg);
+   free(msg, M_DEVBUF);
+   }
+}
+
 /*
  * Process a received frame.  The node associated with the sender
  * should be supplied.  If nothing was found in the node table then
@@ -467,37 +536,8 @@ ieee80211_input(struct ifnet *ifp, struc
goto out;
}
 
-   if (ifp-if_flags  IFF_DEBUG) {
-   /* avoid to print too many frames */
-   int doprint = 0;
-
-   switch (subtype) {
-   case IEEE80211_FC0_SUBTYPE_BEACON:
-   if (ic-ic_state == IEEE80211_S_SCAN)
-   doprint = 1;
-   break;
-#ifndef IEEE80211_STA_ONLY
-   case IEEE80211_FC0_SUBTYPE_PROBE_REQ:
-   if (ic-ic_opmode == IEEE80211_M_IBSS)
-   doprint = 1;
-   break;
-#endif
-   

make acpiec _GLK aware

2012-07-12 Thread Paul Irofti
This is a preparation diff making acpiec(4) global lock aware.

Others will build on it when doing reads and writes.

Okay?

Index: acpiec.c
===
RCS file: /cvs/src/sys/dev/acpi/acpiec.c,v
retrieving revision 1.45
diff -u -p -r1.45 acpiec.c
--- acpiec.c10 Mar 2012 21:27:07 -  1.45
+++ acpiec.c12 Jul 2012 16:37:18 -
@@ -253,7 +253,8 @@ acpiec_match(struct device *parent, void
struct acpi_softc   *acpisc = (struct acpi_softc *)parent;
 
/* Check for early ECDT table attach */
-   if (ecdt  !memcmp(ecdt-hdr.signature, ECDT_SIG, sizeof(ECDT_SIG) - 
1))
+   if (ecdt  
+   !memcmp(ecdt-hdr.signature, ECDT_SIG, sizeof(ECDT_SIG) - 1))
return (1);
if (acpisc-sc_ec)
return (0);
@@ -267,6 +268,7 @@ acpiec_attach(struct device *parent, str
 {
struct acpiec_softc *sc = (struct acpiec_softc *)self;
struct acpi_attach_args *aa = aux;
+   struct aml_value res;
 
sc-sc_acpi = (struct acpi_softc *)parent;
sc-sc_devnode = aa-aaa_node;
@@ -291,6 +293,13 @@ acpiec_attach(struct device *parent, str
acpi_set_gpehandler(sc-sc_acpi, sc-sc_gpe, acpiec_gpehandler,
sc, 1);
 #endif
+   
+   if (aml_evalname(sc-sc_acpi, sc-sc_devnode, _GLK, 0, NULL, res))
+   sc-sc_glk = 0;
+   if (res.type != AML_OBJTYPE_INTEGER)
+   sc-sc_glk = 0;
+   else
+   sc-sc_glk = res.v_integer ? 1 : 0;
 
printf(\n);
 }
Index: acpidev.h
===
RCS file: /cvs/src/sys/dev/acpi/acpidev.h,v
retrieving revision 1.32
diff -u -p -r1.32 acpidev.h
--- acpidev.h   6 Aug 2010 21:12:27 -   1.32
+++ acpidev.h   12 Jul 2012 16:37:18 -
@@ -332,6 +332,7 @@ struct acpiec_softc {
u_int32_t   sc_gpe;
struct acpiec_event sc_events[ACPIEC_MAX_EVENTS];
int sc_gotsci;
+   charsc_glk;
 };
 
 void   acpibtn_disable_psw(void);



Re: make acpiec _GLK aware

2012-07-12 Thread Matthew Dempsky
On Thu, Jul 12, 2012 at 9:48 AM, Paul Irofti p...@irofti.net wrote:
 +   if (aml_evalname(sc-sc_acpi, sc-sc_devnode, _GLK, 0, NULL, res))
 +   sc-sc_glk = 0;
 +   if (res.type != AML_OBJTYPE_INTEGER)
 +   sc-sc_glk = 0;
 +   else
 +   sc-sc_glk = res.v_integer ? 1 : 0;

The second if should be an else if, no?  Or is res.type guaranteed
to be initialized even if aml_evalname() fails?



Re: make acpiec _GLK aware

2012-07-12 Thread Mark Kettenis
 Date: Thu, 12 Jul 2012 19:48:33 +0300
 From: Paul Irofti p...@irofti.net
 
 This is a preparation diff making acpiec(4) global lock aware.
 
 Others will build on it when doing reads and writes.
 
 Okay?

Makes sense to me, except for:

 Index: acpidev.h
 ===
 RCS file: /cvs/src/sys/dev/acpi/acpidev.h,v
 retrieving revision 1.32
 diff -u -p -r1.32 acpidev.h
 --- acpidev.h 6 Aug 2010 21:12:27 -   1.32
 +++ acpidev.h 12 Jul 2012 16:37:18 -
 @@ -332,6 +332,7 @@ struct acpiec_softc {
   u_int32_t   sc_gpe;
   struct acpiec_event sc_events[ACPIEC_MAX_EVENTS];
   int sc_gotsci;
 + charsc_glk;

..using char here is a bit weird.  It won't save any space and it
makes more sense to use int like we already do for sc_gotsci.

With that change this is ok kettenis@



Re: make acpiec _GLK aware

2012-07-12 Thread Mark Kettenis
 Date: Thu, 12 Jul 2012 19:46:27 +0200 (CEST)
 From: Mark Kettenis mark.kette...@xs4all.nl

 With that change this is ok kettenis@

Except for the thing that matthwe@ pointed out of course.



Re: fun with libtool for masochistic guys

2012-07-12 Thread Joerg Sonnenberger
On Thu, Jul 12, 2012 at 12:33:18AM +0200, Marc Espie wrote:
 On Wed, Jul 11, 2012 at 11:24:37PM +0200, Joerg Sonnenberger wrote:
  On Wed, Jul 11, 2012 at 03:13:19PM +0200, Marc Espie wrote:
   On Wed, Jul 11, 2012 at 01:08:43PM +0200, Joerg Sonnenberger wrote:
On Wed, Jul 11, 2012 at 10:57:21AM +0200, Marc Espie wrote:
 1/ Turns out GNU libtool simply *removes* stuff it doesn't understand 
 while
 linking.

I find that no more buggy than GCC passing all unknown junk to ld...

Joerg
   
   Is that a joke ? 
   
   'cause I can't tell.
  
  Nope, I'm pretty serious. Sure enough, either behavior sucks...
 
 You should get your priorities straight ! occasionnally, gcc behavior
 can be a bit annoying, but it's never ever a silent bug !

There is a difference e.g. between using -static and -Wl,-static. Depending
on which combination of gcc and ld you are using, that can result in
pretty obnoxious bugs too.

Joerg



Re: ncheck_ffs DUID support

2012-07-12 Thread Alexander Hall
On 07/11/12 23:43, Jan Stary wrote:
 On Jul 11 19:18:21, Alexander Hall wrote:
 This adds DUID support to ncheck_ffs.
 Testers? ok?
 
 This indeed enables ncheck_ffs for DUIDs,
 but breaks ncheck_ffs for /dev/wd0x
 
 My fstab says
 
 5d2ade1fc5a8d569.n /tmp   ffs rw,softdep,nodev,nosuid 1 2
 
 With your diff I can do 'ncheck_ffs /tmp',
 which previously said
 
   5d2ade1fc5a8d569.n: no such file or directory
 
 But I can no longer do 'ncheck_ffs /dev/wd0n'
 which worked before this diff, but now says
 
   ncheck_ffs: cannot open /dev/wd0n: Device busy
 
 'ncheck_ffs /dev/rwd0n' works though.

Indeed, thanks.

Another try follows, with less entangled diff. Does it work better?

/Alexander


Index: Makefile
===
RCS file: /data/openbsd/cvs/src/sbin/ncheck_ffs/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- Makefile29 Jun 1996 19:25:09 -  1.3
+++ Makefile11 Jul 2012 13:54:01 -
@@ -1,6 +1,8 @@
 #  $OpenBSD: Makefile,v 1.3 1996/06/29 19:25:09 mickey Exp $
 
 PROG=  ncheck_ffs
+LDADD=  -lutil
+DPADD=  ${LIBUTIL}
 MAN=   ncheck_ffs.8
 
 LINKS= ${BINDIR}/ncheck_ffs ${BINDIR}/ncheck
Index: ncheck_ffs.c
===
RCS file: /data/openbsd/cvs/src/sbin/ncheck_ffs/ncheck_ffs.c,v
retrieving revision 1.35
diff -u -p -r1.35 ncheck_ffs.c
--- ncheck_ffs.c27 Oct 2009 23:59:33 -  1.35
+++ ncheck_ffs.c12 Jul 2012 20:51:26 -
@@ -542,8 +542,16 @@ main(int argc, char *argv[])
if (optind != argc - 1 || (mflag  format))
usage();
 
-   odisk = argv[optind];
-   if (realpath(odisk, rdisk) == NULL)
+disk = argv[optind];
+if ((diskfd = opendev(disk, O_RDONLY, 0, NULL)) = 0) {
+if (fstat(diskfd, stblock))
+err(1, cannot stat %s, disk);
+if (S_ISCHR(stblock.st_mode))
+goto gotdev;
+close(diskfd);
+}
+
+   if (realpath(disk, rdisk) == NULL)
err(1, cannot find real path for %s, odisk);
disk = rdisk;
 
@@ -558,8 +566,10 @@ main(int argc, char *argv[])
 disk = rawname(fsp-fs_spec);
 }
 
-   if ((diskfd = open(disk, O_RDONLY))  0)
+   if ((diskfd = opendev(disk, O_RDONLY, 0, NULL))  0)
err(1, cannot open %s, disk);
+
+gotdev:
sblock = (struct fs *)sblock_buf;
for (i = 0; sblock_try[i] != -1; i++) {
n = pread(diskfd, sblock, SBLOCKSIZE, (off_t)sblock_try[i]);



Re: Virtio drivers for OpenBSD

2012-07-12 Thread Jiri B
On Wed, Jul 11, 2012 at 01:01:03PM -0700, Matthew Dempsky wrote:
 I'm not terribly familiar with mpi(4), but I see it has code to call
 scsi_req_probe() if it receives a MPI_EVT_SASCH_REASON_ADDED or
 MPI_EVT_SASCH_REASON_NO_PERSIST_ADDED event from the adapter
 controller.  However, it appears to only watch for events from Serial
 Attached SCSI and Fibre Channel controllers, whereas 53c1030 is a
 Parallel SCSI controller.

 Are you able to configure VMWare to emulate a different mpi(4) device?
  E.g., one that uses SAS or FC instead?  Do you use the 53c1030 with
 Linux too?

Yes, Linux uses 53c1030 for LSI Logic Parallel as well. LSI SAS is available
on ESXi 5.x but it is not, as stu@ pointed out, recognized.

VMware Virtual Machine Communication Interface rev 0x10 at pci0 dev 7
function 7 not configured

Full dmesg:

booting cd0a:/5.2/amd64/bsd.rd:
|/-\|/2994884-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/
-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-
\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\
|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/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
[89-+320208\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|
/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/
-\|/-\|/-\|/-\+207144|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\
|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/]=0xb7ab18
entry point at 0x1001e0 [7205c766, 3404, 24448b12, b5f8a304]
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2012 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 5.2-beta (RAMDISK_CD) #90: Thu Jun 28 01:19:28 MDT 2012
t...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
real mem = 133103616 (126MB)
avail mem = 109703168 

Re: ftp mput recursiv upload diff for testing

2012-07-12 Thread Jan Klemkow
I fixed the most things.

It took me a while to figure out what that code does, so I think the
comments are usefull for everybody who tries to read it.

The file type information comes from this special remglob2() function.
There is no equivalent thing in the context of mput().  So I check the
local file type with stat(2) and S_ISDIR().

The makedir() function has no return value, so it is not posible at the
moment to detect an error inside that function.

Here is the current diff.

bye,
Jan

Index: cmds.c
===
RCS file: /cvs/src/usr.bin/ftp/cmds.c,v
retrieving revision 1.70
diff -u -p -r1.70 cmds.c
--- cmds.c  5 May 2009 19:35:30 -   1.70
+++ cmds.c  13 Jul 2012 01:10:57 -
@@ -231,15 +231,32 @@ mput(int argc, char *argv[])
extern int optind, optreset;
int ch, i, restartit = 0;
sig_t oldintr;
-   char *cmd, *tp;
+   char *cmd, *tp, *xargv[] = {argv[0], NULL, NULL};
+   const char *errstr;
+   static int depth = 0, max_depth = 0;
 
optind = optreset = 1;
 
-   while ((ch = getopt(argc, argv, c)) != -1) {
+   if (depth)
+   depth++;
+
+   while ((ch = getopt(argc, argv, cd:r)) != -1) {
switch(ch) {
case 'c':
restartit = 1;
break;
+   case 'd':
+   max_depth = strtonum(optarg, 0, INT_MAX, errstr);
+   if (errstr != NULL) {
+   fprintf(ttyout, bad depth value, %s: %s\n,
+   errstr, optarg);
+   code = -1;
+   return;
+   }
+   break;
+   case 'r':
+   depth = 1;
+   break;
default:
goto usage;
}
@@ -247,7 +264,8 @@ mput(int argc, char *argv[])
 
if (argc - optind  1  !another(argc, argv, local-files)) {
 usage:
-   fprintf(ttyout, usage: %s [-c] local-files\n, argv[0]);
+   fprintf(ttyout, usage: %s [-cr] [-d depth] local-files\n,
+   argv[0]);
code = -1;
return;
}
@@ -318,11 +336,13 @@ usage:
mflag = 0;
return;
}
+
for (i = 1; i  argc; i++) {
char **cpp;
glob_t gl;
int flags;
 
+   /* Copy files without word expansion */
if (!doglob) {
if (mflag  confirm(argv[0], argv[i])) {
tp = (ntflag) ? dotrans(argv[i]) : argv[i];
@@ -348,6 +368,7 @@ usage:
continue;
}
 
+   /* expanding file names */
memset(gl, 0, sizeof(gl));
flags = GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
if (glob(argv[i], flags, NULL, gl) || gl.gl_pathc == 0) {
@@ -355,8 +376,58 @@ usage:
globfree(gl);
continue;
}
+
+   /* traverse all expanded file names */
for (cpp = gl.gl_pathv; cpp  *cpp != NULL; cpp++) {
+   struct stat filestat;
+
if (mflag  confirm(argv[0], *cpp)) {
+
+   /*
+* If file is a directory then create a new one
+* at the remote machine.
+*/
+   stat(*cpp, filestat);
+
+   if (S_ISDIR(filestat.st_mode)) {
+
+   if (depth == max_depth)
+   continue;
+
+   xargv[1] = *cpp;
+   makedir(2, xargv);
+
+   /*
+* Copy the hole directory recursivly.
+*/
+   if (chdir(*cpp) != 0) {
+   warn(local: %s, *cpp);
+   continue;
+   }
+
+   xargv[1] = *cpp;
+   cd(2, xargv);
+   if (dirchange != 1) {
+   mflag = 0;
+   goto out;
+   }
+
+   xargv[1] = *;
+   mput(2, xargv);
+
+   xargv[1] = ..;
+   cd(2, xargv);
+