Subject: Re: PR 35897 - absurd IPv6 config ioctl
To: Robert Elz <kre@munnari.OZ.AU>
From: Greg Troxel <gdt@ir.bbn.com>
List: tech-net
Date: 08/31/2007 11:42:24
I believe that you are correct that this is completely broken.

Does this diff look ok?  I'll commit in a week or so if there are no
objections.

Index: sys/netinet6/in6.c
===================================================================
RCS file: /cvsroot/src/sys/netinet6/in6.c,v
retrieving revision 1.131
diff -u -p -r1.131 in6.c
--- sys/netinet6/in6.c	19 Jul 2007 20:48:56 -0000	1.131
+++ sys/netinet6/in6.c	31 Aug 2007 15:41:50 -0000
@@ -447,7 +447,6 @@ in6_control1(struct socket *so, u_long c
 	case SIOCSPFXFLUSH_IN6:
 	case SIOCSRTRFLUSH_IN6:
 	case SIOCGIFALIFETIME_IN6:
-	case SIOCSIFALIFETIME_IN6:
 	case SIOCGIFSTAT_IN6:
 	case SIOCGIFSTAT_ICMP6:
 		sa6 = &ifr->ifr_addr;
@@ -512,26 +511,6 @@ in6_control1(struct socket *so, u_long c
 		if (ia == NULL)
 			return EADDRNOTAVAIL;
 		break;
-	case SIOCSIFALIFETIME_IN6:
-	    {
-		struct in6_addrlifetime *lt;
-
-		if (!privileged)
-			return EPERM;
-		if (ia == NULL)
-			return EADDRNOTAVAIL;
-		/* sanity for overflow - beware unsigned */
-		lt = &ifr->ifr_ifru.ifru_lifetime;
-		if (lt->ia6t_vltime != ND6_INFINITE_LIFETIME
-		 && lt->ia6t_vltime + time_second < time_second) {
-			return EINVAL;
-		}
-		if (lt->ia6t_pltime != ND6_INFINITE_LIFETIME
-		 && lt->ia6t_pltime + time_second < time_second) {
-			return EINVAL;
-		}
-		break;
-	    }
 	}
 
 	switch (cmd) {
@@ -620,21 +599,6 @@ in6_control1(struct socket *so, u_long c
 		}
 		break;
 
-	case SIOCSIFALIFETIME_IN6:
-		ia->ia6_lifetime = ifr->ifr_ifru.ifru_lifetime;
-		/* for sanity */
-		if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
-			ia->ia6_lifetime.ia6t_expire =
-				time_second + ia->ia6_lifetime.ia6t_vltime;
-		} else
-			ia->ia6_lifetime.ia6t_expire = 0;
-		if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
-			ia->ia6_lifetime.ia6t_preferred =
-				time_second + ia->ia6_lifetime.ia6t_pltime;
-		} else
-			ia->ia6_lifetime.ia6t_preferred = 0;
-		break;
-
 	case SIOCAIFADDR_IN6:
 	{
 		int i;
Index: sys/netinet6/in6_var.h
===================================================================
RCS file: /cvsroot/src/sys/netinet6/in6_var.h,v
retrieving revision 1.52
diff -u -p -r1.52 in6_var.h
--- sys/netinet6/in6_var.h	19 Jul 2007 20:48:56 -0000	1.52
+++ sys/netinet6/in6_var.h	31 Aug 2007 15:41:50 -0000
@@ -419,7 +419,10 @@ struct	in6_rrenumreq {
 #define SIOCSRTRFLUSH_IN6	_IOWR('i', 80, struct in6_ifreq)
 
 #define SIOCGIFALIFETIME_IN6	_IOWR('i', 81, struct in6_ifreq)
+#if 0
+/* withdrawn - do not reuse number 82 */
 #define SIOCSIFALIFETIME_IN6	_IOWR('i', 82, struct in6_ifreq)
+#endif
 #define SIOCGIFSTAT_IN6		_IOWR('i', 83, struct in6_ifreq)
 #define SIOCGIFSTAT_ICMP6	_IOWR('i', 84, struct in6_ifreq)
 
Index: sys/compat/common/uipc_syscalls_43.c
===================================================================
RCS file: /cvsroot/src/sys/compat/common/uipc_syscalls_43.c,v
retrieving revision 1.36
diff -u -p -r1.36 uipc_syscalls_43.c
--- sys/compat/common/uipc_syscalls_43.c	20 Aug 2007 19:19:33 -0000	1.36
+++ sys/compat/common/uipc_syscalls_43.c	31 Aug 2007 15:41:50 -0000
@@ -454,7 +454,6 @@ compat_cvtcmd(u_long cmd)
 	case SIOCSDEFIFACE_IN6:
 	case SIOCSIFADDR:
 	case SIOCSIFADDR_IN6:
-	case SIOCSIFALIFETIME_IN6:
 	case SIOCSIFBRDADDR:
 	case SIOCSIFDSTADDR:
 	case SIOCSIFDSTADDR_IN6: