Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netipsec ipsec_getpolicybysock() should also call key_ha...



details:   https://anonhg.NetBSD.org/src/rev/5b52d94c36c5
branches:  trunk
changeset: 463063:5b52d94c36c5
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Wed Aug 07 10:10:00 2019 +0000

description:
ipsec_getpolicybysock() should also call key_havesp() like ipsec_getpolicybyaddr().

That can reduce KEYDEBUG messages.

diffstat:

 sys/netipsec/ipsec.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r f268674694df -r 5b52d94c36c5 sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c      Wed Aug 07 10:08:04 2019 +0000
+++ b/sys/netipsec/ipsec.c      Wed Aug 07 10:10:00 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.169 2019/07/09 16:56:24 maxv Exp $ */
+/* $NetBSD: ipsec.c,v 1.170 2019/08/07 10:10:00 knakahara Exp $ */
 /* $FreeBSD: ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */
 /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.169 2019/07/09 16:56:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.170 2019/08/07 10:10:00 knakahara Exp $");
 
 /*
  * IPsec controller part.
@@ -466,7 +466,10 @@
 
                case IPSEC_POLICY_ENTRUST:
                        /* look for a policy in SPD */
-                       sp = KEY_LOOKUP_SP_BYSPIDX(&currsp->spidx, dir);
+                       if (key_havesp(dir))
+                               sp = KEY_LOOKUP_SP_BYSPIDX(&currsp->spidx, dir);
+                       else
+                               sp = NULL;
                        if (sp == NULL)         /* no SP found */
                                sp = KEY_GET_DEFAULT_SP(af);
                        break;
@@ -478,7 +481,10 @@
                        return NULL;
                }
        } else {                                /* unpriv, SPD has policy */
-               sp = KEY_LOOKUP_SP_BYSPIDX(&currsp->spidx, dir);
+               if (key_havesp(dir))
+                       sp = KEY_LOOKUP_SP_BYSPIDX(&currsp->spidx, dir);
+               else
+                       sp = NULL;
                if (sp == NULL) {               /* no SP found */
                        switch (currsp->policy) {
                        case IPSEC_POLICY_BYPASS:



Home | Main Index | Thread Index | Old Index