public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Safonov <dima@arista.com>
To: linux-kernel@vger.kernel.org
Cc: Dmitry Safonov <0x7f454c46@gmail.com>,
	Dmitry Safonov <dima@arista.com>,
	Andy Lutomirski <luto@amacapital.net>,
	David Ahern <dsahern@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Francesco Ruggeri <fruggeri@arista.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	Leonard Crestez <cdleonard@gmail.com>,
	linux-crypto@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH 4/5] tcp/md5: Use tcp_md5sig_pool_* naming scheme
Date: Fri,  5 Nov 2021 01:49:52 +0000	[thread overview]
Message-ID: <20211105014953.972946-5-dima@arista.com> (raw)
In-Reply-To: <20211105014953.972946-1-dima@arista.com>

Use common prefixes for operations with (struct tcp_md5sig_pool).

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 include/net/tcp.h   |  6 +++---
 net/ipv4/tcp.c      | 18 +++++++++---------
 net/ipv4/tcp_ipv4.c | 14 +++++++-------
 net/ipv6/tcp_ipv6.c | 14 +++++++-------
 4 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3e5423a10a74..27eb71dd7ff8 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1671,11 +1671,11 @@ tcp_md5_do_lookup(const struct sock *sk, int l3index,
 #define tcp_twsk_md5_key(twsk)	NULL
 #endif
 
-bool tcp_alloc_md5sig_pool(void);
+bool tcp_md5sig_pool_alloc(void);
 bool tcp_md5sig_pool_ready(void);
 
-struct tcp_md5sig_pool *tcp_get_md5sig_pool(void);
-static inline void tcp_put_md5sig_pool(void)
+struct tcp_md5sig_pool *tcp_md5sig_pool_get(void);
+static inline void tcp_md5sig_pool_put(void)
 {
 	local_bh_enable();
 }
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index eb478028b1ea..8d8692fc9cd5 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -4257,7 +4257,7 @@ static DEFINE_PER_CPU(struct tcp_md5sig_pool, tcp_md5sig_pool);
 static DEFINE_MUTEX(tcp_md5sig_mutex);
 static bool tcp_md5sig_pool_populated = false;
 
-static void __tcp_alloc_md5sig_pool(void)
+static void __tcp_md5sig_pool_alloc(void)
 {
 	struct crypto_ahash *hash;
 	int cpu;
@@ -4289,7 +4289,7 @@ static void __tcp_alloc_md5sig_pool(void)
 		per_cpu(tcp_md5sig_pool, cpu).md5_req = req;
 	}
 	/* before setting tcp_md5sig_pool_populated, we must commit all writes
-	 * to memory. See smp_rmb() in tcp_get_md5sig_pool()
+	 * to memory. See smp_rmb() in tcp_md5sig_pool_get()
 	 */
 	smp_wmb();
 	tcp_md5sig_pool_populated = true;
@@ -4305,13 +4305,13 @@ static void __tcp_alloc_md5sig_pool(void)
 	crypto_free_ahash(hash);
 }
 
-bool tcp_alloc_md5sig_pool(void)
+bool tcp_md5sig_pool_alloc(void)
 {
 	if (unlikely(!tcp_md5sig_pool_populated)) {
 		mutex_lock(&tcp_md5sig_mutex);
 
 		if (!tcp_md5sig_pool_populated) {
-			__tcp_alloc_md5sig_pool();
+			__tcp_md5sig_pool_alloc();
 			if (tcp_md5sig_pool_populated)
 				static_branch_inc(&tcp_md5_needed);
 		}
@@ -4320,7 +4320,7 @@ bool tcp_alloc_md5sig_pool(void)
 	}
 	return tcp_md5sig_pool_populated;
 }
-EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
+EXPORT_SYMBOL(tcp_md5sig_pool_alloc);
 
 bool tcp_md5sig_pool_ready(void)
 {
@@ -4329,25 +4329,25 @@ bool tcp_md5sig_pool_ready(void)
 EXPORT_SYMBOL(tcp_md5sig_pool_ready);
 
 /**
- *	tcp_get_md5sig_pool - get md5sig_pool for this user
+ *	tcp_md5sig_pool_get - get md5sig_pool for this user
  *
  *	We use percpu structure, so if we succeed, we exit with preemption
  *	and BH disabled, to make sure another thread or softirq handling
  *	wont try to get same context.
  */
-struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
+struct tcp_md5sig_pool *tcp_md5sig_pool_get(void)
 {
 	local_bh_disable();
 
 	if (tcp_md5sig_pool_populated) {
-		/* coupled with smp_wmb() in __tcp_alloc_md5sig_pool() */
+		/* coupled with smp_wmb() in __tcp_md5sig_pool_alloc() */
 		smp_rmb();
 		return this_cpu_ptr(&tcp_md5sig_pool);
 	}
 	local_bh_enable();
 	return NULL;
 }
-EXPORT_SYMBOL(tcp_get_md5sig_pool);
+EXPORT_SYMBOL(tcp_md5sig_pool_get);
 
 int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
 			  const struct sk_buff *skb, unsigned int header_len)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6a8ff9ab1cbc..44db9afa17fc 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1294,7 +1294,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname,
 	if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
 		return -EINVAL;
 
