Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec Use LIST_* functions (NFC)
details: https://anonhg.NetBSD.org/src/rev/c64e6a5845a1
branches: trunk
changeset: 353482:c64e6a5845a1
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue May 09 04:17:13 2017 +0000
description:
Use LIST_* functions (NFC)
diffstat:
sys/netipsec/key.c | 109 ++++++++++++----------------------------------------
1 files changed, 25 insertions(+), 84 deletions(-)
diffs (239 lines):
diff -r 0dc2940ffa25 -r c64e6a5845a1 sys/netipsec/key.c
--- a/sys/netipsec/key.c Tue May 09 04:08:37 2017 +0000
+++ b/sys/netipsec/key.c Tue May 09 04:17:13 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.118 2017/04/26 08:36:32 ozaki-r Exp $ */
+/* $NetBSD: key.c,v 1.119 2017/05/09 04:17:13 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.118 2017/04/26 08:36:32 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.119 2017/05/09 04:17:13 ozaki-r Exp $");
/*
* This code is referd to RFC 2367
@@ -573,7 +573,7 @@
key_havesp(u_int dir)
{
return (dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND ?
- LIST_FIRST(&sptree[dir]) != NULL : 1);
+ !LIST_EMPTY(&sptree[dir]) : 1);
}
/* %%% IPsec policy management */
@@ -927,17 +927,12 @@
static struct secasvar *
key_do_allocsa_policy(struct secashead *sah, u_int state)
{
- struct secasvar *sav, *nextsav, *candidate, *d;
+ struct secasvar *sav, *candidate, *d;
/* initilize */
candidate = NULL;
- for (sav = LIST_FIRST(&sah->savtree[state]);
- sav != NULL;
- sav = nextsav) {
-
- nextsav = LIST_NEXT(sav, chain);
-
+ LIST_FOREACH(sav, &sah->savtree[state], chain) {
/* sanity check */
KEY_CHKSASTATE(sav->state, state, "key_do_allocsa_policy");
@@ -2395,11 +2390,7 @@
for (dir = 0; dir < IPSEC_DIR_MAX; dir++) {
struct secpolicy * nextsp;
- for (sp = LIST_FIRST(&sptree[dir]);
- sp != NULL;
- sp = nextsp) {
-
- nextsp = LIST_NEXT(sp, chain);
+ LIST_FOREACH_SAFE(sp, &sptree[dir], chain, nextsp) {
if (sp->state == IPSEC_SPSTATE_DEAD)
continue;
key_sp_dead(sp);
@@ -2875,12 +2866,7 @@
stateidx++) {
state = saorder_state_any[stateidx];
- for (sav = (struct secasvar *)LIST_FIRST(&sah->savtree[state]);
- sav != NULL;
- sav = nextsav) {
-
- nextsav = LIST_NEXT(sav, chain);
-
+ LIST_FOREACH_SAFE(sav, &sah->savtree[state], chain, nextsav) {
if (sav->refcnt == 0) {
/* sanity check */
KEY_CHKSASTATE(state, sav->state, "key_delsah");
@@ -4542,12 +4528,7 @@
struct secpolicy *sp, *nextsp;
for (dir = 0; dir < IPSEC_DIR_MAX; dir++) {
- for (sp = LIST_FIRST(&sptree[dir]);
- sp != NULL;
- sp = nextsp) {
-
- nextsp = LIST_NEXT(sp, chain);
-
+ LIST_FOREACH_SAFE(sp, &sptree[dir], chain, nextsp) {
if (sp->state == IPSEC_SPSTATE_DEAD) {
key_sp_unlink(sp); /*XXX*/
@@ -4576,12 +4557,7 @@
struct secashead *sah, *nextsah;
struct secasvar *sav, *nextsav;
- for (sah = LIST_FIRST(&sahtree);
- sah != NULL;
- sah = nextsah) {
-
- nextsah = LIST_NEXT(sah, chain);
-
+ LIST_FOREACH_SAFE(sah, &sahtree, chain, nextsah) {
/* if sah has been dead, then delete it and process next sah. */
if (sah->state == SADB_SASTATE_DEAD) {
key_delsah(sah);
@@ -4589,12 +4565,8 @@
}
/* if LARVAL entry doesn't become MATURE, delete it. */
- for (sav = LIST_FIRST(&sah->savtree[SADB_SASTATE_LARVAL]);
- sav != NULL;
- sav = nextsav) {
-
- nextsav = LIST_NEXT(sav, chain);
-
+ LIST_FOREACH_SAFE(sav, &sah->savtree[SADB_SASTATE_LARVAL],
+ chain, nextsav) {
if (now - sav->created > key_larval_lifetime) {
KEY_FREESAV(&sav);
}
@@ -4604,12 +4576,8 @@
* check MATURE entry to start to send expire message
* whether or not.
*/
- for (sav = LIST_FIRST(&sah->savtree[SADB_SASTATE_MATURE]);
- sav != NULL;
- sav = nextsav) {
-
- nextsav = LIST_NEXT(sav, chain);
-
+ LIST_FOREACH_SAFE(sav, &sah->savtree[SADB_SASTATE_MATURE],
+ chain, nextsav) {
/* we don't need to check. */
if (sav->lft_s == NULL)
continue;
@@ -4661,12 +4629,8 @@
}
/* check DYING entry to change status to DEAD. */
- for (sav = LIST_FIRST(&sah->savtree[SADB_SASTATE_DYING]);
- sav != NULL;
- sav = nextsav) {
-
- nextsav = LIST_NEXT(sav, chain);
-
+ LIST_FOREACH_SAFE(sav, &sah->savtree[SADB_SASTATE_DYING],
+ chain, nextsav) {
/* we don't need to check. */
if (sav->lft_h == NULL)
continue;
@@ -4708,12 +4672,8 @@
}
/* delete entry in DEAD */
- for (sav = LIST_FIRST(&sah->savtree[SADB_SASTATE_DEAD]);
- sav != NULL;
- sav = nextsav) {
-
- nextsav = LIST_NEXT(sav, chain);
-
+ LIST_FOREACH_SAFE(sav, &sah->savtree[SADB_SASTATE_DEAD],
+ chain, nextsav) {
/* sanity check */
if (sav->state != SADB_SASTATE_DEAD) {
ipseclog((LOG_DEBUG, "key_timehandler: "
@@ -4738,12 +4698,7 @@
{
struct secacq *acq, *nextacq;
- for (acq = LIST_FIRST(&acqtree);
- acq != NULL;
- acq = nextacq) {
-
- nextacq = LIST_NEXT(acq, chain);
-
+ LIST_FOREACH_SAFE(acq, &acqtree, chain, nextacq) {
if (now - acq->created > key_blockacq_lifetime
&& __LIST_CHAINED(acq)) {
LIST_REMOVE(acq, chain);
@@ -4757,12 +4712,7 @@
{
struct secspacq *acq, *nextacq;
- for (acq = LIST_FIRST(&spacqtree);
- acq != NULL;
- acq = nextacq) {
-
- nextacq = LIST_NEXT(acq, chain);
-
+ LIST_FOREACH_SAFE(acq, &spacqtree, chain, nextacq) {
if (now - acq->created > key_blockacq_lifetime
&& __LIST_CHAINED(acq)) {
LIST_REMOVE(acq, chain);
@@ -5833,9 +5783,8 @@
state = saorder_state_alive[stateidx];
if (state == SADB_SASTATE_LARVAL)
continue;
- for (sav = LIST_FIRST(&sah->savtree[state]);
- sav != NULL; sav = nextsav) {
- nextsav = LIST_NEXT(sav, chain);
+ LIST_FOREACH_SAFE(sav, &sah->savtree[state], chain,
+ nextsav) {
/* sanity check */
if (sav->state != state) {
ipseclog((LOG_DEBUG, "key_delete_all: "
@@ -6968,7 +6917,7 @@
const struct sadb_msghdr *mhp)
{
struct sadb_msg *newmsg;
- struct secashead *sah, *nextsah;
+ struct secashead *sah;
struct secasvar *sav, *nextsav;
u_int16_t proto;
u_int8_t state;
@@ -6985,11 +6934,7 @@
}
/* no SATYPE specified, i.e. flushing all SA. */
- for (sah = LIST_FIRST(&sahtree);
- sah != NULL;
- sah = nextsah) {
- nextsah = LIST_NEXT(sah, chain);
-
+ LIST_FOREACH(sah, &sahtree, chain) {
if (mhp->msg->sadb_msg_satype != SADB_SATYPE_UNSPEC
&& proto != sah->saidx.proto)
continue;
@@ -6998,12 +6943,8 @@
stateidx < _ARRAYLEN(saorder_state_alive);
stateidx++) {
state = saorder_state_any[stateidx];
- for (sav = LIST_FIRST(&sah->savtree[state]);
- sav != NULL;
- sav = nextsav) {
-
- nextsav = LIST_NEXT(sav, chain);
-
+ LIST_FOREACH_SAFE(sav, &sah->savtree[state], chain,
+ nextsav) {
key_sa_chgstate(sav, SADB_SASTATE_DEAD);
KEY_FREESAV(&sav);
}
Home |
Main Index |
Thread Index |
Old Index