< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] DNS update in Ares


Hi all,
I had a look at the code in rutil/dns and I think that it could be possible to 
reload DNS servers configuration even after stack initialization.
First of all I'm developing application under Windows OS, so I used IP helper 
functions to detect network configuration changes.
Then I tried to change some source code in rutil and it seems to work, even if 
DNS queries that are running during configuration reload terminate with cause 
ARES_EDESTRUCTION (I didn't find a better solution).
I would appreciate any suggestion/opinion/comment regarding following changes.

In rutil\dns\DnsStub.hxx I added the following method declaration:
                bool reloadDnsServers();
and the following data members:
                std::vector<GenericIPAddress> mAdditionalNameservers;
                AfterSocketCreationFuncPtr mSocketFunc;

In rutil\dns\DnsStub.cxx I changed DnsStub constructor:
DnsStub::DnsStub(const NameserverList& additional,
                 AfterSocketCreationFuncPtr socketFunc,
                 AsyncProcessHandler* asyncProcessHandler) :
   mTransform(0),
   mDnsProvider(ExternalDnsFactory::createExternalDns()),
   mAsyncProcessHandler(asyncProcessHandler)
{
        mAdditionalNameservers = additional;
        mSocketFunc = socketFunc;
[...]
}

Then I defined the following method definition:
bool
DnsStub::reloadDnsServers()
{
        bool changed = mDnsProvider->checkDnsChange(); 

        if (changed) {
                doClearDnsCache();

                mDnsProvider->init(mAdditionalNameservers,
                                                                 mSocketFunc,
                                                                 mDnsTimeout,
                                                                 mDnsTries,
                                                                 mDnsFeatures);
        }

        return changed;
}

Finally in rutil\dns\AresDns.cxx I changed method AresDns::internalInit() using 
ares_destroy() instead of ares_destroy_suppress_callbacks() function like in 
CARES:
int
AresDns::internalInit(const std::vector<GenericIPAddress>& 
additionalNameservers,
                      AfterSocketCreationFuncPtr socketfunc,
                      unsigned int features,
                      ares_channeldata** channel,
                      int timeout,
                      int tries
)
{
   if(*channel)
   {
#if defined(USE_ARES)
        ares_destroy(*channel);
#elif defined(USE_CARES)
      // Callbacks will be supressed by looking for the ARES_EDESTRUCTION
      // sentinel status
      ares_destroy(*channel);
#endif
      *channel = 0;
   }
[...]

I think it could also be possible to change AresDns::init() and 
AresDns::internalInit() methods declaration adding a new parameter (int 
suppressCallbacks, if necessary defaulted with value 1), so that it could be 
possible to use "void ares_destroy_internal(ares_channel channel, int 
suppressCallbacks);" function (this function is used internally by ares_destroy 
ares_destroy_suppress_callbacks functions): in this way we can decide at 
initialization time to suppress callback or not.

Thank you in advance and best regards.

Dario.


________________________________


-----Original Message-----
From: Byron Campen [mailto:bcampen@xxxxxxxxxxxx] 
Sent: martedì 2 dicembre 2008 0.37
To: Dario Bozzali
Cc: resiprocate-devel@xxxxxxxxxxxxxxxxxxxx
Subject: Re: [reSIProcate] DNS update in Ares

        I don't think this can be done while the stack is already up.

Best regards,
Byron Campen

> Hi all,
> I have a question related to Ares and DNS servers.
> DNS servers in Ares are configured at application startup time.
> Does it exist in Resiprocate the opportunity to detect that something 
> has been changed in network configuration so that I can refresh/update 
> DNS servers in Ares?
> Any suggestion would be appreciated.
> Thank you in advance.
>
> Best regards,
> Dario.
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxx
> https://list.resiprocate.org/mailman/listinfo/resiprocate-devel