RE: [exim] SMTP Transport: Try different interfaces

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Philip Hazel
Fecha:  
A: Jan-Peter Koopmann
Cc: exim-users
Asunto: RE: [exim] SMTP Transport: Try different interfaces
On Wed, 19 Jan 2005, Jan-Peter Koopmann wrote:

> On Wednesday, January 19, 2005 9:56 PM Philip Hazel wrote:
>
> > I haven't looked at the code in connection with this yet. However,
> > the "interface" parameter is already a list. Exim uses the first item
> > that is of the correct type (IPv4 or IPv6). So you don't need to add
> > a new parameter, just modify the code to try the next interface in
> > the list.
>
> I thought about this already and this would be the preferred solution. I
> did not understand the meaning of having multiple interface-entries in
> this list in the first place. So is it ok for you to change the
> behaviour? If so, we will have a look at the code.


The reason for having multiple interfaces is so that you can list an
IPv4 and an IPv6 interface. If the remote address is IPv4 it will use
the IPv4 one; if the remote address is IPv6 it will use the IPv6 one.
Of course, as has been pointed out, the "interface" parameter is
expanded, so that provides another way of switching interfaces.

Of course it's OK for you to change the code - this is GPL software. :-)

I have taken a quick look at the code. As I suspected, it doesn't look
too easy to change the code in transports/smtp.c because of the way it
is written. It would involve introducing a new loop round an already
complicated piece of code (the interface that is chosen affects the key
that is used for retry data). This may be why I have never got round to
implementing this item from the Exim 3 Wish List:

------------------------------------------------------------------------------
(114) 11-Nov-1999 S List of possible outgoing interfaces

Allow the smtp "interface" option to be a list: try them in turn until one
is found to work. Also allow masks to specify a range of addresses.          
------------------------------------------------------------------------------


I suspect the only sensible way of implementing this would be to
abstract out some of the existing code into a new subroutine.

Another approach might be to do the work in the function called
smtp_get_interface(), which is in the smtp_out.c module. This is the
function that scans the list and chooses the IPv4 or IPv6 interface, as
required. You could make it test the interface before accepting it. On
the other hand, if your test consists of making a connection to the
remote host, that is wasteful, so it may not be a very good solution
after all.

The smgp_get_interface() function is also called from the callout code;
one of these days that code and the smtp transport code need to be made
more alike (perhaps use a common set of subroutines) so that callouts
can use AUTH, TLS, LMTP etc. (Exim 4 wish list item 294). The
smtp_get_interface() function is one very small first step on that road.

You can obviously hack in any changes that solve your problem, but
anything that goes into the primary source code must bear all these
things in mind.

-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book