From leres@fun.ee.lbl.gov Tue Jun 22 23:05:53 1999
Return-Path: <leres@fun.ee.lbl.gov>
Received: from fun.ee.lbl.gov (fun.ee.lbl.gov [131.243.1.81])
	by hub.freebsd.org (Postfix) with ESMTP id 8F21514E46
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 22 Jun 1999 23:05:52 -0700 (PDT)
	(envelope-from leres@fun.ee.lbl.gov)
Received: (from leres@localhost)
	by fun.ee.lbl.gov (8.9.3/8.9.3) id XAA32639;
	Tue, 22 Jun 1999 23:05:50 -0700 (PDT)
Message-Id: <199906230605.XAA32639@fun.ee.lbl.gov>
Date: Tue, 22 Jun 1999 23:05:50 PDT
From: Craig Leres <leres@ee.lbl.gov>
Sender: leres@fun.ee.lbl.gov
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] allow route(8) to create "proxy only" arp entries
X-Send-Pr-Version: 3.2

>Number:         12357
>Category:       bin
>Synopsis:       [PATCH] allow route to create "proxy only" arp entries
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 22 23:10:00 PDT 1999
>Closed-Date:    Tue Jun 12 06:31:32 PDT 2001
>Last-Modified:  Tue Jun 12 06:35:37 PDT 2001
>Originator:     Craig Leres
>Release:        FreeBSD 3.2-RELEASE i386
>Organization:
Lawrence Berkeley National Laboratory
>Environment:

>Description:

	It would be really nice if route(8) could add the necessary
	magic to create "proxy only" arp entries.

	One might argue that arp(8) should do this by default
	however route(8) is much more powerful; for example, it
	already allows the user to specify the network interface.
	(One might argue futher that arp(8) could be replaced with
	a shell script that uses route to create entries and netstat
	to display them!)

>How-To-Repeat:

	Try to create a proxy arp entry using arp(8):

	  fun 212 # arp -s 131.243.1.120 0:a0:c9:b7:e3:3c pub
	  fun 213 # netstat -rn | egrep 131.243.1.120
	  131.243.1.120/32   0:a0:c9:b7:e3:3c   ULS2c       0        0     fxp0
	  fun 214 # arp 131.243.1.120
	  kitten.ee.lbl.gov (131.243.1.120) at 0:a0:c9:b7:e3:3c \
	      permanent published

	Notice that the routing table flags are wrong ('H' should
	be set but 'c' should not since this should be a host route
	but not a cloning route). Also notice that arp does not
	indicate "proxy only" in its listing of this entry.

	The example where this is buring me is a system that uses
	a pair of wavelans to do a point to point link. A subset
	of the real subnet is used at the far end of the link so
	we have a route like this:

	  131.243.1.112/28   131.243.1.102      UGSc        0        0      wl1

	Where 131.243.1/24 is the "real" subnet and 131.243.1.112/28
	is the subset subnet at the far end of the uwave link.
	But since arp(8) doesn't set the right flags, the arp entry
	is used to route packets back out the ethernet interface
	which results in lots of icmp redirects and a routing loop.

>Fix:
	
	Add a -proxy flag to route(8) and then we have:

	  fun 216 # route -n add -host 131.243.1.120 \
	      -link fxp0:0.a0.c9.b7.e3.3c -llinfo -proxy -iface
	  add host 131.243.1.120: gateway fxp0:0.a0.c9.b7.e3.3c
	  fun 217 # netstat -rn | egrep 131.243.1.120
	  131.243.1.120      0:a0:c9:b7:e3:3c   UHLS2       0        0     fxp0
	  fun 218 # arp 131.243.1.120
	  kitten.ee.lbl.gov (131.243.1.120) at 0:a0:c9:b7:e3:3c \
	      permanent published (proxy only)

	Notice that this arp/routing entry has the correct flags
	and also is designated as "proxy only" .

	Also note that the proxy arp code in the FreeBSD-current
	version of ppp(8) creates proxy arp entries that have the
	same flags and arp output as shown above.

	Context diffs are appended. However, any similar change to
	that allows RTF_ANNOUNCE (aka RTF_PROTO2) and SIN_PROXY to
	be set would be acceptable.

