Sun Jun 14 14:26:18 2020 UTC ()
inet6: Allow addresses to be marked AUTOCONF from userland


(roy)
diff -r1.279 -r1.280 src/sys/netinet6/in6.c

cvs diff -r1.279 -r1.280 src/sys/netinet6/in6.c (expand / switch to unified diff)

--- src/sys/netinet6/in6.c 2020/06/13 06:05:08 1.279
+++ src/sys/netinet6/in6.c 2020/06/14 14:26:17 1.280
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: in6.c,v 1.279 2020/06/13 06:05:08 mlelstv Exp $ */ 1/* $NetBSD: in6.c,v 1.280 2020/06/14 14:26:17 roy Exp $ */
2/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ 2/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
3 3
4/* 4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE. 59 * SUCH DAMAGE.
60 * 60 *
61 * @(#)in.c 8.2 (Berkeley) 11/15/93 61 * @(#)in.c 8.2 (Berkeley) 11/15/93
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.279 2020/06/13 06:05:08 mlelstv Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.280 2020/06/14 14:26:17 roy Exp $");
66 66
67#ifdef _KERNEL_OPT 67#ifdef _KERNEL_OPT
68#include "opt_inet.h" 68#include "opt_inet.h"
69#include "opt_compat_netbsd.h" 69#include "opt_compat_netbsd.h"
70#include "opt_net_mpsafe.h" 70#include "opt_net_mpsafe.h"
71#endif 71#endif
72 72
73#include <sys/param.h> 73#include <sys/param.h>
74#include <sys/ioctl.h> 74#include <sys/ioctl.h>
75#include <sys/errno.h> 75#include <sys/errno.h>
76#include <sys/malloc.h> 76#include <sys/malloc.h>
77#include <sys/socket.h> 77#include <sys/socket.h>
78#include <sys/socketvar.h> 78#include <sys/socketvar.h>
@@ -672,28 +672,27 @@ in6_control1(struct socket *so, u_long c @@ -672,28 +672,27 @@ in6_control1(struct socket *so, u_long c
672#ifdef OSIOCAIFADDR_IN6 672#ifdef OSIOCAIFADDR_IN6
673 case OSIOCAIFADDR_IN6: 673 case OSIOCAIFADDR_IN6:
674 in6_aliasreq50_to_in6_aliasreq(ifra); 674 in6_aliasreq50_to_in6_aliasreq(ifra);
675#endif 675#endif
676 /*FALLTHROUGH*/ 676 /*FALLTHROUGH*/
677 case SIOCAIFADDR_IN6: 677 case SIOCAIFADDR_IN6:
678 { 678 {
679 struct in6_addrlifetime *lt; 679 struct in6_addrlifetime *lt;
680 680
681 /* reject read-only flags */ 681 /* reject read-only flags */
682 if ((ifra->ifra_flags & IN6_IFF_DUPLICATED) != 0 || 682 if ((ifra->ifra_flags & IN6_IFF_DUPLICATED) != 0 ||
683 (ifra->ifra_flags & IN6_IFF_DETACHED) != 0 || 683 (ifra->ifra_flags & IN6_IFF_DETACHED) != 0 ||
684 (ifra->ifra_flags & IN6_IFF_TENTATIVE) != 0 || 684 (ifra->ifra_flags & IN6_IFF_TENTATIVE) != 0 ||
685 (ifra->ifra_flags & IN6_IFF_NODAD) != 0 || 685 (ifra->ifra_flags & IN6_IFF_NODAD) != 0) {
686 (ifra->ifra_flags & IN6_IFF_AUTOCONF) != 0) { 
687 error = EINVAL; 686 error = EINVAL;
688 break; 687 break;
689 } 688 }
690 /* 689 /*
691 * ia6t_expire and ia6t_preferred won't be used for now, 690 * ia6t_expire and ia6t_preferred won't be used for now,
692 * so just in case. 691 * so just in case.
693 */ 692 */
694 lt = &ifra->ifra_lifetime; 693 lt = &ifra->ifra_lifetime;
695 if (lt->ia6t_expire != 0) 694 if (lt->ia6t_expire != 0)
696 lt->ia6t_expire = time_wall_to_mono(lt->ia6t_expire); 695 lt->ia6t_expire = time_wall_to_mono(lt->ia6t_expire);
697 if (lt->ia6t_preferred != 0) 696 if (lt->ia6t_preferred != 0)
698 lt->ia6t_preferred = 697 lt->ia6t_preferred =
699 time_wall_to_mono(lt->ia6t_preferred); 698 time_wall_to_mono(lt->ia6t_preferred);