[LU-17186] Replace deprecated gethostby*() calls with get*info() to support resolv ordering Created: 11/Oct/23  Updated: 08/Jan/24  Resolved: 03/Jan/24

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.16.0

Type: Improvement Priority: Minor
Reporter: Jian Yu Assignee: Jian Yu
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
is related to LU-16738 Improve mount.lustre with many MGS NIDs Open
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

Please update the last places in the code where gethostbyaddr() and gethostbyname() are used, especially in the Kerberos user space utility with getaddrinfo() and getnameinfo().

That will make Lustre compatible with the /etc/gai.conf file that gives control over how these calls return info, especially ordering of IP address when a DNS host has multiple IP addresses.

(see man gai.conf)
 

CONFORMING TO
POSIX.1-2001  specifies  gethostbyname(), gethostbyaddr(), sethostent(), endhostent(), gethostent(), and h_errno; gethostbyname(), gethostbyaddr(), and h_errno are marked obsolescent in that standard. 
POSIX.1-2008 removes the specifications of gethostbyname(), gethostbyaddr(), and h_errno, recommending the use of getaddrinfo(3) and getnameinfo(3) instead.

This is simple enough that this ticket could be handled by somebody which is not a Kerberos expert.



 Comments   
Comment by Gerrit Updater [ 11/Oct/23 ]

"Jian Yu <yujian@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/52632
Subject: LU-17186 utils: replace gethostby*() with getaddrinfo()
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 2d293e9b72eecd41607834bc5bff31ad24814112

Comment by Andreas Dilger [ 20/Dec/23 ]

Jian, does the getaddrinfo() interface allow returning multiple addresses for the same hostname, and do the tools handle this? It would be useful for LU-16738 if a single MGS hostname could resolve to multiple NIDs with round-robin DNS, and would allow shortening the mount command line.

Comment by Jian Yu [ 20/Dec/23 ]

Yes, adilger.
The getaddrinfo() function allocates and initializes a linked list of addrinfo structures, one for each network address that matches node and service, subject to any restrictions imposed by hints, and returns a pointer to the start of the list in res. The items in the linked list are linked by the ai_next field.

       int getaddrinfo(const char *node, const char *service,
                       const struct addrinfo *hints,
                       struct addrinfo **res);

       struct addrinfo {
           int              ai_flags;
           int              ai_family;
           int              ai_socktype;
           int              ai_protocol;
           socklen_t        ai_addrlen;
           struct sockaddr *ai_addr;
           char            *ai_canonname;
           struct addrinfo *ai_next;
       };
Comment by Gerrit Updater [ 03/Jan/24 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/52632/
Subject: LU-17186 utils: replace gethostby*() with get*info()
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: de82fd88a7e9300f9558f1d30fe1ed744be11aa2

Comment by Peter Jones [ 03/Jan/24 ]

Landed for 2.16

Generated at Sat Feb 10 03:33:21 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.