Skip to content

Commit

Permalink
[Server] Fallback using known DNS name when reverse translation fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Dec 12, 2019
1 parent 63fe86f commit b87fce9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/XrdNet/XrdNetIF.cc
Expand Up @@ -266,7 +266,7 @@ bool XrdNetIF::GenAddrs(ifAddrs &ifTab, const char *hName, bool wantV6)

#define RLOSLOT(xdst) xdst = (ifData *)(ifBuff+((char *)xdst-buff))

bool XrdNetIF::GenIF(XrdNetAddrInfo **src, int srcnum)
bool XrdNetIF::GenIF(XrdNetAddrInfo **src, int srcnum, const char *xName)
{
ifAddrs ifTab;
const char *hName;
Expand Down Expand Up @@ -323,7 +323,9 @@ for (i = 0; i < srcnum; i++)
if (!rPIPA && isPrivate)
{ADDSLOT(ifName[ifT], ifTab.hAddr, ifTab.hALen);
} else {
if ((hName = src[i]->Name()) && src[i]->isRegistered())
hName = src[i]->Name();
if (!hName || !(src[i]->isRegistered())) hName = xName;
if (hName)
{ADDSLOT(ifName[ifT], hName, strlen(hName));
ifxDNS[ifT] = true;
} else ifName[ifT] = ifDest[ifT];
Expand Down Expand Up @@ -688,7 +690,7 @@ char *XrdNetIF::SetDomain()
/******************************************************************************/

bool XrdNetIF::SetIF(XrdNetAddrInfo *src, const char *ifList, int port,
netType nettype)
netType nettype, const char *xName)
{
XrdNetAddrInfo *netIF[4] = {0,0,0,0}; //pub 0:v4, prv 1:v4 pub 2:v6 prv 3:v6
XrdNetAddr netAdr[4];
Expand All @@ -710,13 +712,14 @@ bool XrdNetIF::SetIF(XrdNetAddrInfo *src, const char *ifList, int port,
{XrdNetAddrInfo *ifVec[8];
XrdNetAddr *iP;
const char *hName = src->Name();
if (!(src->isRegistered()) && xName) hName = xName;
ifCnt = 0;
if (!hName
|| XrdNetUtils::GetAddrs(hName,&iP,ifCnt,XrdNetUtils::allIPv64,ifPort)
|| !ifCnt) return SetIF64(GenIF(&src, 1));
if (ifCnt > 8) ifCnt = 8;
for (i = 0; i < ifCnt; i++) ifVec[i] = &iP[i];
bool aOK = GenIF(ifVec, ifCnt);
bool aOK = GenIF(ifVec, ifCnt, hName);
delete [] iP;
return SetIF64(aOK);
}
Expand Down
6 changes: 4 additions & 2 deletions src/XrdNet/XrdNetIF.hh
Expand Up @@ -338,14 +338,16 @@ static void Routing(netType nettype);
//! >0 -> Use the number passed.
//! @param nettype Determines how undefined interfaces are resolved. See
//! the netType definition.
//! @param xName the known registered host name should ip address
//! translation fail.
//!
//! @return Success: True.
//! Failure: False and if eText is supplied, the error message,
//! in persistent storage, is returned.
//------------------------------------------------------------------------------

bool SetIF(XrdNetAddrInfo *src, const char *ifList, int port=0,
netType nettype=netDefault);
netType nettype=netDefault, const char *xName=0);

//------------------------------------------------------------------------------
//! Set the public and private network interface names.
Expand Down Expand Up @@ -399,7 +401,7 @@ struct ifAddrs

bool GenAddrs(ifAddrs &ifTab, XrdNetAddrInfo *src);
bool GenAddrs(ifAddrs &ifTab, const char *hName, bool wantV6);
bool GenIF(XrdNetAddrInfo **src, int srcnum);
bool GenIF(XrdNetAddrInfo **src, int srcnum, const char *xName=0);
static
bool IsOkName(const char *ifn, short &ifIdx);
static
Expand Down

0 comments on commit b87fce9

Please sign in to comment.