Recently I build Alpha 11 on FreeBSD. This time configure and compile went smooth, that is a big step forward! Trying to join another FreeBSD machine with Samba 3.[345] I came accross several issues in the tsocket library of Samba 4. tsocket_bsd.c, function tdgram_bsd_recvfrom_handler: This calls tsocket_bsd_pending first which in turn makes an ioctl(fd, FIONREAD, ...) to get the number of pending bytes and then tries to recvfrom exactly that much bytes. For UDP sockets FreeBSDs implementation of FIONREAD does not only return the size of the UDP payload but includes the UDP header and the source and destination address as well, returning 16 bytes more than recvfrom will return. I have seen this in Wireshark as well: An UDP packet with a payload of 100 bytes arrived, the UDP length field was set to 108, FIONREAD returned 116 and recvfrom returned 100, no bytes from the payload missing. I don't understand why recvfrom could ever not read what is pending, a sufficient large buffer provided, and I don't know what FIONREAD will return if more than one UDP packet is pending, especially if those are from more than one source. In my opinion one should be happy with whatever recvfrom has read. In the same file some calls are made to bind or connect with the length argument set to "sizeof(struct sockaddr_storage)". FreeBSD seems not to like it and returns the error EINVAL. There is already a special treatment for the AF_UNIX family, maybe it should be done for AF_INET and AF_INET6 as well. There is one call to dsdb/sambd/ldb_modules/dsdb_module_search with a format string deliberately set to NULL. This function passes the format string as is to talloc_vasprintf which passes it on to vasprintf. I could not find anything about the expected behaviour of vasprintf with NULL as the format string. At least FreeBSD doesn't like it and dumps core.
Well, I hope that the tsocket bugs will be fixed by metze since he is the author of the tsocket library I think. Regarding the NULL format string: I think it's indeed a bug - yeah. I will push a fix.
Created attachment 5367 [details] Patch for v3-5 Can you please test this? This should fix the tsocket_bsd_pending() problem with tdgram_bsd_recvfrom*
(In reply to comment #2) > Created an attachment (id=5367) [details] > Patch for v3-5 > > Can you please test this? This should fix the tsocket_bsd_pending() problem > with > tdgram_bsd_recvfrom* > It's working :) One remark: In the comment "some systems too much bytes" there is a verb missing. A second remark: I still had to patch the calculation of sa_socklen. I can send you the patch I made for this. And a third remark: If "v3-5" means Samba 3.5, then there should also be a patch for Samba 4.
I'll fix the comment:-) Are the socklen problems fixed by the patch on bug https://bugzilla.samba.org/show_bug.cgi?id=7140
The patch is already in the master branch
(In reply to comment #4) > Are the socklen problems fixed by the patch on bug > https://bugzilla.samba.org/show_bug.cgi?id=7140 Yes, that includes my patch. And addresses also the IPv6 issue I had (I blamed my DNS setup for this).
I ask as QA: Is it working now, Christoph? Then feel free to close with "FIXED".
(In reply to comment #7) > I ask as QA: Is it working now, Christoph? Then feel free to close with > "FIXED". Yes, it is working. Thanks a lot!
Kai, please assign the bug bug to Karolin, when you're done with our tests and the patch can go into 3.5.0 Karolin: this should be picked after the patches from https://bugzilla.samba.org/show_bug.cgi?id=7140
Pending the patch JRA added on top of this one, this seems to be ok. Metze, can you have a look at 936828de71023d90aaec6c1dba84052246bbad11 ?
Created attachment 5374 [details] Patches for v3-5 This includes the fix from Jeremy and a additional patch that fixes the comment.
Comment on attachment 5374 [details] Patches for v3-5 Looks good,
Karolin, please pick.
Pushed to v3-5-test. Closing out bug report. Thanks!