Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/netinet6 Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/fba6ee2873c6
branches:  netbsd-7
changeset: 798882:fba6ee2873c6
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jan 23 09:27:15 2015 +0000

description:
Pull up following revision(s) (requested by pettai in ticket #441):
        sys/netinet6/ip6_var.h: revision 1.64
        sys/netinet6/in6.h: revision 1.82
        sys/netinet6/in6_src.c: revision 1.56
        sys/netinet6/mld6.c: revision 1.62
        sys/netinet6/ip6_input.c: revision 1.150
        sys/netinet6/ip6_output.c: revision 1.161
Add net.inet6.ip6.prefer_tempaddr sysctl knob so that we can prefer
IPv6 temporary addresses as the source address.
Fixes PR kern/47100 based on a patch by Dieter Roelants.

diffstat:

 sys/netinet6/in6.h        |   4 +++-
 sys/netinet6/in6_src.c    |  10 ++--------
 sys/netinet6/ip6_input.c  |  12 ++++++++++--
 sys/netinet6/ip6_output.c |  35 +++++++++++++++++++++++++++++++++--
 sys/netinet6/ip6_var.h    |   7 ++++++-
 sys/netinet6/mld6.c       |   5 +++--
 6 files changed, 57 insertions(+), 16 deletions(-)

diffs (257 lines):

diff -r 7054b4d17f9b -r fba6ee2873c6 sys/netinet6/in6.h
--- a/sys/netinet6/in6.h        Fri Jan 23 09:02:48 2015 +0000
+++ b/sys/netinet6/in6.h        Fri Jan 23 09:27:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.h,v 1.78 2014/06/05 23:48:16 rmind Exp $   */
+/*     $NetBSD: in6.h,v 1.78.2.1 2015/01/23 09:27:15 martin Exp $      */
 /*     $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $    */
 
 /*
@@ -437,6 +437,8 @@
 
 #define IPV6_TCLASS            61 /* int; send traffic class value */
 #define IPV6_DONTFRAG          62 /* bool; disable IPv6 fragmentation */
+#define IPV6_PREFER_TEMPADDR   63 /* int; prefer temporary address as
+                                   * the sorce address */
 /* to define items, should talk with KAME guys first, for *BSD compatibility */
 
 #define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
diff -r 7054b4d17f9b -r fba6ee2873c6 sys/netinet6/in6_src.c
--- a/sys/netinet6/in6_src.c    Fri Jan 23 09:02:48 2015 +0000
+++ b/sys/netinet6/in6_src.c    Fri Jan 23 09:27:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_src.c,v 1.54 2014/05/17 21:26:20 rmind Exp $       */
+/*     $NetBSD: in6_src.c,v 1.54.2.1 2015/01/23 09:27:15 martin Exp $  */
 /*     $KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $     */
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.54 2014/05/17 21:26:20 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.54.2.1 2015/01/23 09:27:15 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -118,9 +118,7 @@
 #define ADDR_LABEL_NOTAPP (-1)
 struct in6_addrpolicy defaultaddrpolicy;
 
-#ifdef notyet /* until introducing ND extensions and address selection */
 int ip6_prefer_tempaddr = 0;
-#endif
 
 static int selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
        struct ip6_moptions *, struct route *, struct ifnet **,
@@ -184,9 +182,7 @@
        struct in6_addrpolicy *dst_policy = NULL, *best_policy = NULL;
        u_int32_t odstzone;
        int error;
-#ifdef notyet /* until introducing ND extensions and address selection */
        int prefer_tempaddr;
-#endif
 #if defined(MIP6) && NMIP > 0
        u_int8_t ip6po_usecoa = 0;
 #endif /* MIP6 && NMIP > 0 */
@@ -458,7 +454,6 @@
                 * a sysctl variable, so that privacy conscious users can
                 * always prefer temporary addresses.
                 */
-#ifdef notyet /* until introducing ND extensions and address selection */
                if (opts == NULL ||
                    opts->ip6po_prefer_tempaddr == IP6PO_TEMPADDR_SYSTEM) {
                        prefer_tempaddr = ip6_prefer_tempaddr;
@@ -481,7 +476,6 @@
                        else
                                REPLACE(7);
                }
-#endif
 
                /*
                 * Rule 8: prefer addresses on alive interfaces.
diff -r 7054b4d17f9b -r fba6ee2873c6 sys/netinet6/ip6_input.c
--- a/sys/netinet6/ip6_input.c  Fri Jan 23 09:02:48 2015 +0000
+++ b/sys/netinet6/ip6_input.c  Fri Jan 23 09:27:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_input.c,v 1.149 2014/06/16 00:33:39 ozaki-r Exp $  */
+/*     $NetBSD: ip6_input.c,v 1.149.2.1 2015/01/23 09:27:15 martin Exp $       */
 /*     $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $     */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.149 2014/06/16 00:33:39 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.149.2.1 2015/01/23 09:27:15 martin Exp $");
 
 #include "opt_gateway.h"
 #include "opt_inet.h"
@@ -1902,6 +1902,14 @@
                       CTL_CREATE, CTL_EOL);
        sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+                      CTLTYPE_INT, "prefer_tempaddr",
