Subject: kern/17202: SIOCSIFADDR/IFDSTADDR on gre* interface destroys outer IP address setting
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 06/10/2002 11:52:52
>Number:         17202
>Category:       kern
>Synopsis:       SIOCSIFADDR/IFDSTADDR on gre* interface destroys outer IP address setting
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 09 19:54:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jun-ichiro itojun Hagino
>Release:        NetBSD 1.6A
>Organization:
	itojun
>Environment:
System: NetBSD starfruit.itojun.org 1.6A NetBSD 1.6A (STARFRUIT) #60: Mon Jun 10 02:00:55 JST 2002 itojun@starfruit.itojun.org:/usr/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386
Architecture: i386
Machine: i386
>Description:
	gre* interface uses addresses configured by SIOCSIFADDR/IFDSTADDR to
	be IPv4 outer address pair (set by SIOCS*PHYADDR).  SIOCSIFADDR/
	IFDSTADDR operation overwrites SIOCS*PHYADDR setting, and the behavior
	is not intuitive.
>How-To-Repeat:
	code inspection
>Fix:
	remove SIOCSIFADDR/IFDSTADDR handling code from sys/net/if_gre.c.
	issue - backward compatibility.

Index: if_gre.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if_gre.c,v
retrieving revision 1.35
diff -u -r1.35 if_gre.c
--- if_gre.c	2002/06/09 19:17:43	1.35
+++ if_gre.c	2002/06/10 02:53:09
@@ -356,26 +356,9 @@
 	s = splnet();
 	switch (cmd) {
 	case SIOCSIFADDR:
+		ifp->if_flags |= IFF_UP;
+		break;
 	case SIOCSIFDSTADDR: 
-		if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
-			break;
-		/*
-		 * set tunnel endpoints in case that we "only"
-		 * have ip over ip encapsulation. This allows to
-		 * set tunnel endpoints with ifconfig.
-		 */
-		if (ifa->ifa_addr->sa_family == AF_INET) {
-			sa = ifa->ifa_addr;
-			sc->g_src = (satosin(sa))->sin_addr;
-			sc->g_dst = ia->ia_dstaddr.sin_addr;
-			if ((sc->g_src.s_addr != INADDR_ANY) &&
-			    (sc->g_dst.s_addr != INADDR_ANY)) {
-				if (sc->route.ro_rt != 0) /* free old route */
-					RTFREE(sc->route.ro_rt);
-				if (gre_compute_route(sc) == 0)
-					ifp->if_flags |= IFF_UP;
-			}
-		}
 		break;
 	case SIOCSIFFLAGS:
 		if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
>Release-Note:
>Audit-Trail:
>Unformatted: