Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/setkey make it possible to use /kern/ipsec{sp, sa} for d...
details: https://anonhg.NetBSD.org/src/rev/f720ad96807c
branches: trunk
changeset: 551581:f720ad96807c
user: itojun <itojun%NetBSD.org@localhost>
date: Mon Sep 08 12:34:29 2003 +0000
description:
make it possible to use /kern/ipsec{sp,sa} for dumping policy/SA. it will
workaround the issue with socket buffer size in PF_KEY SADB_DUMP.
diffstat:
sbin/setkey/setkey.c | 41 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 38 insertions(+), 3 deletions(-)
diffs (104 lines):
diff -r 740a4ca7bffe -r f720ad96807c sbin/setkey/setkey.c
--- a/sbin/setkey/setkey.c Mon Sep 08 11:45:23 2003 +0000
+++ b/sbin/setkey/setkey.c Mon Sep 08 12:34:29 2003 +0000
@@ -1,5 +1,5 @@
-/* $NetBSD: setkey.c,v 1.9 2003/09/08 07:09:53 wiz Exp $ */
-/* $KAME: setkey.c,v 1.29 2003/09/08 06:08:52 itojun Exp $ */
+/* $NetBSD: setkey.c,v 1.10 2003/09/08 12:34:29 itojun Exp $ */
+/* $KAME: setkey.c,v 1.31 2003/09/08 12:31:58 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -34,6 +34,7 @@
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <err.h>
#include <net/route.h>
#include <netinet/in.h>
@@ -51,6 +52,7 @@
#include <errno.h>
#include <netdb.h>
#include <fcntl.h>
+#include <dirent.h>
#include "libpfkey.h"
@@ -62,6 +64,7 @@
int sendkeymsg __P((char *, size_t));
int postproc __P((struct sadb_msg *, int));
int fileproc __P((const char *));
+int dumpkernfs __P((const char *));
const char *numstr __P((int));
void shortdump_hdr __P((void));
void shortdump __P((struct sadb_msg *));
@@ -84,6 +87,7 @@
int f_hexdump = 0;
int f_tflag = 0;
static time_t thiszone;
+int kernfs = 0; /* kernfs support */
extern int lineno;
@@ -109,6 +113,7 @@
{
FILE *fp = stdin;
int c;
+ struct stat sb;
if (argc == 1) {
usage();
@@ -173,6 +178,10 @@
exit(0);
}
+ if (stat("/kern/ipsecsa", &sb) == 0 && S_ISDIR(sb.st_mode) &&
+ stat("/kern/ipsecsp", &sb) == 0 && S_ISDIR(sb.st_mode))
+ kernfs++;
+
so = pfkey_open();
if (so < 0) {
perror("pfkey_open");
@@ -181,7 +190,10 @@
switch (f_mode) {
case MODE_CMDDUMP:
- sendkeyshort(f_policy ? SADB_X_SPDDUMP: SADB_DUMP);
+ if (kernfs)
+ dumpkernfs(f_policy ? "/kern/ipsecsp" : "/kern/ipsecsa");
+ else
+ sendkeyshort(f_policy ? SADB_X_SPDDUMP: SADB_DUMP);
break;
case MODE_CMDFLUSH:
sendkeyshort(f_policy ? SADB_X_SPDFLUSH: SADB_FLUSH);
@@ -509,6 +521,29 @@
return (0);
}
+int
+dumpkernfs(dir)
+ const char *dir;
+{
+ DIR *p;
+ struct dirent *d;
+ char path[MAXPATHLEN];
+
+ p = opendir(dir);
+ if (!p)
+ return -1;
+
+ while ((d = readdir(p)) != NULL) {
+ if (d->d_type != DT_REG)
+ continue;
+ snprintf(path, sizeof(path), "%s/%s", dir, d->d_name);
+ fileproc(path);
+ }
+
+ closedir(p);
+ return (0);
+}
+
/*------------------------------------------------------------*/
static const char *satype[] = {
NULL, NULL, "ah", "esp"
Home |
Main Index |
Thread Index |
Old Index