Re: Secrets of Buffer Cache Enlargement.

2013-03-05 Thread Bob Beck
On Mon, Mar 4, 2013 at 4:24 PM, Bob Beck  wrote:
> You too can have a GIANT buffer cache etc. etc...

Great.. and now I have people mailing me dmesg's from machines with 16
and 32 Gigs of ram. I only have 8 I feel so. small...



Re: whois: add -P for peeringdb

2013-03-05 Thread Claudio Jeker
On Tue, Mar 05, 2013 at 01:58:25PM +, Stuart Henderson wrote:
> OK?
> 
OK claudio@

> 
> Index: whois.1
> ===
> RCS file: /cvs/src/usr.bin/whois/whois.1,v
> retrieving revision 1.31
> diff -u -p -r1.31 whois.1
> --- whois.1   26 Sep 2012 16:12:14 -  1.31
> +++ whois.1   5 Mar 2013 13:56:54 -
> @@ -175,6 +175,10 @@ defaults to the
>  port listed in
>  .Pa /etc/services
>  (port 43).
> +.It Fl P
> +Use the PeeringDB database.
> +It contains details about presence at internet peering points
> +for many network operators.
>  .It Fl Q
>  Do a quick lookup.
>  This means that
> Index: whois.c
> ===
> RCS file: /cvs/src/usr.bin/whois/whois.c,v
> retrieving revision 1.43
> diff -u -p -r1.43 whois.c
> --- whois.c   4 Mar 2010 21:37:56 -   1.43
> +++ whois.c   5 Mar 2013 13:56:54 -
> @@ -57,6 +57,7 @@
>  #define LNICHOST "whois.lacnic.net"
>  #define  AFNICHOST   "whois.afrinic.net"
>  #define BNICHOST "whois.registro.br"
> +#define  PDBHOST "whois.peeringdb.com"
>  #define  QNICHOST_TAIL   ".whois-servers.net"
>  
>  #define  WHOIS_PORT  "whois"
> @@ -81,7 +82,7 @@ main(int argc, char *argv[])
>  
>   country = host = NULL;
>   flags = rval = 0;
> - while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:qQrR")) != -1)
> + while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:PqQrR")) != -1)
>   switch (ch) {
>   case 'a':
>   host = ANICHOST;
> @@ -112,6 +113,9 @@ main(int argc, char *argv[])
>   break;
>   case 'p':
>   port_whois = optarg;
> + break;
> + case 'P':
> + host = PDBHOST;
>   break;
>   case 'q':
>   /* deprecated, now the default */
> 

-- 
:wq Claudio



Re: Kill IFAFREE()

2013-03-05 Thread Claudio Jeker
On Tue, Mar 05, 2013 at 12:03:49PM +0100, Mike Belopuhov wrote:
> On 5 March 2013 11:55, Mark Kettenis  wrote:
> >> Date: Tue, 5 Mar 2013 11:36:36 +0100
> >> From: Martin Pieuchot 
> >>
> >> The ifaddr structure contains a reference counter and two different way
> >> to check it before freeing its memory: a macro IFAFREE(), and a function
> >> ifafree().
> >> Because the former calls the latter when the reference counter is null,
> >> and then also check for the reference counter, I see no point in keeping
> >> two ways to do the same thing.
> >
> > Well, the point is probably that by doing the refcount check in the
> > macro you avoid a function call in most cases.  It's very well
> > possible that this is a case of premature optimization.  Almost
> > certainly the case unless the macro is called in a
> > performance-critical path.  If it is called in a performance-critical
> > path, some benchmarking should probably be done to make sure this
> > doesn't impact something like packet forwarding performance in a
> > negative way.
> >
> 
> to be fair, there are millions of these function calls. i highly
> doubt one can measure any performance difference -- it'll all be
> within error margin.

If we do IFAFREE() on a per packet basis then we do something wrong. 
Glancing at the diff I see no hot pathes that would matter.

-- 
:wq Claudio



Re: whois: add -P for peeringdb

2013-03-05 Thread Stuart Henderson
On 2013/03/05 19:04, Alexander Hall wrote:
> On 03/05/13 18:58, Stuart Henderson wrote:
> >On 2013/03/05 18:31, Alexander Hall wrote:
> >>Not that I mind either way, but did we want to add more "hardcoded"
> >>flags to whois?
> >
> >Did you any some others in mind? Most of the domain-lookup ones are handled
> >by XX.whois-servers.net, of the others I know of Team Cymru's servers may be
> >useful but I don't think they're as widely used as peeringdb, probably not
> >common enough to be worth adding a flag for.
> 
> Oh, well, no. My point was rather the opposite.
> 
> Adding a hardcoded switch for a new server every now and then seems
> like a good waste of switchable characters. But I'm quite a limited
> user of whois, so maybe it makes sense.
> 

Ah I see :-) peeringdb is quite widely used amongst bgp network operators
so this is quite a useful one to have.



Re: whois: add -P for peeringdb

2013-03-05 Thread Theo de Raadt
> On 03/05/13 18:58, Stuart Henderson wrote:
> > On 2013/03/05 18:31, Alexander Hall wrote:
> >> Not that I mind either way, but did we want to add more "hardcoded"
> >> flags to whois?
> >
> > Did you any some others in mind? Most of the domain-lookup ones are handled
> > by XX.whois-servers.net, of the others I know of Team Cymru's servers may be
> > useful but I don't think they're as widely used as peeringdb, probably not
> > common enough to be worth adding a flag for.
> 
> Oh, well, no. My point was rather the opposite.
> 
> Adding a hardcoded switch for a new server every now and then seems like 
> a good waste of switchable characters. But I'm quite a limited user of 
> whois, so maybe it makes sense.

Adding a new option to whois hurts noone.  This is not a standardized
portable interface.  Adding them here does not hurt you like it would
for cp, ls, ksh, traceroute, ping, route, bgpd [trying to get you to guess
whereabouts whois fits on that line].



Re: whois: add -P for peeringdb

2013-03-05 Thread Theo de Raadt
> On 2013/03/05 18:31, Alexander Hall wrote:
> > Not that I mind either way, but did we want to add more "hardcoded"
> > flags to whois?
> 
> Did you any some others in mind? Most of the domain-lookup ones are handled
> by XX.whois-servers.net, of the others I know of Team Cymru's servers may be
> useful but I don't think they're as widely used as peeringdb, probably not
> common enough to be worth adding a flag for.

Unfortunately I have to agree with Stuart here.

Around 1998 there was a bit of an attempt to connect these databases
together in whois in an automatic fashion, but that has been falling apart
ever since.



Re: whois: add -P for peeringdb

2013-03-05 Thread Alexander Hall

On 03/05/13 18:58, Stuart Henderson wrote:

On 2013/03/05 18:31, Alexander Hall wrote:

Not that I mind either way, but did we want to add more "hardcoded"
flags to whois?


Did you any some others in mind? Most of the domain-lookup ones are handled
by XX.whois-servers.net, of the others I know of Team Cymru's servers may be
useful but I don't think they're as widely used as peeringdb, probably not
common enough to be worth adding a flag for.


Oh, well, no. My point was rather the opposite.

Adding a hardcoded switch for a new server every now and then seems like 
a good waste of switchable characters. But I'm quite a limited user of 
whois, so maybe it makes sense.




Re: whois: add -P for peeringdb

2013-03-05 Thread Stuart Henderson
On 2013/03/05 18:31, Alexander Hall wrote:
> Not that I mind either way, but did we want to add more "hardcoded"
> flags to whois?

Did you any some others in mind? Most of the domain-lookup ones are handled
by XX.whois-servers.net, of the others I know of Team Cymru's servers may be
useful but I don't think they're as widely used as peeringdb, probably not
common enough to be worth adding a flag for.



Re: whois: add -P for peeringdb

2013-03-05 Thread Alexander Hall
Not that I mind either way, but did we want to add more "hardcoded" 
flags to whois?


On 03/05/13 14:58, Stuart Henderson wrote:

OK?


Index: whois.1
===
RCS file: /cvs/src/usr.bin/whois/whois.1,v
retrieving revision 1.31
diff -u -p -r1.31 whois.1
--- whois.1 26 Sep 2012 16:12:14 -  1.31
+++ whois.1 5 Mar 2013 13:56:54 -
@@ -175,6 +175,10 @@ defaults to the
  port listed in
  .Pa /etc/services
  (port 43).
+.It Fl P
+Use the PeeringDB database.
+It contains details about presence at internet peering points
+for many network operators.
  .It Fl Q
  Do a quick lookup.
  This means that
Index: whois.c
===
RCS file: /cvs/src/usr.bin/whois/whois.c,v
retrieving revision 1.43
diff -u -p -r1.43 whois.c
--- whois.c 4 Mar 2010 21:37:56 -   1.43
+++ whois.c 5 Mar 2013 13:56:54 -
@@ -57,6 +57,7 @@
  #define LNICHOST  "whois.lacnic.net"
  #define   AFNICHOST   "whois.afrinic.net"
  #define BNICHOST  "whois.registro.br"
+#definePDBHOST "whois.peeringdb.com"
  #define   QNICHOST_TAIL   ".whois-servers.net"

  #define   WHOIS_PORT  "whois"
@@ -81,7 +82,7 @@ main(int argc, char *argv[])

