svn commit: r257089 - user/ae/inet6/sys/netinet6
Andrey V. Elsukov
ae at FreeBSD.org
Fri Oct 25 02:21:01 UTC 2013
Author: ae
Date: Fri Oct 25 02:21:00 2013
New Revision: 257089
URL: http://svnweb.freebsd.org/changeset/base/257089
Log:
Refactor udp6_getcred():
* remove sa6_embedscope() calls, use sa6_checkzone() instead;
* determine interface by zone id and pass it to in6_pcblookup.
Modified:
user/ae/inet6/sys/netinet6/udp6_usrreq.c
Modified: user/ae/inet6/sys/netinet6/udp6_usrreq.c
==============================================================================
--- user/ae/inet6/sys/netinet6/udp6_usrreq.c Fri Oct 25 02:16:36 2013 (r257088)
+++ user/ae/inet6/sys/netinet6/udp6_usrreq.c Fri Oct 25 02:21:00 2013 (r257089)
@@ -550,7 +550,9 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
{
struct xucred xuc;
struct sockaddr_in6 addrs[2];
+ struct ifnet *ifp;
struct inpcb *inp;
+ uint32_t zoneid;
int error;
error = priv_check(req->td, PRIV_NETINET_GETCRED);
@@ -564,13 +566,30 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
error = SYSCTL_IN(req, addrs, sizeof(addrs));
if (error)
return (error);
- if ((error = sa6_embedscope(&addrs[0], V_ip6_use_defzone)) != 0 ||
- (error = sa6_embedscope(&addrs[1], V_ip6_use_defzone)) != 0) {
+ error = sa6_checkzone(&addrs[0]);
+ if (error)
+ return (error);
+ error = sa6_checkzone(&addrs[1]);
+ if (error)
return (error);
+
+ ifp = NULL;
+ zoneid = 0;
+ if (addrs[0].sin6_scope_id != 0)
+ zoneid = addrs[0].sin6_scope_id;
+ if (addrs[1].sin6_scope_id != 0) {
+ if (zoneid != 0 && zoneid != addrs[1].sin6_scope_id)
+ return (EINVAL);
+ zoneid = addrs[1].sin6_scope_id;
+ }
+ if (zoneid != 0) {
+ ifp = in6_getlinkifnet(zoneid);
+ if (ifp == NULL)
+ return (ENOENT);
}
inp = in6_pcblookup(&V_udbinfo, &addrs[1].sin6_addr,
addrs[1].sin6_port, &addrs[0].sin6_addr, addrs[0].sin6_port,
- INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB, NULL);
+ INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB, ifp);
if (inp != NULL) {
INP_RLOCK_ASSERT(inp);
if (inp->inp_socket == NULL)
More information about the svn-src-user
mailing list