From nobody@FreeBSD.org  Fri Jun 22 22:38:56 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 6360037B401
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 22 Jun 2001 22:38:56 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.3/8.11.3) id f5N5cuH35571;
	Fri, 22 Jun 2001 22:38:56 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200106230538.f5N5cuH35571@freefall.freebsd.org>
Date: Fri, 22 Jun 2001 22:38:56 -0700 (PDT)
From: "David W. Chapman Jr." <dwcjr@inethouston.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /sbin/route bug
X-Send-Pr-Version: www-1.0

>Number:         28360
>Category:       kern
>Synopsis:       /sbin/route bug
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 22 22:40:01 PDT 2001
>Closed-Date:    Wed Oct 17 10:49:39 PDT 2001
>Last-Modified:  Wed Oct 17 11:09:12 PDT 2001
>Originator:     David W. Chapman Jr.
>Release:        4.3-stable
>Organization:
Raintree Network Services
>Environment:
FreeBSD leviathan.inethouston.net 4.3-STABLE FreeBSD 4.3-STABLE #6: Fri Jun 22 23:51:39 CDT 2001     root@leviathan.inethouston.net:/stripe1/compile/obj/stripe1/compile/src/sys/LEVIATHAN  i386
>Description:
BACKGROUND:
    2 nics, one wan and one lan
    wan has 66.64.6.25/26 to get to default gateway and 66.64.12.249/32
    lan has 66.64.12.248/29 and 192.168.0.0/24

I want internet traffic to come from source ip 66.64.12.249 when using internet from router.

>How-To-Repeat:
route add default 66.64.6.1 -ifa 66.64.12.249
>Fix:
temp workaround:

route add default 66.64.6.1
route change default -ipa 66.64.12.249
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Sat Jun 23 01:26:13 PDT 2001 
Responsible-Changed-Why:  
Will look into this next week. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28360 

From: Ruslan Ermilov <ru@FreeBSD.org>
To: "David W. Chapman Jr." <dwcjr@FreeBSD.org>
Cc: bug-followup@FreeBSD.org, net@FreeBSD.org
Subject: Re: misc/28360: /sbin/route bug
Date: Sat, 23 Jun 2001 14:44:06 +0300

 On Fri, Jun 22, 2001 at 10:38:56PM -0700, David W. Chapman Jr. wrote:
 > 
 > I want internet traffic to come from source ip 66.64.12.249 when
 > using internet from router.
 > 
 > >How-To-Repeat:
 > route add default 66.64.6.1 -ifa 66.64.12.249
 > >Fix:
 > temp workaround:
 > 
 > route add default 66.64.6.1
 > route change default -ifa 66.64.12.249
 > 
 This isn't a bug in the route(8) command.  Kernel routing code
 (in rtsock.c) checks for -ifa address only when processing the
 RTM_CHANGE command.  Look here (from the route(8) manpage):
 
 : In a change or add command where the destination and gateway
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 : are not sufficient to specify the route (as in the ISO case
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 : where several interfaces may have the same address), the -ifp
 : or -ifa modifiers may be used to determine the interface or
 : interface address.
 
 But I agree that having such a functionality in `route add'
 would be useful too.  The following patch duplicates some code
 from RTM_CHANGE.  Please test.  (The `ifp' part should probably
 be duplicated too.)
 
 Index: rtsock.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/net/rtsock.c,v
 retrieving revision 1.44.2.2
 diff -u -p -r1.44.2.2 rtsock.c
 --- rtsock.c	2000/08/03 00:09:34	1.44.2.2
 +++ rtsock.c	2001/06/23 11:35:38
 @@ -282,7 +282,7 @@ route_output(m, so)
  	struct rt_addrinfo info;
  	int len, error = 0;
  	struct ifnet *ifp = 0;
 -	struct ifaddr *ifa = 0;
 +	struct ifaddr *ifa = 0, *oifa;
  
  #define senderr(e) { error = e; goto flush;}
  	if (m == 0 || ((m->m_len < sizeof(long)) &&
 @@ -332,6 +332,18 @@ route_output(m, so)
  		error = rtrequest(RTM_ADD, dst, gate, netmask,
  					rtm->rtm_flags, &saved_nrt);
  		if (error == 0 && saved_nrt) {
 +			if (ifaaddr && (ifa = ifa_ifwithaddr(ifaaddr))) {
 +				oifa = saved_nrt->rt_ifa;
 +				if (oifa != ifa) {
 +					if (oifa && oifa->ifa_rtrequest)
 +						oifa->ifa_rtrequest(RTM_DELETE,
 +						    saved_nrt, gate);
 +					IFAFREE(saved_nrt->rt_ifa);
 +					saved_nrt->rt_ifa = ifa;
 +					ifa->ifa_refcnt++;
 +					saved_nrt->rt_ifp = ifa->ifa_ifp;
 +				}
 +			}
  			rt_setmetrics(rtm->rtm_inits,
  				&rtm->rtm_rmx, &saved_nrt->rt_rmx);
  			saved_nrt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits);
 @@ -424,7 +436,7 @@ route_output(m, so)
  							rt_key(rt), gate))))
  				ifp = ifa->ifa_ifp;
  			if (ifa) {
 -				register struct ifaddr *oifa = rt->rt_ifa;
 +				oifa = rt->rt_ifa;
  				if (oifa != ifa) {
  				    if (oifa && oifa->ifa_rtrequest)
  					oifa->ifa_rtrequest(RTM_DELETE,
 
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age

From: "David W. Chapman Jr." <dwcjr@inethouston.net>
To: <FreeBSD-gnats-submit@freebsd.org>, <dwcjr@FreeBSD.org>,
	"Ruslan Ermilov" <ru@FreeBSD.org>
Cc:  
Subject: Re: misc/28360: /sbin/route bug
Date: Fri, 6 Jul 2001 15:06:02 -0500

 I must have misplaced my reply.  This patch works great!
 
 

From: "David W. Chapman Jr." <dwcjr@inethouston.net>
To: freebsd-gnats-submit@FreeBSD.org, dwcjr@inethouston.net,
	ru@freebsd.org
Cc:  
Subject: Re: misc/28360: /sbin/route bug
Date: Sun, 23 Sep 2001 13:00:33 -0500

 I forget, what is the reason this hasn't been in -current yet?
 

From: Ruslan Ermilov <ru@FreeBSD.org>
To: "David W. Chapman Jr." <dwcjr@inethouston.net>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/28360: /sbin/route bug
Date: Mon, 24 Sep 2001 12:36:47 +0300

 On Sun, Sep 23, 2001 at 01:00:33PM -0500, David W. Chapman Jr. wrote:
 > I forget, what is the reason this hasn't been in -current yet?
 > 
 NetBSD has a more generic solution to this problem, which also
 allows the -ifp to be specified with RTM_ADD.  This is very
 useful in the IPv6 case.
 
 This requires some substantial changes to sys/net/rtsock.c, and
 I haven't yet found the time to do it.
 
 Sorry for the delay, but please be patient.
 
 
 Thanks,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Wed Oct 17 10:49:39 PDT 2001 
State-Changed-Why:  
Fixed in 5.0-CURRENT, sys/net/rtsock.c,v 1.61. 
MFC after 1 month. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28360 
>Unformatted:
