Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Jan 2017 20:05:19 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r311034 - projects/ipsec/sys/netipsec
Message-ID:  <201701012005.v01K5JgY071509@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Sun Jan  1 20:05:19 2017
New Revision: 311034
URL: https://svnweb.freebsd.org/changeset/base/311034

Log:
  Initialize address family and length fields in the source and destination
  addresses of security policy index based on the INPCB vflag.

Modified:
  projects/ipsec/sys/netipsec/ipsec_pcb.c

Modified: projects/ipsec/sys/netipsec/ipsec_pcb.c
==============================================================================
--- projects/ipsec/sys/netipsec/ipsec_pcb.c	Sun Jan  1 19:46:56 2017	(r311033)
+++ projects/ipsec/sys/netipsec/ipsec_pcb.c	Sun Jan  1 20:05:19 2017	(r311034)
@@ -216,6 +216,24 @@ ipsec_set_pcbpolicy(struct inpcb *inp, s
 		if (newsp == NULL)
 			return (error);
 		newsp->state = IPSEC_SPSTATE_PCB;
+#ifdef INET
+		if (inp->inp_vflag & INP_IPV4) {
+			newsp->spidx.src.sin.sin_family =
+			    newsp->spidx.dst.sin.sin_family = AF_INET;
+			newsp->spidx.src.sin.sin_len =
+			    newsp->spidx.dst.sin.sin_len =
+			    sizeof(struct sockaddr_in);
+		}
+#endif
+#ifdef INET6
+		if (inp->inp_vflag & INP_IPV6) {
+			newsp->spidx.src.sin6.sin6_family =
+			    newsp->spidx.dst.sin6.sin6_family = AF_INET6;
+			newsp->spidx.src.sin6.sin6_len =
+			    newsp->spidx.dst.sin6.sin6_len =
+			    sizeof(struct sockaddr_in6);
+		}
+#endif
 		break;
 	case IPSEC_POLICY_ENTRUST:
 		/* We just use NULL pointer for ENTRUST policy */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701012005.v01K5JgY071509>