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, ...@@ -1198,6 +1198,8 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr,
struct alias_link *lnk_unknown_all; struct alias_link *lnk_unknown_all;
struct alias_link *lnk_unknown_dst_addr; struct alias_link *lnk_unknown_dst_addr;
struct alias_link *lnk_unknown_dst_port; struct alias_link *lnk_unknown_dst_port;
struct in_addr src_addr;
u_short src_port;
LIBALIAS_LOCK_ASSERT(la); LIBALIAS_LOCK_ASSERT(la);
/* Initialize pointers */ /* Initialize pointers */
...@@ -1274,34 +1276,26 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, ...@@ -1274,34 +1276,26 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr,
} }
#undef INGUARD #undef INGUARD
if (lnk_unknown_dst_port != NULL) lnk = (lnk_unknown_dst_port != NULL) ? lnk_unknown_dst_port
lnk = lnk_unknown_dst_port; : (lnk_unknown_dst_addr != NULL) ? lnk_unknown_dst_addr
else if (lnk_unknown_dst_addr != NULL) : lnk_unknown_all;
lnk = lnk_unknown_dst_addr;
else if (lnk_unknown_all != NULL)
lnk = lnk_unknown_all;
else
return (NULL);
if (replace_partial_links && if (lnk == NULL || !replace_partial_links)
(lnk->flags & LINK_PARTIALLY_SPECIFIED || lnk->server != NULL)) { return (lnk);
struct in_addr src_addr;
u_short src_port;
if (lnk->server != NULL) { /* LSNAT link */ if (lnk->server != NULL) { /* LSNAT link */
src_addr = lnk->server->addr; src_addr = lnk->server->addr;
src_port = lnk->server->port; src_port = lnk->server->port;
lnk->server = lnk->server->next; lnk->server = lnk->server->next;
} else { } else {
src_addr = lnk->src_addr; src_addr = lnk->src_addr;
src_port = lnk->src_port; src_port = lnk->src_port;
} }
if (link_type == LINK_SCTP) { if (link_type == LINK_SCTP) {
lnk->src_addr = src_addr; lnk->src_addr = src_addr;
lnk->src_port = src_port; lnk->src_port = src_port;
return (lnk); } else {
}
lnk = ReLink(lnk, lnk = ReLink(lnk,
src_addr, dst_addr, alias_addr, src_addr, dst_addr, alias_addr,
src_port, dst_port, alias_port, 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