Date: Sat, 19 Jun 2021 17:21:33 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: 32f9c2ceb3ec - main - libalias: Restructure - Separate fully qualified search Message-ID: <202106191721.15JHLXS1038951@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=32f9c2ceb3ec8266e48ec0f6d1556fd98ef12db6 commit 32f9c2ceb3ec8266e48ec0f6d1556fd98ef12db6 Author: Lutz Donnerhacke <donner@FreeBSD.org> AuthorDate: 2021-05-25 13:44:34 +0000 Commit: Lutz Donnerhacke <donner@FreeBSD.org> CommitDate: 2021-06-19 17:21:05 +0000 libalias: Restructure - Separate fully qualified search Search fully specified links first. Some performance loss due to need to revisit the db twice, if not found. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30569 --- sys/netinet/libalias/alias_db.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index 342f6117f878..dfb4cd9c8287 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -1210,18 +1210,27 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, /* Search loop */ start_point = StartPointIn(alias_addr, alias_port, link_type); + if (!(flags_in & LINK_PARTIALLY_SPECIFIED)) { + LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) { + INGUARD; + if (lnk->flags & LINK_PARTIALLY_SPECIFIED) + continue; + if (lnk->dst_addr.s_addr == dst_addr.s_addr + && lnk->dst_port == dst_port) { + CleanupLink(la, &lnk); + if (lnk != NULL) { + lnk->timestamp = LibAliasTime; + return (lnk); + } + } + } + } LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) { int flags; INGUARD; flags = flags_in | lnk->flags; - if (!(flags & LINK_PARTIALLY_SPECIFIED)) { - if (lnk->dst_addr.s_addr == dst_addr.s_addr - && lnk->dst_port == dst_port) { - lnk_fully_specified = lnk; - break; - } - } else if ((flags & LINK_UNKNOWN_DEST_ADDR) + if ((flags & LINK_UNKNOWN_DEST_ADDR) && (flags & LINK_UNKNOWN_DEST_PORT)) { if (lnk_unknown_all == NULL) lnk_unknown_all = lnk; @@ -1239,11 +1248,7 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, } #undef INGUARD - CleanupLink(la, &lnk_fully_specified); - if (lnk_fully_specified != NULL) { - lnk_fully_specified->timestamp = LibAliasTime; - lnk = lnk_fully_specified; - } else if (lnk_unknown_dst_port != NULL) + if (lnk_unknown_dst_port != NULL) lnk = lnk_unknown_dst_port; else if (lnk_unknown_dst_addr != NULL) lnk = lnk_unknown_dst_addr;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106191721.15JHLXS1038951>