diff options
author | ru <ru@FreeBSD.org> | 2000-04-12 18:44:50 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2000-04-12 18:44:50 +0000 |
commit | c93d494562c83aeaf960ba067bc0e9c1abcc2f2d (patch) | |
tree | 5c3692896457fd32a78dbd692d3b355912b26f97 | |
parent | c3fb68865735f4e9708766b6c6e77ce7c67f370a (diff) | |
download | FreeBSD-src-c93d494562c83aeaf960ba067bc0e9c1abcc2f2d.zip FreeBSD-src-c93d494562c83aeaf960ba067bc0e9c1abcc2f2d.tar.gz |
Make partially specified permanent links without `dst_addr'
but with `dst_port' work for outgoing packets.
This case was not handled properly when I first fixed this
in revision 1.17.
This change is also required for the upcoming improved PPTP
support patches -- that is how I found the problem.
Before this change:
# natd -v -a aliasIP \
-redirect_port tcp localIP:localPORT publicIP:publicPORT 0:remotePORT
Out [TCP] [TCP] localIP:localPORT -> remoteIP:remotePORT aliased to
[TCP] aliasIP:localPORT -> remoteIP:remotePORT
After this change:
# natd -v -a aliasIP \
-redirect_port tcp localIP:localPORT publicIP:publicPORT 0:remotePORT
Out [TCP] [TCP] localIP:localPORT -> remoteIP:remotePORT aliased to
[TCP] publicIP:publicPORT -> remoteIP:remotePORT
-rw-r--r-- | lib/libalias/alias_db.c | 26 | ||||
-rw-r--r-- | sys/netinet/libalias/alias_db.c | 26 |
2 files changed, 30 insertions, 22 deletions
diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c index b0a2642..86223cd 100644 --- a/lib/libalias/alias_db.c +++ b/lib/libalias/alias_db.c @@ -1046,25 +1046,29 @@ _FindLinkOut(struct in_addr src_addr, } /* Search for partially specified links. */ - if (link == NULL) + if (link == NULL && replace_partial_links) { - if (dst_port != 0) + if (dst_port != 0 && dst_addr.s_addr != INADDR_ANY) { link = _FindLinkOut(src_addr, dst_addr, src_port, 0, link_type, 0); - if (link != NULL && replace_partial_links) - { - link = ReLink(link, - src_addr, dst_addr, link->alias_addr, - src_port, dst_port, link->alias_port, - link_type); - } + if (link == NULL) + link = _FindLinkOut(src_addr, nullAddress, src_port, + dst_port, link_type, 0); } - else if (dst_addr.s_addr != 0) + if (link == NULL && + (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { link = _FindLinkOut(src_addr, nullAddress, src_port, 0, link_type, 0); } + if (link != NULL) + { + link = ReLink(link, + src_addr, dst_addr, link->alias_addr, + src_port, dst_port, link->alias_port, + link_type); + } } return(link); @@ -1228,7 +1232,7 @@ _FindLinkIn(struct in_addr dst_addr, } } -struct alias_link * +static struct alias_link * FindLinkIn(struct in_addr dst_addr, struct in_addr alias_addr, u_short dst_port, diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index b0a2642..86223cd 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -1046,25 +1046,29 @@ _FindLinkOut(struct in_addr src_addr, } /* Search for partially specified links. */ - if (link == NULL) + if (link == NULL && replace_partial_links) { - if (dst_port != 0) + if (dst_port != 0 && dst_addr.s_addr != INADDR_ANY) { link = _FindLinkOut(src_addr, dst_addr, src_port, 0, link_type, 0); - if (link != NULL && replace_partial_links) - { - link = ReLink(link, - src_addr, dst_addr, link->alias_addr, - src_port, dst_port, link->alias_port, - link_type); - } + if (link == NULL) + link = _FindLinkOut(src_addr, nullAddress, src_port, + dst_port, link_type, 0); } - else if (dst_addr.s_addr != 0) + if (link == NULL && + (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { link = _FindLinkOut(src_addr, nullAddress, src_port, 0, link_type, 0); } + if (link != NULL) + { + link = ReLink(link, + src_addr, dst_addr, link->alias_addr, + src_port, dst_port, link->alias_port, + link_type); + } } return(link); @@ -1228,7 +1232,7 @@ _FindLinkIn(struct in_addr dst_addr, } } -struct alias_link * +static struct alias_link * FindLinkIn(struct in_addr dst_addr, struct in_addr alias_addr, u_short dst_port, |