From: Lennart Poettering Date: Fri, 14 Aug 2015 11:11:04 +0000 (+0200) Subject: nss-myhostname: use LOOPBACK_IFINDEX instead of if_nametoindex("lo") X-Git-Tag: v225~64^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f43242886cae3daf0474134175707cbc02c05191;p=thirdparty%2Fsystemd.git nss-myhostname: use LOOPBACK_IFINDEX instead of if_nametoindex("lo") Given that we already hardocde the loopback ifindex, following the kernel's own logic, we can replace the invocation of if_nametoindex("lo") with LOOPBACK_IFINDEX. --- diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index ab96cb231ef..69069cc75d2 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -39,7 +39,6 @@ #define LOCALADDRESS_IPV4 (htonl(0x7F000002)) #define LOCALADDRESS_IPV6 &in6addr_loopback -#define LOOPBACK_INTERFACE "lo" NSS_GETHOSTBYNAME_PROTOTYPES(myhostname); NSS_GETHOSTBYADDR_PROTOTYPES(myhostname); @@ -117,7 +116,7 @@ enum nss_status _nss_myhostname_gethostbyname4_r( } /* If this call fails we fill in 0 as scope. Which is fine */ - lo_ifi = n_addresses <= 0 ? if_nametoindex(LOOPBACK_INTERFACE) : 0; + lo_ifi = n_addresses <= 0 ? LOOPBACK_IFINDEX : 0; l = strlen(canonical); ms = ALIGN(l+1) + ALIGN(sizeof(struct gaih_addrtuple)) * (n_addresses > 0 ? n_addresses : 2);