Re: [Dovecot] listen=*, :: broken?

2010-08-05 Thread Phil Howard
On Wed, Aug 4, 2010 at 10:47, Peer Heinlein
p.heinlein+dove...@heinlein-support.de wrote:

 the default:

 listen = *, ::

 should work and should open port 143 on IPv4 and IPv6.

On Linux, listening to :: in IPv6 has the effect of listening also on
0.0.0.0 in IPv4, even though only a single socket is involved.

If the process binds a socket first to IPv4 then another socket to
IPv6, the IPv6 bind will fail with EADDRINUSE (Address already in
use).  At this point the process is listening to IPv4 but not IPv6.

If the process binds a socket first to IPv6 then another socket to
IPv4, the IPv4 bind will fail with the same error.  But the socket
bound to IPv6 will be listening also to IPv4 via 4-in-6.  IPv4 peers
can connect and will show a peer address like :::: or
:::xx.xx.xx.xx depending on how the address gets formatted.

On OpenBSD, this does not happen, and a process must bind a socket
separately for IPv6 and IPv4 to be able to listen in both address
spaces.

I don't know how other operating systems do it.  But it should be one
way or the other.

What a program doing such socket binding could (maybe should) do is
either understand what OS it is running on and act accordingly, or
just bind the IPv6 socket first and treat a failure to bind on IPv4 as
a soft error if the IPv6 succeeded.

So, if you are on Linux, just use listen = :: and test if you can
connect via the IPv4 address.  If so, you are good to go.  But, if you
are on OpenBSD, just use listen = * and test if you can connect via
the IPv6 interface address (you can use the IPv6 link-local address if
you connect from an IPv6 peer on the same LAN segment and specify the
outgoing interface index as part of the address).  On another OS, try
each way and use what works.

Or you can listen on your explicit interface addresses (not
:::: or ::.xx.xx.xx.xx) in each address space.

-- 
sHiFt HaPpEnS!


Re: [Dovecot] listen=*, :: broken?

2010-08-05 Thread Timo Sirainen
On Thu, 2010-08-05 at 09:44 -0400, Phil Howard wrote:

 On Linux, listening to :: in IPv6 has the effect of listening also on
 0.0.0.0 in IPv4, even though only a single socket is involved.

Not if you do this (and Dovecot does):

opt = 1;
setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, opt, sizeof(opt));




Re: [Dovecot] listen=*, :: broken?

2010-08-05 Thread Tom Hendrikx
On 05/08/10 15:44, Phil Howard wrote:
 On Wed, Aug 4, 2010 at 10:47, Peer Heinlein
 p.heinlein+dove...@heinlein-support.de wrote:
 
 the default:

 listen = *, ::

 should work and should open port 143 on IPv4 and IPv6.
 
 On Linux, listening to :: in IPv6 has the effect of listening also on
 0.0.0.0 in IPv4, even though only a single socket is involved.
 

Hi,

This is not true for my linux distro at least, which does not listen on
ipv4 interface when setting listen = [::] (in dovecot 1.2.13).

I need listen = *, [::] to enable support for both ipv4 and ipv6. This
sounds like some distro specific implementation/configuration, so saying
'On Linux' is not true.

FWIW: I run gentoo linux (in an openvz container).

--
Regards,
Tom


Re: [Dovecot] listen=*, :: broken?

2010-08-05 Thread Phil Howard
On Thu, Aug 5, 2010 at 09:56, Tom Hendrikx t...@whyscream.net wrote:

 This is not true for my linux distro at least, which does not listen on
 ipv4 interface when setting listen = [::] (in dovecot 1.2.13).

 I need listen = *, [::] to enable support for both ipv4 and ipv6. This
 sounds like some distro specific implementation/configuration, so saying
 'On Linux' is not true.

 FWIW: I run gentoo linux (in an openvz container).

Then I guess this is distribution specific.  Or maybe kernel version
specific.  The C library may also be influencing this.

So try all combinations and use what works.

-- 
sHiFt HaPpEnS!


[Dovecot] listen=*, :: broken?

2010-08-04 Thread Peer Heinlein

Hi,

the default:

listen = *, ::

should work and should open port 143 on IPv4 and IPv6.

In my setup it looks broken:

r...@mail-archiv:/etc/dovecot# doveconf  | grep ^listen
listen = *, ::
r...@mail-archiv:/etc/dovecot# /etc/init.d/dovecot restart
Restarting mail server: dovecotError: service(imap-login): listen(::, 
143) failed: Address already in use
Fatal: Failed to start listeners
r...@mail-archiv:/etc/dovecot# 


But it's working with listen = *:

r...@mail-archiv:/etc/dovecot# doveconf  | grep ^listen
listen = *
r...@mail-archiv:/etc/dovecot# /etc/init.d/dovecot restart
Restarting mail server: dovecot.
r...@mail-archiv:/etc/dovecot# 


Peer Heinlein



-- 

Heinlein Professional Linux Support GmbH
Linux: Akademie - Support - Hosting
http://www.heinlein-support.de

Tel: 030-405051-42
Fax: 030-405051-19

Zwangsangaben lt. §35a GmbHG:
HRB 93818 B / Amtsgericht Berlin-Charlottenburg, 
Geschäftsführer: Peer Heinlein  -- Sitz: Berlin



Re: [Dovecot] listen=*, :: broken?

2010-08-04 Thread Timo Sirainen
On Wed, 2010-08-04 at 16:47 +0200, Peer Heinlein wrote:
 Restarting mail server: dovecotError: service(imap-login): listen(::, 
 143) failed: Address already in use
..
 But it's working with listen = *:
 
 r...@mail-archiv:/etc/dovecot# doveconf  | grep ^listen
 listen = *
 r...@mail-archiv:/etc/dovecot# /etc/init.d/dovecot restart
 Restarting mail server: dovecot.

Does listen = * also make it listen on IPv6? Sounds like you've
enabled some IPv6 binds listen for IPv4 too feature. What OS is this?
Does compiling this program give the blah error on your system?

#include sys/socket.h
#include netinet/in.h
#include netdb.h
#include arpa/inet.h

#ifdef IPV6_V6ONLY
#  error blah
#endif




Re: [Dovecot] listen=*, :: broken?

2010-08-04 Thread Marcus Rueckert
On 2010-08-04 16:47:10 +0200, Peer Heinlein wrote:
 listen = *, ::

what os/distro? there is this ipv6-mapped-v4 stuff (:::), which
might cause trouble here.

 But it's working with listen = *:
 
 r...@mail-archiv:/etc/dovecot# doveconf  | grep ^listen
 listen = *

how does the netstat -tuplen | grep 143 look like with this?

darix

-- 
   openSUSE - SUSE Linux is my linux
   openSUSE is good for you
   www.opensuse.org