From owner-dev-commits-src-main@freebsd.org Sat Jun 19 19:23:27 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2DFA965FD14; Sat, 19 Jun 2021 19:23:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G6m0v0XmNz4ghx; Sat, 19 Jun 2021 19:23:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E481B1BDD0; Sat, 19 Jun 2021 19:23:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15JJNQQF099579; Sat, 19 Jun 2021 19:23:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15JJNQ2a099578; Sat, 19 Jun 2021 19:23:26 GMT (envelope-from git) Date: Sat, 19 Jun 2021 19:23:26 GMT Message-Id: <202106191923.15JJNQ2a099578@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lutz Donnerhacke Subject: git: 7b44ff4c52ce - main - libalias: Restructure - Group expire handling entries MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7b44ff4c52ce9e7a89e772566a249e5481fe0ac4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jun 2021 19:23:27 -0000 The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=7b44ff4c52ce9e7a89e772566a249e5481fe0ac4 commit 7b44ff4c52ce9e7a89e772566a249e5481fe0ac4 Author: Lutz Donnerhacke AuthorDate: 2021-05-31 16:06:29 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-06-19 19:12:27 +0000 libalias: Restructure - Group expire handling entries Reorder the internal structure semantically. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30575 --- sys/netinet/libalias/alias_db.c | 44 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index 80da3c54fb41..3dae7ac72645 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -318,14 +318,16 @@ struct alias_link { #define LINK_UNFIREWALLED 0x08 int timestamp; /* Time link was last accessed */ - int expire_time; /* Expire time for link */ #ifndef NO_USE_SOCKETS int sockfd; /* socket descriptor */ #endif /* Linked list of pointers for input and output lookup tables */ LIST_ENTRY (alias_link) list_out; LIST_ENTRY (alias_link) list_in; - TAILQ_ENTRY (alias_link) list_expire; + struct { + TAILQ_ENTRY(alias_link) list; + int time; /* Expire time for link */ + } expire; /* Auxiliary data */ union { char *frag_ptr; @@ -839,7 +841,7 @@ CleanupAliasData(struct libalias *la) LIBALIAS_LOCK_ASSERT(la); /* permanent entries may stay */ - TAILQ_FOREACH_SAFE(lnk, &la->checkExpire, list_expire, lnk_tmp) + TAILQ_FOREACH_SAFE(lnk, &la->checkExpire, expire.list, lnk_tmp) DeleteLink(&lnk); for (i = 0; i < LINK_TABLE_IN_SIZE; i++) @@ -858,15 +860,15 @@ CleanupLink(struct libalias *la, struct alias_link **lnk) if (lnk == NULL || *lnk == NULL) return; - if (LibAliasTime - (*lnk)->timestamp > (*lnk)->expire_time) { + if (LibAliasTime - (*lnk)->timestamp > (*lnk)->expire.time) { DeleteLink(lnk); if ((*lnk) == NULL) return; } /* move to end, swap may fail on a single entry list */ - TAILQ_REMOVE(&la->checkExpire, (*lnk), list_expire); - TAILQ_INSERT_TAIL(&la->checkExpire, (*lnk), list_expire); + TAILQ_REMOVE(&la->checkExpire, (*lnk), expire.list); + TAILQ_INSERT_TAIL(&la->checkExpire, (*lnk), expire.list); } static struct alias_link * @@ -912,7 +914,7 @@ DeleteLink(struct alias_link **plnk) LIST_REMOVE(lnk, list_in); /* remove from housekeeping */ - TAILQ_REMOVE(&la->checkExpire, lnk, list_expire); + TAILQ_REMOVE(&la->checkExpire, lnk, expire.list); #ifndef NO_USE_SOCKETS /* Close socket, if one has been allocated */ @@ -995,27 +997,27 @@ AddLink(struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, /* Expiration time */ switch (link_type) { case LINK_ICMP: - lnk->expire_time = ICMP_EXPIRE_TIME; + lnk->expire.time = ICMP_EXPIRE_TIME; break; case LINK_UDP: - lnk->expire_time = UDP_EXPIRE_TIME; + lnk->expire.time = UDP_EXPIRE_TIME; break; case LINK_TCP: - lnk->expire_time = TCP_EXPIRE_INITIAL; + lnk->expire.time = TCP_EXPIRE_INITIAL; break; case LINK_PPTP: lnk->flags |= LINK_PERMANENT; /* no timeout. */ break; case LINK_FRAGMENT_ID: - lnk->expire_time = FRAGMENT_ID_EXPIRE_TIME; + lnk->expire.time = FRAGMENT_ID_EXPIRE_TIME; break; case LINK_FRAGMENT_PTR: - lnk->expire_time = FRAGMENT_PTR_EXPIRE_TIME; + lnk->expire.time = FRAGMENT_PTR_EXPIRE_TIME; break; case LINK_ADDR: break; default: - lnk->expire_time = PROTO_EXPIRE_TIME; + lnk->expire.time = PROTO_EXPIRE_TIME; break; } @@ -1098,7 +1100,7 @@ AddLink(struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, } /* Include the element into the housekeeping list */ - TAILQ_INSERT_TAIL(&la->checkExpire, lnk, list_expire); + TAILQ_INSERT_TAIL(&la->checkExpire, lnk, expire.list); } else { #ifdef LIBALIAS_DEBUG fprintf(stderr, "PacketAlias/AddLink(): "); @@ -1841,13 +1843,13 @@ SetStateIn(struct alias_link *lnk, int state) switch (state) { case ALIAS_TCP_STATE_DISCONNECTED: if (lnk->data.tcp->state.out != ALIAS_TCP_STATE_CONNECTED) - lnk->expire_time = TCP_EXPIRE_DEAD; + lnk->expire.time = TCP_EXPIRE_DEAD; else - lnk->expire_time = TCP_EXPIRE_SINGLEDEAD; + lnk->expire.time = TCP_EXPIRE_SINGLEDEAD; break; case ALIAS_TCP_STATE_CONNECTED: if (lnk->data.tcp->state.out == ALIAS_TCP_STATE_CONNECTED) - lnk->expire_time = TCP_EXPIRE_CONNECTED; + lnk->expire.time = TCP_EXPIRE_CONNECTED; break; default: #ifdef _KERNEL @@ -1866,13 +1868,13 @@ SetStateOut(struct alias_link *lnk, int state) switch (state) { case ALIAS_TCP_STATE_DISCONNECTED: if (lnk->data.tcp->state.in != ALIAS_TCP_STATE_CONNECTED) - lnk->expire_time = TCP_EXPIRE_DEAD; + lnk->expire.time = TCP_EXPIRE_DEAD; else - lnk->expire_time = TCP_EXPIRE_SINGLEDEAD; + lnk->expire.time = TCP_EXPIRE_SINGLEDEAD; break; case ALIAS_TCP_STATE_CONNECTED: if (lnk->data.tcp->state.in == ALIAS_TCP_STATE_CONNECTED) - lnk->expire_time = TCP_EXPIRE_CONNECTED; + lnk->expire.time = TCP_EXPIRE_CONNECTED; break; default: #ifdef _KERNEL @@ -2121,7 +2123,7 @@ SetExpire(struct alias_link *lnk, int expire) } else if (expire == -1) { lnk->flags |= LINK_PERMANENT; } else if (expire > 0) { - lnk->expire_time = expire; + lnk->expire.time = expire; } else { #ifdef LIBALIAS_DEBUG fprintf(stderr, "PacketAlias/SetExpire(): ");