From eugen@grosbein.pp.ru  Wed May  7 08:55:16 2003
Return-Path: <eugen@grosbein.pp.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 70A5C37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  7 May 2003 08:55:16 -0700 (PDT)
Received: from grosbein.pp.ru (D00015.dialonly.kemerovo.su [213.184.66.105])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2CF1C43FA3
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  7 May 2003 08:55:13 -0700 (PDT)
	(envelope-from eugen@grosbein.pp.ru)
Received: from grosbein.pp.ru (smmsp@localhost [127.0.0.1])
	by grosbein.pp.ru (8.12.9/8.12.7) with ESMTP id h47Ft48p003689
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 7 May 2003 23:55:04 +0800 (KRAST)
	(envelope-from eugen@grosbein.pp.ru)
Received: (from eugen@localhost)
	by grosbein.pp.ru (8.12.9/8.12.9/Submit) id h47Ffm0n003484;
	Wed, 7 May 2003 23:41:48 +0800 (KRAST)
Message-Id: <200305071541.h47Ffm0n003484@grosbein.pp.ru>
Date: Wed, 7 May 2003 23:41:48 +0800 (KRAST)
From: Eugene Grosbein <eugen@grosbein.pp.ru>
Reply-To: Eugene Grosbein <eugen@grosbein.pp.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: routed(8) fails to use multicast with IFF_POINTOPOINT interfaces
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         51927
>Category:       bin
>Synopsis:       routed(8) fails to use multicast with IFF_POINTOPOINT interfaces
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 07 09:00:20 PDT 2003
>Closed-Date:    Tue Nov 02 07:10:43 GMT 2004
>Last-Modified:  Tue Nov 02 07:10:43 GMT 2004
>Originator:     Eugene Grosbein
>Release:        FreeBSD 4.8-STABLE i386
>Organization:
Svyaz Service JSC
>Environment:
System: FreeBSD grosbein.pp.ru 4.8-STABLE FreeBSD 4.8-STABLE #0: Sat Apr 26 00:03:18 KRAST 2003 eu@grosbein.pp.ru:/usr/local/obj/usr/local/src/sys/DADV i386

>Description:
	'routed -s' passes remote address of IFF_POINTOPOINT interface
	into setsockopt(rip_sock,IPPROTO_IP, IP_ADD_MEMBERSHIP,&m, sizeof(m)),
	see rip_mcast_on() in the src/sbin/routed/main.c

	A kernel uses a macro INADDR_TO_IFP (see netinet/in_var.h)
	to find an interface that is unable to find it using remote IP.

>How-To-Repeat:
	run 'routed -s' when one on more PPP interfaces 
	(f.e. ppp(4), gif(4)) are up and running.
	You will get error message one time for each of PPP interfaces:

setsockopt(IP_ADD_MEMBERSHIP RIP): Can't assign requested address

>Fix:

	Either change the macro INADDR_TO_IFP, or teach routed(8)
	to pass source IP of the interface. I tried the latter,
	it works for me.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: bms 
State-Changed-When: Tue 25 Nov 2003 16:00:54 PST 
State-Changed-Why:  
I'll take this (network junta macrophage) 


Responsible-Changed-From-To: freebsd-bugs->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Tue 25 Nov 2003 16:00:54 PST 
Responsible-Changed-Why:  
Oop, meant to switch these log messages round. 

Eugene can you supply the patch you used to do this? I think this is 
a reasonable fix -- routed should ask for membership explicitly on the 
interface concerned. 

Have you raised this with the rhyolite.com guys? 

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

From: Eugene Grosbein <eugen@kuzbass.ru>
To: bug-followup@freebsd.org
Cc: bms@freebsd.org
Subject: Re: bin/51927: routed(8) fails to use multicast with IFF_POINTOPOINT 
 interfaces
Date: Thu, 08 Jan 2004 18:06:39 +0700

 Hi!
 
 > Eugene can you supply the patch you used to do this? I think this is 
 >      a reasonable fix -- routed should ask for membership explicitly on the 
 >      interface concerned. 
 
 Hmm, now I think that would not be wise. I think about the case
 when there are several "unnumbered" POINTOPOINT interfaces
 that share the same local IP with, say, ethernet interface (arp proxy).
 
 So routed does the right thing here and FreeBSD kernel does not,
 it cannot locate IFF_POINTOPOINT interface using its remote IP.
 
 Eugene