country = host = NULL;
flags = rval = 0;
-   while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:qQrR")) != -1)
+   while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:PqQrR")) != -1)
switch (ch) {
case 'a':
host = ANICHOST;
@@ -112,6 +113,9 @@ main(int argc, char *argv[])
break;
case 'p':
port_whois = optarg;
+   break;
+   case 'P':
+   host = PDBHOST;
break;
case 'q':
/* deprecated, now the default */





Re: write(2) man page

2013-03-05 Thread Ted Unangst
On Tue, Mar 05, 2013 at 12:26, Sachidananda Urs wrote:

>> Attaching patch for review.
> Hi,
> 
> Any thoughts on this?

It's in my queue.  I wanted to touch it up a bit, but waited for the
tree to unlock (it just did).  Thanks again.



Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Sylvestre Gallon
On Tue, Mar 5, 2013 at 4:29 PM, Sylvestre Gallon  wrote:
>
> Martin,
>
> You will find inline the kernel patch
>

And here the userland :

Index: Makefile
===
RCS file: /cvs/src/sbin/Makefile,v
retrieving revision 1.97
diff -u -p -u -p -r1.97 Makefile
--- Makefile23 Aug 2012 06:37:27 -1.97
+++ Makefile5 Mar 2013 15:21:12 -
@@ -5,7 +5,7 @@ SUBDIR=atactl badsect bioctl clri dhcli
 fsck_msdos fsdb fsirand growfs ifconfig iked init iopctl ipsecctl  \
 isakmpd kbd ldattach lmccontrol mknod modload modunload mount \
 mount_cd9660 mount_ext2fs mount_ffs mount_msdos \
-mount_nfs mount_ntfs mount_procfs mount_udf \
+mount_nfs mount_ntfs mount_procfs mount_fusefs mount_udf \
 mount_vnd mountd ncheck_ffs newfs newfs_ext2fs newfs_msdos \
 nfsd nologin pdisk pfctl pflogd ping ping6 quotacheck \
 reboot restore route rtsol savecore scan_ffs \
Index: mount_fusefs/Makefile
===
RCS file: mount_fusefs/Makefile
diff -N mount_fusefs/Makefile
--- /dev/null1 Jan 1970 00:00:00 -
+++ mount_fusefs/Makefile5 Mar 2013 15:21:18 -
@@ -0,0 +1,10 @@
+#$OpenBSD: src/sbin/mount_procfs/Makefile,v 1.7 2004/06/22
21:12:00 otto Exp $
+
+PROG=mount_fusefs
+SRCS=mount_fusefs.c getmntopts.c
+
+MOUNT=${.CURDIR}/../mount
+CFLAGS+= -I${MOUNT}
+.PATH:${MOUNT}
+
+.include 
Index: mount_fusefs/mount_fusefs.c
===
RCS file: mount_fusefs/mount_fusefs.c
diff -N mount_fusefs/mount_fusefs.c
--- /dev/null1 Jan 1970 00:00:00 -
+++ mount_fusefs/mount_fusefs.c5 Mar 2013 15:21:18 -
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012 Sylvestre Gallon 
+ *
+ * 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 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mntopts.h"
+
+const struct mntopt mopts[] = {
+MOPT_STDOPTS,
+{ "subtype",0, MFLAG_SET | MFLAG_STRVAL | MFLAG_OPT },
+{ "fsname",0, MFLAG_SET | MFLAG_STRVAL | MFLAG_OPT },
+{ NULL }
+};
+
+voidusage(void);
+
+int
+main(int argc, char *argv[])
+{
+int ch, mntflags, altflags;
+struct fusefs_args args;
+char path[MAXPATHLEN];
+
+mntflags = altflags = 0;
+while ((ch = getopt(argc, argv, "o:")) != -1)
+switch (ch) {
+case 'o':
+altflags |= getmntopts(optarg, mopts, &mntflags);
+break;
+case '?':
+default:
+usage();
+}
+argc -= optind;
+argv += optind;
+
+if (argc != 2)
+usage();
+
+args.flags = altflags;
+args.fd = atoi(argv[0]);
+
+if (realpath(argv[1], path) == NULL)
+err(1, "realpath %s", argv[1]);
+
+if (mount(MOUNT_FUSEFS, path, mntflags, &args)) {
+if (errno == EOPNOTSUPP)
+errx(1, "%s: Filesystem not supported by kernel",
+argv[1]);
+else
+err(1, "%s", argv[1]);
+}
+exit(0);
+}
+
+void
+usage(void)
+{
+(void)fprintf(stderr,
+"usage: mount_procfs [-o options] fd mount_point\n");
+exit(1);
+}



Re: PATCH: nodump for directories

2013-03-05 Thread Vadim Zhukov
2012/2/16 Vadim Zhukov :
> Hello all.
>
> Resending now, after unlock, a not-so-big patch implementing recursive
> "nodump" flag handling in dump(8), for the case the flag is being set on
> a directory. Tested successfully for many months on i386. Patch is
> modelled after FreeBSD's dump(8) code.

Just remembered about that patch. Anyone using dump(8) and nodump flag
willing to test? Tested by me on i386 (dump and restore) for more
almost two years.

While there, I removed extra "#ifdef UF_NODUMP" check and the whole
corresponding "#else" block, they probably came from the old days?

--
  WBR,
  Vadim Zhukov


> Index: traverse.c
> ===
> RCS file: /cvs/src/sbin/dump/traverse.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 traverse.c
> --- traverse.c  27 Oct 2009 23:59:32 -  1.24
> +++ traverse.c  16 Feb 2012 11:02:26 -
> @@ -60,9 +60,9 @@ union dinode {
>  #defineHASDUMPEDFILE   0x1
>  #defineHASSUBDIRS  0x2
>
> -static int dirindir(ino_t ino, daddr64_t blkno, int level, off_t
> *size);
> -static void dmpindir(ino_t ino, daddr64_t blk, int level, off_t *size);
> -static int searchdir(ino_t ino, daddr64_t blkno, long size, off_t
> filesize);
> +static int dirindir(ino_t, daddr64_t, int, off_t *, off_t *, int);
> +static void dmpindir(ino_t, daddr64_t, int, off_t *);
> +static int searchdir(ino_t, daddr64_t, long, off_t, off_t *, int);
>
>  /*
>   * This is an estimation of the number of TP_BSIZE blocks in the file.
> @@ -103,18 +103,9 @@ blockest(union dinode *dp)
> return (blkest + 1);
>  }
>
> -/* Auxiliary macro to pick up files changed since previous dump. */
> -#defineCHANGEDSINCE(dp, t) \
> -   (DIP(dp, di_mtime) >= (t) || DIP(dp, di_ctime) >= (t))
> -
> -/* The WANTTODUMP macro decides whether a file should be dumped. */
> -#ifdef UF_NODUMP
> -#defineWANTTODUMP(dp) \
> -   (CHANGEDSINCE(dp, spcl.c_ddate) && \
> -(nonodump || (DIP(dp, di_flags) & UF_NODUMP) != UF_NODUMP))
> -#else
> -#defineWANTTODUMP(dp) CHANGEDSINCE(dp, spcl.c_ddate)
> -#endif
> +/* true if "nodump" flag has no effect here, i.e. dumping allowed */
> +#define CHECKNODUMP(dp) \
> +   (nonodump || (DIP((dp), di_flags) & UF_NODUMP) != UF_NODUMP)
>
>  /*
>   * Determine if given inode should be dumped
> @@ -131,7 +122,7 @@ mapfileino(ino_t ino, off_t *tapesize, i
> SETINO(ino, usedinomap);
> if (mode == IFDIR)
> SETINO(ino, dumpdirmap);
> -   if (WANTTODUMP(dp)) {
> +   if (CHECKNODUMP(dp) && DIP(dp, di_mtime) >= spcl.c_ddate) {
> SETINO(ino, dumpinomap);
> if (mode != IFREG && mode != IFDIR && mode != IFLNK)
> *tapesize += 1;
> @@ -139,8 +130,11 @@ mapfileino(ino_t ino, off_t *tapesize, i
> *tapesize += blockest(dp);
> return;
> }
> -   if (mode == IFDIR)
> +   if (mode == IFDIR) {
> +   if (!CHECKNODUMP(dp))
> +   CLRINO(ino, usedinomap);
> *dirskipped = 1;
> +   }
>  }
>
>  void
> @@ -307,7 +301,7 @@ int
>  mapdirs(ino_t maxino, off_t *tapesize)
>  {
> union dinode *dp;
> -   int i, isdir;
> +   int i, isdir, nodump;
> char *map;
> ino_t ino;
> union dinode di;
> @@ -320,7 +314,15 @@ mapdirs(ino_t maxino, off_t *tapesize)
> isdir = *map++;
> else
> isdir >>= 1;
> -   if ((isdir & 1) == 0 || TSTINO(ino, dumpinomap))
> +/*
> +* If a directory has been removed from usedinomap, it
> +* either has the nodump flag set, or has inherited
> +* it.  Although a directory can't be in dumpinomap if
> +* it isn't in usedinomap, we have to go through it to
> +* propagate the nodump flag.
> +*/
> +   nodump = !nonodump && !TSTINO(ino, usedinomap);
> +   if ((isdir & 1) == 0 || TSTINO(ino, dumpinomap) && !nodump)
> continue;
> dp = getino(ino, &i);
> /*
> @@ -335,7 +337,7 @@ mapdirs(ino_t maxino, off_t *tapesize)
> if (DIP(&di, di_db[i]) != 0)
> ret |= searchdir(ino, DIP(&di, di_db[i]),
> sblksize(sblock, DIP(dp, di_size), i),
> -   filesize);
> +   filesize, tapesize, nodump);
> if (ret & HASDUMPEDFILE)
> filesize = 0;
> else
> @@ -344,7 +346,8 @@ mapdirs(ino_t maxino, off_t *tapesize)
> for (i = 0; filesize > 0 && i < NIADDR; i++) {
> if (DIP(&di, di_ib[i]) == 0)
> continue;
> -   

Re: whois: add -P for peeringdb

2013-03-05 Thread Jérémie Courrèges-Anglas

Nice, that would be one alias less in my .kshrc. :)

-- 
Jérémie Courrèges-Anglas
GPG Key fingerprint: 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494



Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Sylvestre Gallon
On Tue, Mar 5, 2013 at 2:44 PM, Bob Beck  wrote:

> Sylvestre, one of the problems with fuse itself is that it's GPL
> licensed, and not appropriate
> for inclusion in base. If you've got interets and talent in this area,
> you might want to consider
> having a peek at puffs (and refuse) from netbsd which has a workable
> license and could
> be included in base.   I would definitely help if you're interested...
>
> -Bob
>
>
Bob,

I am not quite sure but I think that only libfuse and sshfs are GPL
licenced. The patches for those two items are only present in ports.

All the code present in src is ISC licenced. The kernel communicate with
libfuse througth a device (ie /dev/fuse) and only share a header with the
libfuse (fuse_kernel.h) which is BSD licenced. FreeBSD used the same way to
implement it. (I do not know if it is a good example)

Anyway, It could be fun to have a peek at puffs/refuse and have your help :)

Cheers,

-- 
Sylvestre Gallon


Re: whois: add -P for peeringdb

2013-03-05 Thread Stuart Henderson
On 2013/03/05 13:58, Stuart Henderson wrote:
> OK?

Tweak after a comment from phessler, to make it more clear what you can lookup:
change "Use the PeeringDB database" to "Use the PeeringDB database of AS 
numbers"

Index: whois.1
===
RCS file: /cvs/src/usr.bin/whois/whois.1,v
retrieving revision 1.31
diff -u -p -r1.31 whois.1
--- whois.1 26 Sep 2012 16:12:14 -  1.31
+++ whois.1 5 Mar 2013 14:11:53 -
@@ -175,6 +175,10 @@ defaults to the
 port listed in
 .Pa /etc/services
 (port 43).
+.It Fl P
+Use the PeeringDB database of AS numbers.
+It contains details about presence at internet peering points
+for many network operators.
 .It Fl Q
 Do a quick lookup.
 This means that
Index: whois.c
===
RCS file: /cvs/src/usr.bin/whois/whois.c,v
retrieving revision 1.43
diff -u -p -r1.43 whois.c
--- whois.c 4 Mar 2010 21:37:56 -   1.43
+++ whois.c 5 Mar 2013 14:11:53 -
@@ -57,6 +57,7 @@
 #define LNICHOST   "whois.lacnic.net"
 #defineAFNICHOST   "whois.afrinic.net"
 #define BNICHOST   "whois.registro.br"
+#definePDBHOST "whois.peeringdb.com"
 #defineQNICHOST_TAIL   ".whois-servers.net"
 
 #defineWHOIS_PORT  "whois"
@@ -81,7 +82,7 @@ main(int argc, char *argv[])
 
country = host = NULL;
flags = rval = 0;
-   while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:qQrR")) != -1)
+   while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:PqQrR")) != -1)
switch (ch) {
case 'a':
host = ANICHOST;
@@ -112,6 +113,9 @@ main(int argc, char *argv[])
break;
case 'p':
port_whois = optarg;
+   break;
+   case 'P':
+   host = PDBHOST;
break;
case 'q':
/* deprecated, now the default */



Re: faithd fcntl diff

2013-03-05 Thread Martin Pieuchot
On 05/03/13(Tue) 09:03, David Hill wrote:
> On Mon, Feb 11, 2013 at 11:54:58AM -0700, Bob Beck wrote:
> >
> >
> >On Mon, Feb 11, 2013 at 05:00:08PM +0100, Mark Kettenis wrote:
> >> > Date: Mon, 11 Feb 2013 00:05:29 -0600
> >> > From: "Todd T. Fries" 
> >> > 
> >> > In light of nat64 in pf(4), what purpose does faithd(8) serve anymore?
> >> > 
> >> > I played with it a bit over a decade ago, but don't recall having any use
> >> > for it in the last number of years.
> >> > 
> >> > I vote it gets tedu'ed.
> >> 
> >> I fear it's too late in the game to do that now.
> >> 
> >> Bring this up again after unlock.  Meanwhile, perhaps that bug (if it
> >> really is a bug) should be fixed?
> >
> >yeah, I'd probably shy away from tedu'ing it at this late stage
> >in the release cycle - make sure it's adequate for release, and then
> >get your inner ted out as soon as the tree unlocks after release...
> >
> 
> tedu time? :)

Sure do you have a diff?



Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Martin Pieuchot
On 05/03/13(Tue) 06:44, Bob Beck wrote:
> Sylvestre, one of the problems with fuse itself is that it's GPL
> licensed, and not appropriate for inclusion in base. If you've got
> interets and talent in this area,  you might want to consider
> having a peek at puffs (and refuse) from netbsd which has a workable
> license and could be included in base. 
> I would definitely help if you're interested...

It looks to me that Sylvestre wrote it's own ISC-licensed implementation.

Sylvestre that's a lot of work, and a lot of new code :) I'd suggest you
to send your diff inline (maybe splitting the userland and kernel parts) 
so that people can comment on them.

M.



Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Jiri B
On Tue, Mar 05, 2013 at 02:11:41PM +0100, Gilles Chehade wrote:
> On Tue, Mar 05, 2013 at 01:49:20PM +0100, Antoine Jacoutot wrote:
> > On Tue, Mar 05, 2013 at 01:43:24PM +0100, Sylvestre Gallon wrote:
> > > Hi tech@
> > > 
> > > I send you this mail because a few months ago I tried to dabble with fuse
> > > filesystem and OpenBSD. After some time working on this subject I have
> > > succeeded to create something that works. It is not even near to be 
> > > perfect
> > > but with some changes and adaptions I think it could do the job.
> > 
> > Before anyone flame you for whatever reason, let me say that I am *very* 
> > happy that some work in done in this area.
> > I'll try and play with this and see what comes out of it; may take a little 
> > bit of time though.
> > 
> 
> Yup, same here

Yes, it would be nice to have libguestfs which uses FUSE
working on OpenBSD so one could modify qemu/kvm OpenBSD images
directly ;)

