openresolv-discuss

Re: Clear cache for dnsmasq when DBus is used

Daniel Letkiewicz

Sun Sep 01 11:53:48 2019

Hi Roy,

On Fri, Aug 30, 2019, 02:12 Roy Marples <roy@xxxxxxxxxxxx> wrote:

> Hi Daniel
>
> On 29/08/2019 12:44, Daniel Letkiewicz wrote:
> > Hi guys,
> >
> > I'm sorry if this is the well-known issue but it seems that resolvconf
> > doesn't clear dnsmasq cache via DBus when the configuration is changed.
> > I use OpenVPN + resolvconf + dnsmasq (with DBus) to manage DNS server /
> > domain via VPN tunnel. Everything works fine for me but I had to modify
> > https://github.com/rsmarples/openresolv/blob/master/dnsmasq.in#L206 to
> > clear dnsmasq cache.
> > I've just added the following command before line 206.
> >          dbus-send --system --dest=uk.org.thekelleys.dnsmasq \
> >                  /uk/org/thekelleys/dnsmasq uk.org.thekelleys.ClearCache
> >
> > Otherwise, when my VPN tunnel is down all record received from DNS
> > server exposed via the tunnel stay in dnsmasq cache what is incorrect.
> >
> > Is there any better way to do that ?
>
> I would argue that it's a regression in DNSMasq.
> See line 196: # Send even if empty so old servers are cleared
> This imples that old servers are cleared, and thus any cache would be as
> well. Maybe ask upstream if this is a designed change or a regression.
>

This is a good question, as you wrote the line 196 and few lines after are
to remove old servers but it seems that the cache is just not cleared.


> If it's a designed change, then the clear cache needs to happen after
> setting servers, not before.
>

I agree, this is more a design decision. Regardless whether dbus is used or
not, when a server is removed the cache should be cleared IMHO.
I'm not sure if it should be cleared by dnsmasq or by resolvconf.

Looking at the code, there is a flag "changed" which is set to true if
there is a difference in config files.
When the flag is set to true resolvconf restarts dnsmasq or sends SIGHUP,
so the cache is cleared.
The problem with using dbus is that the config files are not changed, so
the flag is never set to true and SIGHUP is not sent.

Anyway, whatever method is the best it would be worth to fix it IMHO. I
just send ClearCache as I wrote before to solve this problem for my setup.

Thanks

Daniel





>
> Roy
>

Follow-Ups:
Re: Clear cache for dnsmasq when DBus is usedRoy Marples
References:
Clear cache for dnsmasq when DBus is usedDaniel Letkiewicz
Re: Clear cache for dnsmasq when DBus is usedRoy Marples
Archive administrator: postmaster@marples.name