libxtables: Call ipaddr_to_network before ipaddr_to_host.
PATCH 1/1 libxtables: Call ipaddr_to_network before ipaddr_to_host.
Call ipaddr_to_network before ipaddr_to_host.
This saves waiting for a reverse DNS lookup query when the entry is present in /etc/networks. This also follows the same order as in rules creation.
--- libxtables/xtables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
libxtables/xtables.c +2 -2
@@ -1207,8 +1207,8 @@ const char *xtables_ipaddr_to_anyname(const struct in_addr *addr) {const char *name; -if ((name =ipaddr_to_host (addr)) !=NULL || - (name =ipaddr_to_network (addr)) !=NULL ) +if ((name =ipaddr_to_network (addr)) !=NULL || + (name =ipaddr_to_host (addr)) !=NULL )return name;return xtables_ipaddr_to_numeric (addr);
Signature · 1 line
1.8.3.2
Pablo Neira Ayuso
maintainerQuoted 4 lines · Hani Benhabiles
Call
ipaddr_to_networkbeforeipaddr_to_host.This saves waiting for a reverse DNS lookup query when the entry is present in
/etc/networks. This also follows the same order as in rules creation.
This saves time and it makes sense to me to check local file before name resolution via network, but...
Quoted 10 lines
Signed-off-by Hani Benhabiles <[email protected]>--- libxtables/xtables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)libxtables/xtables.c +0
-0
libxtables/xtables.c const char *xtables_ipaddr_to_anyname(const struct in_addr *addr) · line 1211
Quoted 7 lines
libxtables/xtables.c +2
-2@@ -1207,8 +1207,8 @@ const char *xtables_ipaddr_to_anyname(const struct in_addr *addr) {const char *name; -if ((name =ipaddr_to_host (addr)) !=NULL || - (name =ipaddr_to_network (addr)) !=NULL ) +if ((name =ipaddr_to_network (addr)) !=NULL || + (name =ipaddr_to_host (addr)) !=NULL )
My only concern is the remote case in which you may have a network name that overlaps with some existing host name, in that case the expected output different.
Hi Pablo,
Quoted 22 lines · Pablo Neira Ayuso
Quoted 4 lines · Hani Benhabiles
Call
ipaddr_to_networkbeforeipaddr_to_host.This saves waiting for a reverse DNS lookup query when the entry is present in
/etc/networks. This also follows the same order as in rules creation.This saves time and it makes sense to me to check local file before name resolution via network, but...
Quoted 13 lines
Signed-off-by Hani Benhabiles <[email protected]>--- libxtables/xtables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)libxtables/xtables.c +0
-0@@ -1207,8 +1207,8 @@ const char *xtables_ipaddr_to_anyname(const struct in_addr *addr) {const char *name;
Quoted 9 lines
libxtables/xtables.c const char *xtables_ipaddr_to_anyname(const struct in_addr *addr) · line 1211
Quoted 4 lines
libxtables/xtables.c +2
-2-if ((name =ipaddr_to_host (addr)) !=NULL || - (name =ipaddr_to_network (addr)) !=NULL ) +if ((name =ipaddr_to_network (addr)) !=NULL || + (name =ipaddr_to_host (addr)) !=NULL )My only concern is the remote case in which you may have a network name that overlaps with some existing host name, in that case the expected output different.
This is already the case in rules creation. In xtables.c:ipparse_hostnetwork() we have network_to_ipaddr() call prior to host_to_ipaddr().
I believe that a consistent behaviour for users is important ie. either network names or host names should come first in both resolving and reverse resolving.
Maybe be consistent, and make host names a priority in rules creation, then ? However, I believe networks should come first, mainly due to the potential time/bandwidth save.
Regards,
Hani.