This is a completely mechanical diff to get rid of the 7-params madness
in in6_selectsrc().
I also apply the same treatment to in_selectsrc() for consistency.
Ok?
Index: sys/netinet/in_pcb.c
===================================================================
RCS file: /cvs/src/sys/netinet/in_pcb.c,v
retrieving revision 1.210
diff -u -p -r1.210 in_pcb.c
--- sys/netinet/in_pcb.c 19 Jul 2016 14:49:46 -0000 1.210
+++ sys/netinet/in_pcb.c 20 Jul 2016 10:21:17 -0000
@@ -525,8 +525,7 @@ in_pcbconnect(struct inpcb *inp, struct
if (sin->sin_port == 0)
return (EADDRNOTAVAIL);
- error = in_selectsrc(&ina, sin, inp->inp_moptions, &inp->inp_route,
- &inp->inp_laddr, inp->inp_rtableid);
+ error = in_selpcbsrc(&ina, sin, inp);
if (error)
return (error);
@@ -876,10 +875,14 @@ in_pcbrtentry(struct inpcb *inp)
* an entry to the caller for later use.
*/
int
-in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin,
- struct ip_moptions *mopts, struct route *ro, struct in_addr *laddr,
- u_int rtableid)
+in_selpcbsrc(struct in_addr **insrc, struct sockaddr_in *sin,
+ struct inpcb *inp)
{
+ struct ip_moptions *mopts = inp->inp_moptions;
+ struct route *ro = &inp->inp_route;
+ struct in_addr *laddr = &inp->inp_laddr;
+ u_int rtableid = inp->inp_rtableid;
+
struct sockaddr_in *sin2;
struct in_ifaddr *ia = NULL;
Index: sys/netinet/in_pcb.h
===================================================================
RCS file: /cvs/src/sys/netinet/in_pcb.h,v
retrieving revision 1.100
diff -u -p -r1.100 in_pcb.h
--- sys/netinet/in_pcb.h 27 Jun 2016 16:33:48 -0000 1.100
+++ sys/netinet/in_pcb.h 20 Jul 2016 10:21:17 -0000
@@ -289,8 +289,7 @@ void in_setpeeraddr(struct inpcb *, str
void in_setsockaddr(struct inpcb *, struct mbuf *);
int in_baddynamic(u_int16_t, u_int16_t);
int in_rootonly(u_int16_t, u_int16_t);
-int in_selectsrc(struct in_addr **, struct sockaddr_in *,
- struct ip_moptions *, struct route *, struct in_addr *, u_int);
+int in_selpcbsrc(struct in_addr **, struct sockaddr_in *, struct inpcb *);
struct rtentry *
in_pcbrtentry(struct inpcb *);
Index: sys/netinet/udp_usrreq.c
===================================================================
RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.214
diff -u -p -r1.214 udp_usrreq.c
--- sys/netinet/udp_usrreq.c 28 Jun 2016 11:22:53 -0000 1.214
+++ sys/netinet/udp_usrreq.c 20 Jul 2016 10:21:19 -0000
@@ -989,8 +989,7 @@ udp_output(struct inpcb *inp, struct mbu
goto release;
}
- error = in_selectsrc(&laddr, sin, inp->inp_moptions,
- &inp->inp_route, &inp->inp_laddr, inp->inp_rtableid);
+ error = in_selpcbsrc(&laddr, sin, inp);
if (error)
goto release;
Index: sys/netinet6/icmp6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.186
diff -u -p -r1.186 icmp6.c
--- sys/netinet6/icmp6.c 5 Jul 2016 10:17:14 -0000 1.186
+++ sys/netinet6/icmp6.c 20 Jul 2016 10:21:19 -0000
@@ -1259,7 +1259,7 @@ icmp6_reflect(struct mbuf *m, size_t off
* source address of the erroneous packet.
*/
bzero(&ro, sizeof(ro));
- error = in6_selectsrc(&src, &sa6_src, NULL, NULL, &ro, NULL,
+ error = in6_selectsrc(&src, &sa6_src, NULL, &ro,
m->m_pkthdr.ph_rtableid);
if (ro.ro_rt)
rtfree(ro.ro_rt); /* XXX: we could use this */
Index: sys/netinet6/in6_pcb.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_pcb.c,v
retrieving revision 1.93
diff -u -p -r1.93 in6_pcb.c
--- sys/netinet6/in6_pcb.c 5 Jul 2016 10:17:14 -0000 1.93
+++ sys/netinet6/in6_pcb.c 20 Jul 2016 10:21:19 -0000
@@ -281,9 +281,7 @@ in6_pcbconnect(struct inpcb *inp, struct
* with the address specified by setsockopt(IPV6_PKTINFO).
* Is it the intended behavior?
*/
- error = in6_selectsrc(&in6a, sin6, inp->inp_outputopts6,
- inp->inp_moptions6, &inp->inp_route6, &inp->inp_laddr6,
- inp->inp_rtableid);
+ error = in6_selpcbsrc(&in6a, sin6, inp, inp->inp_outputopts6);
if (error)
return (error);
Index: sys/netinet6/in6_src.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_src.c,v
retrieving revision 1.76
diff -u -p -r1.76 in6_src.c
--- sys/netinet6/in6_src.c 5 Jul 2016 10:17:14 -0000 1.76
+++ sys/netinet6/in6_src.c 20 Jul 2016 10:21:19 -0000
@@ -88,15 +88,18 @@ int in6_selectif(struct sockaddr_in6 *,
/*
* Return an IPv6 address, which is the most appropriate for a given
- * destination and user specified options.
- * If necessary, this function lookups the routing table and returns
- * an entry to the caller for later use.
+ * destination and pcb. We need the additional opt parameter because
+ * the values set at pcb level can be overriden via cmsg.
*/
int
-in6_selectsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
- struct ip6_pktopts *opts, struct ip6_moptions *mopts,
- struct route_in6 *ro, struct in6_addr *laddr, u_int rtableid)
+in6_selpcbsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
+ struct inpcb *inp, struct ip6_pktopts *opts)
{
+ struct ip6_moptions *mopts = inp->inp_moptions6;
+ struct route_in6 *ro = &inp->inp_route6;
+ struct in6_addr *laddr = &inp->inp_laddr6;
+ u_int rtableid = inp->inp_rtableid;
+
struct ifnet *ifp = NULL;
struct in6_addr *dst;
struct in6_ifaddr *ia6 = NULL;
@@ -168,6 +171,23 @@ in6_selectsrc(struct in6_addr **in6src,
*in6src = &ia6->ia_addr.sin6_addr;
return (0);
}
+
+ return in6_selectsrc(in6src, dstsock, mopts, ro, rtableid);
+}
+
+/*
+ * Return an IPv6 address, which is the most appropriate for a given
+ * destination and multicast options.
+ * If necessary, this function lookups the routing table and returns
+ * an entry to the caller for later use.
+ */
+int
+in6_selectsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
+ struct ip6_moptions *mopts, struct route_in6 *ro, u_int rtableid)
+{
+ struct ifnet *ifp = NULL;
+ struct in6_addr *dst;
+ struct in6_ifaddr *ia6 = NULL;
/*
* If the destination address is a link-local unicast address or
Index: sys/netinet6/ip6_var.h
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_var.h,v
retrieving revision 1.60
diff -u -p -r1.60 ip6_var.h
--- sys/netinet6/ip6_var.h 1 Jun 2016 11:11:44 -0000 1.60
+++ sys/netinet6/ip6_var.h 20 Jul 2016 10:21:20 -0000
@@ -294,9 +294,10 @@ int rip6_sysctl(int *, u_int, void *, si
int dest6_input(struct mbuf **, int *, int);
int none_input(struct mbuf **, int *, int);
+int in6_selpcbsrc(struct in6_addr **, struct sockaddr_in6 *,
+ struct inpcb *, struct ip6_pktopts *);
int in6_selectsrc(struct in6_addr **, struct sockaddr_in6 *,
- struct ip6_pktopts *, struct ip6_moptions *, struct route_in6 *,
- struct in6_addr *, u_int);
+ struct ip6_moptions *, struct route_in6 *, u_int);
struct rtentry *in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
struct route_in6 *, unsigned int rtableid);
Index: sys/netinet6/nd6_nbr.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6_nbr.c,v
retrieving revision 1.105
diff -u -p -r1.105 nd6_nbr.c
--- sys/netinet6/nd6_nbr.c 5 Jul 2016 10:17:14 -0000 1.105
+++ sys/netinet6/nd6_nbr.c 20 Jul 2016 10:21:20 -0000
@@ -471,8 +471,8 @@ nd6_ns_output(struct ifnet *ifp, struct
int error;
bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa));
- error = in6_selectsrc(&src0, &dst_sa, NULL, NULL, &ro,
- NULL, m->m_pkthdr.ph_rtableid);
+ error = in6_selectsrc(&src0, &dst_sa, NULL, &ro,
+ m->m_pkthdr.ph_rtableid);
if (error) {
char addr[INET6_ADDRSTRLEN];
@@ -990,7 +990,7 @@ nd6_na_output(struct ifnet *ifp, struct
* Select a source whose scope is the same as that of the dest.
*/
bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa));
- error = in6_selectsrc(&src0, &dst_sa, NULL, NULL, &ro, NULL,
+ error = in6_selectsrc(&src0, &dst_sa, NULL, &ro,
m->m_pkthdr.ph_rtableid);
if (error) {
char addr[INET6_ADDRSTRLEN];
Index: sys/netinet6/raw_ip6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/raw_ip6.c,v
retrieving revision 1.91
diff -u -p -r1.91 raw_ip6.c
--- sys/netinet6/raw_ip6.c 5 Jul 2016 10:17:14 -0000 1.91
+++ sys/netinet6/raw_ip6.c 20 Jul 2016 10:21:20 -0000
@@ -396,9 +396,7 @@ rip6_output(struct mbuf *m, ...)
{
struct in6_addr *in6a;
- error = in6_selectsrc(&in6a, dstsock, optp,
- in6p->inp_moptions6, &in6p->inp_route6, &in6p->inp_laddr6,
- in6p->inp_rtableid);
+ error = in6_selpcbsrc(&in6a, dstsock, in6p, optp);
if (error)
goto bad;
@@ -700,9 +698,7 @@ rip6_usrreq(struct socket *so, int req,
}
/* Source address selection. XXX: need pcblookup? */
- error = in6_selectsrc(&in6a, addr, in6p->inp_outputopts6,
- in6p->inp_moptions6, &in6p->inp_route6,
- &in6p->inp_laddr6, in6p->inp_rtableid);
+ error = in6_selpcbsrc(&in6a, addr, in6p, in6p->inp_outputopts6);
if (error)
break;
in6p->inp_laddr6 = *in6a;
Index: sys/netinet6/udp6_output.c
===================================================================
RCS file: /cvs/src/sys/netinet6/udp6_output.c,v
retrieving revision 1.48
diff -u -p -r1.48 udp6_output.c
--- sys/netinet6/udp6_output.c 19 May 2016 08:02:22 -0000 1.48
+++ sys/netinet6/udp6_output.c 20 Jul 2016 10:21:20 -0000
@@ -154,9 +154,7 @@ udp6_output(struct inpcb *in6p, struct m
goto release;
}
- error = in6_selectsrc(&laddr, sin6, optp,
- in6p->inp_moptions6, &in6p->inp_route6,
- &in6p->inp_laddr6, in6p->inp_rtableid);
+ error = in6_selpcbsrc(&laddr, sin6, in6p, optp);
if (error)
goto release;