jirib



Re: faithd fcntl diff

2013-03-05 Thread David Hill
On Mon, Feb 11, 2013 at 11:54:58AM -0700, Bob Beck wrote:
>
>
>On Mon, Feb 11, 2013 at 05:00:08PM +0100, Mark Kettenis wrote:
>> > Date: Mon, 11 Feb 2013 00:05:29 -0600
>> > From: "Todd T. Fries" 
>> > 
>> > In light of nat64 in pf(4), what purpose does faithd(8) serve anymore?
>> > 
>> > I played with it a bit over a decade ago, but don't recall having any use
>> > for it in the last number of years.
>> > 
>> > I vote it gets tedu'ed.
>> 
>> I fear it's too late in the game to do that now.
>> 
>> Bring this up again after unlock.  Meanwhile, perhaps that bug (if it
>> really is a bug) should be fixed?
>
>yeah, I'd probably shy away from tedu'ing it at this late stage
>in the release cycle - make sure it's adequate for release, and then
>get your inner ted out as soon as the tree unlocks after release...
>

tedu time? :)



whois: add -P for peeringdb

2013-03-05 Thread Stuart Henderson
OK?


Index: whois.1
===
RCS file: /cvs/src/usr.bin/whois/whois.1,v
retrieving revision 1.31
diff -u -p -r1.31 whois.1
--- whois.1 26 Sep 2012 16:12:14 -  1.31
+++ whois.1 5 Mar 2013 13:56:54 -
@@ -175,6 +175,10 @@ defaults to the
 port listed in
 .Pa /etc/services
 (port 43).