From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: bug-followup@freebsd.org
Cc: net@freebsd.org, bms@freebsd.org, ru@freebsd.org
Subject: Re: bin/51927: routed(8) fails to use multicast with IFF_POINTOPOINT interfaces
Date: Mon, 17 May 2004 00:36:29 +0800

 Reply-To: 
 
 Hi!
 
 ip(4) man page says that IP_MULTICAST_IF, IP_ADD_MEMBERSHIP etc.
 must use local IP address of desired interface. There are (at least)
 two undersirable consequents:
 
 1) It is hard (if not impossible) to distinguish between "unnumbered"
 IFF_POINTOPOINT interfaces, those share the same local IP address with
 an ethernet interface (think of pppd and proxyarp).
 2) routed, zebra and quagga cannot currently use outgoing RIPv2 multicasts
 with IFF_POINTOPOINT interfaces (ppp, gif etc.) at least in 4-STABLE.
 
 There was an attempt to fix this by modifying INADDR_TO_IFP:
 http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netinet/in_var.h#rev1.7
 
 It was unsuccessful and Ruslan undid it:
 http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netinet/in_var.h#rev1.39
 
 However, we still need working RIPv2:
 http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/51927
 
 Presently there are only two consumers of INADDR_TO_IFP in a 4.x kernel:
 ipfw[2] and ip_multicast_if() in src/sys/netinet/ip_output.h,
 the latter is exactly what prevents routed and ripd to enable
 multicasts on IFF_POINTOPOINT.
 
 Another attempt to fix that is presented. The next patch introduces another
 macro INADDR_TO_IFP_P2P that is used by ip_multicast_if() when INADDR_TO_IFP
 does not find ifp.
 
 --- in_var.h.orig	Sat Dec 15 03:09:34 2001
 +++ in_var.h	Sun May 16 23:51:14 2004
 @@ -117,6 +117,20 @@
  	(ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
  }
  
 +#define INADDR_TO_IFP_P2P(addr, ifp) \
 +	/* struct in_addr addr; */ \
 +	/* struct ifnet *ifp; */ \
 +{ \
 +	struct in_ifaddr *ia; \
 +\
 +	TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) \
 +		if ((ia->ia_ifp->if_flags & IFF_POINTOPOINT) && \
 +		    IA_DSTSIN(ia)->sin_addr.s_addr == (addr).s_addr) { \
 +				break; \
 +		} \
 +	(ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
 +}
 +
  /*
   * Macro for finding the internet address structure (in_ifaddr) corresponding
   * to a given interface (ifnet structure).
 --- sys/netinet/ip_output.c.orig	Fri May 14 18:51:35 2004
 +++ sys/netinet/ip_output.c	Fri May 14 20:40:49 2004
 @@ -1785,6 +1785,9 @@
  			*ifindexp = ifindex;
  	} else {
  		INADDR_TO_IFP(*a, ifp);
 +		if (ifp == NULL) {
 +			INADDR_TO_IFP_P2P(*a, ifp);
 +		}
  	}
  	return ifp;
  }
 
 
 I think this can be improved by introducing another hash for remote IPs
 of IFF_POINTOPOINT intefaces (similar to in_ifaddrhashtbl) to avoid
 linear search but leave that for later stage.
 
 Eugene Grosbein
State-Changed-From-To: feedback->patched 
State-Changed-By: bms 
State-Changed-When: Wed Jun 16 05:09:01 GMT 2004 
State-Changed-Why:  
We support RFC 1724's 0/8 IP_ADD_MEMBERSHIP logic; this behaviour has 
been turned on in the -CURRENT build for routed. 
This should solve the issue. 

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

From: Eugene Grosbein <eugen@kuzbass.ru>
To: Bruce M Simpson <bms@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/51927: routed(8) fails to use multicast with IFF_POINTOPOINT 
 interfaces
Date: Wed, 16 Jun 2004 14:53:02 +0800

 Bruce M Simpson wrote:
 
 > We support RFC 1724's 0/8 IP_ADD_MEMBERSHIP logic; this behaviour has
 > been turned on in the -CURRENT build for routed.
 > This should solve the issue.
 
 Will it work for zebra too?

From: Bruce M Simpson <bms@spc.org>
To: Eugene Grosbein <eugen@kuzbass.ru>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/51927: routed(8) fails to use multicast with IFF_POINTOPOINT interfaces
Date: Wed, 16 Jun 2004 08:02:36 +0100

 On Wed, Jun 16, 2004 at 02:53:02PM +0800, Eugene Grosbein wrote:
 > > We support RFC 1724's 0/8 IP_ADD_MEMBERSHIP logic; this behaviour has
 > > been turned on in the -CURRENT build for routed.
 > > This should solve the issue.
 > 
 > Will it work for zebra too?
 
 No idea. I've notified the Quagga and XORP teams about this change. The
 kernel support has been lying in the tree for years, as part of a KAME
 merge, and wasn't documented!!
 
 BMS

From: Eugene Grosbein <eugen@kuzbass.ru>
To: Bruce M Simpson <bms@spc.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/51927: routed(8) fails to use multicast with IFF_POINTOPOINT 
 interfaces
Date: Wed, 16 Jun 2004 15:17:08 +0800

 Bruce M Simpson wrote:
 
 > > Will it work for zebra too?
 > 
 > No idea. I've notified the Quagga and XORP teams about this change. The
 > kernel support has been lying in the tree for years, as part of a KAME
 > merge, and wasn't documented!!
 
 It is possible to distinguish "unnumbered" IFF_POINTOPOINT interfaces
 using "0/8 IP_ADD_MEMBERSHIP logic"? I mean, to enable RIPv2 multicast
 for one of several P2P interfaces only when they share the same local IP?
 
 Eugene

From: Bruce M Simpson <bms@spc.org>
To: Eugene Grosbein <eugen@kuzbass.ru>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/51927: routed(8) fails to use multicast with IFF_POINTOPOINT interfaces
Date: Wed, 16 Jun 2004 08:19:26 +0100

 On Wed, Jun 16, 2004 at 03:17:08PM +0800, Eugene Grosbein wrote:
 > It is possible to distinguish "unnumbered" IFF_POINTOPOINT interfaces
 > using "0/8 IP_ADD_MEMBERSHIP logic"? I mean, to enable RIPv2 multicast
 > for one of several P2P interfaces only when they share the same local IP?
 
 Correct, in theory - the RFC 1724 hack (which NetBSD also picked up) does
 not use a locally configured IP address to distinguish between the
 interfaces. It uses their index.
 
 regards,
 BMS
State-Changed-From-To: patched->closed 
State-Changed-By: bms 
State-Changed-When: Tue Nov 2 07:09:18 GMT 2004 
State-Changed-Why:  
This is a routed(8) problem. 
RELENG_5 has now been branched as -STABLE. 
No current plans to merge this to RELENG_4. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51927 
>Unformatted:
