Fix memory initialization for the octeon-based DSR-500

2013-08-21 Thread Paul Irofti
I don't think we should substract the 256 upperbound from realmem_bytes
if our current available memory is less than that.

The following diff attempts to fix that. Comments, okays?


Index: arch/octeon/octeon/machdep.c
===
RCS file: /cvs/src/sys/arch/octeon/octeon/machdep.c,v
retrieving revision 1.39
diff -u -p -r1.39 machdep.c
--- arch/octeon/octeon/machdep.c21 Aug 2013 11:25:33 -  1.39
+++ arch/octeon/octeon/machdep.c21 Aug 2013 11:27:10 -
@@ -168,12 +168,13 @@ octeon_memory_init(struct boot_info *boo
if (boot_info-board_type == BOARD_TYPE_SIM) {
phys_avail[1] = (96  20);
} else {
-   if (realmem_bytes  OCTEON_DRAM_FIRST_256_END)
+   if (realmem_bytes  OCTEON_DRAM_FIRST_256_END) {
phys_avail[1] = OCTEON_DRAM_FIRST_256_END;
-   else
+   realmem_bytes -= OCTEON_DRAM_FIRST_256_END;
+   realmem_bytes = ~(PAGE_SIZE - 1);
+   } else
phys_avail[1] = realmem_bytes;
-   realmem_bytes -= OCTEON_DRAM_FIRST_256_END;
-   realmem_bytes = ~(PAGE_SIZE - 1);
+
mem_layout[0].mem_last_page = atop(phys_avail[1]);
}
 



Re: Don't iterate over in_ifaddr in in_control()

2013-08-21 Thread Martin Pieuchot
On 21/08/13(Wed) 16:29, Martin Pieuchot wrote:
 Now that IPv4 addresses stay on the interface list even if something 
 bad occurs during in_ifinit(), I'd like to make in_control() look for
 the previously configured addresses on the interface list rather than
 on the global list.

Please disregard this diff, it's not ready.



Re: bump time_t/other type fixes to spamd

2013-08-21 Thread Todd C. Miller
Speaking of spamd, I've been running the following diff for five
months or so.  It removes the use of time_t in the greylist db file
and provides backwards compat for 32-bit times.

 - todd

Index: usr.sbin/spamdb/Makefile
===
RCS file: /home/cvs/openbsd/src/usr.sbin/spamdb/Makefile,v
retrieving revision 1.3
diff -u -p -u -r1.3 Makefile
--- usr.sbin/spamdb/Makefile24 May 2005 22:23:05 -  1.3
+++ usr.sbin/spamdb/Makefile22 Apr 2013 20:03:45 -
@@ -1,9 +1,11 @@
 #  $OpenBSD: Makefile,v 1.3 2005/05/24 22:23:05 millert Exp $
 
 PROG=  spamdb
-SRCS=  spamdb.c
+SRCS=  spamdb.c gdcopy.c
 MAN=   spamdb.8
 
 CFLAGS+= -Wall -Wstrict-prototypes -I${.CURDIR}/../../libexec/spamd
+
+.PATH: ${.CURDIR}/../../libexec/spamd
 
 .include bsd.prog.mk
Index: usr.sbin/spamdb/spamdb.c
===
RCS file: /home/cvs/openbsd/src/usr.sbin/spamdb/spamdb.c,v
retrieving revision 1.26
diff -u -p -u -r1.26 spamdb.c
--- usr.sbin/spamdb/spamdb.c22 Apr 2013 19:49:36 -  1.26
+++ usr.sbin/spamdb/spamdb.c22 Apr 2013 20:03:45 -
@@ -129,12 +129,11 @@ dbupdate(DB *db, char *ip, int add, int 
goto bad;
}
} else {
-   if (dbd.size != sizeof(gd)) {
+   if (gdcopyin(dbd, gd) == -1) {
/* whatever this is, it doesn't belong */
db-del(db, dbk, 0);
goto bad;
}
-   memcpy(gd, dbd.data, sizeof(gd));
gd.pcount++;
switch (type) {
case WHITE:
@@ -185,11 +184,10 @@ dblist(DB *db)
r = db-seq(db, dbk, dbd, R_NEXT)) {
char *a, *cp;
 
-   if ((dbk.size  1) || dbd.size != sizeof(struct gdata)) {
+   if ((dbk.size  1) || gdcopyin(dbd, gd) == -1) {
db-close(db);
errx(1, bogus size db entry - bad db file?);
}
-   memcpy(gd, dbd.data, sizeof(gd));
a = malloc(dbk.size + 1);
if (a == NULL)
err(1, malloc);
Index: libexec/spamd/Makefile
===
RCS file: /home/cvs/openbsd/src/libexec/spamd/Makefile,v
retrieving revision 1.9
diff -u -p -u -r1.9 Makefile
--- libexec/spamd/Makefile  4 Mar 2007 03:19:41 -   1.9
+++ libexec/spamd/Makefile  22 Apr 2013 20:03:45 -
@@ -1,7 +1,7 @@
 #  $OpenBSD: Makefile,v 1.9 2007/03/04 03:19:41 beck Exp $
 
 PROG=  spamd
-SRCS=  spamd.c sdl.c grey.c sync.c
+SRCS=  spamd.c sdl.c gdcopy.c grey.c sync.c
 MAN=   spamd.8
 
 CFLAGS+= -Wall -Wstrict-prototypes
Index: libexec/spamd/gdcopy.c
===
RCS file: libexec/spamd/gdcopy.c
diff -N libexec/spamd/gdcopy.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ libexec/spamd/gdcopy.c  22 Apr 2013 20:03:45 -
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013 Todd C. Miller todd.mil...@courtesan.com
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include sys/types.h
+#include db.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include time.h
+
+#include grey.h
+
+/* Fill in struct gdata from DBT, converting from obsolete format as needed. */
+int
+gdcopyin(const void *v, struct gdata *gd)
+{
+   const DBT *dbd = v;
+   int rc = 0;
+
+   if (dbd-size == sizeof(struct gdata)) {
+   /* Current grey data format. */
+   memcpy(gd, dbd-data, sizeof(struct gdata));
+   } else if (dbd-size == sizeof(struct ogdata)) {
+   /* Backwards compat for obsolete grey data format. */
+   struct ogdata ogd;
+   memcpy(ogd, dbd-data, sizeof(struct ogdata));
+   gd-first = ogd.first;
+   gd-pass = ogd.pass;
+   gd-expire = ogd.expire;
+   gd-bcount = ogd.bcount;
+   gd-pcount = ogd.pcount;
+   } else {
+   /* Unsupported grey data format. */
+   rc = -1;
+   }
+   

Re: bump time_t/other type fixes to spamd

2013-08-21 Thread Bob Beck
I think this would be the way to go.

On Wed, Aug 21, 2013 at 9:14 AM, Todd C. Miller
todd.mil...@courtesan.com wrote:
 Speaking of spamd, I've been running the following diff for five
 months or so.  It removes the use of time_t in the greylist db file
 and provides backwards compat for 32-bit times.

  - todd

 Index: usr.sbin/spamdb/Makefile
 ===
 RCS file: /home/cvs/openbsd/src/usr.sbin/spamdb/Makefile,v
 retrieving revision 1.3
 diff -u -p -u -r1.3 Makefile
 --- usr.sbin/spamdb/Makefile24 May 2005 22:23:05 -  1.3
 +++ usr.sbin/spamdb/Makefile22 Apr 2013 20:03:45 -
 @@ -1,9 +1,11 @@
  #  $OpenBSD: Makefile,v 1.3 2005/05/24 22:23:05 millert Exp $

  PROG=  spamdb
 -SRCS=  spamdb.c
 +SRCS=  spamdb.c gdcopy.c
  MAN=   spamdb.8

  CFLAGS+= -Wall -Wstrict-prototypes -I${.CURDIR}/../../libexec/spamd
 +
 +.PATH: ${.CURDIR}/../../libexec/spamd

  .include bsd.prog.mk
 Index: usr.sbin/spamdb/spamdb.c
 ===
 RCS file: /home/cvs/openbsd/src/usr.sbin/spamdb/spamdb.c,v
 retrieving revision 1.26
 diff -u -p -u -r1.26 spamdb.c
 --- usr.sbin/spamdb/spamdb.c22 Apr 2013 19:49:36 -  1.26
 +++ usr.sbin/spamdb/spamdb.c22 Apr 2013 20:03:45 -
 @@ -129,12 +129,11 @@ dbupdate(DB *db, char *ip, int add, int
 goto bad;
 }
 } else {
 -   if (dbd.size != sizeof(gd)) {
 +   if (gdcopyin(dbd, gd) == -1) {
 /* whatever this is, it doesn't belong */
 db-del(db, dbk, 0);
 goto bad;
 }
 -   memcpy(gd, dbd.data, sizeof(gd));
 gd.pcount++;
 switch (type) {
 case WHITE:
 @@ -185,11 +184,10 @@ dblist(DB *db)
 r = db-seq(db, dbk, dbd, R_NEXT)) {
 char *a, *cp;

 -   if ((dbk.size  1) || dbd.size != sizeof(struct gdata)) {
 +   if ((dbk.size  1) || gdcopyin(dbd, gd) == -1) {
 db-close(db);
 errx(1, bogus size db entry - bad db file?);
 }
 -   memcpy(gd, dbd.data, sizeof(gd));
 a = malloc(dbk.size + 1);
 if (a == NULL)
 err(1, malloc);
 Index: libexec/spamd/Makefile
 ===
 RCS file: /home/cvs/openbsd/src/libexec/spamd/Makefile,v
 retrieving revision 1.9
 diff -u -p -u -r1.9 Makefile
 --- libexec/spamd/Makefile  4 Mar 2007 03:19:41 -   1.9
 +++ libexec/spamd/Makefile  22 Apr 2013 20:03:45 -
 @@ -1,7 +1,7 @@
  #  $OpenBSD: Makefile,v 1.9 2007/03/04 03:19:41 beck Exp $

  PROG=  spamd
 -SRCS=  spamd.c sdl.c grey.c sync.c
 +SRCS=  spamd.c sdl.c gdcopy.c grey.c sync.c
  MAN=   spamd.8

  CFLAGS+= -Wall -Wstrict-prototypes
 Index: libexec/spamd/gdcopy.c
 ===
 RCS file: libexec/spamd/gdcopy.c
 diff -N libexec/spamd/gdcopy.c
 --- /dev/null   1 Jan 1970 00:00:00 -
 +++ libexec/spamd/gdcopy.c  22 Apr 2013 20:03:45 -
 @@ -0,0 +1,50 @@
 +/*
 + * Copyright (c) 2013 Todd C. Miller todd.mil...@courtesan.com
 + *
 + * Permission to use, copy, modify, and distribute this software for any
 + * purpose with or without fee is hereby granted, provided that the above
 + * copyright notice and this permission notice appear in all copies.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 + */
 +
 +#include sys/types.h
 +#include db.h
 +#include stdio.h
 +#include stdlib.h
 +#include string.h
 +#include time.h
 +
 +#include grey.h
 +
 +/* Fill in struct gdata from DBT, converting from obsolete format as needed. 
 */
 +int
 +gdcopyin(const void *v, struct gdata *gd)
 +{
 +   const DBT *dbd = v;
 +   int rc = 0;
 +
 +   if (dbd-size == sizeof(struct gdata)) {
 +   /* Current grey data format. */
 +   memcpy(gd, dbd-data, sizeof(struct gdata));
 +   } else if (dbd-size == sizeof(struct ogdata)) {
 +   /* Backwards compat for obsolete grey data format. */
 +   struct ogdata ogd;
 +   memcpy(ogd, dbd-data, sizeof(struct ogdata));
 +   gd-first = ogd.first;
 +   gd-pass = ogd.pass;
 

Re: bump time_t/other type fixes to spamd

2013-08-21 Thread Todd C. Miller
On Tue, 20 Aug 2013 20:36:38 -0700, William Orr wrote:

 Theo pointed out that it would be better to change whitecount to an int,
 so as to match the call to configure_pf().
 
 Since trapcount is logically similar, and uses the same iterator
 variable in freeaddrlists(), I changed that to an int as well. This
 still includes the sscanf time_t fix.

That looks fine to me.

 - todd



openbsd ioctl fix (in6.c)

2013-08-21 Thread Loganaden Velvindron
I'm not sure if applies to OpenBSD as well, but NetBSD
also disallowed SIOCSIFDSTADDR for ioctl.

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/netinet6/in6.c?annotate=1.166only_with_tag=MAIN

1.2   itojun374:switch (cmd) {
1.104 christos  375:/*
1.105 christos  376: * XXX: Fix me, once we fix SIOCSIFADDR, 
SIOCIFDSTADDR, etc.
1.104 christos  377: */
378:case SIOCSIFADDR:
1.105 christos  379:case SIOCSIFDSTADDR:
1.129 cube  380: #ifdef SIOCSIFCONF_X25
1.106 christos  381:case SIOCSIFCONF_X25:
1.110 matt  382: #endif
1.104 christos  383:return EOPNOTSUPP;

If it's indeed the case in OpenBSD, here's a diff:

Index: sys/netinet6/in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.117
diff -u -p -r1.117 in6.c
--- sys/netinet6/in6.c  13 Aug 2013 05:52:25 -  1.117
+++ sys/netinet6/in6.c  21 Aug 2013 15:50:00 -
@@ -429,8 +429,9 @@ in6_control(struct socket *so, u_long cm
sa6 = ifr-ifr_addr;
break;
case SIOCSIFADDR:
+   case SIOCSIFDSTADDR:
/*
-* Do not pass this ioctl to driver handler since it is not
+* Do not pass those ioctl to driver handler since they are not
 * properly setup. Instead just error out.
 */
return (EOPNOTSUPP);



Re: OpenBSD in6 ioctl fix

2013-08-21 Thread Loganaden Velvindron
On Wed, Aug 21, 2013 at 8:05 PM, Loganaden Velvindron
lo...@elandsys.com wrote:
 It appears that SIOCSIFDSTADDR should not be allowed
 upon an AF_INET6 socket as well.


 From netbsd:
 http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/netinet6/in6.c?annotate=1.166only_with_tag=MAIN

 1.2   itojun374:switch (cmd) {
 1.104 christos  375:/*
 1.105 christos  376: * XXX: Fix me, once we fix SIOCSIFADDR, 
 SIOCIFDSTADDR, etc.
 1.104 christos  377: */
 378:case SIOCSIFADDR:
 1.105 christos  379:case SIOCSIFDSTADDR:
 1.129 cube  380: #ifdef SIOCSIFCONF_X25
 1.106 christos  381:case SIOCSIFCONF_X25:
 1.110 matt  382: #endif
 1.104 christos  383:return EOPNOTSUPP;

 diff:
 Index: sys/netinet6/in6.c
 ===
 RCS file: /cvs/src/sys/netinet6/in6.c,v
 retrieving revision 1.117
 diff -u -p -r1.117 in6.c
 --- sys/netinet6/in6.c  13 Aug 2013 05:52:25 -  1.117
 +++ sys/netinet6/in6.c  21 Aug 2013 15:50:00 -
 @@ -429,8 +429,9 @@ in6_control(struct socket *so, u_long cm
 sa6 = ifr-ifr_addr;
 break;
 case SIOCSIFADDR:
 +   case SIOCSIFDSTADDR:
 /*
 -* Do not pass this ioctl to driver handler since it is not
 +* Do not pass those ioctl to driver handler since they are 
 not
  * properly setup. Instead just error out.
  */
 return (EOPNOTSUPP);


Sorry for double-posting. please disregard this mail.


-- 
This message is strictly personal and the opinions expressed do not
represent those of my employers, either past or present.



OpenBSD in6 ioctl fix

2013-08-21 Thread Loganaden Velvindron
It appears that SIOCSIFDSTADDR should not be allowed
upon an AF_INET6 socket as well.


From netbsd:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/netinet6/in6.c?annotate=1.166only_with_tag=MAIN

1.2   itojun374:switch (cmd) {
1.104 christos  375:/*
1.105 christos  376: * XXX: Fix me, once we fix SIOCSIFADDR, 
SIOCIFDSTADDR, etc.
1.104 christos  377: */
378:case SIOCSIFADDR:
1.105 christos  379:case SIOCSIFDSTADDR:
1.129 cube  380: #ifdef SIOCSIFCONF_X25
1.106 christos  381:case SIOCSIFCONF_X25:
1.110 matt  382: #endif
1.104 christos  383:return EOPNOTSUPP;

diff:
Index: sys/netinet6/in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.117
diff -u -p -r1.117 in6.c
--- sys/netinet6/in6.c  13 Aug 2013 05:52:25 -  1.117
+++ sys/netinet6/in6.c  21 Aug 2013 15:50:00 -
@@ -429,8 +429,9 @@ in6_control(struct socket *so, u_long cm
sa6 = ifr-ifr_addr;
break;
case SIOCSIFADDR:
+   case SIOCSIFDSTADDR:
/*
-* Do not pass this ioctl to driver handler since it is not
+* Do not pass those ioctl to driver handler since they are not
 * properly setup. Instead just error out.
 */
return (EOPNOTSUPP);



Mention -I option in cvs update synopsis

2013-08-21 Thread Vadim Zhukov
This adds a mention of -I name option for cvs update command in
its synopsis. Okay?

--
  WBR,
Vadim Zhukov


Index: man/cvs.1
===
RCS file: /cvs/src/gnu/usr.bin/cvs/man/cvs.1,v
retrieving revision 1.12
diff -u -p -r1.12 cvs.1
--- man/cvs.1   3 Jun 2013 17:02:36 -   1.12
+++ man/cvs.1   21 Aug 2013 22:06:44 -
@@ -1696,7 +1696,7 @@ executes recursively through subdirector
 using the standard \fB\-l\fP option, or specify the recursion
 explicitly by using \fB\-R\fP.
 .TP
-\fBupdate\fP [\fB\-ACdf\|lPpQqR\fP] [\fB\-d\fP] [\fB\-r\fP \fItag\fP|\fB\-D\fP 
\fIdate\fP] \fIfiles\|.\|.\|.\fP
+\fBupdate\fP [\fB\-ACdf\|lPpQqR\fP] [\fB\-d\fP] [\fB\-I\fP \fIname\fP] 
[\fB\-r\fP \fItag\fP|\fB\-D\fP \fIdate\fP] \fIfiles\|.\|.\|.\fP
 .I Requires:
 repository, working directory.
 .br



Re: Mention -I option in cvs update synopsis

2013-08-21 Thread Andres Perera
-l for cvs update is a boolean option that doesn't take an operand

On Wed, Aug 21, 2013 at 5:38 PM, Vadim Zhukov persg...@gmail.com wrote:
 This adds a mention of -I name option for cvs update command in
 its synopsis. Okay?

 --
   WBR,
 Vadim Zhukov


 Index: man/cvs.1
 ===
 RCS file: /cvs/src/gnu/usr.bin/cvs/man/cvs.1,v
 retrieving revision 1.12
 diff -u -p -r1.12 cvs.1
 --- man/cvs.1   3 Jun 2013 17:02:36 -   1.12
 +++ man/cvs.1   21 Aug 2013 22:06:44 -
 @@ -1696,7 +1696,7 @@ executes recursively through subdirector
  using the standard \fB\-l\fP option, or specify the recursion
  explicitly by using \fB\-R\fP.
  .TP
 -\fBupdate\fP [\fB\-ACdf\|lPpQqR\fP] [\fB\-d\fP] [\fB\-r\fP 
 \fItag\fP|\fB\-D\fP \fIdate\fP] \fIfiles\|.\|.\|.\fP
 +\fBupdate\fP [\fB\-ACdf\|lPpQqR\fP] [\fB\-d\fP] [\fB\-I\fP \fIname\fP] 
 [\fB\-r\fP \fItag\fP|\fB\-D\fP \fIdate\fP] \fIfiles\|.\|.\|.\fP
  .I Requires:
  repository, working directory.
  .br




Re: Mention -I option in cvs update synopsis

2013-08-21 Thread Vadim Zhukov
2013/8/22 Andres Perera andre...@zoho.com:
 -l for cvs update is a boolean option that doesn't take an operand

This is ay, not el.

 On Wed, Aug 21, 2013 at 5:38 PM, Vadim Zhukov persg...@gmail.com wrote:
 This adds a mention of -I name option for cvs update command in
 its synopsis. Okay?

 --
   WBR,
 Vadim Zhukov


 Index: man/cvs.1
 ===
 RCS file: /cvs/src/gnu/usr.bin/cvs/man/cvs.1,v
 retrieving revision 1.12
 diff -u -p -r1.12 cvs.1
 --- man/cvs.1   3 Jun 2013 17:02:36 -   1.12
 +++ man/cvs.1   21 Aug 2013 22:06:44 -
 @@ -1696,7 +1696,7 @@ executes recursively through subdirector
  using the standard \fB\-l\fP option, or specify the recursion
  explicitly by using \fB\-R\fP.
  .TP
 -\fBupdate\fP [\fB\-ACdf\|lPpQqR\fP] [\fB\-d\fP] [\fB\-r\fP 
 \fItag\fP|\fB\-D\fP \fIdate\fP] \fIfiles\|.\|.\|.\fP
 +\fBupdate\fP [\fB\-ACdf\|lPpQqR\fP] [\fB\-d\fP] [\fB\-I\fP \fIname\fP] 
 [\fB\-r\fP \fItag\fP|\fB\-D\fP \fIdate\fP] \fIfiles\|.\|.\|.\fP
  .I Requires:
  repository, working directory.
  .br


--
  WBR,
  Vadim Zhukov



Re: Mention -I option in cvs update synopsis

2013-08-21 Thread Stuart Henderson
On 2013/08/22 02:33, Vadim Zhukov wrote:
 2013/8/22 Andres Perera andre...@zoho.com:
  -l for cvs update is a boolean option that doesn't take an operand
 
 This is ay, not el.
 
  On Wed, Aug 21, 2013 at 5:38 PM, Vadim Zhukov persg...@gmail.com wrote:
  This adds a mention of -I name option for cvs update command in
  its synopsis. Okay?

Normally we would push this type of change upstream, but it appears they
have a) switched to a manpage generated from texinfo sources and b) included
-I in the synopsis for update, so I'm OK with adding it.

http://cvs.savannah.gnu.org/viewvc/ccvs/doc/cvs.1?revision=1.57root=cvsview=markup