Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[ace-users] [ACE_INET_Addr::set() treats "localhost" as ::1 in ACE 6.1.1]

157 views
Skip to first unread message

nitin padalia

unread,
Nov 7, 2012, 5:47:19 AM11/7/12
to ace-...@list.isis.vanderbilt.edu
Hi,

In one of my application when I pass "localhost" as host_name to ACE_INET_Addr::set() it is being treated as IPv6 address ::1 in ACE 6.1.1 however earlier, 5.5.1 it was interpreted as IPv4 address. Is this is the correct behavior?

Best Regards,
Nitin Padalia

Douglas C. Schmidt

unread,
Nov 7, 2012, 10:11:56 AM11/7/12
to nitin padalia, ace-...@list.isis.vanderbilt.edu

Hi Nitin,

> In one of my application when I pass "localhost" as host_name
> to ACE_INET_Addr::set() it is being treated as IPv6 address ::1 in ACE
> 6.1.1 however earlier, 5.5.1 it was interpreted as IPv4 address. Is
> this is the correct behavior?

To ensure that we have proper version/platform/compiler/configuration
information, please make sure you fill out the appropriate problem
report form (PRF), which is in

$ACE_ROOT/PROBLEM-REPORT-FORM
$TAO_ROOT/PROBLEM-REPORT-FORM

Make sure to include this information when asking any questions since
otherwise we have to "guess" what version/platform/compiler/options
you've using, which is very error-prone and slows down our
responsiveness. If you don't use the PRF, therefore, it is less likely
that someone from the core developer team will be able to answer your
question. Naturally, we encourage and appreciate other members of the
ACE, TAO, CIAO, and DAnCE user community who can respond to questions
that they have the answers to.

Please note, moreover, that the DOC group at Vanderbilt University
only provides "best effort" support for non-sponsors who are using the
latest release, as described in

http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/docs/ACE-bug-process.html

Therefore, please make sure you are using ACE+TAO+CIAO+DAnCE x.1.5
(i.e., ACE 6.1.5, TAO 2.1.5, CIAO 1.5.1, and DAnCE 1.5.1), which you
can download from

http://download.dre.vanderbilt.edu

If you need more "predictable" help or need help for earlier versions
of ACE+TAO+CIAO+DAnCE please see

http://www.dre.vanderbilt.edu/support.html

for a list of companies that will provide you with ACE+TAO+CIAO+DAnCE
commercial support.

Thanks,

Doug

James Edmondson

unread,
Nov 7, 2012, 11:36:20 AM11/7/12
to Douglas C. Schmidt, ace-...@list.isis.vanderbilt.edu
Hi Nitin,

Like Doug said, without more information, it's hard to help
you--especially for an old release. However, the culprit might be that
you are not setting the address_family argument to AF_INET, which
should ensure that the address is IPv4. By default, it's generally
AF_UNSPEC, meaning that you don't care if you get IPv6 or IPv4.

You might want to take a look at the INET_Addr.h file inside of
$ACE_ROOT/ace/INET_Addr.h and specifically look at the set functions
to ensure that you are writing portable code that crosses ACE versions
and platforms. Hope that helps.

Thanks,
James
> _______________________________________________
> ace-users mailing list
> ace-...@list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/ace-users

nitin padalia

unread,
Nov 7, 2012, 2:06:58 PM11/7/12
to James Edmondson, ace-...@list.isis.vanderbilt.edu
Thanks! Doug and James for the reply.
Doug:
Please find below PRF.  I believe subject is already as per PRF

ACE VERSION: 6.1.1
HOST MACHINE and OPERATING SYSTEM: RHEL6.2
TARGET MACHINE and OPERATING SYSTEM, if different from HOST: RHEL6.2
COMPILER NAME AND VERSION (AND PATCHLEVEL): GCC 4.4.6
THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform-specific file, simply state which one]: 
#define ACE_HAS_IPV6 1
#define ACE_USES_IPV4_IPV6_MIGRATION 1
#define ACE_HAS_LIMITED_SELECT 1
#include "ace/config-linux.h"
THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE [if you use a link to a platform-specific file, simply state which one (unless this isn't used in this case, e.g., with Microsoft Visual C++)]: NARW
CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features (used by MPC when you generate your own makefiles): NARW
AREA/CLASS/EXAMPLE AFFECTED: ACE_INET_Addr::set (u_short port_number,
                    const char host_name[],
                    int encode,
                    int address_family)
DOES THE PROBLEM AFFECT: EXECUTION
SYNOPSIS:
ACE default protocol has been changed to IPv6 (AFAIK 6.1.1 onwards) on IPv6 enabled kernels if ACE has IPv6 Enabled
DESCRIPTION:
In one of my application I am using "localhost" and some port with ACE_INET_Addr::set(port,host). Then at later stage the application tries to connect on the same. 
My issue here is that the same application used to work fine when it was using ACE-5.5.1 but it started failing After I upgraded to ACE-6.1.1. 
Issue I could find is that >=ACE-6.1.1 is treating "localhost" as an IPv6 address by default, if your kernel supports IPv6 and ACE is IPv6 enabled. However this was not the case with ACE-5.5.1.

I've compared the code of ACE_INET_Addr::set (u_short port_number, const char host_name[], int encode,      int address_family) in INET_Addr.cpp for both ACE-5.5.1 and ACE-6.1.1. What I could find is that in ACE-5.5.1:
if you don't specify address_family in ACE_INET_Addr::set() which would be by default AF_UNSPEC, also if ACE has IPv6 enabled then hints.ai_family will have value as AF_UNSPEC to getaddrinfo() which then detects the address as IPv4.

However in newer version >=ACE-6.1.1:
if you don't specify address_family in ACE_INET_Addr::set() which would be by default AF_UNSPEC, also if ACE has IPv6 enabled and your kernel support IPv6 then hints.ai_family will have value as AF_INET6  to getaddrinfo() hence "localhost" is treated as IPv6 ::1. 
  
So Is there any workaround/solution/configuration to get through this new behavior, without modifying my existing code ( passing "127.0.0.1" instead of "localhost" or passing the address_family IPv4/IPv6) ?

This might save some efforts of mine replacing function calls as per the new library in all of my code base. This might help others too :)

Thanks! a lot in advance.
Nitin Padalia

--
Nitin Padalia
9999256157

Douglas C. Schmidt

unread,
Nov 7, 2012, 2:19:16 PM11/7/12
to nitin padalia, ace-...@list.isis.vanderbilt.edu

Hi Nitin,

Thanks for using the PRF and for providing the in-depth explanation.
If you have some suggestions for the right fix please let us know.
Also, if you could update the

ACE_ROOT/tests/INET_Addr_Test_IPV6.cpp

regression test to check for the situation you describe below that would
be super.

thanks!

Doug
0 new messages