[Dnsmasq-discuss] [PATCH] --bind-dynamic and fast netlink changes

Petr Menšík pemensik at redhat.com
Thu Feb 18 11:56:21 UTC 2021


Hi Simon and others,

I have started checking behaviour of dnsmasq on fast netlink changes,
reported originally on RHEL7 bug[1]. Found commit 1627d577[2] helps a
lot on RHEL 7, which is already in current version. But for some reason,
even latest dnsmasq 2.84 does not pass my test[3] on RHEL8 (bug #1927973
[4]).

The core of the test is repeating few times this:
one_retry() {
	local MAX=254
	local DOWN_DELAY=0
	for X in `seq 1 $MAX`; do
		ifconfig eth0:${X} 100.123.1.${X} netmask 255.255.255.0
		#ip address add 100.123.1.${X} dev eth0 label eth0:${X}
	done && sleep $DOWN_DELAY && for X in `seq 1 $MAX`; do
		ifconfig eth0:${X} down
		#ip address del 100.123.1.${X} dev eth0 label eth0:${X}
	done
}

Then checking dnsmasq stops listening on them again.

I found by analysing strace of test, it re-reads current addresses
innecessary often. It enqueues re-reading every time multicast netlink
arrives. That means a lot of CPU cycles, when it just sends newaddress()
event request every time. It seems to me, just once per multicast
messages row is enough. It needs to know just current state to run
newaddress() just last time.

I have tested my patches with my test and it helps, works also on RHEL8.
I think it takes a lot less netlink reading without affecting accuracy.
Patches 1 and 2 are fixing things. Patches 3 and 4 are just attempt to
optimize speed of netlink handling a bit. Changed netlink_multicast to
read in a row, until EAGAIN appears. Should help to drain netlink socket
faster, avoiding ENOBUFFS.

I think it should handle errors better in create_listeners. If tcp fails
to bind on address, just UDP received would listen. Problem is
create_bound_listeners does not know it is incomplete, it would be fixed
only by deletion of interface address and re-adding it again. But that
is related but different problem, I have no fix candidate yet.

When it fails, lines similar to this appear in log:
failed to create listening socket for 100.123.1.250: Cannot assign
requested address

What do you think? Have you ever got dnsmasq --bind-dynamic into state,
where it required restart to continue serving correct addresses?

Also opinions welcome.

Thanks,
Petr

1. https://bugzilla.redhat.com/show_bug.cgi?id=1887649
2.
http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=1627d577af03cdf747285e79fa747b6aaae8033f
3.
https://github.com/InfrastructureServices/dnsmasq-tests/tree/master/Regression/netlink-interface-fast-changes
4. https://bugzilla.redhat.com/show_bug.cgi?id=1927973
-- 
Petr Menšík
Software Engineer
Red Hat, http://www.redhat.com/
email: pemensik at redhat.com
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Move-flags-to-recvmsg-function-in-netlink.patch
Type: text/x-patch
Size: 2783 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210218/e839b0fa/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Obtain-MTU-of-interface-only-when-it-would-be-used.patch
Type: text/x-patch
Size: 1635 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210218/e839b0fa/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Remove-sleeping-on-netlink-ENOBUFS.patch
Type: text/x-patch
Size: 1002 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210218/e839b0fa/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Request-only-one-re-read-of-addresses-and-or-routes.patch
Type: text/x-patch
Size: 4042 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210218/e839b0fa/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210218/e839b0fa/attachment-0001.sig>


More information about the Dnsmasq-discuss mailing list