Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Rename key_alloc* functions (NFC)
details: https://anonhg.NetBSD.org/src/rev/35ffb229560a
branches: trunk
changeset: 354982:35ffb229560a
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Jul 07 01:37:34 2017 +0000
description:
Rename key_alloc* functions (NFC)
We shouldn't use the term "alloc" for functions that just look up
data and actually don't allocate memory.
diffstat:
sys/netinet/tcp_input.c | 6 +++---
sys/netinet/tcp_var.h | 4 ++--
sys/netipsec/ipsec.c | 26 +++++++++++++-------------
sys/netipsec/ipsec_input.c | 8 ++++----
sys/netipsec/ipsec_netbsd.c | 12 ++++++------
sys/netipsec/key.c | 17 +++++++++--------
sys/netipsec/key.h | 20 ++++++++++----------
sys/netipsec/xform_ah.c | 8 ++++----
sys/netipsec/xform_esp.c | 8 ++++----
sys/netipsec/xform_ipcomp.c | 8 ++++----
10 files changed, 59 insertions(+), 58 deletions(-)
diffs (truncated from 455 to 300 lines):
diff -r 8ecfd0294656 -r 35ffb229560a sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c Fri Jul 07 00:55:15 2017 +0000
+++ b/sys/netinet/tcp_input.c Fri Jul 07 01:37:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_input.c,v 1.358 2017/06/19 10:04:23 ozaki-r Exp $ */
+/* $NetBSD: tcp_input.c,v 1.359 2017/07/07 01:37:34 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.358 2017/06/19 10:04:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.359 2017/07/07 01:37:34 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -3208,7 +3208,7 @@
/*
* Look up an SADB entry which matches the address of the peer.
*/
- return KEY_ALLOCSA(&dst, IPPROTO_TCP, htonl(TCP_SIG_SPI), 0, 0);
+ return KEY_LOOKUP_SA(&dst, IPPROTO_TCP, htonl(TCP_SIG_SPI), 0, 0);
#else
return NULL;
#endif
diff -r 8ecfd0294656 -r 35ffb229560a sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h Fri Jul 07 00:55:15 2017 +0000
+++ b/sys/netinet/tcp_var.h Fri Jul 07 01:37:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_var.h,v 1.177 2015/02/14 22:09:53 he Exp $ */
+/* $NetBSD: tcp_var.h,v 1.178 2017/07/07 01:37:34 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -157,7 +157,7 @@
#define TCP_KEYLEN_MAX 80 /* maximum length of TCP-MD5 key */
/*
* Only a single SA per host may be specified at this time. An SPI is
- * needed in order for the KEY_ALLOCSA() lookup to work.
+ * needed in order for the KEY_LOOKUP_SA() lookup to work.
*/
#define TCP_SIG_SPI 0x1000
#endif /* TCP_SIGNATURE */
diff -r 8ecfd0294656 -r 35ffb229560a sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c Fri Jul 07 00:55:15 2017 +0000
+++ b/sys/netipsec/ipsec.c Fri Jul 07 01:37:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.100 2017/06/14 02:00:43 ozaki-r Exp $ */
+/* $NetBSD: ipsec.c,v 1.101 2017/07/07 01:37:34 ozaki-r Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/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.100 2017/06/14 02:00:43 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.101 2017/07/07 01:37:34 ozaki-r Exp $");
/*
* IPsec controller part.
@@ -362,7 +362,7 @@
* Return a held reference to the default SP.
*/
static struct secpolicy *
-key_allocsp_default(int af, const char *where, int tag)
+key_get_default_sp(int af, const char *where, int tag)
{
struct secpolicy *sp;
@@ -395,8 +395,8 @@
sp, sp->refcnt);
return sp;
}
-#define KEY_ALLOCSP_DEFAULT(af) \
- key_allocsp_default((af), __func__, __LINE__)
+#define KEY_GET_DEFAULT_SP(af) \
+ key_get_default_sp((af), __func__, __LINE__)
/*
* For OUTBOUND packet having a socket. Searching SPD for packet,
@@ -418,9 +418,9 @@
KASSERT(tdbi != NULL);
KASSERTMSG(IPSEC_DIR_IS_INOROUT(dir), "invalid direction %u", dir);
- sp = KEY_ALLOCSP2(tdbi->spi, &tdbi->dst, tdbi->proto, dir);
+ sp = KEY_LOOKUP_SP(tdbi->spi, &tdbi->dst, tdbi->proto, dir);
if (sp == NULL) /*XXX????*/
- sp = KEY_ALLOCSP_DEFAULT(tdbi->dst.sa.sa_family);
+ sp = KEY_GET_DEFAULT_SP(tdbi->dst.sa.sa_family);
KASSERT(sp != NULL);
return sp;
}
@@ -515,9 +515,9 @@
case IPSEC_POLICY_ENTRUST:
/* look for a policy in SPD */
- sp = KEY_ALLOCSP(&currsp->spidx, dir);
+ sp = KEY_LOOKUP_SP_BYSPIDX(&currsp->spidx, dir);
if (sp == NULL) /* no SP found */
- sp = KEY_ALLOCSP_DEFAULT(af);
+ sp = KEY_GET_DEFAULT_SP(af);
break;
default:
@@ -527,7 +527,7 @@
return NULL;
}
} else { /* unpriv, SPD has policy */
- sp = KEY_ALLOCSP(&currsp->spidx, dir);
+ sp = KEY_LOOKUP_SP_BYSPIDX(&currsp->spidx, dir);
if (sp == NULL) { /* no SP found */
switch (currsp->policy) {
case IPSEC_POLICY_BYPASS:
@@ -538,7 +538,7 @@
return NULL;
case IPSEC_POLICY_ENTRUST:
- sp = KEY_ALLOCSP_DEFAULT(af);
+ sp = KEY_GET_DEFAULT_SP(af);
break;
case IPSEC_POLICY_IPSEC:
@@ -596,11 +596,11 @@
spidx.dir = dir;
if (key_havesp(dir)) {
- sp = KEY_ALLOCSP(&spidx, dir);
+ sp = KEY_LOOKUP_SP_BYSPIDX(&spidx, dir);
}
if (sp == NULL) /* no SP found, use system default */
- sp = KEY_ALLOCSP_DEFAULT(spidx.dst.sa.sa_family);
+ sp = KEY_GET_DEFAULT_SP(spidx.dst.sa.sa_family);
KASSERT(sp != NULL);
return sp;
}
diff -r 8ecfd0294656 -r 35ffb229560a sys/netipsec/ipsec_input.c
--- a/sys/netipsec/ipsec_input.c Fri Jul 07 00:55:15 2017 +0000
+++ b/sys/netipsec/ipsec_input.c Fri Jul 07 01:37:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec_input.c,v 1.46 2017/07/06 09:49:46 ozaki-r Exp $ */
+/* $NetBSD: ipsec_input.c,v 1.47 2017/07/07 01:37:34 ozaki-r Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $ */
/* $OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $ */
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.46 2017/07/06 09:49:46 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.47 2017/07/07 01:37:34 ozaki-r Exp $");
/*
* IPsec input processing.
@@ -267,8 +267,8 @@
s = splsoftnet();
- /* NB: only pass dst since key_allocsa follows RFC2401 */
- sav = KEY_ALLOCSA(&dst_address, sproto, spi, sport, dport);
+ /* NB: only pass dst since key_lookup_sa follows RFC2401 */
+ sav = KEY_LOOKUP_SA(&dst_address, sproto, spi, sport, dport);
if (sav == NULL) {
IPSECLOG(LOG_DEBUG,
"no key association found for SA %s/%08lx/%u/%u\n",
diff -r 8ecfd0294656 -r 35ffb229560a sys/netipsec/ipsec_netbsd.c
--- a/sys/netipsec/ipsec_netbsd.c Fri Jul 07 00:55:15 2017 +0000
+++ b/sys/netipsec/ipsec_netbsd.c Fri Jul 07 01:37:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec_netbsd.c,v 1.43 2017/07/04 08:12:28 ozaki-r Exp $ */
+/* $NetBSD: ipsec_netbsd.c,v 1.44 2017/07/07 01:37:34 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.43 2017/07/04 08:12:28 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_netbsd.c,v 1.44 2017/07/07 01:37:34 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -107,7 +107,7 @@
* the address in the ICMP message payload.
*/
ah = (struct ah *)((char *)ip + (ip->ip_hl << 2));
- sav = KEY_ALLOCSA((const union sockaddr_union *)sa,
+ sav = KEY_LOOKUP_SA((const union sockaddr_union *)sa,
IPPROTO_AH, ah->ah_spi, 0, 0);
if (sav) {
@@ -152,7 +152,7 @@
* the address in the ICMP message payload.
*/
esp = (struct esp *)((char *)ip + (ip->ip_hl << 2));
- sav = KEY_ALLOCSA((const union sockaddr_union *)sa,
+ sav = KEY_LOOKUP_SA((const union sockaddr_union *)sa,
IPPROTO_ESP, esp->esp_spi, 0, 0);
if (sav) {
@@ -231,7 +231,7 @@
* Check to see if we have a valid SA corresponding
* to the address in the ICMP message payload.
*/
- sav = KEY_ALLOCSA((const union sockaddr_union*)sa,
+ sav = KEY_LOOKUP_SA((const union sockaddr_union*)sa,
IPPROTO_AH, ahp->ah_spi, 0, 0);
if (sav) {
@@ -336,7 +336,7 @@
* the address in the ICMP message payload.
*/
- sav = KEY_ALLOCSA((const union sockaddr_union*)sa,
+ sav = KEY_LOOKUP_SA((const union sockaddr_union*)sa,
IPPROTO_ESP, espp->esp_spi, 0, 0);
if (sav) {
diff -r 8ecfd0294656 -r 35ffb229560a sys/netipsec/key.c
--- a/sys/netipsec/key.c Fri Jul 07 00:55:15 2017 +0000
+++ b/sys/netipsec/key.c Fri Jul 07 01:37:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.167 2017/07/06 09:48:42 ozaki-r Exp $ */
+/* $NetBSD: key.c,v 1.168 2017/07/07 01:37:34 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.167 2017/07/06 09:48:42 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.168 2017/07/07 01:37:34 ozaki-r Exp $");
/*
* This code is referd to RFC 2367
@@ -644,7 +644,8 @@
* others: found and return the pointer.
*/
struct secpolicy *
-key_allocsp(const struct secpolicyindex *spidx, u_int dir, const char* where, int tag)
+key_lookup_sp_byspidx(const struct secpolicyindex *spidx,
+ u_int dir, const char* where, int tag)
{
struct secpolicy *sp;
int s;
@@ -697,7 +698,7 @@
* others: found and return the pointer.
*/
struct secpolicy *
-key_allocsp2(u_int32_t spi,
+key_lookup_sp(u_int32_t spi,
const union sockaddr_union *dst,
u_int8_t proto,
u_int dir,
@@ -1116,7 +1117,7 @@
* sport and dport are used for NAT-T. network order is always used.
*/
struct secasvar *
-key_allocsa(
+key_lookup_sa(
const union sockaddr_union *dst,
u_int proto,
u_int32_t spi,
@@ -1254,7 +1255,7 @@
}
/*
- * Must be called after calling key_allocsp().
+ * Must be called after calling key_lookup_sp*().
* For both the packet without socket and key_freeso().
*/
void
@@ -1279,7 +1280,7 @@
#if 0
/*
- * Must be called after calling key_allocsp().
+ * Must be called after calling key_lookup_sp*().
* For the packet with socket.
*/
static void
@@ -1353,7 +1354,7 @@
#endif
/*
- * Must be called after calling key_allocsa().
+ * Must be called after calling key_lookup_sa().
* This function is called by key_freesp() to free some SA allocated
* for a policy.
*/
diff -r 8ecfd0294656 -r 35ffb229560a sys/netipsec/key.h
--- a/sys/netipsec/key.h Fri Jul 07 00:55:15 2017 +0000
+++ b/sys/netipsec/key.h Fri Jul 07 01:37:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.h,v 1.19 2017/05/30 01:31:07 ozaki-r Exp $ */
Home |
Main Index |
Thread Index |
Old Index