Commit 19dcc4f2 authored by Lutz Donnerhacke's avatar Lutz Donnerhacke
Browse files

libalias: Restructure - Cleanup _FindLinkIn

Simplify program flow in function _FindLinkIn.

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D30571
parent 23408297
......@@ -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,19 +1276,12 @@ _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;
......@@ -1300,8 +1295,7 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr,
if (link_type == LINK_SCTP) {
lnk->src_addr = src_addr;
lnk->src_port = src_port;
return (lnk);
}
} else {
lnk = ReLink(lnk,
src_addr, dst_addr, alias_addr,
src_port, dst_port, alias_port,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment