git: 4f49e3382f11 - main - tcp_hostcache: style(9)

Gleb Smirnoff glebius at FreeBSD.org
Fri Apr 9 21:21:09 UTC 2021


The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=4f49e3382f11f34d1ddd3da79b58ec6eb233cd7e

commit 4f49e3382f11f34d1ddd3da79b58ec6eb233cd7e
Author:     Gleb Smirnoff <glebius at FreeBSD.org>
AuthorDate: 2021-04-08 21:23:23 +0000
Commit:     Gleb Smirnoff <glebius at FreeBSD.org>
CommitDate: 2021-04-09 21:07:27 +0000

    tcp_hostcache: style(9)
    
    Reviewed by:    rscheff
---
 sys/netinet/tcp_hostcache.c | 53 +++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c
index 300cbafe4bcd..49e9b0822592 100644
--- a/sys/netinet/tcp_hostcache.c
+++ b/sys/netinet/tcp_hostcache.c
@@ -180,7 +180,7 @@ SYSCTL_UINT(_net_inet_tcp_hostcache, OID_AUTO, bucketlimit,
     "Per-bucket hash limit for hostcache");
 
 SYSCTL_UINT(_net_inet_tcp_hostcache, OID_AUTO, count, CTLFLAG_VNET | CTLFLAG_RD,
-     &VNET_NAME(tcp_hostcache.cache_count), 0,
+    &VNET_NAME(tcp_hostcache.cache_count), 0,
     "Current number of entries in hostcache");
 
 SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, expire, CTLFLAG_VNET | CTLFLAG_RW,
@@ -325,7 +325,7 @@ tcp_hc_lookup(struct in_conninfo *inc, bool update)
 	struct hc_head *hc_head;
 	struct hc_metrics *hc_entry;
 
-	KASSERT(inc != NULL, ("tcp_hc_lookup with NULL in_conninfo pointer"));
+	KASSERT(inc != NULL, ("%s: NULL in_conninfo", __func__));
 
 	/*
 	 * Hash the foreign ip address.
@@ -392,7 +392,7 @@ tcp_hc_insert(struct in_conninfo *inc)
 	struct hc_head *hc_head;
 	struct hc_metrics *hc_entry;
 
-	KASSERT(inc != NULL, ("tcp_hc_insert with NULL in_conninfo pointer"));
+	KASSERT(inc != NULL, ("%s: NULL in_conninfo", __func__));
 
 	/*
 	 * Hash the foreign ip address.
@@ -428,14 +428,14 @@ tcp_hc_insert(struct in_conninfo *inc)
 		 */
 		if (hc_entry == NULL) {
 			THC_UNLOCK(&hc_head->hch_mtx);
-			return NULL;
+			return (NULL);
 		}
 		TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q);
 		KASSERT(V_tcp_hostcache.hashbase[hash].hch_length > 0 &&
-			V_tcp_hostcache.hashbase[hash].hch_length <=
-			V_tcp_hostcache.bucket_limit,
-			("tcp_hostcache: bucket length range violated at %u: %u",
-			hash, V_tcp_hostcache.hashbase[hash].hch_length));
+		    V_tcp_hostcache.hashbase[hash].hch_length <=
+		    V_tcp_hostcache.bucket_limit,
+		    ("tcp_hostcache: bucket length range violated at %u: %u",
+		    hash, V_tcp_hostcache.hashbase[hash].hch_length));
 		V_tcp_hostcache.hashbase[hash].hch_length--;
 		atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);
 		TCPSTAT_INC(tcps_hc_bucketoverflow);
@@ -449,7 +449,7 @@ tcp_hc_insert(struct in_conninfo *inc)
 		hc_entry = uma_zalloc(V_tcp_hostcache.zone, M_NOWAIT);
 		if (hc_entry == NULL) {
 			THC_UNLOCK(&hc_head->hch_mtx);
-			return NULL;
+			return (NULL);
 		}
 	}
 
