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
This commit is contained in:
parent
3386347f65
commit
32f9c2ceb3
@ -1210,18 +1210,27 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr,
|
|||||||
|
|
||||||
/* Search loop */
|
/* Search loop */
|
||||||
start_point = StartPointIn(alias_addr, alias_port, link_type);
|
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) {
|
LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) {
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
INGUARD;
|
INGUARD;
|
||||||
flags = flags_in | lnk->flags;
|
flags = flags_in | lnk->flags;
|
||||||
if (!(flags & LINK_PARTIALLY_SPECIFIED)) {
|
if ((flags & LINK_UNKNOWN_DEST_ADDR)
|
||||||
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)
|
|
||||||
&& (flags & LINK_UNKNOWN_DEST_PORT)) {
|
&& (flags & LINK_UNKNOWN_DEST_PORT)) {
|
||||||
if (lnk_unknown_all == NULL)
|
if (lnk_unknown_all == NULL)
|
||||||
lnk_unknown_all = lnk;
|
lnk_unknown_all = lnk;
|
||||||
@ -1239,11 +1248,7 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr,
|
|||||||
}
|
}
|
||||||
#undef INGUARD
|
#undef INGUARD
|
||||||
|
|
||||||
CleanupLink(la, &lnk_fully_specified);
|
if (lnk_unknown_dst_port != NULL)
|
||||||
if (lnk_fully_specified != NULL) {
|
|
||||||
lnk_fully_specified->timestamp = LibAliasTime;
|
|
||||||
lnk = lnk_fully_specified;
|
|
||||||
} else if (lnk_unknown_dst_port != NULL)
|
|
||||||
lnk = lnk_unknown_dst_port;
|
lnk = lnk_unknown_dst_port;
|
||||||
else if (lnk_unknown_dst_addr != NULL)
|
else if (lnk_unknown_dst_addr != NULL)
|
||||||
lnk = lnk_unknown_dst_addr;
|
lnk = lnk_unknown_dst_addr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user