summaryrefslogtreecommitdiff
path: root/src/netlink.c
Commit message (Collapse)AuthorAgeFilesLines
* Bump copyrights to 2023.Simon Kelley2023-04-051-1/+1
|
* Fix parsing of IPv6 addresses with peer from netlink.Beniamino Galvani2022-05-271-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the most common case, an IPv6 address doesn't have a peer and the IFA_ADDRESS netlink attribute contains the address itself. But if the address has a peer (typically for point to point links), then IFA_ADDRESS contains the peer address and IFA_LOCAL contains the address [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv6/addrconf.c?h=v5.17#n5030 Fix the parsing of IPv6 addresses with peers, as currently dnsmasq unsuccessfully tries to bind on the peer address. A simple reproducer is: dnsmasq --conf-file=/dev/null -i dummy1 -d --bind-dynamic & sleep 2 ip link add dummy1 type dummy ip link set dummy1 up ip addr add dev dummy1 fd01::1/64 peer fd01::2/64 ip addr add dev dummy1 fd01::42/64 sleep 2 ss -lnp | grep dnsmasq | grep fd01 Before the patch: dnsmasq: failed to create listening socket for fd01::2: Cannot assign requested address dnsmasq: failed to create listening socket for fd01::2: Cannot assign requested address udp UNCONN 0 [fd01::42]:53 [::]:* users:(("dnsmasq",pid=23947,fd=14)) tcp LISTEN 0 [fd01::42]:53 [::]:* users:(("dnsmasq",pid=23947,fd=15 After: udp UNCONN 0 [fd01::42]:53 [::]:* users:(("dnsmasq",pid=23973,fd=16)) udp UNCONN 0 [fd01::1]:53 [::]:* users:(("dnsmasq",pid=23973,fd=14)) tcp LISTEN 0 [fd01::42]:53 [::]:* users:(("dnsmasq",pid=23973,fd=17)) tcp LISTEN 0 [fd01::1]:53 [::]:* users:(("dnsmasq",pid=23973,fd=15))
* Ask netlink for new address events unconditionally.Simon Kelley2022-02-041-9/+2
| | | | | The circumstances under which actions occur depending on configuration is now controlled only by newaddress() in network.c
* Bump copyright to 2022.Simon Kelley2022-01-241-1/+1
|
* Chomp file endsGeert Stappers2021-04-091-3/+1
| | | | | | Removed empty lines from end of src/*.[ch] files. If the new last line became '#endif' was the condition of the '#if' added.
* Move flags to recvmsg function in netlinkPetr Menšík2021-03-021-13/+6
| | | | | | | | | | netlink_multicast used 3 calls to fcntl in order to set O_NONBLOCK on socket. It is possible to pass MSG_DONTWAIT flag just to recvmsg function, without setting it permanently on socket. Save few kernel calls and use recvmsg flags. It is supported since kernel 2.2, should be fine for any device still receiving updates.
* Correct occasional --bind-dynamic synchronization breakPetr Menšík2021-03-021-24/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Request only one re-read of addresses and/or routes Previous implementation re-reads systemd addresses exactly the same number of time equal number of notifications received. This is not necessary, we need just notification of change, then re-read the current state and adapt listeners. Repeated re-reading slows netlink processing and highers CPU usage on mass interface changes. Continue reading multicast events from netlink, even when ENOBUFS arrive. Broadcasts are not trusted anyway and refresh would be done in iface_enumerate. Save queued events sent again. Remove sleeping on netlink ENOBUFS With reduced number of written events netlink should receive ENOBUFS rarely. It does not make sense to wait if it is received. It is just a signal some packets got missing. Fast reading all pending packets is required, seq checking ensures it already. Finishes changes by commit 1d07667ac77c55b9de56b1b2c385167e0e0ec27a. Move restart from iface_enumerate to enumerate_interfaces When ENOBUFS is received, restart of reading addresses is done. But previously found addresses might not have been found this time. In order to catch this, restart both IPv4 and IPv6 enumeration with clearing found interfaces first. It should deliver up-to-date state also after ENOBUFS. Read all netlink messages before netlink restart Before writing again into netlink socket, try fetching all pending messages. They would be ignored, only might trigger new address synchronization. Should ensure new try has better chance to succeed. ENOBUFS error handling was improved. Netlink is correctly drained before sending a new request again. It seems ENOBUFS supression is no longer necessary or wanted. Let kernel tell us when it failed and handle it a good way.
* Bump copyright notices for 2021. Happy New Year!Simon Kelley2021-01-241-1/+1
|
* Convert failure of setsockopt(..., SOL_NETLINK, NETLINK_NO_ENOBUFS, ...) ↵Simon Kelley2020-04-191-3/+8
| | | | | | | | | into warning. We call this, which avoids POLLERR returns from netlink on a loaded system, if the kernel is new enough to support it. Sadly, qemu-user doesn't support the socket option, so if it fails despite the kernel being new enough to support it, we just emit a warning, rather than failing hard.
* Handle old kernels that don't do NETLINK_NO_ENOBUFS.Simon Kelley2020-03-191-2/+6
| | | | | | | Deal with both old kernel header files that don't define it, and old kernels that don't implement it. Also generalise Linux kernel version handling.
* Set NETLINK_NO_ENOBUFS in netlink socket, to avoid POLLERR returns.Simon Kelley2020-03-101-0/+8
|
* Ignore routes in non-main tablesv2.81rc1Donald Sharp2020-03-021-1/+3
| | | | | | | | | | | | | | | | | | | | Route lookup in Linux is bounded by `ip rules` as well as the contents of specific routing tables. With the advent of vrf's(l3mdev's) non-default tables are regularly being used for routing purposes. dnsmasq listens to all route changes on the box and responds to each one with an event. This is *expensive* when a full BGP routing table is placed into the linux kernel, moreso when dnsmasq is responding to events in tables that it will never actually need to respond to, since dnsmasq at this point in time has no concept of vrf's and would need to be programmed to understand them. Help alleviate this load by reducing the set of data that dnsmasq pays attention to when we know there are events that are not useful at this point in time. Signed-off-by: Donald Sharp <donaldsharp72@gmail.com>
* Update copyrights to 2020.Simon Kelley2020-01-051-1/+1
|
* Remove ability to compile without IPv6 support.Simon Kelley2018-10-231-4/+1
| | | | | | | This was the source of a large number of #ifdefs, originally included for use with old embedded libc versions. I'm sure no-one wants or needs IPv6-free code these days, so this is a move towards more maintainable code.
* Picky changes to 47b45b2967c931fed3c89a2e6a8df9f9183a5789Simon Kelley2018-09-041-5/+0
|
* Fix lengths of interface namesPetr Menšík2018-09-041-0/+5
| | | | | Use helper function similar to copy correctly limited names into buffers.
* Update copyrights to 2018.Simon Kelley2018-01-011-1/+1
|
* Bump year in copyrights.Simon Kelley2017-06-241-1/+1
|
* Fix getsockname error return check.Reiter Wolfgang2017-01-081-1/+1
|
* Fix logic error in Linux netlink code.Ivan Kokshaysky2016-07-111-1/+7
| | | | | This could cause dnsmasq to enter a tight loop on systems with a very large number of network interfaces.
* Update copyright notices. Happy new year!Simon Kelley2016-01-061-1/+1
|
* Major tidy up of EDNS0 handling and computation/use of udp packet size.Simon Kelley2015-12-201-1/+2
|
* Fix boilerplate code for re-running system calls on EINTR and EAGAIN etc.Simon Kelley2015-03-111-4/+4
| | | | | | The nasty code with static variable in retry_send() which avoids looping forever needs to be called on success of the syscall, to reset the static variable.
* Update copyrights for dawn of 2015.Simon Kelley2015-01-311-1/+1
|
* Fix length->netmask conversions to avoid undefined behaviour.Richard Genoud2014-09-171-1/+2
|
* Use event system to re-send query on new route. Tidies module boundaries.Simon Kelley2014-07-081-20/+2
|
* Handle async notification of address changes using the event system.Simon Kelley2014-06-071-29/+10
|
* Tweak definition of a permanent IPv6 address on Linux.Jonas Gorski2014-01-221-3/+3
| | | | | | | | | | | | | | The linux kernel treats all addresses with a limited lifetime as being non permanent, but when taking over the prefix livetimes from upstream assigned prefixes through DHCP, addresses will always have a limited lifetime. Still reject temporary addresses, as they indicate autoconfigured interfaces. Contributed by T-Labs, Deutsche Telekom Innovation Laboratories Signed-off-by: Jonas Gorski<jogo@openwrt.org>
* Update copyright for 2014.Simon Kelley2014-01-081-1/+1
|
* Implement dynamic interface discovery on *BSDv2.69test1Simon Kelley2013-12-091-27/+2
|
* Remove unused variable warnings when omitting stuff at compile-time.Vladislav Grishenko2013-09-241-0/+2
|
* Add --dhcp-relay config option.v2.67test10Simon Kelley2013-09-041-5/+5
|
* IFACE_PERMANENT interface flag in enumeration.Vladislav Grishenko2013-08-191-0/+3
|
* Generalise --interface-name to cope with IPv6 addresses.Simon Kelley2013-05-201-2/+5
|
* Handle IPv4 interface-address labels in Linux.v2.67test4Simon Kelley2013-05-141-2/+5
|
* Change copyright messages to include 2013.Simon Kelley2013-01-311-1/+1
|
* saner function nameSimon Kelley2012-12-221-4/+4
|
* Fix new-address logic and ordering for first address on new interface.Simon Kelley2012-12-221-5/+5
|
* add general flag param to iface_enumerate IPv6 callbackSimon Kelley2012-12-201-1/+9
|
* Rationalise join_multicast()Simon Kelley2012-12-201-32/+25
|
* Missed interface re-read path in netlink.cSimon Kelley2012-12-181-1/+7
|
* Fix initialisation order.Simon Kelley2012-12-181-1/+7
|
* First checkin of interface-address constructor mode for DHCPv6 and RA.Simon Kelley2012-12-181-27/+36
|
* Don't elide code needed for --bind-dynamic if compiled without IPv6.Simon Kelley2012-11-291-3/+3
|
* Don't report spurious netlink errors.Simon Kelley2012-09-181-1/+2
|
* Fix build-failure with -DNO_DHCP6.Simon Kelley2012-06-281-45/+39
|
* Tidy up - no functional change.Simon Kelley2012-06-201-3/+3
|
* Add --bind-dynamicv2.63test1Simon Kelley2012-06-201-58/+85
|
* Check assumed SLAAC addresses by pinging them.v2.61test6Simon Kelley2012-03-191-2/+3
|
* Make RA without DHCPv6 possible.Simon Kelley2012-02-271-1/+1
|