From forrestc@workhorse.imach.com  Tue Jan 14 03:27:49 2003
Return-Path: <forrestc@workhorse.imach.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 95AE037B401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 14 Jan 2003 03:27:49 -0800 (PST)
Received: from workhorse.imach.com (barbwire.iMach.com [206.127.77.82])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B3C0F43EB2
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 14 Jan 2003 03:27:48 -0800 (PST)
	(envelope-from forrestc@workhorse.imach.com)
Received: (from forrestc@localhost)
	by workhorse.imach.com (8.11.6/8.11.6) id h0EBRi092030;
	Tue, 14 Jan 2003 04:27:47 -0700 (MST)
	(envelope-from forrestc)
Message-Id: <200301141127.h0EBRi092030@workhorse.imach.com>
Date: Tue, 14 Jan 2003 04:27:47 -0700 (MST)
From: "Forrest W. Christian" <forrestc@imach.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: Sendmail "Can't assign requested addresses"

>Number:         47044
>Category:       bin
>Synopsis:       Sendmail "Can't assign requested addresses"
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    gshapiro
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 14 03:30:04 PST 2003
>Closed-Date:    Fri Jan 02 10:43:41 PST 2004
>Last-Modified:  Fri Jan 02 10:43:41 PST 2004
>Originator:     Forrest W. Chritian
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
Montana Internet Corporation
>Environment:
System: FreeBSD relay.mt.net 4.7-STABLE FreeBSD 4.7-STABLE #7: Tue Jan 14 18:45:13 GMT 2003 root@relay.mt.net:/usr/src/sys/compile/MAIL i386

This is on a multiprocessor box.  IPv6 has tried both compiled into the kernel, and not.  IPv6 has been both enabled and disabled in rc.conf.

>Description:

For some reason, the following code snippet from the daemon.c source file in /usr/src/contrib/sendmail/src results in a corrupted address in the clt_addr.sin.sin_addr.s_addr field on my system, along with clt_bind being set to true, which indicates the code *thinks* it got a valid address.


---------------
        clt_bind = false;

        /* Set up the address for outgoing connection. */
        if (bitnset(D_BINDIF, d_flags) &&
            (p = macvalue(macid("{if_addr}"), e)) != NULL &&
            *p != '\0')
        {
#if NETINET6
                char p6[INET6_ADDRSTRLEN];
#endif /* NETINET6 */

                memset(&clt_addr, '\0', sizeof clt_addr);

                /* infer the address family from the address itself */
                clt_addr.sa.sa_family = addr_family(p);
                switch (clt_addr.sa.sa_family)
                {
#if NETINET
                  case AF_INET:
                        clt_addr.sin.sin_addr.s_addr = inet_addr(p);
                        if (clt_addr.sin.sin_addr.s_addr != INADDR_NONE &&
                            clt_addr.sin.sin_addr.s_addr != INADDR_LOOPBACK)
                        {
                                clt_bind = true;
                                socksize = sizeof (struct sockaddr_in);
                        }
                        break;
#endif /* NETINET */

#if NETINET6
                  case AF_INET6:
                        if (inet_addr(p) != INADDR_NONE)
                                (void) sm_snprintf(p6, sizeof p6,
                                                   "IPv6:::ffff:%s", p);
                        else
                                (void) sm_strlcpy(p6, p, sizeof p6);
                        if (anynet_pton(AF_INET6, p6,
                                        &clt_addr.sin6.sin6_addr) == 1 &&
                            !IN6_IS_ADDR_LOOPBACK(&clt_addr.sin6.sin6_addr))
                        {
                                clt_bind = true;
                                socksize = sizeof (struct sockaddr_in6);
                        }
                        break;
#endif /* NETINET6 */

#if 0
                  default:
                        syserr("554 5.3.5 Address= option unsupported for family %d",
                               clt_addr.sa.sa_family);
                        break;
#endif /* 0 */
                }
                if (clt_bind)
                        family = clt_addr.sa.sa_family;
        }

-------------------

As stands, this results in sendmail failing when doing a queue run, getting errors like:

------------
relay# sendmail -v -qRmtha.org

Running /var/spool/mqueue/h0E9KMnX000089 (sequence 1 of 108)
<xxxxx@mtha.org>... Connecting to mail.mtha.org. via esmtp...
makeconnection: cannot bind socket [209.181.34.149]: Can't assign
requested address
<xxxx@mtha.org>... Connecting to mail.mt.net. via esmtp...
makeconnection: cannot bind socket [209.181.34.149]: Can't assign
requested address
<xxxx@mtha.org>... Deferred: Can't assign requested address

Running /var/spool/mqueue/h0E9KMnV000089 (sequence 2 of 108)
 <xxxx@mtha.org>... Deferred: Can't assign requested address
-------------

209.181.34.149 varies from run to run (although seems to be consistent for several runs in a row, then it changes).   209.181.34.149 is *not* any address here and is *not* associated with the domains in question.

On occasion the code works as designed.  I have also tried changing -DINET6 to -DINET in the sendmail makefile to verify that it isn't IPV6 code specific.  No changes.

I have worked around the issue by adding a clt_bind=0; statement at the end of the code snipplet above, which forces the next section of code to disregard the corrupted address and refill the fields.

