From sam@infres.enst.fr  Wed Mar 22 09:35:46 2000
Return-Path: <sam@infres.enst.fr>
Received: from ada.eu.org (marvin.enst.fr [137.194.161.2])
	by hub.freebsd.org (Postfix) with ESMTP id 80F5B37B99A
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 Mar 2000 09:35:38 -0800 (PST)
	(envelope-from sam@infres.enst.fr)
Received: from antinea.enst.fr (antinea.enst.fr [137.194.160.145])
	by ada.eu.org (Postfix) with ESMTP id AC0C71907E
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 Mar 2000 18:35:33 +0100 (CET)
Received: by antinea.enst.fr (Postfix, from userid 1000)
	id 6FE491E3; Wed, 22 Mar 2000 18:13:51 +0100 (CET)
Message-Id: <20000322171351.6FE491E3@antinea.enst.fr>
Date: Wed, 22 Mar 2000 18:13:51 +0100 (CET)
From: sam@enst.fr
Sender: sam@infres.enst.fr
Reply-To: sam@enst.fr
To: FreeBSD-gnats-submit@freebsd.org
Subject: Documentation error in divert(4)
X-Send-Pr-Version: 3.2

>Number:         17552
>Category:       docs
>Synopsis:       Documentation error in divert(4)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 22 09:40:01 PST 2000
>Closed-Date:    Tue May 2 17:24:59 PDT 2000
>Last-Modified:  Tue May  2 19:16:57 PDT 2000
>Originator:     Samuel Tardieu
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
TELECOM Paris
>Environment:
>Description:

When developing an toy application using divert(4), I was surprised to see
that it was working only if the PF_INET/SOCK_RAW/IPPROTO_DIVERT socket,
at bind() time, has a *valid* interface address (such as INADDR_ANY).

divert(4) manpage says:

                                                                   The IP ad-
     dress in the bind is ignored; only the port number is significant.  A di-
     vert socket bound to a divert port will receive all packets diverted to
     that port by some (here unspecified) kernel mechanism(s).

This is false, as the bind() operation for a divert socket will call
in_pcbbind() which makes use of the interface address.

>How-To-Repeat:

Build a PF_INET/SOCK_RAW/IPPROTO_DIVERT socket, bind it with a sockaddr_in
structure which has an invalid sin_addr field. Diverted packets will not be
available on the socket and will be silently dropped by the kernel as if
no diverted socket was listening.

>Fix:

Two possible immediate fixes:

  (1) Doc fix: change divert(4) manpage

  (2) Code fix: when entering div_bind, change the nam->sin_addr field
      if nam->sin_family is AF_INET so that it contains INADDR_ANY. It may
      break things that would depend on the fact that a diverted socket
      can be bound to a particular interface though (natd does use
      INADDR_ANY explicitely).

>Release-Note:
>Audit-Trail:

From: Nik Clayton <nik@freebsd.org>
To: sam@enst.fr
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: docs/17552: Documentation error in divert(4)
Date: Sun, 30 Apr 2000 15:39:40 +0100

 On Wed, Mar 22, 2000 at 06:13:51PM +0100, sam@enst.fr wrote:
 > >Fix:
 > 
 > Two possible immediate fixes:
 > 
 >   (1) Doc fix: change divert(4) manpage
 > 
 >   (2) Code fix: when entering div_bind, change the nam->sin_addr field
 >       if nam->sin_family is AF_INET so that it contains INADDR_ANY. It may
 >       break things that would depend on the fact that a diverted socket
 >       can be bound to a particular interface though (natd does use
 >       INADDR_ANY explicitely).
 
 According to Brian and Paul (who are sat next to me on the train back
 from a UK Newcastle meet) this really needs a code change rather than a
 doc change.  So I'm following up to this in order to remind me to 
 reassign this PR to the appropriate people when I get IP connectivity
 back. . .
 
 N
 -- 
 Internet connection, $19.95 a month.  Computer, $799.95.  Modem, $149.95.
 Telephone line, $24.95 a month.  Software, free.  USENET transmission,
 hundreds if not thousands of dollars.  Thinking before posting, priceless.
 Somethings in life you can't buy.  For everything else, there's MasterCard.
   -- Graham Reed, in the Scary Devil Monastery
 
State-Changed-From-To: open->closed 
State-Changed-By: paul 
State-Changed-When: Tue May 2 17:24:59 PDT 2000 
State-Changed-Why:  
The problem was a code error which has now been fixed. 
>Unformatted:
