Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rpc.lockd Add -4 and -6 options to rpd.lockd for co...
details: https://anonhg.NetBSD.org/src/rev/f947233d12b1
branches: trunk
changeset: 780966:f947233d12b1
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Aug 13 12:22:21 2012 +0000
description:
Add -4 and -6 options to rpd.lockd for consistent control over the
protocols to which it listens. As discussed on tech-userlevel.
diffstat:
usr.sbin/rpc.lockd/lockd.c | 47 ++++++++++++++++++++++++++++-------------
usr.sbin/rpc.lockd/rpc.lockd.8 | 16 ++++++++++++-
2 files changed, 46 insertions(+), 17 deletions(-)
diffs (145 lines):
diff -r 657726eeabb0 -r f947233d12b1 usr.sbin/rpc.lockd/lockd.c
--- a/usr.sbin/rpc.lockd/lockd.c Mon Aug 13 11:26:13 2012 +0000
+++ b/usr.sbin/rpc.lockd/lockd.c Mon Aug 13 12:22:21 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lockd.c,v 1.10 2007/12/15 19:44:56 perry Exp $ */
+/* $NetBSD: lockd.c,v 1.11 2012/08/13 12:22:21 pgoyette Exp $ */
/*
* Copyright (c) 1995
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lockd.c,v 1.10 2007/12/15 19:44:56 perry Exp $");
+__RCSID("$NetBSD: lockd.c,v 1.11 2012/08/13 12:22:21 pgoyette Exp $");
#endif
/*
@@ -51,6 +51,7 @@
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <errno.h>
#include <syslog.h>
#include <signal.h>
@@ -84,14 +85,16 @@
main(int argc, char **argv)
{
SVCXPRT *transp;
- int ch, i, maxindex, s;
+ int ch, i, minindex, maxindex, s;
+ bool use_ipv4, use_ipv6;
struct sigaction sigchild, sigalarm;
int grace_period = 30;
struct netconfig *nconf;
int maxrec = RPC_MAXDATASIZE;
(void)setprogname(*argv);
- while ((ch = getopt(argc, argv, "d:g:")) != (-1)) {
+ use_ipv4 = use_ipv6 = false;
+ while ((ch = getopt(argc, argv, "d:g:46")) != (-1)) {
switch (ch) {
case 'd':
debug_level = atoi(optarg);
@@ -107,6 +110,12 @@
/* NOTREACHED */
}
break;
+ case '4':
+ use_ipv4 = true;
+ break;
+ case '6':
+ use_ipv6 = true;
+ break;
default:
case '?':
usage();
@@ -119,23 +128,31 @@
(void)rpcb_unset(NLM_PROG, NLM_VERSX, NULL);
(void)rpcb_unset(NLM_PROG, NLM_VERS4, NULL);
- /*
- * Check if IPv6 support is present.
- */
- s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
- if (s < 0)
+ if (!use_ipv4 && !use_ipv6) {
+ s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+ if (s < 0)
+ use_ipv4 = true;
+ else {
+ (void)close(s);
+ use_ipv4 = use_ipv6 = true;
+ }
+ }
+ if (use_ipv4)
+ minindex = 0;
+ else
+ minindex = 2;
+
+ if (use_ipv6)
+ maxindex = 4;
+ else
maxindex = 2;
- else {
- (void)close(s);
- maxindex = 4;
- }
(void)rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
- for (i = 0; i < maxindex; i++) {
+ for (i = minindex; i < maxindex; i++) {
nconf = getnetconfigent(transports[i]);
if (nconf == NULL)
- errx(1, "cannot get udp netconf.");
+ errx(1, "cannot get %s netconf.", transports[i]);
transp = svc_tli_create(RPC_ANYFD, nconf, NULL, RPC_MAXDATASIZE,
RPC_MAXDATASIZE);
diff -r 657726eeabb0 -r f947233d12b1 usr.sbin/rpc.lockd/rpc.lockd.8
--- a/usr.sbin/rpc.lockd/rpc.lockd.8 Mon Aug 13 11:26:13 2012 +0000
+++ b/usr.sbin/rpc.lockd/rpc.lockd.8 Mon Aug 13 12:22:21 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rpc.lockd.8,v 1.6 2002/02/02 01:42:45 wiz Exp $
+.\" $NetBSD: rpc.lockd.8,v 1.7 2012/08/13 12:22:21 pgoyette Exp $
.\"
.\" Copyright (c) 1995 A.R.Gordon, andrew.gordon%net-tel.co.uk@localhost
.\" All rights reserved.
@@ -32,7 +32,7 @@
.\" SUCH DAMAGE.
.\"
.\"
-.Dd September 24, 1995
+.Dd August 11, 2012
.Dt RPC.LOCKD 8
.Os
.Sh NAME
@@ -42,6 +42,7 @@
.Nm
.Op Fl d Ar debug_level
.Op Fl g Ar grace period
+.Op Fl 46
.Sh DESCRIPTION
The
.Nm
@@ -71,6 +72,17 @@
.Nm
only accepts requests from hosts which are reinitialising locks which
existed before the server restart. Default is 30 seconds.
+.It Fl 4
+Listen for requests using IPv4.
+Do not listen using IPv6 unless the
+.Fl 6
+option is also specified.
+By default,
+.Nm
+listens for requests using both IPv4 and IPv6 if available.
+.It Fl 6
+Listen for requests using IPv6.
+It is an error if IPv6 is not available.
.El
.Pp
Error conditions are logged to syslog, irrespective of the debug level,
Home |
Main Index |
Thread Index |
Old Index