+.It Fl P
+Use the PeeringDB database.
+It contains details about presence at internet peering points
+for many network operators.
 .It Fl Q
 Do a quick lookup.
 This means that
Index: whois.c
===
RCS file: /cvs/src/usr.bin/whois/whois.c,v
retrieving revision 1.43
diff -u -p -r1.43 whois.c
--- whois.c 4 Mar 2010 21:37:56 -   1.43
+++ whois.c 5 Mar 2013 13:56:54 -
@@ -57,6 +57,7 @@
 #define LNICHOST   "whois.lacnic.net"
 #defineAFNICHOST   "whois.afrinic.net"
 #define BNICHOST   "whois.registro.br"
+#definePDBHOST "whois.peeringdb.com"
 #defineQNICHOST_TAIL   ".whois-servers.net"
 
 #defineWHOIS_PORT  "whois"
@@ -81,7 +82,7 @@ main(int argc, char *argv[])
 
country = host = NULL;
flags = rval = 0;
-   while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:qQrR")) != -1)
+   while ((ch = getopt(argc, argv, "aAc:dgh:ilmp:PqQrR")) != -1)
switch (ch) {
case 'a':
host = ANICHOST;
@@ -112,6 +113,9 @@ main(int argc, char *argv[])
break;
case 'p':
port_whois = optarg;
+   break;
+   case 'P':
+   host = PDBHOST;
break;
case 'q':
/* deprecated, now the default */



Re: touch(1) doesn't act as expected: One for JMC

2013-03-05 Thread Jason McIntyre
On Tue, Mar 05, 2013 at 08:50:08PM +1100, Rod Whitworth wrote:
> On Tue, 5 Mar 2013 07:42:32 +, Jason McIntyre wrote:
> 
> >i don;t much like describing shell behaviour in other pages, but
> >we do do it in other pages, and i agree this one seems particularly
> >likely to catch folks out. fix coming...
> 
> I agree about the shell behaviour being something the beginners should
> learn pretty early in their exploration of unix-like topics.
> 
> I too agonised a bit about this case and I think I could be convinced
> that an example in the syntax lines would catch the eye of anyone who
> has learned that that is an "always read this" item when reading ANY
> man page.
> 

fix from millert now committed. thanks for the mail.
jmc



Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Bob Beck
Sylvestre, one of the problems with fuse itself is that it's GPL
licensed, and not appropriate
for inclusion in base. If you've got interets and talent in this area,
you might want to consider
having a peek at puffs (and refuse) from netbsd which has a workable
license and could
be included in base.   I would definitely help if you're interested...

-Bob


On Tue, Mar 5, 2013 at 5:43 AM, Sylvestre Gallon  wrote:
> Hi tech@
>
> I send you this mail because a few months ago I tried to dabble with fuse
> filesystem and OpenBSD. After some time working on this subject I have
> succeeded to create something that works. It is not even near to be perfect
> but with some changes and adaptions I think it could do the job.
>
> In order to use these patches you will need to follow this procedure:
>
> * apply the ports patch :
> root # cd /usr/ports
> root # ftp http://www.pmbsd.org/patch-fuse-ports
> root # patch -p0 < patch-fuse-ports
>
> * apply the src patch
> root # cd /usr/src
> root # ftp http://www.pmbsd.org/patch-fuse-src
> root # patch -p0 < patch-fuse-src
>
> * upgrade your system mount.h
> root # cp /usr/src/sys/sys/mount.h /usr/include/sys/mount.h
>
> * compile all mount and umount binaries
> root # cd /usr/src/sbin/mount && make && make install
> root # cd /usr/src/sbin/mount_ffs && make && make install
> root # cd /usr/src/sbin/mount_fusefs && make && make install (there are
> warning for a missing manpage)
>   ...
> root # cd /usr/src/sbin/umount && make && make install
>
> * build a new kernel
> root # cd /usr/src/sys/arch/i386/conf
> root # config GENERIC
> root # cd ../compile/GENERIC
> root # make && make install
>
> * update MAKEDEV script and launch it to create the fuse device
> root # cd /dev
> root # ftp http://www.pmbsd.org/patch-fuse-MAKEDEV
> root # patch MAKEDEV < patch-fuse-MAKEDEV
> root # ./MAKEDEV
> root # ./MAKEDEV fuse
>
> * install devel/fuse and sysutils/sshfs-fuse packages
>root # cd /usr/ports/devel/fuse && make && make install
>root # cd /usr/ports/sysutils/sshfs-fuse && make && make install
>
> * reboot and try sshfs
>root # reboot
>root # sshfs s...@pmbsd.org:/home/syl/code /mnt
>root # ls /mnt
>
>
> As I said before, this is not perfect... There are some outstanding
> features to implement and bugs or architectural mistakes to solve...
>
> There is some work to do to implement these missing vnops and vfs features :
>
>   * vptof
>   * fhtovp
>   * checkexp
>   * sysctl
>   * strategy
>   * fsync
>   * symlink
>   * rename vnop
>   * you could only mount one filesystem at once.
>
> I think some security improvement could be done on these patches like :
> - fix some panics and tsleep hole that could produce DoS...
> - allow the use of fuse with a securelevel equal to -1...
> - other security stuff that I'm surely missing :)
>
> I will not explain all the fuse protocol in this mail but if you want
> information on how it works I will answer your questions in a private mail.
>
> If you have any questions about these patches or want me to change or
> rework something in this code I will be happy to do it.
>
> Thanks for your time,
>
> Cheers,
>
> --
> Sylvestre Gallon



Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Gilles Chehade
On Tue, Mar 05, 2013 at 01:49:20PM +0100, Antoine Jacoutot wrote:
> On Tue, Mar 05, 2013 at 01:43:24PM +0100, Sylvestre Gallon wrote:
> > Hi tech@
> > 
> > I send you this mail because a few months ago I tried to dabble with fuse
> > filesystem and OpenBSD. After some time working on this subject I have
> > succeeded to create something that works. It is not even near to be perfect
> > but with some changes and adaptions I think it could do the job.
> 
> Before anyone flame you for whatever reason, let me say that I am *very* 
> happy that some work in done in this area.
> I'll try and play with this and see what comes out of it; may take a little 
> bit of time though.
> 

Yup, same here

-- 
Gilles Chehade

https://www.poolp.org  @poolpOrg



Re: Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Antoine Jacoutot
On Tue, Mar 05, 2013 at 01:43:24PM +0100, Sylvestre Gallon wrote:
> Hi tech@
> 
> I send you this mail because a few months ago I tried to dabble with fuse
> filesystem and OpenBSD. After some time working on this subject I have
> succeeded to create something that works. It is not even near to be perfect
> but with some changes and adaptions I think it could do the job.

Before anyone flame you for whatever reason, let me say that I am *very* happy 
that some work in done in this area.
I'll try and play with this and see what comes out of it; may take a little bit 
of time though.


