I'm trying to help Claudio murdering some IPv6 madness.  Here's a first
baby step to clean the source address selection code.

Ok?

Index: netinet6/in6_src.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_src.c,v
retrieving revision 1.57
diff -u -p -r1.57 in6_src.c
--- netinet6/in6_src.c  11 Sep 2015 07:42:35 -0000      1.57
+++ netinet6/in6_src.c  11 Sep 2015 09:30:57 -0000
@@ -85,9 +85,6 @@
 
 int in6_selectif(struct sockaddr_in6 *, struct ip6_pktopts *,
     struct ip6_moptions *, struct route_in6 *, struct ifnet **, u_int);
-int selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
-    struct ip6_moptions *, struct route_in6 *, struct ifnet **,
-    struct rtentry **, int, u_int);
 
 /*
  * Return an IPv6 address, which is the most appropriate for a given
@@ -297,7 +294,7 @@ in6_selectsrc(struct in6_addr **in6src, 
 }
 
 int
-selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
+in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
     struct ip6_moptions *mopts, struct route_in6 *ro, struct ifnet **retifp,
     struct rtentry **retrt, int norouteok, u_int rtableid)
 {
@@ -310,21 +307,6 @@ selectroute(struct sockaddr_in6 *dstsock
 
        dst = &dstsock->sin6_addr;
 
-#if 0
-       char ip[INET6_ADDRSTRLEN];
-
-       if (dstsock->sin6_addr.s6_addr32[0] == 0 &&
-           dstsock->sin6_addr.s6_addr32[1] == 0 &&
-           !IN6_IS_ADDR_LOOPBACK(&dstsock->sin6_addr)) {
-               printf("in6_selectroute: strange destination %s\n",
-                   inet_ntop(AF_INET6, &dstsock->sin6_addr, ip, sizeof(ip)));
-       } else {
-               printf("in6_selectroute: destination = %s%%%d\n",
-                   inet_ntop(AF_INET6, &dstsock->sin6_addr, ip, sizeof(ip)),
-                   dstsock->sin6_scope_id); /* for debug */
-       }
-#endif
-
        /* If the caller specify the outgoing interface explicitly, use it. */
        if (opts && (pi = opts->ip6po_pktinfo) != NULL && pi->ipi6_ifindex) {
                ifp = if_get(pi->ipi6_ifindex);
@@ -504,7 +486,7 @@ in6_selectif(struct sockaddr_in6 *dstsoc
        struct rtentry *rt = NULL;
        int error;
 
-       if ((error = selectroute(dstsock, opts, mopts, ro, retifp,
+       if ((error = in6_selectroute(dstsock, opts, mopts, ro, retifp,
            &rt, 1, rtableid)) != 0)
                return (error);
 
@@ -539,16 +521,6 @@ in6_selectif(struct sockaddr_in6 *dstsoc
                *retifp = rt->rt_ifa->ifa_ifp;
 
        return (0);
-}
-
-int
-in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
-    struct ip6_moptions *mopts, struct route_in6 *ro, struct ifnet **retifp,
-    struct rtentry **retrt, u_int rtableid)
-{
-
-       return (selectroute(dstsock, opts, mopts, ro, retifp, retrt, 0,
-           rtableid));
 }
 
 /*
Index: netinet6/ip6_output.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
retrieving revision 1.181
diff -u -p -r1.181 ip6_output.c
--- netinet6/ip6_output.c       11 Sep 2015 08:17:06 -0000      1.181
+++ netinet6/ip6_output.c       11 Sep 2015 09:29:58 -0000
@@ -529,7 +529,7 @@ reroute:
        dstsock.sin6_len = sizeof(dstsock);
        ro->ro_tableid = m->m_pkthdr.ph_rtableid;
        if ((error = in6_selectroute(&dstsock, opt, im6o, ro, &ifp,
-           &rt, m->m_pkthdr.ph_rtableid)) != 0) {
+           &rt, 0, m->m_pkthdr.ph_rtableid)) != 0) {
                switch (error) {
                case EHOSTUNREACH:
                        ip6stat.ip6s_noroute++;
Index: netinet6/ip6_var.h
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_var.h,v
retrieving revision 1.52
diff -u -p -r1.52 ip6_var.h
--- netinet6/ip6_var.h  11 Sep 2015 08:17:06 -0000      1.52
+++ netinet6/ip6_var.h  11 Sep 2015 09:29:37 -0000
@@ -312,7 +312,7 @@ int in6_selectsrc(struct in6_addr **, st
            struct in6_addr *, u_int);
 int    in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
            struct ip6_moptions *, struct route_in6 *, struct ifnet **,
-           struct rtentry **, u_int rtableid);
+           struct rtentry **, int, u_int rtableid);
 
 u_int32_t ip6_randomflowlabel(void);
 #endif /* _KERNEL */

Reply via email to