Created attachment 8603 [details] git format-patch On FreeBSD, local DCE/RPC (eg, samba-tool drs showrepl) fails with the following error: ERROR(runtime): DsReplicaGetInfo of type 0 failed - (-1073610723, 'NT_STATUS_RPC_PROTOCOL_ERROR') Investigating the cause, the call actually completes successfully, but the response is never sent due to sendto() returning EMSGSIZE in unixdom_sendto(). This is caused by FreeBSD's default 2048 byte SO_SNDBUF for UNIX domain sockets; the DsReplicaGetInfo response is on the order of 3004+ bytes long, and thus EMSGSIZE is returned. This succeeds on Linux due to the use of a larger default SO_SNDBUF size, but there is no guarantee that the buffer will be sized appropriately. I see two possible fixes: the first is to statically configure the SO_SNDBUF for the largest possible packet size. The second would be to set SO_SNDBUF based on the actual packet size upon the return of EMSGSIZE. The latter seems safer to me, given that it may not be reasonable to predetermine the largest possible packet size, but I'm not familiar with the code base. I've attached a patch that implements the latter solution, but I am content to implement the former, as well. Lastly, this particular DsReplicaGetInfo response is also larger than the MTU of most network transports, and by default neither Linux nor FreeBSD will fragment 'atomically' sent messages. I do not know the code base or protocols well enough to know whether this is a problem outside of this particular UNIX domain socket failure case, but -- in theory -- this bug could occur elsewhere. I also don't know enough about DCE/RPC to know whether it would make sense to use framed stream sockets rather than relying on atomic sends. As a work-around on FreeBSD, one can also set a higher system-wide default, eg: sysctl -w net.local.dgram.maxdgram=4096
Created attachment 8604 [details] required patch from master to cherry-pick the fix
Created attachment 8605 [details] patches cherry-picked from master
Metze, Does tsocket need a similar fix?
Comment on attachment 8605 [details] patches cherry-picked from master I think we should return the sendto() errno (EMSGSIZE) if setsockopt() fails.
(In reply to comment #3) > Metze, > > Does tsocket need a similar fix? I guess so
Created attachment 8606 [details] pathes for master to address metze's concerns and apply to tsocket_bsd Metze, I don't have a good way to test this (any ideas?) but this seems to be what is needed for both issues.
Created attachment 8607 [details] patches cherry-picked from master (2nd set) This patch is attachment 8606 [details] with the cherry-pick markers from master. Apply after the other patches.
Comment on attachment 8604 [details] required patch from master to cherry-pick the fix Looks good
Comment on attachment 8605 [details] patches cherry-picked from master Looks ok
Comment on attachment 8607 [details] patches cherry-picked from master (2nd set) Looks good
Pushed to autobuild-v4-0-test.
Pushed to autobuild-v4-0-test. Closing out bug report. Thanks!