[DragonFlyBSD - Bug #3294] drill(1) with IPv6 NS fails with UDP but works with TCP

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Tue Nov 2 19:02:41 PDT 2021


Issue #3294 has been updated by y0n3t4n1.


sendto(which ends up calling udp_send or udp6_send) behaves differently in the point of view of the hash tables involved.

When it auto-binds the local port
- udp_send() calls in_pcbbind(nam = NULL), which calls in_pcbsetlport(), then udp_inswildcardhash(), which populates both localgroup hash and wildcard hash.
- udp6_send() only calls in6_pcbsetlport (in udp6_output)

so sendto() populates the localgroup hash, the port hash, and the wildcard hash for IPv4, whereas only the port hash for IPv6.

For receiving replies(which probably is not a multicast or a broadcast) on the socket used by sendto()
- udp_input() uses in_pcblookup_pkthash(wildcard = TRUE), which looks up on hashbase, calls inp_localgroup_lookup(), then looks up on wildcardhashbase
- udp6_input() uses in6_pcblookup_hash(wildcard = 1), which looks up on hashbase, then wildcardhashbase

so the possible fixes are:
- call in_pcbinswildcardhash() in udp6_output() for local port auto-bind, or
- create in_pcbinslocalgrphash() and call it in udp_output for auto-bind; call inp_localgroup_lookup() in in6_pcblookup_hash()

The change for the first fix seems to work for me.
<pre><code class="diff">
diff --git a/sys/netinet6/udp6_output.c b/sys/netinet6/udp6_output.c
index 355735e7f9..d2627a7c96 100644
--- a/sys/netinet6/udp6_output.c
+++ b/sys/netinet6/udp6_output.c
@@ -186,9 +186,11 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct sockaddr *addr6,
 				error = EADDRNOTAVAIL;
 			goto release;
 		}
-		if (in6p->in6p_lport == 0 &&
-		    (error = in6_pcbsetlport(laddr, in6p, td)) != 0)
-			goto release;
+		if (in6p->in6p_lport == 0) {
+			if ((error = in6_pcbsetlport(laddr, in6p, td)) != 0)
+				goto release;
+			in_pcbinswildcardhash(in6p);
+		}
 	} else {
 		if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
 			error = ENOTCONN;

</code></pre>


----------------------------------------
Bug #3294: drill(1) with IPv6 NS fails with UDP but works with TCP
http://bugs.dragonflybsd.org/issues/3294#change-14184

* Author: liweitianux
* Status: New
* Priority: Normal
* Target version: 6.2
* Start date: 2021-08-13
----------------------------------------
YONETANI Tomokazu reported this issue on users@ mailing list: https://lists.dragonflybsd.org/pipermail/users/2021-August/404805.html

<pre>
$ drill  @2001:4860:4860::8888 aaaa leaf.dragonflybsd.org | egrep -v
'^(\;|$)'
Error: error sending query: Could not send or receive, because of network
error
</pre>

unless using TCP query:

<pre>
$ drill -t @2001:4860:4860::8888 aaaa leaf.dragonflybsd.org | egrep -v
'^(\;|$)'
leaf.dragonflybsd.org. 3599 IN AAAA 2001:470:1:43b:1::68
</pre>

Similar DNS queries on other boxes running different OSes don't have the same problem, and tcpdump output shows the response from the DNS server, so I doubt it's an network issue.

<pre>
$ uname -a
DragonFly c60 6.0-RELEASE DragonFly v6.0.0.33.gc7b638-RELEASE #0: Wed Aug 4
20:25:25 JST 2021 root at c60:/usr/obj/build/usr/src/sys/X86_64_GENERIC x86_64
</pre>

----

I also confirmed this issue on leaf, which running master as of Aug 4.



-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Bugs mailing list