> In order to use these patches you will need to follow this procedure:
> 
> * apply the ports patch :
> root # cd /usr/ports
> root # ftp http://www.pmbsd.org/patch-fuse-ports
> root # patch -p0 < patch-fuse-ports
> 
> * apply the src patch
> root # cd /usr/src
> root # ftp http://www.pmbsd.org/patch-fuse-src
> root # patch -p0 < patch-fuse-src
> 
> * upgrade your system mount.h
> root # cp /usr/src/sys/sys/mount.h /usr/include/sys/mount.h
> 
> * compile all mount and umount binaries
> root # cd /usr/src/sbin/mount && make && make install
> root # cd /usr/src/sbin/mount_ffs && make && make install
> root # cd /usr/src/sbin/mount_fusefs && make && make install (there are
> warning for a missing manpage)
>   ...
> root # cd /usr/src/sbin/umount && make && make install
> 
> * build a new kernel
> root # cd /usr/src/sys/arch/i386/conf
> root # config GENERIC
> root # cd ../compile/GENERIC
> root # make && make install
> 
> * update MAKEDEV script and launch it to create the fuse device
> root # cd /dev
> root # ftp http://www.pmbsd.org/patch-fuse-MAKEDEV
> root # patch MAKEDEV < patch-fuse-MAKEDEV
> root # ./MAKEDEV
> root # ./MAKEDEV fuse
> 
> * install devel/fuse and sysutils/sshfs-fuse packages
>root # cd /usr/ports/devel/fuse && make && make install
>root # cd /usr/ports/sysutils/sshfs-fuse && make && make install
> 
> * reboot and try sshfs
>root # reboot
>root # sshfs s...@pmbsd.org:/home/syl/code /mnt
>root # ls /mnt
> 
> 
> As I said before, this is not perfect... There are some outstanding
> features to implement and bugs or architectural mistakes to solve...
> 
> There is some work to do to implement these missing vnops and vfs features :
> 
>   * vptof
>   * fhtovp
>   * checkexp
>   * sysctl
>   * strategy
>   * fsync
>   * symlink
>   * rename vnop
>   * you could only mount one filesystem at once.
> 
> I think some security improvement could be done on these patches like :
> - fix some panics and tsleep hole that could produce DoS...
> - allow the use of fuse with a securelevel equal to -1...
> - other security stuff that I'm surely missing :)
> 
> I will not explain all the fuse protocol in this mail but if you want
> information on how it works I will answer your questions in a private mail.
> 
> If you have any questions about these patches or want me to change or
> rework something in this code I will be happy to do it.
> 
> Thanks for your time,
> 
> Cheers,
> 
> -- 
> Sylvestre Gallon

-- 
Antoine



Fuse (and sshfs) support for OpenBSD

2013-03-05 Thread Sylvestre Gallon
Hi tech@

I send you this mail because a few months ago I tried to dabble with fuse
filesystem and OpenBSD. After some time working on this subject I have
succeeded to create something that works. It is not even near to be perfect
but with some changes and adaptions I think it could do the job.

In order to use these patches you will need to follow this procedure:

* apply the ports patch :
root # cd /usr/ports
root # ftp http://www.pmbsd.org/patch-fuse-ports
root # patch -p0 < patch-fuse-ports

* apply the src patch
root # cd /usr/src
root # ftp http://www.pmbsd.org/patch-fuse-src
root # patch -p0 < patch-fuse-src

* upgrade your system mount.h
root # cp /usr/src/sys/sys/mount.h /usr/include/sys/mount.h

* compile all mount and umount binaries
root # cd /usr/src/sbin/mount && make && make install
root # cd /usr/src/sbin/mount_ffs && make && make install
root # cd /usr/src/sbin/mount_fusefs && make && make install (there are
warning for a missing manpage)
  ...
root # cd /usr/src/sbin/umount && make && make install

* build a new kernel
root # cd /usr/src/sys/arch/i386/conf
root # config GENERIC
root # cd ../compile/GENERIC
root # make && make install

* update MAKEDEV script and launch it to create the fuse device
root # cd /dev
root # ftp http://www.pmbsd.org/patch-fuse-MAKEDEV
root # patch MAKEDEV < patch-fuse-MAKEDEV
root # ./MAKEDEV
root # ./MAKEDEV fuse

* install devel/fuse and sysutils/sshfs-fuse packages
   root # cd /usr/ports/devel/fuse && make && make install
   root # cd /usr/ports/sysutils/sshfs-fuse && make && make install

* reboot and try sshfs
   root # reboot
   root # sshfs s...@pmbsd.org:/home/syl/code /mnt
   root # ls /mnt


As I said before, this is not perfect... There are some outstanding
features to implement and bugs or architectural mistakes to solve...

There is some work to do to implement these missing vnops and vfs features :

  * vptof
  * fhtovp
  * checkexp
  * sysctl
  * strategy
  * fsync
  * symlink
  * rename vnop
  * you could only mount one filesystem at once.

I think some security improvement could be done on these patches like :
- fix some panics and tsleep hole that could produce DoS...
- allow the use of fuse with a securelevel equal to -1...
- other security stuff that I'm surely missing :)

I will not explain all the fuse protocol in this mail but if you want
information on how it works I will answer your questions in a private mail.

If you have any questions about these patches or want me to change or
rework something in this code I will be happy to do it.

Thanks for your time,

Cheers,

-- 
Sylvestre Gallon


Re: Kill IFAFREE()

2013-03-05 Thread Mike Belopuhov
On 5 March 2013 11:55, Mark Kettenis  wrote:
>> Date: Tue, 5 Mar 2013 11:36:36 +0100
>> From: Martin Pieuchot 
>>
>> The ifaddr structure contains a reference counter and two different way
>> to check it before freeing its memory: a macro IFAFREE(), and a function
>> ifafree().
>> Because the former calls the latter when the reference counter is null,
>> and then also check for the reference counter, I see no point in keeping
>> two ways to do the same thing.
>
> Well, the point is probably that by doing the refcount check in the
> macro you avoid a function call in most cases.  It's very well
> possible that this is a case of premature optimization.  Almost
> certainly the case unless the macro is called in a
> performance-critical path.  If it is called in a performance-critical
> path, some benchmarking should probably be done to make sure this
> doesn't impact something like packet forwarding performance in a
> negative way.
>

to be fair, there are millions of these function calls. i highly
doubt one can measure any performance difference -- it'll all be
within error margin.



Re: Kill IFAFREE()

2013-03-05 Thread Mark Kettenis
> Date: Tue, 5 Mar 2013 11:36:36 +0100
> From: Martin Pieuchot 
> 
> The ifaddr structure contains a reference counter and two different way
> to check it before freeing its memory: a macro IFAFREE(), and a function
> ifafree().
> Because the former calls the latter when the reference counter is null,
> and then also check for the reference counter, I see no point in keeping
> two ways to do the same thing.

