EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: gethostbyname and getaddrinfo - multiple DNS entries for a hostname
From: Mark Rivers <[email protected]>
To: "'Andrew Johnson'" <[email protected]>, "[email protected]" <[email protected]>
Cc: Eric Norum <[email protected]>
Date: Mon, 11 Mar 2013 15:20:50 +0000
I checked an getaddrinfo also appears to be present on Windows.  If this adds useful functionality then should it also be changed in the Windows OSI code?

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andrew Johnson
Sent: Monday, March 11, 2013 10:18 AM
To: [email protected]
Cc: Eric Norum
Subject: Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname

Hi Eric,

On 2013-03-09 Eric Norum wrote:
> It sounds like getaddrinfo is a better routine to use.  Will this cause
>  problems for folks on old POSIX platforms?  I suppose that those so
>  affected could use the existing gethostbyname code by copying it from the
>  posix directory to, say, solaris? Or should this be a 3.15 change and
>  we'll wave goodbye to those folks?

Our solaris-10 systems have getaddrinfo() so I think we could safely make such 
a change in the osi/posix area — it was apparently in POSIX.1-2001 according 
to the Linux man-pages.  If someone wants to send me a patch or propose 
merging a branch containing it on Launchpad I'd be happy to take it.

The only question is whether this should be a 3.15 change; I don't think it 
has to be, since it's not really adding functionality and is fixing a problem 
in the 3.14 code.  However from what Matt says it will change the behavior 
from the existing code, so I will listen to any arguments people have against 
putting it in 3.14.

- Andrew

> On Mar 9, 2013, at 2:41 AM, <[email protected]> wrote:
> > Hi,
> >
> > In the POSIX code in libCom for networking (posix/osdSock.c) there is the
> > use of gethostbyname to map a hostname to IP address. This is what the
> > Asyn function drvAsynIPPort uses to map hostname to IP address (that we
> > use in IOC startup scripts).
> >
> > We have a problem at Diamond for a few systems that move around different
> > beamlines. These typically comprise a few ethernet attached devices and
> > an Epics IOC running on Linux. The IP addresses of the device that an IOC
> > can talk to changes depending on which beamline it's running on, but the
> > hostname can stay the same. So in our DNS server we have multiple IPv4
> > address for a hostname, and we would like to be able to use the hostname
> > in the IOC startup script.
> >
> > The problem is our DNS server can't/doesn't prioritise local subnets, so
> > our hostname to IP address lookup can return any value from the list (and
> > only one value is returned). At least, that's what gethostbyname does in
> > hostToIPAddr in posix/osdSock.c. However, I've found that if I use
> > getaddrinfo instead I always get the correct IP address for the local
> > subnet first (in the list of returned IP address). So getaddrinfo seems
> > to be matching the localhost to the list of possible IP addresses.
> >
> > getaddrinfo seems to be the newer POSIX way of doing DNS lookups, and has
> > superseded gethostbyname. From the man page: The gethostbyname*() and
> > gethostbyaddr*() functions are obsolete. Applications should use
> > getaddrinfo(3) and getnameinfo(3) instead.
> >
> >
> > Has anyone else had this problem with multiple DNS entries? Any one see a
> > problem with changing hostToIPAddr to use getaddrinfo instead of
> > gethostbyname?
> >
> > In the meantime we may start doing our own hostname to IP mapping, using
> > getaddrinfo, and only ever pass an IP address into drvAsynIPPort.
> >
> > Cheers,
> > Matt

-- 
There is no such thing as a free lunch.  When invited for lunch,
it is best to check if you are there to eat, or to be eaten.
-- Clive Robinson



References:
gethostbyname and getaddrinfo - multiple DNS entries for a hostname matthew.pearson
Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname Eric Norum
Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname Andrew Johnson

Navigate by Date:
Prev: RE: I/O Intr scanning Mark Rivers
Next: Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: gethostbyname and getaddrinfo - multiple DNS entries for a hostname Andrew Johnson
Next: Area Detector Zenon Szalata
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·