Bug 9618 - dcerpc_pipe_connect() fails if one of multiple addresses is not reachable
Summary: dcerpc_pipe_connect() fails if one of multiple addresses is not reachable
Status: ASSIGNED
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: DCE-RPCs and pipes (show other bugs)
Version: 4.0.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Stefan Metzmacher
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on: 11284
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-30 11:11 UTC by Sumit Bose
Modified: 2015-07-31 08:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sumit Bose 2013-01-30 11:11:46 UTC
The following python script

----------------------------------------------------------------
from samba.dcerpc import lsa

try:
    result = lsa.lsarpc('ncacn_np:fqdn.of.ad.dc[,]', None, None)
except RuntimeError, (num, message):
    print '%d %s\n' % (num, message)
----------------------------------------------------------------

or "smbtorture 'ncacn_np:qdn.of.ad.dc' rpc.spoolss.access" fail in dcerpc_pipe_connect() if both the IPv4 (A record) and IPv6 (AAAA record) addresses are returned by the DNS server for fqdn.of.ad.dc but the host is not reachable via IPv6, e.g. because of some network components not able to handle IPv6 in the path.

With strace I see

-----------------------------------------------------
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4
fcntl64(4, F_GETFD)                     = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
fcntl64(4, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
connect(4, {sa_family=AF_INET, sin_port=htons(445), sin_addr=inet_addr("192.168.201.118")}, 16) = -1 EINPROGRESS (Operation now in progress)
epoll_ctl(3, EPOLL_CTL_ADD, 4, {...})   = 0
gettimeofday({1359370069, 674788}, NULL) = 0
gettimeofday({1359370069, 674946}, NULL) = 0
epoll_wait(3, {}, 1, 2)                 = 0
gettimeofday({1359370069, 677161}, NULL) = 0
socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 5
fcntl64(5, F_GETFD)                     = 0
fcntl64(5, F_SETFD, FD_CLOEXEC)         = 0
fcntl64(5, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(5, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
connect(5, {sa_family=AF_INET6, sin6_port=htons(445), inet_pton(AF_INET6, "2430:54:0:4359:c581:513b:d49c:c4bf", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 ENETUNREACH (Network is unreachable)
gettimeofday({1359370069, 678233}, NULL) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 4, {...})   = 0
close(4)                                = 0
setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
dup(5)                                  = 4
getsockname(5, {sa_family=AF_INET6, sin6_port=htons(0), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0
getpeername(5, 0x8808e30, [128])        = -1 ENOTCONN (Transport endpoint is not connected)
close(4)                                = 0
close(5)                                = 0
close(3)                                = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb771e000
write(1, "-1073741801 Memory allocation er"..., 36-1073741801 Memory allocation error
) = 36
write(1, "\n", 1
)                       = 1
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x4effd570, [], 0}, 8) = 0
exit_group(0)                           = ?
+++ exited with 0 +++
-----------------------------------------------------

I guess dcerpc_pipe_connect() tries to open connections to all available addresses to avoid timeouts trying one after the other. But instead of failing until all connection attempts fail, it fails on the first failure.

Additionally, although connect() returned ENETUNREACH the related file descriptor is still used later on.
Comment 1 Andreas Schneider 2013-01-30 13:11:07 UTC
Metze can you please take a look?
Comment 2 Karolin Seeger 2013-12-10 15:46:50 UTC
Any news on this one?