RCS file: RCS/route.c,v
retrieving revision 1.1
diff -c -r1.1 route.c
*** /tmp/,RCSt1X32288	Tue Jun 22 22:50:34 1999
--- route.c	Tue Jun 22 22:12:12 1999
***************
*** 55,60 ****
--- 55,61 ----
  #include <net/route.h>
  #include <net/if_dl.h>
  #include <netinet/in.h>
+ #include <netinet/if_ether.h>
  #include <netatalk/at.h>
  #ifdef NS
  #include <netns/ns.h>
***************
*** 88,93 ****
--- 89,95 ----
  	struct	sockaddr_ns sns;
  #endif
  	struct	sockaddr_dl sdl;
+ 	struct	sockaddr_inarp sia;
  } so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp;
  
  typedef union sockunion *sup;
***************
*** 505,511 ****
  	register char **argv;
  {
  	char *cmd, *dest = "", *gateway = "", *err;
! 	int ishost = 0, ret, attempts, oerrno, flags = RTF_STATIC;
  	int key;
  	struct hostent *hp = 0;
  
--- 507,513 ----
  	register char **argv;
  {
  	char *cmd, *dest = "", *gateway = "", *err;
! 	int ishost = 0, proxy = 0, ret, attempts, oerrno, flags = RTF_STATIC;
  	int key;
  	struct hostent *hp = 0;
  
***************
*** 571,576 ****
--- 573,581 ----
  			case K_PROTO2:
  				flags |= RTF_PROTO2;
  				break;
+ 			case K_PROXY:
+ 				++proxy;
+ 				break;
  			case K_CLONING:
  				flags |= RTF_CLONING;
  				break;
***************
*** 643,648 ****
--- 648,658 ----
  		flags |= RTF_HOST;
  	if (iflag == 0)
  		flags |= RTF_GATEWAY;
+ 	if (proxy) {
+ 		/* XXX probably only makes sense for RTF_HOST */
+ 		flags |= RTF_ANNOUNCE;		/* aka RTF_PROTO2 */
+ 		so_dst.sia.sin_other = SIN_PROXY;
+ 	}
  	for (attempts = 1; ; attempts++) {
  		errno = 0;
  		if ((ret = rtmsg(*cmd, flags)) == 0)
RCS file: RCS/keywords,v
retrieving revision 1.1
diff -c -r1.1 keywords
*** /tmp/,RCSt1h32293	Tue Jun 22 22:50:42 1999
--- keywords	Tue Jun 22 22:11:27 1999
***************
*** 33,38 ****
--- 33,39 ----
  osi
  proto1
  proto2
+ proxy
  recvpipe
  reject
  rtt
RCS file: RCS/route.8,v
retrieving revision 1.1
diff -c -r1.1 route.8
*** /tmp/,RCSt1p32298	Tue Jun 22 22:50:46 1999
--- route.8	Tue Jun 22 22:16:35 1999
***************
*** 32,38 ****
  .\"     @(#)route.8	8.3 (Berkeley) 3/19/94
  .\"	$Id: route.8,v 1.12.2.1 1999/05/04 18:41:32 ghelmer Exp $
  .\"
! .Dd March 19, 1994
  .Dt ROUTE 8
  .Os BSD 4.4
  .Sh NAME
--- 32,38 ----
  .\"     @(#)route.8	8.3 (Berkeley) 3/19/94
  .\"	$Id: route.8,v 1.12.2.1 1999/05/04 18:41:32 ghelmer Exp $
  .\"
! .Dd June 22, 1999
  .Dt ROUTE 8
  .Os BSD 4.4
  .Sh NAME
***************
*** 239,244 ****
--- 239,245 ----
  -blackhole RTF_BLACKHOLE  - silently discard pkts (during updates)
  -proto1    RTF_PROTO1     - set protocol specific routing flag #1
  -proto2    RTF_PROTO2     - set protocol specific routing flag #2
+ -proxy     RTF_ANNOUNCE   - respond to "proxy only" arp requests
  -llinfo    RTF_LLINFO     - validly translates proto addr to link addr
  .Ed
  .Pp

>Release-Note:
>Audit-Trail:

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  
Subject: bin/12357: [PATCH] allow route(8) to create "proxy only" arp entries
Date: Wed, 23 Jun 1999 11:15:40 -0400 (EDT)

 <<On Tue, 22 Jun 1999 23:05:50 PDT, Craig Leres <leres@ee.lbl.gov> said:
 
 > 	It would be really nice if route(8) could add the necessary
 > 	magic to create "proxy only" arp entries.
 
 As titular networking czar, I don't have a strong feeling about this
 patch, so if someone wants to apply it, that's fine with me.
 
 -GAWollman
 
 --
 Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
 wollman@lcs.mit.edu  | O Siem / The fires of freedom 
 Opinions not those of| Dance in the burning flame
 MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick
 

From: Pierre Beyssac <beyssac@enst.fr>
To: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>,
	freebsd-gnats-submit@FreeBSD.ORG, Craig <Leresleres@ee.lbl.gov>
Cc:  
Subject: Re: bin/12357: [PATCH] allow route(8) to create "proxy only" arp entries
Date: Fri, 25 Jun 1999 21:28:08 +0200

 On Wed, Jun 23, 1999 at 08:20:02AM -0700, Garrett Wollman wrote:
 >  As titular networking czar, I don't have a strong feeling about this
 >  patch, so if someone wants to apply it, that's fine with me.
 
 I'd like to commit it, but what about renaming the option -announce
 instead of -proxy, for consistency with the route flag name?
 
 Besides, it's a patch for 3.2 and this doesn't exactly qualify as
 a stability fix, should it be committed to the stable branch?
 -- 
 Pierre Beyssac		pb@enst.fr
 

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: Pierre Beyssac <beyssac@enst.fr>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/12357: [PATCH] allow route(8) to create "proxy only" arp entries
Date: Fri, 25 Jun 1999 15:30:05 -0400 (EDT)

 <<On Fri, 25 Jun 1999 21:28:08 +0200, Pierre Beyssac <beyssac@enst.fr> said:
 
 > I'd like to commit it, but what about renaming the option -announce
 > instead of -proxy, for consistency with the route flag name?
 
 Hmmm.  I'm not sure I like either name much....
 
 > Besides, it's a patch for 3.2 and this doesn't exactly qualify as
 > a stability fix, should it be committed to the stable branch?
 
 No.
 
 -GAWollman
 
 --
 Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
 wollman@lcs.mit.edu  | O Siem / The fires of freedom 
 Opinions not those of| Dance in the burning flame
 MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick
 

From: Craig Leres <leres@ee.lbl.gov>
To: Pierre Beyssac <beyssac@enst.fr>
Cc: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>,
	freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: [beyssac@enst.fr: Re: bin/12357: [PATCH] allow route(8) to create "
Date: Fri, 25 Jun 1999 13:00:15 PDT

 > I'd like to commit it, but what about renaming the option -announce
 > instead of -proxy, for consistency with the route flag name?
 
 Let me suggest adding -announce as a command line alias for -proto2
 (since RTF_ANNOUNCE and RTF_PROTO2 are the same bit) and then have
 -proxy do the SIN_PROXY (i.e. "proxy only") magic.
 
 The example would then be:
 
   fun 216 # route -n add -host 131.243.1.120 \
       -link fxp0:0.a0.c9.b7.e3.3c -llinfo -proxy -announce -iface
 
 or:
 
   fun 216 # route -n add -host 131.243.1.120 \
       -link fxp0:0.a0.c9.b7.e3.3c -llinfo -proxy -proto2 -iface
 
 		Craig
 
State-Changed-From-To: open->analyzed 
State-Changed-By: ru 
State-Changed-When: Thu Jun 7 05:38:23 PDT 2001 
State-Changed-Why:  
I have just fixed the arp(8) command so that it can create 
published proxy-only ARP entries irrespective of whether or 
not the route to a destination already exists. 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Thu Jun 7 05:38:23 PDT 2001 
Responsible-Changed-Why:  
But I think having a similar functionality in route(8) would 
also be great. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=12357 
State-Changed-From-To: analyzed->closed 
State-Changed-By: ru 
State-Changed-When: Tue Jun 12 06:31:32 PDT 2001 
State-Changed-Why:  
Committed, thanks! 

It's pity that you can't use the new -proxy modifier to 
provide a single cloning entry for a whole subnet, due 
to SIN_PROXY bit being reset by applying the netmask to 
the key (destination) when putting an entrey into the 
routing table. 

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