@@ -471,13 +471,13 @@ tcp_hc_insert(struct in_conninfo *inc)
 	TAILQ_INSERT_HEAD(&hc_head->hch_bucket, hc_entry, rmx_q);
 	V_tcp_hostcache.hashbase[hash].hch_length++;
 	KASSERT(V_tcp_hostcache.hashbase[hash].hch_length <
-		V_tcp_hostcache.bucket_limit,
-		("tcp_hostcache: bucket length too high at %u: %u",
-		hash, V_tcp_hostcache.hashbase[hash].hch_length));
+	    V_tcp_hostcache.bucket_limit,
+	    ("tcp_hostcache: bucket length too high at %u: %u",
+	    hash, V_tcp_hostcache.hashbase[hash].hch_length));
 	atomic_add_int(&V_tcp_hostcache.cache_count, 1);
 	TCPSTAT_INC(tcps_hc_added);
 
-	return hc_entry;
+	return (hc_entry);
 }
 
 /*
@@ -534,16 +534,16 @@ tcp_hc_getmtu(struct in_conninfo *inc)
 	uint32_t mtu;
 
 	if (!V_tcp_use_hostcache)
-		return 0;
+		return (0);
 
 	hc_entry = tcp_hc_lookup(inc, false);
 	if (hc_entry == NULL) {
-		return 0;
+		return (0);
 	}
 
 	mtu = hc_entry->rmx_mtu;
 	THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
-	return mtu;
+	return (mtu);
 }
 
 /*
@@ -589,7 +589,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
 		TCPSTAT_INC(tcps_cachedrtt);
 	}
 	if (hcml->rmx_rttvar != 0) {
-	        if (hc_entry->rmx_rttvar == 0)
+		if (hc_entry->rmx_rttvar == 0)
 			hc_entry->rmx_rttvar = hcml->rmx_rttvar;
 		else
 			hc_entry->rmx_rttvar = ((uint64_t)hc_entry->rmx_rttvar +
@@ -684,7 +684,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
 	for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
 		THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
 		TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
-			      rmx_q) {
+		    rmx_q) {
 			sbuf_printf(&sb,
 			    "%-15s %5u %8u %6lums %6lums %8u %8u %8u "
 #ifdef	TCP_HC_COUNTERS
@@ -746,8 +746,8 @@ sysctl_tcp_hc_histo(SYSCTL_HANDLER_ARGS)
 	for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
 		hch_length = V_tcp_hostcache.hashbase[i].hch_length;
 		KASSERT(hch_length <= V_tcp_hostcache.bucket_limit,
-			("tcp_hostcache: bucket limit exceeded at %u: %u",
-			i, hch_length));
+		    ("tcp_hostcache: bucket limit exceeded at %u: %u",
+		    i, hch_length));
 		histo[hch_length]++;
 	}
 
@@ -778,13 +778,14 @@ tcp_hc_purge_internal(int all)
 		TAILQ_FOREACH_SAFE(hc_entry,
 		    &V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q, hc_next) {
 			KASSERT(V_tcp_hostcache.hashbase[i].hch_length > 0 &&
-				V_tcp_hostcache.hashbase[i].hch_length <=
-				V_tcp_hostcache.bucket_limit,
-				("tcp_hostcache: bucket length out of range at %u: %u",
-				i, V_tcp_hostcache.hashbase[i].hch_length));
+			    V_tcp_hostcache.hashbase[i].hch_length <=
+			    V_tcp_hostcache.bucket_limit, ("tcp_hostcache: "
+			    "bucket length out of range at %u: %u",
+			    i, V_tcp_hostcache.hashbase[i].hch_length));
 			if (all || hc_entry->rmx_expire <= 0) {
-				TAILQ_REMOVE(&V_tcp_hostcache.hashbase[i].hch_bucket,
-					      hc_entry, rmx_q);
+				TAILQ_REMOVE(
+				    &V_tcp_hostcache.hashbase[i].hch_bucket,
+				    hc_entry, rmx_q);
 				uma_zfree(V_tcp_hostcache.zone, hc_entry);
 				V_tcp_hostcache.hashbase[i].hch_length--;
 				atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);


More information about the dev-commits-src-all mailing list