Date: Sat, 19 Jun 2021 18:20:31 GMT From: Lutz Donnerhacke <donner@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 19dcc4f2250b - main - libalias: Restructure - Cleanup _FindLinkIn Message-ID: <202106191820.15JIKVaH015128@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=19dcc4f2250b3850991366e3058ca8a64b2f135d commit 19dcc4f2250b3850991366e3058ca8a64b2f135d Author: Lutz Donnerhacke <donner@FreeBSD.org> AuthorDate: 2021-05-25 17:08:48 +0000 Commit: Lutz Donnerhacke <donner@FreeBSD.org> CommitDate: 2021-06-19 18:19:16 +0000 libalias: Restructure - Cleanup _FindLinkIn Simplify program flow in function _FindLinkIn. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30571 --- sys/netinet/libalias/alias_db.c | 44 ++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index 39b82d9d3a01..229ca24bfe29 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -1198,6 +1198,8 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, struct alias_link *lnk_unknown_all; struct alias_link *lnk_unknown_dst_addr; struct alias_link *lnk_unknown_dst_port; + struct in_addr src_addr; + u_short src_port; LIBALIAS_LOCK_ASSERT(la); /* Initialize pointers */ @@ -1274,34 +1276,26 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, } #undef INGUARD - if (lnk_unknown_dst_port != NULL) - lnk = lnk_unknown_dst_port; - else if (lnk_unknown_dst_addr != NULL) - lnk = lnk_unknown_dst_addr; - else if (lnk_unknown_all != NULL) - lnk = lnk_unknown_all; - else - return (NULL); + lnk = (lnk_unknown_dst_port != NULL) ? lnk_unknown_dst_port + : (lnk_unknown_dst_addr != NULL) ? lnk_unknown_dst_addr + : lnk_unknown_all; - if (replace_partial_links && - (lnk->flags & LINK_PARTIALLY_SPECIFIED || lnk->server != NULL)) { - struct in_addr src_addr; - u_short src_port; + if (lnk == NULL || !replace_partial_links) + return (lnk); - if (lnk->server != NULL) { /* LSNAT link */ - src_addr = lnk->server->addr; - src_port = lnk->server->port; - lnk->server = lnk->server->next; - } else { - src_addr = lnk->src_addr; - src_port = lnk->src_port; - } + if (lnk->server != NULL) { /* LSNAT link */ + src_addr = lnk->server->addr; + src_port = lnk->server->port; + lnk->server = lnk->server->next; + } else { + src_addr = lnk->src_addr; + src_port = lnk->src_port; + } - if (link_type == LINK_SCTP) { - lnk->src_addr = src_addr; - lnk->src_port = src_port; - return (lnk); - } + if (link_type == LINK_SCTP) { + lnk->src_addr = src_addr; + lnk->src_port = src_port; + } else { lnk = ReLink(lnk, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106191820.15JIKVaH015128>