-	if (!tcp_alloc_md5sig_pool())
+	if (!tcp_md5sig_pool_alloc())
 		return -ENOMEM;
 
 	return tcp_md5_do_add(sk, addr, AF_INET, prefixlen, l3index, flags,
@@ -1332,7 +1332,7 @@ static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
 	struct tcp_md5sig_pool *hp;
 	struct ahash_request *req;
 
-	hp = tcp_get_md5sig_pool();
+	hp = tcp_md5sig_pool_get();
 	if (!hp)
 		goto clear_hash_noput;
 	req = hp->md5_req;
@@ -1347,11 +1347,11 @@ static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
 	if (crypto_ahash_final(req))
 		goto clear_hash;
 
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 	return 0;
 
 clear_hash:
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 clear_hash_noput:
 	memset(md5_hash, 0, 16);
 	return 1;
@@ -1375,7 +1375,7 @@ int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
 		daddr = iph->daddr;
 	}
 
-	hp = tcp_get_md5sig_pool();
+	hp = tcp_md5sig_pool_get();
 	if (!hp)
 		goto clear_hash_noput;
 	req = hp->md5_req;
@@ -1393,11 +1393,11 @@ int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
 	if (crypto_ahash_final(req))
 		goto clear_hash;
 
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 	return 0;
 
 clear_hash:
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 clear_hash_noput:
 	memset(md5_hash, 0, 16);
 	return 1;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3af13bd6fed0..9147f9f69196 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -654,7 +654,7 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname,
 	if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
 		return -EINVAL;
 
-	if (!tcp_alloc_md5sig_pool())
+	if (!tcp_md5sig_pool_alloc())
 		return -ENOMEM;
 
 	if (ipv6_addr_v4mapped(&sin6->sin6_addr))
@@ -701,7 +701,7 @@ static int tcp_v6_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
 	struct tcp_md5sig_pool *hp;
 	struct ahash_request *req;
 
-	hp = tcp_get_md5sig_pool();
+	hp = tcp_md5sig_pool_get();
 	if (!hp)
 		goto clear_hash_noput;
 	req = hp->md5_req;
@@ -716,11 +716,11 @@ static int tcp_v6_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
 	if (crypto_ahash_final(req))
 		goto clear_hash;
 
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 	return 0;
 
 clear_hash:
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 clear_hash_noput:
 	memset(md5_hash, 0, 16);
 	return 1;
@@ -745,7 +745,7 @@ static int tcp_v6_md5_hash_skb(char *md5_hash,
 		daddr = &ip6h->daddr;
 	}
 
-	hp = tcp_get_md5sig_pool();
+	hp = tcp_md5sig_pool_get();
 	if (!hp)
 		goto clear_hash_noput;
 	req = hp->md5_req;
@@ -763,11 +763,11 @@ static int tcp_v6_md5_hash_skb(char *md5_hash,
 	if (crypto_ahash_final(req))
 		goto clear_hash;
 
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 	return 0;
 
 clear_hash:
-	tcp_put_md5sig_pool();
+	tcp_md5sig_pool_put();
 clear_hash_noput:
 	memset(md5_hash, 0, 16);
 	return 1;
-- 
2.33.1


  parent reply	other threads:[~2021-11-05  1:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  1:49 [PATCH 0/5] tcp/md5: Generic tcp_sig_pool Dmitry Safonov
2021-11-05  1:49 ` [PATCH 1/5] tcp/md5: Don't BUG_ON() failed kmemdup() Dmitry Safonov
2021-11-05  2:55   ` Eric Dumazet
2021-11-05  9:16     ` Leonard Crestez
2021-11-05 13:31     ` Dmitry Safonov
2021-11-05  1:49 ` [PATCH 2/5] tcp/md5: Don't leak ahash in OOM Dmitry Safonov
2021-11-05  2:24   ` Eric Dumazet
2021-11-05  1:49 ` [PATCH 3/5] tcp/md5: Alloc tcp_md5sig_pool only in setsockopt() Dmitry Safonov
2021-11-05  1:49 ` Dmitry Safonov [this message]
2021-11-05  1:49 ` [PATCH 5/5] tcp/md5: Make more generic tcp_sig_pool Dmitry Safonov
2021-11-05  9:54   ` Leonard Crestez
2021-11-05 13:59     ` Dmitry Safonov
2021-11-05 16:53       ` Leonard Crestez
2021-11-06  3:43       ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211105014953.972946-5-dima@arista.com \
    --to=dima@arista.com \
    --cc=0x7f454c46@gmail.com \
    --cc=cdleonard@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fruggeri@arista.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox