1From a41cbeee3cf660663a9baac80545050a8d960898 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 28 Mar 2017 18:09:58 -0700
4Subject: [PATCH 2/2] user ipv6 structures
5
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8Update for ipv6 address compare
9Signed-off-by: Changqing Li <changqing.li@windriver.com>
10---
11Upstream-Status: Pending
12
13 l2tp_api.c | 8 +++++---
14 1 file changed, 5 insertions(+), 3 deletions(-)
15
16diff --git a/l2tp_api.c b/l2tp_api.c
17index 9d6f60a..f0946fd 100644
18--- a/l2tp_api.c
19+++ b/l2tp_api.c
20@@ -450,10 +450,12 @@ int l2tp_api_rpc_check_request(SVCXPRT *xprt)
21 	 * non-loopback interface, reject the request.
22 	 */
23 	if ((!l2tp_opt_remote_rpc) &&
24-	    ((xprt->xp_raddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)) &&
25-	     (xprt->xp_raddr.sin_addr.s_addr != htonl(INADDR_ANY)))) {
26+	    ((memcmp(&xprt->xp_raddr.sin6_addr, &in6addr_loopback, sizeof(struct in6_addr)) != 0) &&
27+	     (memcmp(&xprt->xp_raddr.sin6_addr, &in6addr_any, sizeof(struct in6_addr)) != 0))) {
28+		char straddr[INET6_ADDRSTRLEN];
29+		inet_ntop(AF_INET6, &xprt->xp_raddr.sin6_addr, straddr, sizeof(straddr));
30 		if (l2tp_opt_trace_flags & L2TP_DEBUG_API) {
31-			l2tp_log(LOG_ERR, "Rejecting RPC request from %s", inet_ntoa(xprt->xp_raddr.sin_addr));
32+			l2tp_log(LOG_ERR, "Rejecting RPC request from %s", straddr);
33 		}
34 		svcerr_auth(xprt, AUTH_TOOWEAK);
35 		return -EPERM;
36--
372.12.1
38
39