git: b03a41befeaf - main - libalias: Fix nameing and initialization of a constant

Lutz Donnerhacke donner at FreeBSD.org
Sun May 30 13:47:54 UTC 2021


The branch main has been updated by donner:

URL: https://cgit.FreeBSD.org/src/commit/?id=b03a41befeaf17ef25da96fc7bc2dc19c9a6b253

commit b03a41befeaf17ef25da96fc7bc2dc19c9a6b253
Author:     Lutz Donnerhacke <donner at FreeBSD.org>
AuthorDate: 2021-05-30 13:41:24 +0000
Commit:     Lutz Donnerhacke <donner at FreeBSD.org>
CommitDate: 2021-05-30 13:47:29 +0000

    libalias: Fix nameing and initialization of a constant
    
    The commit 189f8eea contains a refactorisation of a constant.  During
    later review D30283 the naming of the constant was improved and the
    initialization became explicit.  Put this into the tree, in order to
    MFC the correct naming.
---
 sys/netinet/libalias/alias_db.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c
index 518f221c63f9..7a84cf310d5a 100644
--- a/sys/netinet/libalias/alias_db.c
+++ b/sys/netinet/libalias/alias_db.c
@@ -224,9 +224,8 @@ 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;
+/* Matches any/unknown address in FindLinkIn/Out() and AddLink(). */
+static struct in_addr const ANY_ADDR = { INADDR_ANY };
 
 /* Data Structures
 
@@ -1115,12 +1114,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, NO_ADDR, src_port,
+				lnk = _FindLinkOut(la, src_addr, ANY_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, NO_ADDR, src_port, 0,
+			lnk = _FindLinkOut(la, src_addr, ANY_ADDR, src_port, 0,
 			    link_type, 0);
 		}
 		if (lnk != NULL) {
@@ -1156,7 +1155,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, NO_ADDR, dst_addr, src_port, dst_port,
+			lnk = _FindLinkOut(la, ANY_ADDR, dst_addr, src_port, dst_port,
 			    link_type, replace_partial_links);
 		}
 	}
@@ -1298,7 +1297,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, NO_ADDR, dst_port, alias_port,
+			lnk = _FindLinkIn(la, dst_addr, ANY_ADDR, dst_port, alias_port,
 			    link_type, replace_partial_links);
 		}
 	}
@@ -1380,7 +1379,7 @@ FindFragmentIn1(struct libalias *la, struct in_addr dst_addr,
 	    LINK_FRAGMENT_ID, 0);
 
 	if (lnk == NULL) {
-		lnk = AddLink(la, NO_ADDR, dst_addr, alias_addr,
+		lnk = AddLink(la, ANY_ADDR, dst_addr, alias_addr,
 		    NO_SRC_PORT, NO_DEST_PORT, ip_id,
 		    LINK_FRAGMENT_ID);
 	}
@@ -1403,7 +1402,7 @@ AddFragmentPtrLink(struct libalias *la, struct in_addr dst_addr,
     u_short ip_id)
 {
 	LIBALIAS_LOCK_ASSERT(la);
-	return AddLink(la, NO_ADDR, dst_addr, NO_ADDR,
+	return AddLink(la, ANY_ADDR, dst_addr, ANY_ADDR,
 	    NO_SRC_PORT, NO_DEST_PORT, ip_id,
 	    LINK_FRAGMENT_PTR);
 }
@@ -1413,7 +1412,7 @@ FindFragmentPtr(struct libalias *la, struct in_addr dst_addr,
     u_short ip_id)
 {
 	LIBALIAS_LOCK_ASSERT(la);
-	return FindLinkIn(la, dst_addr, NO_ADDR,
+	return FindLinkIn(la, dst_addr, ANY_ADDR,
 	    NO_DEST_PORT, ip_id,
 	    LINK_FRAGMENT_PTR, 0);
 }
@@ -1673,7 +1672,7 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr)
 	struct alias_link *lnk;
 
 	LIBALIAS_LOCK_ASSERT(la);
-	lnk = FindLinkIn(la, NO_ADDR, alias_addr,
+	lnk = FindLinkIn(la, ANY_ADDR, alias_addr,
 	    0, 0, LINK_ADDR, 0);
 	if (lnk == NULL) {
 		la->newDefaultLink = 1;
@@ -1705,7 +1704,7 @@ FindAliasAddress(struct libalias *la, struct in_addr original_addr)
 	struct alias_link *lnk;
 
 	LIBALIAS_LOCK_ASSERT(la);
-	lnk = FindLinkOut(la, original_addr, NO_ADDR,
+	lnk = FindLinkOut(la, original_addr, ANY_ADDR,
 	    0, 0, LINK_ADDR, 0);
 	if (lnk == NULL) {
 		return (la->aliasAddress.s_addr != INADDR_ANY) ?
@@ -2321,7 +2320,7 @@ LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr,
 	struct alias_link *lnk;
 
 	LIBALIAS_LOCK(la);
-	lnk = AddLink(la, src_addr, NO_ADDR, alias_addr,
+	lnk = AddLink(la, src_addr, ANY_ADDR, alias_addr,
 	    0, 0, 0,
 	    LINK_ADDR);
 


More information about the dev-commits-src-main mailing list