Well, the point is probably that by doing the refcount check in the
macro you avoid a function call in most cases.  It's very well
possible that this is a case of premature optimization.  Almost
certainly the case unless the macro is called in a
performance-critical path.  If it is called in a performance-critical
path, some benchmarking should probably be done to make sure this
doesn't impact something like packet forwarding performance in a
negative way.

> diff --git sys/net/if.c sys/net/if.c
> index 534d434..3edd0a7 100644
> --- sys/net/if.c
> +++ sys/net/if.c
> @@ -599,7 +599,7 @@ do { \
>   continue;
>  
>   ifa->ifa_ifp = NULL;
> - IFAFREE(ifa);
> + ifafree(ifa);
>   }
>  
>   for (ifg = TAILQ_FIRST(&ifp->if_groups); ifg;
> @@ -609,7 +609,7 @@ do { \
>   if_free_sadl(ifp);
>  
>   ifnet_addrs[ifp->if_index]->ifa_ifp = NULL;
> - IFAFREE(ifnet_addrs[ifp->if_index]);
> + ifafree(ifnet_addrs[ifp->if_index]);
>   ifnet_addrs[ifp->if_index] = NULL;
>  
>   free(ifp->if_addrhooks, M_TEMP);
> @@ -1007,7 +1007,7 @@ link_rtrequest(int cmd, struct rtentry *rt, struct 
> rt_addrinfo *info)
>   return;
>   if ((ifa = ifaof_ifpforaddr(dst, ifp)) != NULL) {
>   ifa->ifa_refcnt++;
> - IFAFREE(rt->rt_ifa);
> + ifafree(rt->rt_ifa);
>   rt->rt_ifa = ifa;
>   if (ifa->ifa_rtrequest && ifa->ifa_rtrequest != link_rtrequest)
>   ifa->ifa_rtrequest(cmd, rt, info);
> @@ -1515,7 +1515,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, 
> struct proc *p)
>   (struct in_ifaddr *)ifa, ia_list);
>   ifa_del(ifp, ifa);
>   ifa->ifa_ifp = NULL;
> - IFAFREE(ifa);
> + ifafree(ifa);
>   }
>  #endif
>   splx(s);
> diff --git sys/net/if.h sys/net/if.h
> index 26ea6b1..27b209b 100644
> --- sys/net/if.h
> +++ sys/net/if.h
> @@ -704,14 +704,6 @@ struct if_laddrreq {
>  #include 
>  
>  #ifdef _KERNEL
> -#define  IFAFREE(ifa) \
> -do { \
> - if ((ifa)->ifa_refcnt <= 0) \
> - ifafree(ifa); \
> - else \
> - (ifa)->ifa_refcnt--; \
> -} while (/* CONSTCOND */0)
> -
>  #ifdef ALTQ
>  
>  #define  IFQ_ENQUEUE(ifq, m, pattr, err) 
> \
> diff --git sys/net/route.c sys/net/route.c
> index 9ec8a47..a0dc710 100644
> --- sys/net/route.c
> +++ sys/net/route.c
> @@ -401,7 +401,7 @@ rtfree(struct rtentry *rt)
>   rt_timer_remove_all(rt);
>   ifa = rt->rt_ifa;
>   if (ifa)
> - IFAFREE(ifa);
> + ifafree(ifa);
>   rtlabel_unref(rt->rt_labelid);
>  #ifdef MPLS
>   if (rt->rt_flags & RTF_MPLS)
> @@ -926,7 +926,7 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t 
> prio,
>   if ((*ret_nrt)->rt_ifa->ifa_rtrequest)
>   (*ret_nrt)->rt_ifa->ifa_rtrequest(
>   RTM_DELETE, *ret_nrt, NULL);
> - IFAFREE((*ret_nrt)->rt_ifa);
> + ifafree((*ret_nrt)->rt_ifa);
>   (*ret_nrt)->rt_ifa = ifa;
>   (*ret_nrt)->rt_ifp = ifa->ifa_ifp;
>   ifa->ifa_refcnt++;
> @@ -957,7 +957,7 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t 
> prio,
>   RTFREE(crt);
>   }
>   if (rn == 0) {
> - IFAFREE(ifa);
> + ifafree(ifa);
>   if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent)
>   rtfree(rt->rt_parent);
>   if (rt->rt_gwroute)
> @@ -1139,7 +1139,7 @@ rtinit(struct ifaddr *ifa, int cmd, int flags)
>   ifa, rt->rt_ifa);
>   if (rt->rt_ifa->ifa_rtrequest)
>   rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, NULL);
> - IFAFREE(rt->rt_ifa);
> + ifafree(rt->rt_ifa);
>   rt->rt_ifa = ifa;
>   rt->rt_ifp = ifa->ifa_ifp;
>   ifa->ifa_refcnt++;
> diff --git sys/net/rtsock.c sys/net/rtsock.c
> index 091ec53..e8784ea 100644
> --- sys/net/rtsock.c
> +++ sys/net/rtsock.c
> @@ -785,7 +785,7 @@ re

kill ifa_ifwithaf()

2013-03-05 Thread Martin Pieuchot
Function ifa_ifwithaf() is not used, any reason to keep it?

Ok to kill it?

diff --git sys/net/if.c sys/net/if.c
index e3c4ba4..826e526 100644
--- sys/net/if.c
+++ sys/net/if.c
@@ -934,27 +934,6 @@ ifa_ifwithnet(struct sockaddr *addr, u_int rdomain)
 }
 
 /*
- * Find an interface using a specific address family
- */
-struct ifaddr *
-ifa_ifwithaf(int af, u_int rdomain)
-{
-   struct ifnet *ifp;
-   struct ifaddr *ifa;
-
-   rdomain = rtable_l2(rdomain);
-   TAILQ_FOREACH(ifp, &ifnet, if_list) {
-   if (ifp->if_rdomain != rdomain)
-   continue;
-   TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
-   if (ifa->ifa_addr->sa_family == af)
-   return (ifa);
-   }
-   }
-   return (NULL);
-}
-
-/*
  * Find an interface address specific to an interface best matching
  * a given address.
  */
diff --git sys/net/if.h sys/net/if.h
index 76fea5b..9649462 100644
--- sys/net/if.h
+++ sys/net/if.h
@@ -842,7 +842,6 @@ voidif_start(struct ifnet *);
 void   ifnewlladdr(struct ifnet *);
 
 struct ifaddr *ifa_ifwithaddr(struct sockaddr *, u_int);
