Cc'ing Brad (maintainer),

Marc Peters <m...@mpeters.org> writes:

> Am 01/23/17 um 00:34 schrieb Jeremie Courreges-Anglas:
>> Stuart Henderson <s...@spacehopper.org> writes:
>> 
>>>
>>> Here is the upstream code with more context.
>>>
>>>  789         /*
>>>  790          * Set the target address we're sending to.
>>>  791          * Enforce the scope ID for bogus BSDs.
>>>  792          */
>>>  793         memcpy(&dst, to, sizeof(dst));
>>>  794         m.msg_name = &dst;
>>>  795         m.msg_namelen = sizeof(dst);
>>>  796         ifindex = if_nametoindex(interface->name);
>>>  797         if (no_global_v6_socket)
>>>  798                 dst.sin6_scope_id = ifindex;
>>>
>>> So, setting the scope ID is exactly what they are already trying to do.
>>> I don't really want to spend much time understanding code which they
>>> have marked as "XXX: this is gross. we need to go back and overhaul the
>>> API for socket handling". But it looks like they'd be expecting
>>> no_global_v6_socket to be set on a BSD which needs the scope id.
>> 
>> Whether no_global_v6_socket is true doesn't seem to depend on the OS: it
>> appears true when running dhclient, false when running dhcpd/dhcrelay;
>> see if_register_linklocal6().  This looks more like a lack of testing,
>> as it appears safe to set sin6_scope_id everywhere.
>> 
>>> Better if someone who already knows the code looks at it - can you
>>> bring this up on dhcp-users or somewhere similar?
>> 
>> I don't volunteer to move this to dhcp-users... yet.  Maybe the actual
>> fix is in our base system.  It *looks like* our kernel has indeed a bug,
>> it should use the ifindex in the cmsg.
>> 
>
> Ok, i already prepared a mail i was going to send later today, but if
> the bug is in our base system, it won't do any good.
>
> Maybe someone with knowledge of the network stack can have a look? I
> would help in testing patches.

I took a look and I feel dirty.

The patch below works around the issue by always setting sin6_scope_id.
In the dhclient case, all platforms both set sin6_scope_id and use the
cmsg API.  So there shouldn't be breakage on other platforms.

Thoughts?


Index: Makefile
===================================================================
RCS file: /d/cvs/ports/net/isc-dhcp/Makefile,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile
--- Makefile    24 Oct 2016 12:24:13 -0000      1.43
+++ Makefile    22 Jan 2017 23:34:03 -0000
@@ -5,6 +5,7 @@ COMMENT-client= ISC DHCP Client
 COMMENT-omapi= ISC DHCP OMAPI
 
 VERSION=       4.3.5
+REVISION=      0
 DISTNAME=      isc-dhcp-${VERSION}
 PKGNAME=       isc-dhcp-${VERSION:S/-P/./}
 PKGNAME-main=  isc-dhcp-server-${VERSION:S/-P/./}
Index: patches/patch-common_socket_c
===================================================================
RCS file: patches/patch-common_socket_c
diff -N patches/patch-common_socket_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-common_socket_c       22 Jan 2017 23:16:05 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+--- common/socket.c.orig       Mon Jan 23 00:15:45 2017
++++ common/socket.c    Mon Jan 23 00:15:51 2017
+@@ -794,8 +794,7 @@ ssize_t send_packet6(struct interface_info *interface,
+       m.msg_name = &dst;
+       m.msg_namelen = sizeof(dst);
+       ifindex = if_nametoindex(interface->name);
+-      if (no_global_v6_socket)
+-              dst.sin6_scope_id = ifindex;
++      dst.sin6_scope_id = ifindex;
+ 
+       /*
+        * Set the data buffer we're sending. (Using this wacky 


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to