>How-To-Repeat:

        Easily repeatable on my installation.  First time I've seen it.  System was originally
        running earlier (>6months old) copy of FreeBSD-Stable, and had same issues.  May just
        be a subtle configuration error.  Willing to work with appropriate FreeBSD/Sendmail
         team members to help reproduce or fix the problem.  I am unsure if this is a FreeBSD library bug or a sendmail bug, thus the freebsd-pr (as I'm more active in the FreeBSD community than the sendmail one).

>Fix:

        Unknown.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gshapiro 
Responsible-Changed-By: johan 
Responsible-Changed-When: Mon Feb 3 12:42:21 PST 2003 
Responsible-Changed-Why:  
Over to sendmail maintainer/guru. Might be config error. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47044 

From: Gregory Neil Shapiro <gshapiro@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, forrestc@imach.com
Cc:  
Subject: Re: bin/47044: Sendmail "Can't assign requested addresses"
Date: Sat, 8 Feb 2003 12:48:56 -0800

 This does sound like a configuration error.  Please send us your .mc file.
 Chances are you are setting either ClientPortOptions (CLIENT_OPTIONS()) or
 DaemonPortOptions' F= flag (DAEMON_OPTIONS(..., F=...)) improperly.
State-Changed-From-To: open->feedback 
State-Changed-By: gshapiro 
State-Changed-When: Sat Feb 8 14:55:16 PST 2003 
State-Changed-Why:  
Waiting for configuration file from submitter. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47044 

From: "Forrest W. Christian" <forrestc@imach.com>
To: Gregory Neil Shapiro <gshapiro@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/47044: Sendmail "Can't assign requested addresses"
Date: Sun, 9 Feb 2003 14:10:39 -0700 (MST)

 On Sat, 8 Feb 2003, Gregory Neil Shapiro wrote:
 
 > This does sound like a configuration error.  Please send us your .mc file.
 > Chances are you are setting either ClientPortOptions (CLIENT_OPTIONS()) or
 > DaemonPortOptions' F= flag (DAEMON_OPTIONS(..., F=...)) improperly.
 
 I was thinking more on the "other side" meaning something subtle with a
 hostname/dns issue.  I've attached the mc file currently in use.
 
 .mc file follows:
 
 --------------------
 divert(0)
 VERSIONID(`$FreeBSD: src/etc/sendmail/freebsd.mc,v 1.10.2.17 2002/11/14
 03:21:18 keramida Exp $')
 OSTYPE(freebsd4)
 DOMAIN(generic)
 
 FEATURE(access_db, `hash -o -T<TMPF> /etc/mail/access')
 FEATURE(blacklist_recipients)
 FEATURE(local_lmtp)
 FEATURE(mailertable, `hash -o /etc/mail/mailertable')
 FEATURE(virtusertable, `hash -o /etc/mail/virtusertable')
 
 dnl Uncomment to allow relaying based on your MX records.
 dnl NOTE: This can allow sites to use your server as a backup MX without
 dnl       your permission.
 dnl FEATURE(relay_based_on_MX)
 
 dnl DNS based black hole lists
 dnl --------------------------------
 dnl DNS based black hole lists come and go on a regular basis
 dnl so this file will not serve as a database of the available servers.
 dnl For that, visit
 dnl
 http://directory.google.com/Top/Computers/Internet/Abuse/Spam/Blacklists/
 
 dnl Uncomment to activate Realtime Blackhole List
 dnl information available at http://www.mail-abuse.com/
 dnl NOTE: This is a subscription service as of July 31, 2001
 dnl FEATURE(dnsbl)
 dnl Alternatively, you can provide your own server and rejection message:
 dnl FEATURE(dnsbl, `blackholes.mail-abuse.org', `"550 Mail from "
 $&{client_addr} " rejected, see http://mail-a
 buse.org/cgi-bin/lookup?" $&{client_addr}')
 
 dnl Dialup users should uncomment and define this appropriately
 dnl define(`SMART_HOST', `your.isp.mail.server')
 
 dnl Uncomment the first line to change the location of the default
 dnl /etc/mail/local-host-names and comment out the second line.
 dnl define(`confCW_FILE', `-o /etc/mail/sendmail.cw')
 define(`confCW_FILE', `-o /etc/mail/local-host-names')
 
 dnl Uncomment both of the following lines to listen on IPv6 as well as
 IPv4
 dnl DAEMON_OPTIONS(`Name=IPv4, Family=inet')
 dnl DAEMON_OPTIONS(`Name=IPv6, Family=inet6')
 
 define(`confBIND_OPTS', `WorkAroundBrokenAAAA')
 define(`confMAX_MIME_HEADER_LENGTH', `256/128')
 define(`confNO_RCPT_ACTION', `add-to-undisclosed')
 define(`confPRIVACY_FLAGS', `authwarnings,noexpn,novrfy')
 define(`confDOUBLE_BOUNCE_ADDRESS', `')
 define(`confMIN_QUEUE_AGE', `15m')dnl
 define(`confQUEUE_SORT_ORDER',`host')dnl
 dnl define(`confSEPARATE_PROC',`true')
 MAILER(local)
 MAILER(smtp)
 -----------------------
 
State-Changed-From-To: feedback->closed 
State-Changed-By: gshapiro 
State-Changed-When: Fri Jan 2 10:41:57 PST 2004 
State-Changed-Why:  
The issue is no longer a problem for the submitter and couldn't be 
reproduced on other machines.  If it happens again, the PR can be 
reopened. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47044 
>Unformatted:
 Sendmail "Can't assign requested addresses"
 From: Forrest W. Christian <forrestc@imach.com>
 Reply-To: Forrest W. Christian <forrestc@imach.com>
 Cc: 
 X-send-pr-version: 3.113
 X-GNATS-Notify: 
 
 
