tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Limiting rpc.lockd to IPv4 only



While starting my transition to an IPv6-enabled network, I discovered that rpc.lockd was failing to start on my systems.

It seems that rpc.lockd insists on using IPv6 if it is available in the kernel, whether or not IPv6 is enabled in /etc/netconfig

The attached patch adds options to rpc.lockd

        -4  Use IPv4 only, whether IPv6 is available or not
        -6  Use both IPv4 and IPv6 if IPv6 is available;  silently
            use IPv4 only if IPv6 is not available (default)

Any objections or comments?


Patch was previously posted on current-users at

   http://mail-index.netbsd.org/current-users/2012/08/12/msg020860.html



-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------
Index: lockd.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/rpc.lockd/lockd.c,v
retrieving revision 1.10
diff -u -p -r1.10 lockd.c
--- lockd.c     15 Dec 2007 19:44:56 -0000      1.10
+++ lockd.c     12 Aug 2012 00:41:59 -0000
@@ -84,14 +84,15 @@ int
 main(int argc, char **argv)
 {
        SVCXPRT *transp;
-       int ch, i, maxindex, s;
+       int ch, i, maxindex, s, proto;
        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)) {
+       proto = 4;
+       while ((ch = getopt(argc, argv, "d:g:46")) != (-1)) {
                switch (ch) {
                case 'd':
                        debug_level = atoi(optarg);
@@ -107,6 +108,10 @@ main(int argc, char **argv)
                                /* NOTREACHED */
                        }
                        break;
+               case '4':
+               case '6':
+                       proto = ch - '2';
+                       break;
                default:
                case '?':
                        usage();
@@ -120,14 +125,18 @@ main(int argc, char **argv)
        (void)rpcb_unset(NLM_PROG, NLM_VERS4, NULL);
 
        /*
-        * Check if IPv6 support is present.
+        * Check if IPv6 support is present and wanted.
         */
-       s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
-       if (s < 0)
+       if (proto == 2)
                maxindex = 2;
        else {
-               (void)close(s);
-               maxindex = 4;
+               s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+               if (s < 0)
+                       maxindex = 2;
+               else {
+                       (void)close(s);
+                       maxindex = 4;
+               }
        }
 
        (void)rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
Index: rpc.lockd.8
===================================================================
RCS file: /cvsroot/src/usr.sbin/rpc.lockd/rpc.lockd.8,v
retrieving revision 1.6
diff -u -p -r1.6 rpc.lockd.8
--- rpc.lockd.8 2 Feb 2002 01:42:45 -0000       1.6
+++ rpc.lockd.8 12 Aug 2012 00:41:59 -0000
@@ -32,7 +32,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd September 24, 1995
+.Dd August 11, 2012
 .Dt RPC.LOCKD 8
 .Os
 .Sh NAME
@@ -42,6 +42,8 @@
 .Nm
 .Op Fl d Ar debug_level
 .Op Fl g Ar grace period
+.Op Fl 4
+.Op Fl 6
 .Sh DESCRIPTION
 The
 .Nm
@@ -71,6 +73,14 @@ option allow to specify the grace period
 .Nm
 only accepts requests from hosts which are reinitialising locks which
 existed before the server restart. Default is 30 seconds.
+.It Fl 4
+.It Fl 6
+Specify whether
+.Nm
+should register for both IPv4 and IPv6 clients, or only for IPv4 clients.
+By default,
+.Nm
+will register for both IPv4 and IPv6 if IPv6 support is available.
 .El
 .Pp
 Error conditions are logged to syslog, irrespective of the debug level,


Home | Main Index | Thread Index | Old Index