summaryrefslogtreecommitdiffstats
path: root/lib/libalias
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>1999-09-27 08:40:36 +0000
committerru <ru@FreeBSD.org>1999-09-27 08:40:36 +0000
commitd8acaf9b945223111f44cd039d78f09c2fb8faf1 (patch)
treece0115fda23d444320db19c736c01727ac02b041 /lib/libalias
parent69c745b9cb95ca7d142ef11732d275eaa64f6ff4 (diff)
downloadFreeBSD-src-d8acaf9b945223111f44cd039d78f09c2fb8faf1.zip
FreeBSD-src-d8acaf9b945223111f44cd039d78f09c2fb8faf1.tar.gz
Properly handle the case when either the aliasing or source address of
the link are equal to the default aliasing address. Do not zero them! This will fix the problem with non-working links added with the source and/or aliasing address equal to the default aliasing address, but the default aliasing address is set later, after the link has been set up, like both natd(8) and ppp(8) do (for objective reasons). Reviewed by: Brian Somers <brian@FreeBSD.org>, Eivind Eklund <eivind@FreeBSD.org>, Charles Mott <cmott@srv.net>
Diffstat (limited to 'lib/libalias')
-rw-r--r--lib/libalias/alias_db.c92
1 files changed, 66 insertions, 26 deletions
diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c
index e52656a..203b96b 100644
--- a/lib/libalias/alias_db.c
+++ b/lib/libalias/alias_db.c
@@ -859,17 +859,6 @@ AddLink(struct in_addr src_addr,
link = malloc(sizeof(struct alias_link));
if (link != NULL)
{
- /* If either the aliasing address or source address are
- equal to the default device address (equal to the
- global variable aliasAddress), then set the alias
- address field of the link record to zero */
-
- if (src_addr.s_addr == aliasAddress.s_addr)
- src_addr.s_addr = 0;
-
- if (alias_addr.s_addr == aliasAddress.s_addr)
- alias_addr.s_addr = 0;
-
/* Basic initialization */
link->src_addr = src_addr;
link->dst_addr = dst_addr;
@@ -1030,7 +1019,7 @@ ReLink(struct alias_link *old_link,
}
static struct alias_link *
-FindLinkOut(struct in_addr src_addr,
+_FindLinkOut(struct in_addr src_addr,
struct in_addr dst_addr,
u_short src_port,
u_short dst_port,
@@ -1040,9 +1029,6 @@ FindLinkOut(struct in_addr src_addr,
u_int i;
struct alias_link *link;
- if (src_addr.s_addr == aliasAddress.s_addr)
- src_addr.s_addr = 0;
-
i = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type);
link = linkTableOut[i];
while (link != NULL)
@@ -1064,7 +1050,8 @@ FindLinkOut(struct in_addr src_addr,
{
if (dst_port != 0)
{
- link = FindLinkOut(src_addr, dst_addr, src_port, 0, link_type, 0);
+ link = _FindLinkOut(src_addr, dst_addr, src_port, 0,
+ link_type, 0);
if (link != NULL && replace_partial_links)
{
link = ReLink(link,
@@ -1075,7 +1062,38 @@ FindLinkOut(struct in_addr src_addr,
}
else if (dst_addr.s_addr != 0)
{
- link = FindLinkOut(src_addr, nullAddress, src_port, 0, link_type, 0);
+ link = _FindLinkOut(src_addr, nullAddress, src_port, 0,
+ link_type, 0);
+ }
+ }
+
+ return(link);
+}
+
+static struct alias_link *
+FindLinkOut(struct in_addr src_addr,
+ struct in_addr dst_addr,
+ u_short src_port,
+ u_short dst_port,
+ int link_type,
+ int replace_partial_links)
+{
+ struct alias_link *link;
+
+ link = _FindLinkOut(src_addr, dst_addr, src_port, dst_port,
+ link_type, replace_partial_links);
+
+ if (link == NULL)
+ {
+ /* The following allows permanent links to be
+ specified as using the default source address
+ (i.e. device interface address) without knowing
+ in advance what that address is. */
+ if (aliasAddress.s_addr != 0 &&
+ src_addr.s_addr == aliasAddress.s_addr)
+ {
+ link = _FindLinkOut(nullAddress, dst_addr, src_port, dst_port,
+ link_type, replace_partial_links);
}
}
@@ -1084,7 +1102,7 @@ FindLinkOut(struct in_addr src_addr,
struct alias_link *
-FindLinkIn(struct in_addr dst_addr,
+_FindLinkIn(struct in_addr dst_addr,
struct in_addr alias_addr,
u_short dst_port,
u_short alias_port,
@@ -1114,14 +1132,6 @@ FindLinkIn(struct in_addr dst_addr,
if (dst_port == 0)
flags_in |= LINK_UNKNOWN_DEST_PORT;
-/* The following allows permanent links to be
- be specified as using the default aliasing address
- (i.e. device interface address) without knowing
- in advance what that address is. */
-
- if (alias_addr.s_addr == aliasAddress.s_addr)
- alias_addr.s_addr = 0;
-
/* Search loop */
start_point = StartPointIn(alias_addr, alias_port, link_type);
link = linkTableIn[start_point];
@@ -1218,6 +1228,36 @@ FindLinkIn(struct in_addr dst_addr,
}
}
+struct alias_link *
+FindLinkIn(struct in_addr dst_addr,
+ struct in_addr alias_addr,
+ u_short dst_port,
+ u_short alias_port,
+ int link_type,
+ int replace_partial_links)
+{
+ struct alias_link *link;
+
+ link = _FindLinkIn(dst_addr, alias_addr, dst_port, alias_port,
+ link_type, replace_partial_links);
+
+ if (link == NULL)
+ {
+ /* The following allows permanent links to be
+ specified as using the default aliasing address
+ (i.e. device interface address) without knowing
+ in advance what that address is. */
+ if (aliasAddress.s_addr != 0 &&
+ alias_addr.s_addr == aliasAddress.s_addr)
+ {
+ link = _FindLinkIn(dst_addr, nullAddress, dst_port, alias_port,
+ link_type, replace_partial_links);
+ }
+ }
+
+ return(link);
+}
+
OpenPOWER on IntegriCloud