Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Introduce and use SADB_SASTATE_USABLE_P
details: https://anonhg.NetBSD.org/src/rev/78987803be5c
branches: trunk
changeset: 354928:78987803be5c
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue Jul 04 08:11:32 2017 +0000
description:
Introduce and use SADB_SASTATE_USABLE_P
diffstat:
sys/net/pfkeyv2.h | 5 ++++-
sys/netipsec/ipsec_netbsd.c | 18 ++++++------------
sys/netipsec/key.c | 7 +++----
3 files changed, 13 insertions(+), 17 deletions(-)
diffs (107 lines):
diff -r 856f6e22eee1 -r 78987803be5c sys/net/pfkeyv2.h
--- a/sys/net/pfkeyv2.h Tue Jul 04 08:09:19 2017 +0000
+++ b/sys/net/pfkeyv2.h Tue Jul 04 08:11:32 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pfkeyv2.h,v 1.31 2017/04/13 16:38:31 christos Exp $ */
+/* $NetBSD: pfkeyv2.h,v 1.32 2017/07/04 08:11:32 ozaki-r Exp $ */
/* $KAME: pfkeyv2.h,v 1.36 2003/07/25 09:33:37 itojun Exp $ */
/*
@@ -339,6 +339,9 @@
#define SADB_SASTATE_DEAD 3
#define SADB_SASTATE_MAX 3
+#define SADB_SASTATE_USABLE_P(sav) \
+ ((sav)->state == SADB_SASTATE_MATURE || (sav)->state == SADB_SASTATE_DYING)
+
#define SADB_SAFLAGS_PFS 1
/*
diff -r 856f6e22eee1 -r 78987803be5c sys/netipsec/ipsec_netbsd.c
--- a/sys/netipsec/ipsec_netbsd.c Tue Jul 04 08:09:19 2017 +0000
+++ b/sys/netipsec/ipsec_netbsd.c Tue Jul 04 08:11:32 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec_netbsd.c,v 1.41 2017/07/04 08:09:19 ozaki-r Exp $ */
+/* $NetBSD: ipsec_netbsd.c,v 1.42 2017/07/04 08:11:32 ozaki-r Exp $ */
/* $KAME: esp_input.c,v 1.60 2001/09/04 08:43:19 itojun Exp $ */
/* $KAME: ah_input.c,v 1.64 2001/09/04 08:43:19 itojun Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.41 2017/07/04 08:09:19 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.42 2017/07/04 08:11:32 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -111,9 +111,7 @@
IPPROTO_AH, ah->ah_spi, 0, 0);
if (sav) {
- if (sav->state == SADB_SASTATE_MATURE ||
- sav->state == SADB_SASTATE_DYING) {
-
+ if (SADB_SASTATE_USABLE_P(sav)) {
/*
* Now that we've validated that we are actually
* communicating with the host indicated in the
@@ -159,9 +157,7 @@
IPPROTO_ESP, esp->esp_spi, 0, 0);
if (sav) {
- if (sav->state == SADB_SASTATE_MATURE ||
- sav->state == SADB_SASTATE_DYING) {
-
+ if (SADB_SASTATE_USABLE_P(sav)) {
/*
* Now that we've validated that we are actually
* communicating with the host indicated in the
@@ -242,8 +238,7 @@
IPPROTO_AH, ahp->ah_spi, 0, 0);
if (sav) {
- if (sav->state == SADB_SASTATE_MATURE ||
- sav->state == SADB_SASTATE_DYING)
+ if (SADB_SASTATE_USABLE_P(sav))
valid++;
KEY_FREESAV(&sav);
}
@@ -348,8 +343,7 @@
IPPROTO_ESP, espp->esp_spi, 0, 0);
if (sav) {
- if (sav->state == SADB_SASTATE_MATURE ||
- sav->state == SADB_SASTATE_DYING)
+ if (SADB_SASTATE_USABLE_P(sav))
valid++;
KEY_FREESAV(&sav);
}
diff -r 856f6e22eee1 -r 78987803be5c sys/netipsec/key.c
--- a/sys/netipsec/key.c Tue Jul 04 08:09:19 2017 +0000
+++ b/sys/netipsec/key.c Tue Jul 04 08:11:32 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.164 2017/06/10 14:21:01 ozaki-r Exp $ */
+/* $NetBSD: key.c,v 1.165 2017/07/04 08:11:32 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $ */
/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.164 2017/06/10 14:21:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.165 2017/07/04 08:11:32 ozaki-r Exp $");
/*
* This code is referd to RFC 2367
@@ -1191,8 +1191,7 @@
/* sanity check */
KEY_CHKSASTATE(sav->state, state);
/* do not return entries w/ unusable state */
- if (sav->state != SADB_SASTATE_MATURE &&
- sav->state != SADB_SASTATE_DYING) {
+ if (!SADB_SASTATE_USABLE_P(sav)) {
KEYDEBUG_PRINTF(KEYDEBUG_MATCH,
"bad state %d\n", sav->state);
continue;
Home |
Main Index |
Thread Index |
Old Index