-struct ifaddr *ifa_ifwithaf(int, u_int);
 struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *, u_int);
 struct ifaddr *ifa_ifwithnet(struct sockaddr *, u_int);
 struct ifaddr *ifa_ifwithroute(int, struct sockaddr *,
diff --git sys/netinet6/nd6_rtr.c sys/netinet6/nd6_rtr.c
index 9539113..b1e2a18 100644
--- sys/netinet6/nd6_rtr.c
+++ sys/netinet6/nd6_rtr.c
@@ -1598,7 +1598,6 @@ nd6_prefix_onlink(struct nd_prefix *pr)
ifa = &in6ifa_ifpforlinklocal(ifp,
IN6_IFF_NOTREADY | IN6_IFF_ANYCAST)->ia_ifa;
if (ifa == NULL) {
-   /* XXX: freebsd does not have ifa_ifwithaf */
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family == AF_INET6)
break;



Kill IFAFREE()

2013-03-05 Thread Martin Pieuchot
The ifaddr structure contains a reference counter and two different way
to check it before freeing its memory: a macro IFAFREE(), and a function
ifafree().
Because the former calls the latter when the reference counter is null,
and then also check for the reference counter, I see no point in keeping
two ways to do the same thing.

The diff below kills the IFAFREE() macro and replace it by the function.

ok?


diff --git sys/net/if.c sys/net/if.c
index 534d434..3edd0a7 100644
--- sys/net/if.c
+++ sys/net/if.c
@@ -599,7 +599,7 @@ do { \
continue;
 
ifa->ifa_ifp = NULL;
-   IFAFREE(ifa);
+   ifafree(ifa);
}
 
for (ifg = TAILQ_FIRST(&ifp->if_groups); ifg;
@@ -609,7 +609,7 @@ do { \
if_free_sadl(ifp);
 
ifnet_addrs[ifp->if_index]->ifa_ifp = NULL;
-   IFAFREE(ifnet_addrs[ifp->if_index]);
+   ifafree(ifnet_addrs[ifp->if_index]);
ifnet_addrs[ifp->if_index] = NULL;
 
free(ifp->if_addrhooks, M_TEMP);
@@ -1007,7 +1007,7 @@ link_rtrequest(int cmd, struct rtentry *rt, struct 
rt_addrinfo *info)
return;
if ((ifa = ifaof_ifpforaddr(dst, ifp)) != NULL) {
ifa->ifa_refcnt++;
-   IFAFREE(rt->rt_ifa);
+   ifafree(rt->rt_ifa);
rt->rt_ifa = ifa;
if (ifa->ifa_rtrequest && ifa->ifa_rtrequest != link_rtrequest)
ifa->ifa_rtrequest(cmd, rt, info);
@@ -1515,7 +1515,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, 
struct proc *p)
(struct in_ifaddr *)ifa, ia_list);
ifa_del(ifp, ifa);
ifa->ifa_ifp = NULL;
-   IFAFREE(ifa);
+   ifafree(ifa);
}
 #endif
splx(s);
diff --git sys/net/if.h sys/net/if.h
index 26ea6b1..27b209b 100644
--- sys/net/if.h
+++ sys/net/if.h
@@ -704,14 +704,6 @@ struct if_laddrreq {
 #include 
 
 #ifdef _KERNEL
-#defineIFAFREE(ifa) \
-do { \
-   if ((ifa)->ifa_refcnt <= 0) \
-   ifafree(ifa); \
-   else \
-   (ifa)->ifa_refcnt--; \
-} while (/* CONSTCOND */0)
-
 #ifdef ALTQ
 
 #defineIFQ_ENQUEUE(ifq, m, pattr, err) 
\
diff --git sys/net/route.c sys/net/route.c
index 9ec8a47..a0dc710 100644
--- sys/net/route.c
+++ sys/net/route.c
@@ -401,7 +401,7 @@ rtfree(struct rtentry *rt)
rt_timer_remove_all(rt);
ifa = rt->rt_ifa;
if (ifa)
-   IFAFREE(ifa);
+   ifafree(ifa);
rtlabel_unref(rt->rt_labelid);
 #ifdef MPLS
if (rt->rt_flags & RTF_MPLS)
@@ -926,7 +926,7 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio,
if ((*ret_nrt)->rt_ifa->ifa_rtrequest)
(*ret_nrt)->rt_ifa->ifa_rtrequest(
RTM_DELETE, *ret_nrt, NULL);
-   IFAFREE((*ret_nrt)->rt_ifa);
+   ifafree((*ret_nrt)->rt_ifa);
(*ret_nrt)->rt_ifa = ifa;
(*ret_nrt)->rt_ifp = ifa->ifa_ifp;
ifa->ifa_refcnt++;
@@ -957,7 +957,7 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio,
RTFREE(crt);
}
if (rn == 0) {
-   IFAFREE(ifa);
+   ifafree(ifa);
if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent)
rtfree(rt->rt_parent);
if (rt->rt_gwroute)
@@ -1139,7 +1139,7 @@ rtinit(struct ifaddr *ifa, int cmd, int flags)
ifa, rt->rt_ifa);
if (rt->rt_ifa->ifa_rtrequest)
rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, NULL);
-   IFAFREE(rt->rt_ifa);
+   ifafree(rt->rt_ifa);
rt->rt_ifa = ifa;
rt->rt_ifp = ifa->ifa_ifp;
ifa->ifa_refcnt++;
diff --git sys/net/rtsock.c sys/net/rtsock.c
index 091ec53..e8784ea 100644
--- sys/net/rtsock.c
+++ sys/net/rtsock.c
@@ -785,7 +785,7 @@ report:
if (oifa && oifa->ifa_rtrequest)
oifa->ifa_rtrequest(RTM_DELETE, rt,
&info);
-   IFAFREE(rt->rt_ifa);
+   ifafree(rt->rt_ifa);
rt->rt_ifa = ifa;
ifa->ifa_refcnt++;
rt->rt_ifp = ifp;
diff --git sys/netinet/if_ether.c sys/netinet/if_ether.c
index 83e4204..0

Re: touch(1) doesn't act as expected: One for JMC

2013-03-05 Thread Rod Whitworth
On Tue, 5 Mar 2013 07:42:32 +, Jason McIntyre wrote:

>i don;t much like describing shell behaviour in other pages, but
>we do do it in other pages, and i agree this one seems particularly
>likely to catch folks out. fix coming...

I agree about the shell behaviour being something the beginners should
learn pretty early in their exploration of unix-like topics.

I too agonised a bit about this case and I think I could be convinced
that an example in the syntax lines would catch the eye of anyone who
has learned that that is an "always read this" item when reading ANY
man page.

R/

*** NOTE *** Please DO NOT CC me. I  subscribed to the list.
Mail to the sender address that does not originate at the list server is 
tarpitted. The reply-to: address is provided for those who feel compelled to 
reply off list. Thankyou.

Rod/
---
This life is not the real thing.
It is not even in Beta.
If it was, then OpenBSD would already have a man page for it.