Date: Sat, 15 May 2021 07:08:54 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: 189f8eea138a - main - libalias: replace placeholder with static constant Message-ID: <202105150708.14F78s3J086291@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=189f8eea138a78b09c9f19114b1362b0df1cf87d commit 189f8eea138a78b09c9f19114b1362b0df1cf87d Author: Lutz Donnerhacke <donner@FreeBSD.org> AuthorDate: 2021-05-13 21:47:57 +0000 Commit: Lutz Donnerhacke <donner@FreeBSD.org> CommitDate: 2021-05-15 07:05:30 +0000 libalias: replace placeholder with static constant The field nullAddress in struct libalias is never set and never used. It exists as a placeholder for an unused argument only. Reviewed by: hselasky MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D30253 --- sys/netinet/libalias/alias_db.c | 24 ++++++++++++++---------- sys/netinet/libalias/alias_local.h | 2 -- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index cd29c16ac945..518f221c63f9 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -224,6 +224,10 @@ static LIST_HEAD(, libalias) instancehead = LIST_HEAD_INITIALIZER(instancehead); #define NO_DEST_PORT 1 #define NO_SRC_PORT 1 +/* Dummy address used for FindLinkIn/Out() and AddLink(). + The value of this variable is never used. */ +static struct in_addr const NO_ADDR; + /* Data Structures The fundamental data structure used in this program is @@ -1111,12 +1115,12 @@ _FindLinkOut(struct libalias *la, struct in_addr src_addr, lnk = _FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 0); if (lnk == NULL) - lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, + lnk = _FindLinkOut(la, src_addr, NO_ADDR, src_port, dst_port, link_type, 0); } if (lnk == NULL && (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { - lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, 0, + lnk = _FindLinkOut(la, src_addr, NO_ADDR, src_port, 0, link_type, 0); } if (lnk != NULL) { @@ -1152,7 +1156,7 @@ FindLinkOut(struct libalias *la, struct in_addr src_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && src_addr.s_addr == la->aliasAddress.s_addr) { - lnk = _FindLinkOut(la, la->nullAddress, dst_addr, src_port, dst_port, + lnk = _FindLinkOut(la, NO_ADDR, dst_addr, src_port, dst_port, link_type, replace_partial_links); } } @@ -1294,7 +1298,7 @@ FindLinkIn(struct libalias *la, struct in_addr dst_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && alias_addr.s_addr == la->aliasAddress.s_addr) { - lnk = _FindLinkIn(la, dst_addr, la->nullAddress, dst_port, alias_port, + lnk = _FindLinkIn(la, dst_addr, NO_ADDR, dst_port, alias_port, link_type, replace_partial_links); } } @@ -1376,7 +1380,7 @@ FindFragmentIn1(struct libalias *la, struct in_addr dst_addr, LINK_FRAGMENT_ID, 0); if (lnk == NULL) { - lnk = AddLink(la, la->nullAddress, dst_addr, alias_addr, + lnk = AddLink(la, NO_ADDR, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, ip_id, LINK_FRAGMENT_ID); } @@ -1399,7 +1403,7 @@ AddFragmentPtrLink(struct libalias *la, struct in_addr dst_addr, u_short ip_id) { LIBALIAS_LOCK_ASSERT(la); - return AddLink(la, la->nullAddress, dst_addr, la->nullAddress, + return AddLink(la, NO_ADDR, dst_addr, NO_ADDR, NO_SRC_PORT, NO_DEST_PORT, ip_id, LINK_FRAGMENT_PTR); } @@ -1409,7 +1413,7 @@ FindFragmentPtr(struct libalias *la, struct in_addr dst_addr, u_short ip_id) { LIBALIAS_LOCK_ASSERT(la); - return FindLinkIn(la, dst_addr, la->nullAddress, + return FindLinkIn(la, dst_addr, NO_ADDR, NO_DEST_PORT, ip_id, LINK_FRAGMENT_PTR, 0); } @@ -1669,7 +1673,7 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) struct alias_link *lnk; LIBALIAS_LOCK_ASSERT(la); - lnk = FindLinkIn(la, la->nullAddress, alias_addr, + lnk = FindLinkIn(la, NO_ADDR, alias_addr, 0, 0, LINK_ADDR, 0); if (lnk == NULL) { la->newDefaultLink = 1; @@ -1701,7 +1705,7 @@ FindAliasAddress(struct libalias *la, struct in_addr original_addr) struct alias_link *lnk; LIBALIAS_LOCK_ASSERT(la); - lnk = FindLinkOut(la, original_addr, la->nullAddress, + lnk = FindLinkOut(la, original_addr, NO_ADDR, 0, 0, LINK_ADDR, 0); if (lnk == NULL) { return (la->aliasAddress.s_addr != INADDR_ANY) ? @@ -2317,7 +2321,7 @@ LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr, struct alias_link *lnk; LIBALIAS_LOCK(la); - lnk = AddLink(la, src_addr, la->nullAddress, alias_addr, + lnk = AddLink(la, src_addr, NO_ADDR, alias_addr, 0, 0, 0, LINK_ADDR); diff --git a/sys/netinet/libalias/alias_local.h b/sys/netinet/libalias/alias_local.h index e6374a72ef75..63bfd857f14f 100644 --- a/sys/netinet/libalias/alias_local.h +++ b/sys/netinet/libalias/alias_local.h @@ -89,8 +89,6 @@ struct libalias { /* IP address incoming packets are sent to * if no aliasing link already exists */ struct in_addr targetAddress; - /* Used as a dummy parameter for some function calls */ - struct in_addr nullAddress; /* Lookup table of pointers to chains of link records. * Each link record is doubly indexed into input and * output lookup tables. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105150708.14F78s3J086291>