+                      SYSCTL_DESCR("Prefer temporary address as source "
+                                   "address"),
+                      NULL, 0, &ip6_prefer_tempaddr, 0,
+                      CTL_NET, PF_INET6, IPPROTO_IPV6,
+                      CTL_CREATE, CTL_EOL);
+       sysctl_createv(clog, 0, NULL, NULL,
+                      CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_INT, "temppltime",
                       SYSCTL_DESCR("preferred lifetime of a temporary address"),
                       NULL, 0, &ip6_temp_preferred_lifetime, 0,
diff -r 7054b4d17f9b -r fba6ee2873c6 sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Fri Jan 23 09:02:48 2015 +0000
+++ b/sys/netinet6/ip6_output.c Fri Jan 23 09:27:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_output.c,v 1.157.2.1 2014/08/24 08:34:58 martin Exp $      */
+/*     $NetBSD: ip6_output.c,v 1.157.2.2 2015/01/23 09:27:15 martin Exp $      */
 /*     $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $    */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.157.2.1 2014/08/24 08:34:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.157.2.2 2015/01/23 09:27:15 martin Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -1505,6 +1505,7 @@
                case IPV6_TCLASS:
                case IPV6_DONTFRAG:
                case IPV6_USE_MIN_MTU:
+               case IPV6_PREFER_TEMPADDR:
                        error = sockopt_getint(sopt, &optval);
                        if (error)
                                break;
@@ -1827,6 +1828,7 @@
                case IPV6_TCLASS:
                case IPV6_DONTFRAG:
                case IPV6_USE_MIN_MTU:
+               case IPV6_PREFER_TEMPADDR:
                        error = ip6_getpcbopt(in6p->in6p_outputopts,
                            optname, sopt);
                        break;
@@ -2007,6 +2009,7 @@
        opt->ip6po_hlim = -1;   /* -1 means default hop limit */
        opt->ip6po_tclass = -1; /* -1 means default traffic class */
        opt->ip6po_minmtu = IP6PO_MINMTU_MCASTONLY;
+       opt->ip6po_prefer_tempaddr = IP6PO_TEMPADDR_SYSTEM;
 }
 
 #define sin6tosa(sin6) ((struct sockaddr *)(sin6)) /* XXX */
@@ -2039,6 +2042,7 @@
        struct in6_pktinfo null_pktinfo;
        int deftclass = 0, on;
        int defminmtu = IP6PO_MINMTU_MCASTONLY;
