Re: Convert hand-rolled lists to TAILQ_* in ac(8)

2014-11-11 Thread Dimitris Papastamos
Hi everyone,

Any interest in this?  It is a cleanup change and not intended to have
any functional differences.

Cheers,
Dimitris



Re: Convert hand-rolled lists to TAILQ_* in ac(8)

2014-11-11 Thread Vadim Zhukov
Why TAILQ? SLIST should be enough.

Also, moving sys/types.h is wrong.

Why do you want to get this in? Any more ac(8) patches coming?

--
Vadim Zhukov
05 нояб. 2014 г. 14:34 пользователь Dimitris Papastamos s...@2f30.org
написал:

 Hi,

 I've attempted to convert the hand-rolled linked lists over to
 TAILQ.  I've tested this briefly and it seems to work okay.

 Does it look good?  Let me know if I need to rework anything.

 ===
 RCS file: /cvs/src/usr.sbin/ac/ac.c,v
 retrieving revision 1.22
 diff -u -p -r1.22 ac.c
 --- ac.c31 Aug 2012 19:57:12 -  1.22
 +++ ac.c5 Nov 2014 11:30:46 -
 @@ -25,9 +25,11 @@
   * SUCH DAMAGE.
   */

 -#include sys/types.h
  #include sys/file.h
 +#include sys/queue.h
  #include sys/time.h
 +#include sys/types.h
 +
  #include err.h
  #include errno.h
  #include pwd.h
 @@ -40,28 +42,28 @@
  /*
   * this is for our list of currently logged in sessions
   */
 -struct utmp_list {
 -   struct utmp_list *next;
 +struct utmp_entry {
 struct utmp usr;
 +   TAILQ_ENTRY(utmp_entry) next;
  };

  /*
   * this is for our list of users that are accumulating time.
   */
 -struct user_list {
 -   struct user_list *next;
 +struct user_entry {
 charname[UT_NAMESIZE+1];
 time_t  secs;
 +   TAILQ_ENTRY(user_entry) next;
  };

  /*
   * this is for chosing whether to ignore a login
   */
 -struct tty_list {
 -   struct tty_list *next;
 +struct tty_entry {
 charname[UT_LINESIZE+3];
 size_t  len;
 int ret;
 +   TAILQ_ENTRY(tty_entry) next;
  };

  /*
 @@ -70,8 +72,9 @@ struct tty_list {
  static time_t  Total = 0;
  static time_t  FirstTime = 0;
  static int Flags = 0;
 -static struct user_list *Users = NULL;
 -static struct tty_list *Ttys = NULL;
 +static TAILQ_HEAD(Utmphead, utmp_entry) Utmphead;
 +static TAILQ_HEAD(Userhead, user_entry) Userhead;
 +static TAILQ_HEAD(Ttyhead, tty_entry) Ttyhead;

  #defineAC_W1   /* not _PATH_WTMP
 */
  #defineAC_D2   /* daily totals
 (ignore -p) */
 @@ -88,14 +91,13 @@ int ac(FILE *);
  void   add_tty(char *);
  intdo_tty(char *);
  FILE   *file(char *);
 -struct utmp_list   *log_in(struct utmp_list *, struct utmp *);
 -struct utmp_list   *log_out(struct utmp_list *, struct utmp *);
 -inton_console(struct utmp_list *);
 +void   log_in(struct utmp *);
 +void   log_out(struct utmp *);
 +inton_console(void);
  void   show(char *, time_t);
 -void   show_today(struct user_list *, struct utmp_list *,
 -   time_t);
 -void   show_users(struct user_list *);
 -struct user_list   *update_user(struct user_list *, char *, time_t);
 +void   show_today(time_t);
 +void   show_users(void);
 +void   update_user(char *, time_t);
  void   usage(void);

  /*
 @@ -119,12 +121,12 @@ file(char *name)
  void
  add_tty(char *name)
  {
 -   struct tty_list *tp;
 +   struct tty_entry *tp;
 char *rcp;

 Flags |= AC_T;

 -   if ((tp = malloc(sizeof(struct tty_list))) == NULL)
 +   if ((tp = malloc(sizeof(sizeof(*tp == NULL)
 err(1, malloc);
 tp-len = 0;/* full match */
 tp-ret = 1;/* do if match */
 @@ -137,8 +139,7 @@ add_tty(char *name)
 *rcp = '\0';
 tp-len = strlen(tp-name); /* match len bytes only */
 }
 -   tp-next = Ttys;
 -   Ttys = tp;
 +   TAILQ_INSERT_HEAD(Ttyhead, tp, next);
  }

  /*
 @@ -147,10 +148,10 @@ add_tty(char *name)
  int
  do_tty(char *name)
  {
 -   struct tty_list *tp;
 +   struct tty_entry *tp;
 int def_ret = 0;

 -   for (tp = Ttys; tp != NULL; tp = tp-next) {
 +   TAILQ_FOREACH(tp, Ttyhead, next) {
 if (tp-ret == 0)   /* specific don't */
 def_ret = 1;/* default do */
 if (tp-len != 0) {
 @@ -167,31 +168,30 @@ do_tty(char *name)
  /*
   * update user's login time
   */
 -struct user_list *
 -update_user(struct user_list *head, char *name, time_t secs)
 +void
 +update_user(char *name, time_t secs)
  {
 -   struct user_list *up;
 +   struct user_entry *up;

 -   for (up = head; up != NULL; up = up-next) {
 +   TAILQ_FOREACH(up, Userhead, next) {
 if (strncmp(up-name, name, sizeof (up-name) - 1) == 0) {
 up-secs += secs;
 Total += secs;
 -   return head;
 +   return;
 }
 }
 /*
  * not found so 

ether_ifdetach: remove unreachable code

2014-11-11 Thread Rafael Zalamena
Remove unreachable code from ether_ifdetach, it has been marked that way
for almost 11 years.

Index: net/if_ethersubr.c
===
RCS file: /home/rzalamena/obsdcvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.177
diff -u -p -u -r1.177 if_ethersubr.c
--- net/if_ethersubr.c  6 Nov 2014 14:28:47 -   1.177
+++ net/if_ethersubr.c  11 Nov 2014 12:17:13 -
@@ -810,11 +810,6 @@ ether_ifdetach(struct ifnet *ifp)
LIST_REMOVE(enm, enm_list);
free(enm, M_IFMADDR, 0);
}
-
-#if 0
-   /* moved to if_detach() */
-   if_free_sadl(ifp);
-#endif
 }
 
 #if 0



Re: Convert hand-rolled lists to TAILQ_* in ac(8)

2014-11-11 Thread Dimitris Papastamos
On Tue, Nov 11, 2014 at 02:21:35PM +0400, Vadim Zhukov wrote:
 Why TAILQ? SLIST should be enough.

SLIST makes sense yes.

 Also, moving sys/types.h is wrong.

OK, will fix.

 Why do you want to get this in? Any more ac(8) patches coming?

Not really, I was just randomly browsing through the source tree
and was looking for something to improve.



Re: [PATCH] CryptAcquireContext and CryptGenRandom returns zero (FALSE) if fails.

2014-11-11 Thread Dongsheng Song
On Tue, Nov 11, 2014 at 9:56 PM, Brent Cook bust...@gmail.com wrote:
 Mystery solved!

This patch fixed the exited immediately issue.
When getentropy failed, LibReSSL will call _getentropy_fail, it call
TerminateProcess(GetCurrentProcess(), 0) to exit.



Re: [PATCH] CryptAcquireContext and CryptGenRandom returns zero (FALSE) if fails.

2014-11-11 Thread Brent Cook
Yes, this is an intentional design feature: fail fast if there is no entropy.

I'm looking at your other patches and testing with mingw 3.1.0, but am
having to fix a number of minor build failures.

Out of curiosity, what version are you testing against?

On Tue, Nov 11, 2014 at 8:07 AM, Dongsheng Song
dongsheng.s...@gmail.com wrote:
 On Tue, Nov 11, 2014 at 9:56 PM, Brent Cook bust...@gmail.com wrote:
 Mystery solved!

 This patch fixed the exited immediately issue.
 When getentropy failed, LibReSSL will call _getentropy_fail, it call
 TerminateProcess(GetCurrentProcess(), 0) to exit.



Re: LibreSSL: GOWindows support

2014-11-11 Thread Brent Cook
I gave the openbsd src patches a spin last night. I wonder if there's
a way we could instead coerce mingw into pretending to be more POSIX
by way of header tricks in the portable tree:

Create a stubs for each POSIX network header, e.g. include/sys/socket.h:

#ifndef _WIN32
#include_next sys/socket.h
#else
#include win32netcompat.h
#endif

Then, include/win32netcompat.h contains:

#ifndef LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H
#define LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H

#include ws2tcpip.h
#define SHUT_RDWR SD_BOTH
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND

#endif

Repeat for each missing networking header. Mingw seens to already be
full of little hacks like this (e.g. look at all the _POSIX sections
in the headers).

On Fri, Nov 7, 2014 at 8:26 PM, Dongsheng Song dongsheng.s...@gmail.com wrote:
 On Fri, Nov 7, 2014 at 11:07 PM, Brent Cook bust...@gmail.com wrote:

 On Nov 7, 2014, at 8:21 AM, Dongsheng Song dongsheng.s...@gmail.com wrote:

 I need some code changes for Windows support.
 e.g.

 --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c
 +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c
 @@ -57,13 +57,17 @@
  *
  */

 +#ifdef _WIN32
 +#include ws2tcpip.h
 +#else
 #include sys/socket.h
 -#include sys/time.h
 -
 #include netinet/in.h
 +#include netdb.h
 +#endif
 +
 +#include sys/time.h

 #include errno.h
 -#include netdb.h
 #include stdio.h
 #include string.h
 #include unistd.h

 Thanks for the first set of patches on the portable tree!

 I would think the #ifdef _WIN32 is probably the lesser of two evils.

 Hopefully this will be largely confined to bio and the openssl app?


 yes, I can generate openssl.exe with my local patches.
 I use #ifdef _WIN32 to guard headres, socket functions, signal
 functions, tty functions.
 fork is more painful, so I defined OPENSSL_NO_SPEED. maybe I'll write
 a Windows version speed_main.

 You'll also need to audit file descriptor usage carefully, so they
 are closed properly:


 Thanks.



Re: LibreSSL GOST code cleanup

2014-11-11 Thread Miod Vallat
  Thanks.
 
 Looking again I saw no obvious issues.

\o/

   +   if (EC_GROUP_get_order(group, order, ctx) == 0) {
   +   /*
   +* XXX EC_GROUP_get_order() will return 0 if successful 
   but
   +* XXX order == 0. But then BN_mod below would fail 
   anyway.
   +*/
   +   goto err;
   +   }
 
  In theory it is fine to add
  if  (BN_is_zero(order)) goto err;
 
  On the other hand no GOST curves/keys should have order == 0.
 
  Agreed. Which is why I did not add explicit BN_is_zero() checks, I think
  this will not be necessary in practice. The comment is there to stress
  the fact that the last reviewer is aware of this particular case.
 
 As this causes questions, it might be better to replace a comment with
 BN_is_zero() and be sure that there will be no further questions.

So do you prefer something like this:

if (EC_GROUP_get_order(group, order, ctx) == 0) {
if (!BN_is_zero(order))
goto err;
}

and let the computation fail at the next step?

However I am not sure we can trust the state of `order' if
EC_GROUP_get_order() fails before checking that order is zero.

I'll probably remove these XXX comments since they seem to produce more
confusion, which is not what I intended (-:

Miod



keyboard problem related to xhci

2014-11-11 Thread Dimitris Papastamos
Hi everyone,

I just built the kernel with XHCI_DEBUG enabled.  I am having
the following problem:

1) boot the machine with keyboard and mouse plugged in
2) keyboard does not respond at the login prompt
3) plug it out and plug it back in at the same USB port
4) keyboard does not respond
5) plug it out and plug it back in at another USB port
6) keyboard works fine

Below is my dmesg, it shows the same sequence of operations
as described above.

Hope this helps, let me know if you need me to test
anything else.

Cheers,
Dimitris

OpenBSD 5.6-current (GENERIC.MP) #11: Tue Nov 11 19:24:27 GMT 2014
r...@pancakes.2f30.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 7450062848 (7104MB)
avail mem = 7247908864 (6912MB)
warning: no entropy supplied by boot loader
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xec1e0 (76 entries)
bios0: vendor American Megatrends Inc. version 1.03 date 06/18/2014
bios0: Shuttle Inc. XH81V
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC FPDT SLIC SSDT SSDT MCFG HPET SSDT SSDT
acpi0: wakeup devices PXSX(S4) RP01(S4) PXSX(S4) RP02(S4) PXSX(S4) RP03(S4) 
PXSX(S4) RP04(S4) PXSX(S4) RP05(S4) PXSX(S4) RP06(S4) PXSX(S4) RP07(S4) 
PXSX(S4) RP08(S4) [...]
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) Core(TM) i3-4360 CPU @ 3.70GHz, 3692.01 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,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
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
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i3-4360 CPU @ 3.70GHz, 3691.47 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,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 1 (application processor)
cpu2: Intel(R) Core(TM) i3-4360 CPU @ 3.70GHz, 3691.47 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,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 1, core 0, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i3-4360 CPU @ 3.70GHz, 3691.47 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,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 8 pa 0xfec0, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xf800, bus 0-63
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (RP01)
acpiprt2 at acpi0: bus 2 (RP03)
acpiprt3 at acpi0: bus 3 (RP04)
acpiprt4 at acpi0: bus -1 (PEG0)
acpiec0 at acpi0: not present
acpicpu0 at acpi0: C1, PSS
acpicpu1 at acpi0: C1, PSS
acpicpu2 at acpi0: C1, PSS
acpicpu3 at acpi0: C1, PSS
acpipwrres0 at acpi0: FN00, resource for FAN0
acpipwrres1 at acpi0: FN01, resource for FAN1
acpipwrres2 at acpi0: FN02, resource for FAN2
acpipwrres3 at acpi0: FN03, resource for FAN3
acpipwrres4 at acpi0: FN04, resource for FAN4
acpitz0 at acpi0: critical temperature is 105 degC
acpitz1 at acpi0: critical temperature is 105 degC
acpibat0 at acpi0: BAT0 not present
acpibat1 at acpi0: BAT1 not present
acpibat2 at acpi0: BAT2 not present
acpibtn0 at acpi0: PWRB
acpibtn1 at acpi0: LID0
acpivideo0 at acpi0: GFX0
acpivout0 at acpivideo0: DD1F
cpu0: Enhanced SpeedStep 3692 MHz: speeds: 3700, 3500, 3300, 3100, 2900, 2700, 
2500, 2300, 2200, 2000, 1800, 1600, 1400, 1200, 1000, 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 Intel Core 4G Host rev 0x06
vga1 at pci0 dev 2 function 0 Intel HD Graphics 4600 rev 0x06
intagp at vga1 not configured
inteldrm0 at vga1
drm0 at inteldrm0
drm: Memory usable by graphics device = 2048M
error: [drm:pid0:i915_write32] *ERROR* Unknown unclaimed register before 
writing 

vi: remove portability goo

2014-11-11 Thread Martin Natano
The more I dig into vi, the more portability goo I find: The TRUE and
FALSE constants are defined by curses.h, thus no need to check for
them. The mvchgat macro, VWERASE and tons of other macros are present
in OpenBSDs curses implementation, this means a lot of the #ifdef maze
can be removed. SIGWINCH is present in libc, so is MAP_FILE and
NL_ARGMAX and d_namlen. The port.h header file does nothing and can be
removed.

See diff below; binary changes due to d_namlen changes and __LINE__
usage in other areas, which are not touched by this diff.

cheers,
natano


Index: cl/cl.h
===
RCS file: /cvs/src/usr.bin/vi/cl/cl.h,v
retrieving revision 1.7
diff -u -r1.7 cl.h
--- cl/cl.h 8 Jan 2006 21:05:39 -   1.7
+++ cl/cl.h 11 Nov 2014 20:08:38 -
@@ -65,16 +65,4 @@
 /* X11 xterm escape sequence to rename the icon/window. */
 #defineXTERM_RENAME\033]0;%s\007
 
-/*
- * XXX
- * Some implementations of curses.h don't define these for us.  Used for
- * compatibility only.
- */
-#ifndef TRUE
-#defineTRUE1
-#endif
-#ifndef FALSE
-#defineFALSE   0
-#endif
-
 #include cl_extern.h
Index: cl/cl_funcs.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_funcs.c,v
retrieving revision 1.15
diff -u -r1.15 cl_funcs.c
--- cl/cl_funcs.c   6 Nov 2014 10:48:52 -   1.15
+++ cl/cl_funcs.c   11 Nov 2014 20:08:38 -
@@ -300,24 +300,7 @@
 */
if (!F_ISSET(sp, SC_SCR_EXWROTE)  IS_SPLIT(sp)) {
getyx(stdscr, oldy, oldx);
-#ifdef mvchgat
mvchgat(RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
-#else
-   for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
-   (void)move(lno, col);
-   ch = winch(stdscr);
-   if (isblank(ch))
-   ++spcnt;
-   else {
-   (void)move(lno, col - spcnt);
-   for (; spcnt  0; --spcnt)
-   (void)addch(' ');
-   (void)addch(ch);
-   }
-   if (++col = sp-cols)
-   break;
-   }
-#endif
(void)move(oldy, oldx);
}
 
@@ -433,11 +416,9 @@
case KEY_VKILL:
*dnep = (*chp = clp-orig.c_cc[VKILL]) == _POSIX_VDISABLE;
break;
-#ifdef VWERASE
case KEY_VWERASE:
*dnep = (*chp = clp-orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
break;
-#endif
default:
*dnep = 1;
break;
Index: cl/cl_main.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_main.c,v
retrieving revision 1.21
diff -u -r1.21 cl_main.c
--- cl/cl_main.c10 Nov 2014 21:34:13 -  1.21
+++ cl/cl_main.c11 Nov 2014 20:08:38 -
@@ -297,12 +297,9 @@
sigaddset(__sigblockset, SIGINT) ||
setsig(SIGINT, clp-oact[INDX_INT], h_int) ||
sigaddset(__sigblockset, SIGTERM) ||
-   setsig(SIGTERM, clp-oact[INDX_TERM], h_term)
-#ifdef SIGWINCH
-   ||
+   setsig(SIGTERM, clp-oact[INDX_TERM], h_term) ||
sigaddset(__sigblockset, SIGWINCH) ||
setsig(SIGWINCH, clp-oact[INDX_WINCH], h_winch)
-#endif
) {
perr(gp-progname, NULL);
return (1);
@@ -310,11 +307,8 @@
} else
if (setsig(SIGHUP, NULL, h_hup) ||
setsig(SIGINT, NULL, h_int) ||
-   setsig(SIGTERM, NULL, h_term)
-#ifdef SIGWINCH
-   ||
+   setsig(SIGTERM, NULL, h_term) ||
setsig(SIGWINCH, NULL, h_winch)
-#endif
) {
msgq(sp, M_SYSERR, signal-reset);
}
@@ -369,9 +363,7 @@
(void)sigaction(SIGHUP, NULL, clp-oact[INDX_HUP]);
(void)sigaction(SIGINT, NULL, clp-oact[INDX_INT]);
(void)sigaction(SIGTERM, NULL, clp-oact[INDX_TERM]);
-#ifdef SIGWINCH
(void)sigaction(SIGWINCH, NULL, clp-oact[INDX_WINCH]);
-#endif
 }
 
 /*
Index: cl/cl_screen.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
retrieving revision 1.20
diff -u -r1.20 cl_screen.c
--- cl/cl_screen.c  28 Nov 2013 22:12:40 -  1.20
+++ cl/cl_screen.c  11 Nov 2014 20:08:38 -
@@ -337,9 +337,7 @@
clp-vi_enter.c_iflag |= IXOFF;
 
clp-vi_enter.c_lflag |= ISIG;
-#ifdef VDSUSP
clp-vi_enter.c_cc[VDSUSP] = _POSIX_VDISABLE;
-#endif
clp-vi_enter.c_cc[VQUIT] = _POSIX_VDISABLE;
clp-vi_enter.c_cc[VSUSP] = 

Re: [PATCH] CryptAcquireContext and CryptGenRandom returns zero (FALSE) if fails.

2014-11-11 Thread Dongsheng Song
On Tue, Nov 11, 2014 at 10:17 PM, Brent Cook bust...@gmail.com wrote:
 Yes, this is an intentional design feature: fail fast if there is no entropy.

 I'm looking at your other patches and testing with mingw 3.1.0, but am
 having to fix a number of minor build failures.

 Out of curiosity, what version are you testing against?


I use mingw-w64, because it support both 32 bit and 64 bit, and accept
patches very fast.

git clone git://git.code.sf.net/p/mingw-w64/mingw-w64

http://sourceforge.net/p/mingw-w64/mingw-w64/commit_browser



VLAN + bridge regression

2014-11-11 Thread Rafael Zalamena
The diff attached to this mail fixes the bridge output for VLANs noted in
this link:
http://marc.info/?l=openbsd-miscm=141508025731320w=2

Now when we are doing VLAN input we check whether the VLAN is a bridge port
or not, if it does then we have to do nothing and just pass the packet and
the bridge will handle it. This way we save some time by not doing VLAN
popping in the packets.

Bridge was not ready or consistent in some places to handle this, so some
checks were altered to consider tagged packets without the M_VLANTAG flag.
(this means we continue to ignore tagged packets in 'bridge_ip' and
'bridge_blocknonip')
Also, when copying packets, remember to copy the packet M_VLANTAG as well.

Altered the function vlan_input to update the ether_input ifp pointer, so
now ether_input doesn't need to be re-entered when we didn't pop the VLAN
tag.

Lightly tested with in my VPLS setup.

Index: net/if_bridge.c
===
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.227
diff -u -p -r1.227 if_bridge.c
--- net/if_bridge.c 8 Sep 2014 06:24:13 -   1.227
+++ net/if_bridge.c 12 Nov 2014 01:40:03 -
@@ -1373,6 +1373,9 @@ bridge_input(struct ifnet *ifp, struct e
if (mc == NULL)
return (m);
bcopy(eh, mtod(mc, caddr_t), ETHER_HDR_LEN);
+   if (m-m_flags  M_VLANTAG)
+   mc-m_flags |= M_VLANTAG;
+
s = splnet();
if (IF_QFULL(sc-sc_if.if_snd)) {
m_freem(mc);
@@ -2064,12 +2067,13 @@ bridge_blocknonip(struct ether_header *e
if (m-m_pkthdr.len  ETHER_HDR_LEN)
return (1);
 
+   etype = ntohs(eh-ether_type);
 #if NVLAN  0
-   if (m-m_flags  M_VLANTAG)
+   if ((m-m_flags  M_VLANTAG) || etype == ETHERTYPE_VLAN ||
+   etype == ETHERTYPE_QINQ)
return (1);
 #endif
 
-   etype = ntohs(eh-ether_type);
switch (etype) {
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
@@ -2399,12 +2403,12 @@ bridge_ip(struct bridge_softc *sc, int d
int hlen;
u_int16_t etype;
 
+   etype = ntohs(eh-ether_type);
 #if NVLAN  0
-   if (m-m_flags  M_VLANTAG)
+   if ((m-m_flags  M_VLANTAG) || etype == ETHERTYPE_VLAN ||
+   etype == ETHERTYPE_QINQ)
return (m);
 #endif
-
-   etype = ntohs(eh-ether_type);
 
if (etype != ETHERTYPE_IP  etype != ETHERTYPE_IPV6) {
if (etype  ETHERMTU ||
Index: net/if_ethersubr.c
===
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.177
diff -u -p -r1.177 if_ethersubr.c
--- net/if_ethersubr.c  6 Nov 2014 14:28:47 -   1.177
+++ net/if_ethersubr.c  12 Nov 2014 01:40:03 -
@@ -552,7 +552,7 @@ ether_input(struct ifnet *ifp0, struct e
 
 #if NVLAN  0
if (((m-m_flags  M_VLANTAG) || etype == ETHERTYPE_VLAN ||
-   etype == ETHERTYPE_QINQ)  (vlan_input(eh, m) == 0))
+   etype == ETHERTYPE_QINQ)  (vlan_input(eh, m, ifp) == 0))
return;
 #endif
 
Index: net/if_vlan.c
===
RCS file: /cvs/src/sys/net/if_vlan.c,v
retrieving revision 1.109
diff -u -p -r1.109 if_vlan.c
--- net/if_vlan.c   7 Oct 2014 11:16:23 -   1.109
+++ net/if_vlan.c   12 Nov 2014 01:40:03 -
@@ -47,6 +47,7 @@
  * will not modify the ethernet header.
  */
 
+#include bridge.h
 #include vlan.h
 
 #include sys/param.h
@@ -272,7 +273,7 @@ vlan_start(struct ifnet *ifp)
  * vlan_input() returns 0 if it has consumed the packet, 1 otherwise.
  */
 int
-vlan_input(struct ether_header *eh, struct mbuf *m)
+vlan_input(struct ether_header *eh, struct mbuf *m, struct ifnet **ifp0)
 {
struct ifvlan   *ifv;
struct ifnet*ifp = m-m_pkthdr.rcvif;
@@ -320,6 +321,21 @@ vlan_input(struct ether_header *eh, stru
 * reentrant!).
 */
m-m_pkthdr.rcvif = ifv-ifv_if;
+
+#if NBRIDGE  0
+   /* If we are in a bridge, let it handle it */
+   if (ifv-ifv_if.if_bridgeport != NULL) {
+   *ifp0 = ifv-ifv_if;
+#if NBPFILTER  0
+   if (ifv-ifv_if.if_bpf)
+   bpf_mtap_hdr(ifv-ifv_if.if_bpf, (char *)eh,
+   ETHER_HDR_LEN, m, BPF_DIRECTION_IN, NULL);
+#endif
+   ifv-ifv_if.if_ipackets++;
+   return (1);
+   }
+#endif
+
if (m-m_flags  M_VLANTAG) {
m-m_flags = ~M_VLANTAG;
} else {
Index: net/if_vlan_var.h
===
RCS file: /cvs/src/sys/net/if_vlan_var.h,v
retrieving revision 1.24
diff -u -p -r1.24 if_vlan_var.h
--- net/if_vlan_var.h   24 Oct 2013 11:14:33 -  1.24
+++ net/if_vlan_var.h   12 Nov 2014 01:40:03 -
@@ -95,7 +95,7 @@ structifvlan {
 #define