+       int defpreftemp = IP6PO_TEMPADDR_SYSTEM;
 
        switch (optname) {
        case IPV6_PKTINFO:
@@ -2110,6 +2114,12 @@
                optdata = (void *)&on;
                optdatalen = sizeof(on);
                break;
+       case IPV6_PREFER_TEMPADDR:
+               if (pktopt)
+                       optdata = (void *)&pktopt->ip6po_prefer_tempaddr;
+               else
+                       optdata = (void *)&defpreftemp;
+               optdatalen = sizeof(int);
        default:                /* should not happen */
 #ifdef DIAGNOSTIC
                panic("ip6_getpcbopt: unexpected option\n");
@@ -2180,6 +2190,7 @@
        dst->ip6po_hlim = src->ip6po_hlim;
        dst->ip6po_tclass = src->ip6po_tclass;
        dst->ip6po_flags = src->ip6po_flags;
+       dst->ip6po_prefer_tempaddr = src->ip6po_prefer_tempaddr;
        if (src->ip6po_pktinfo) {
                dst->ip6po_pktinfo = malloc(sizeof(*dst->ip6po_pktinfo),
                    M_IP6OPT, canwait);
@@ -2704,6 +2715,7 @@
                case IPV6_DONTFRAG:
                case IPV6_OTCLASS:
                case IPV6_TCLASS:
+               case IPV6_PREFER_TEMPADDR: /* XXX not an RFC3542 option */
                        return (ENOPROTOOPT);
                }
        }
@@ -3037,6 +3049,25 @@
                        opt->ip6po_flags |= IP6PO_DONTFRAG;
                break;
 
+       case IPV6_PREFER_TEMPADDR:
+       {
+               int preftemp;
+
+               if (len != sizeof(int))
+                       return (EINVAL);
+               preftemp = *(int *)buf;
+               switch (preftemp) {
+               case IP6PO_TEMPADDR_SYSTEM:
+               case IP6PO_TEMPADDR_NOTPREFER:
+               case IP6PO_TEMPADDR_PREFER:
+                       break;
+               default:
+                       return (EINVAL);
+               }
+               opt->ip6po_prefer_tempaddr = preftemp;
+               break;
+       }
+
        default:
                return (ENOPROTOOPT);
        } /* end of switch */
diff -r 7054b4d17f9b -r fba6ee2873c6 sys/netinet6/ip6_var.h
--- a/sys/netinet6/ip6_var.h    Fri Jan 23 09:02:48 2015 +0000
+++ b/sys/netinet6/ip6_var.h    Fri Jan 23 09:27:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_var.h,v 1.62 2014/06/05 23:48:16 rmind Exp $       */
+/*     $NetBSD: ip6_var.h,v 1.62.2.1 2015/01/23 09:27:15 martin Exp $  */
 /*     $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $        */
 
 /*
@@ -148,6 +148,11 @@
 #define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast*/
 #define IP6PO_MINMTU_DISABLE    0 /* always perform pmtu disc */
 #define IP6PO_MINMTU_ALL        1 /* always send at min MTU */
+       int     ip6po_prefer_tempaddr;  /* whether temporary addresses are
+                                        * preferred as source address */
+#define IP6PO_TEMPADDR_SYSTEM  -1 /* follow the system default */
+#define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */
+#define IP6PO_TEMPADDR_PREFER   1 /* prefer temporary address */
        int ip6po_flags;
 #if 0  /* parameters in this block is obsolete. do not reuse the values. */
 #define IP6PO_REACHCONF        0x01    /* upper-layer reachability confirmation. */
diff -r 7054b4d17f9b -r fba6ee2873c6 sys/netinet6/mld6.c
--- a/sys/netinet6/mld6.c       Fri Jan 23 09:02:48 2015 +0000
+++ b/sys/netinet6/mld6.c       Fri Jan 23 09:27:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mld6.c,v 1.59.2.1 2014/12/29 17:33:49 martin Exp $     */
+/*     $NetBSD: mld6.c,v 1.59.2.2 2015/01/23 09:27:15 martin Exp $     */
 /*     $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $   */
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.59.2.1 2014/12/29 17:33:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.59.2.2 2015/01/23 09:27:15 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -188,6 +188,7 @@
        ip6_opts.ip6po_hbh = hbh;
        /* We will specify the hoplimit by a multicast option. */
        ip6_opts.ip6po_hlim = -1;
+       ip6_opts.ip6po_prefer_tempaddr = IP6PO_TEMPADDR_NOTPREFER;
 }
 
 static void



Home | Main Index | Thread Index | Old Index