Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Sep 2015 05:59:40 +0000 (UTC)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r287607 - in head: sbin/ifconfig share/man/man4 sys/net
Message-ID:  <201509100559.t8A5xeKd015512@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hrs
Date: Thu Sep 10 05:59:39 2015
New Revision: 287607
URL: https://svnweb.freebsd.org/changeset/base/287607

Log:
  - Remove GIF_{SEND,ACCEPT}_REVETHIP.
  - Simplify EADDRNOTAVAIL and EAFNOSUPPORT conditions.
  
  MFC after:	3 days

Modified:
  head/sbin/ifconfig/ifgif.c
  head/share/man/man4/gif.4
  head/sys/net/if_gif.c
  head/sys/net/if_gif.h

Modified: head/sbin/ifconfig/ifgif.c
==============================================================================
--- head/sbin/ifconfig/ifgif.c	Thu Sep 10 04:05:58 2015	(r287606)
+++ head/sbin/ifconfig/ifgif.c	Thu Sep 10 05:59:39 2015	(r287607)
@@ -51,7 +51,7 @@ static const char rcsid[] =
 
 #include "ifconfig.h"
 
-#define	GIFBITS	"\020\1ACCEPT_REV_ETHIP_VER\2IGNORE_SOURCE\5SEND_REV_ETHIP_VER"
+#define	GIFBITS	"\020\2IGNORE_SOURCE"
 
 static void	gif_status(int);
 
@@ -70,8 +70,7 @@ gif_status(int s)
 }
 
 static void
-setgifopts(const char *val,
-	int d, int s, const struct afswtch *afp)
+setgifopts(const char *val, int d, int s, const struct afswtch *afp)
 {
 	int opts;
 
@@ -93,12 +92,8 @@ setgifopts(const char *val,
 }
 
 static struct cmd gif_cmds[] = {
-	DEF_CMD("accept_rev_ethip_ver",	GIF_ACCEPT_REVETHIP,	setgifopts),
-	DEF_CMD("-accept_rev_ethip_ver",-GIF_ACCEPT_REVETHIP,	setgifopts),
 	DEF_CMD("ignore_source",	GIF_IGNORE_SOURCE,	setgifopts),
 	DEF_CMD("-ignore_source",	-GIF_IGNORE_SOURCE,	setgifopts),
-	DEF_CMD("send_rev_ethip_ver",	GIF_SEND_REVETHIP,	setgifopts),
-	DEF_CMD("-send_rev_ethip_ver",	-GIF_SEND_REVETHIP,	setgifopts),
 };
 
 static struct afswtch af_gif = {
@@ -110,11 +105,9 @@ static struct afswtch af_gif = {
 static __constructor void
 gif_ctor(void)
 {
-#define	N(a)	(sizeof(a) / sizeof(a[0]))
 	size_t i;
 
-	for (i = 0; i < N(gif_cmds); i++)
+	for (i = 0; i < nitems(gif_cmds); i++)
 		cmd_register(&gif_cmds[i]);
 	af_register(&af_gif);
-#undef N
 }

Modified: head/share/man/man4/gif.4
==============================================================================
--- head/share/man/man4/gif.4	Thu Sep 10 04:05:58 2015	(r287606)
+++ head/share/man/man4/gif.4	Thu Sep 10 05:59:39 2015	(r287607)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 14, 2014
+.Dd September 10, 2015
 .Dt GIF 4
 .Os
 .Sh NAME
@@ -246,32 +246,3 @@ had a multi-destination behavior, config
 .Dv IFF_LINK0
 flag.
 The behavior is obsolete and is no longer supported.
-.Pp
-On
-.Fx
-6.1, 6.2, 6.3, 7.0, 7.1, and 7.2
-the
-.Nm
-sends and receives incorrect EtherIP packets with reversed version
-field when
-.Xr if_bridge 4
-is used together.  As a workaround on this interoperability issue, the
-following two
-.Xr ifconfig 8
-flags can be used:
-.Bl -tag -width "accept_rev_ethip_ver" -offset indent
-.It accept_rev_ethip_ver
-accepts both correct EtherIP packets and ones with reversed version
-field, if enabled.  If disabled, the
-.Nm
-accepts the correct packets only.  This flag is enabled by default.
-.It send_rev_ethip_ver
-sends EtherIP packets with reversed version field intentionally, if
-enabled.  If disabled, the
-.Nm
-sends the correct packets only.  This flag is disabled by default.
-.El
-.Pp
-If interoperability with the older
-.Fx
-machines is needed, both of these two flags must be enabled.

Modified: head/sys/net/if_gif.c
==============================================================================
--- head/sys/net/if_gif.c	Thu Sep 10 04:05:58 2015	(r287606)
+++ head/sys/net/if_gif.c	Thu Sep 10 05:59:39 2015	(r287607)
@@ -421,13 +421,8 @@ gif_transmit(struct ifnet *ifp, struct m
 		}
 		eth = mtod(m, struct etherip_header *);
 		eth->eip_resvh = 0;
-		if ((sc->gif_options & GIF_SEND_REVETHIP) != 0) {
-			eth->eip_ver = 0;
-			eth->eip_resvl = ETHERIP_VERSION;
-		} else {
-			eth->eip_ver = ETHERIP_VERSION;
-			eth->eip_resvl = 0;
-		}
+		eth->eip_ver = ETHERIP_VERSION;
+		eth->eip_resvl = 0;
 		break;
 	default:
 		error = EAFNOSUPPORT;
@@ -635,19 +630,10 @@ gif_input(struct mbuf *m, struct ifnet *
 		if (m == NULL)
 			goto drop;
 		eip = mtod(m, struct etherip_header *);
-		/*
-		 * GIF_ACCEPT_REVETHIP (enabled by default) intentionally
-		 * accepts an EtherIP packet with revered version field in
-		 * the header.  This is a knob for backward compatibility
-		 * with FreeBSD 7.2R or prior.
-		 */
 		if (eip->eip_ver != ETHERIP_VERSION) {
-			if ((gif_options & GIF_ACCEPT_REVETHIP) == 0 ||
-			    eip->eip_resvl != ETHERIP_VERSION) {
-				/* discard unknown versions */
-				m_freem(m);
-				goto drop;
-			}
+			/* discard unknown versions */
+			m_freem(m);
+			goto drop;
 		}
 		m_adj(m, sizeof(struct etherip_header));
 
@@ -768,50 +754,32 @@ gif_ioctl(struct ifnet *ifp, u_long cmd,
 			goto bad;
 
 		/* validate sa_len */
+		/* check sa_family looks sane for the cmd */
 		switch (src->sa_family) {
 #ifdef INET
 		case AF_INET:
 			if (src->sa_len != sizeof(struct sockaddr_in))
 				goto bad;
-			break;
-#endif
-#ifdef INET6
-		case AF_INET6:
-			if (src->sa_len != sizeof(struct sockaddr_in6))
+			if (cmd != SIOCSIFPHYADDR) {
+				error = EAFNOSUPPORT;
 				goto bad;
-			break;
-#endif
-		default:
-			error = EAFNOSUPPORT;
-			goto bad;
-		}
-		/* check sa_family looks sane for the cmd */
-		error = EAFNOSUPPORT;
-		switch (cmd) {
-#ifdef INET
-		case SIOCSIFPHYADDR:
-			if (src->sa_family == AF_INET)
-				break;
-			goto bad;
-#endif
-#ifdef INET6
-		case SIOCSIFPHYADDR_IN6:
-			if (src->sa_family == AF_INET6)
-				break;
-			goto bad;
-#endif
-		}
-		error = EADDRNOTAVAIL;
-		switch (src->sa_family) {
-#ifdef INET
-		case AF_INET:
+			}
 			if (satosin(src)->sin_addr.s_addr == INADDR_ANY ||
-			    satosin(dst)->sin_addr.s_addr == INADDR_ANY)
+			    satosin(dst)->sin_addr.s_addr == INADDR_ANY) {
+				error = EADDRNOTAVAIL;
 				goto bad;
+			}
 			break;
 #endif
 #ifdef INET6
 		case AF_INET6:
+			if (src->sa_len != sizeof(struct sockaddr_in6))
+				goto bad;
+			if (cmd != SIOCSIFPHYADDR_IN6) {
+				error = EAFNOSUPPORT;
+				goto bad;
+			}
+			error = EADDRNOTAVAIL;
 			if (IN6_IS_ADDR_UNSPECIFIED(&satosin6(src)->sin6_addr)
 			    ||
 			    IN6_IS_ADDR_UNSPECIFIED(&satosin6(dst)->sin6_addr))
@@ -827,8 +795,12 @@ gif_ioctl(struct ifnet *ifp, u_long cmd,
 			error = sa6_embedscope(satosin6(dst), 0);
 			if (error != 0)
 				goto bad;
+			break;
 #endif
-		};
+		default:
+			error = EAFNOSUPPORT;
+			goto bad;
+		}
 		error = gif_set_tunnel(ifp, src, dst);
 		break;
 	case SIOCDIFPHYADDR:

Modified: head/sys/net/if_gif.h
==============================================================================
--- head/sys/net/if_gif.h	Thu Sep 10 04:05:58 2015	(r287606)
+++ head/sys/net/if_gif.h	Thu Sep 10 05:59:39 2015	(r287607)
@@ -126,10 +126,7 @@ int in6_gif_attach(struct gif_softc *);
 #define GIFGOPTS	_IOWR('i', 150, struct ifreq)
 #define GIFSOPTS	_IOW('i', 151, struct ifreq)
 
-#define	GIF_ACCEPT_REVETHIP	0x0001
 #define	GIF_IGNORE_SOURCE	0x0002
-#define	GIF_SEND_REVETHIP	0x0010
-#define	GIF_OPTMASK		(GIF_ACCEPT_REVETHIP|GIF_SEND_REVETHIP| \
-    GIF_IGNORE_SOURCE)
+#define	GIF_OPTMASK		(GIF_IGNORE_SOURCE)
 
 #endif /* _NET_IF_GIF_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509100559.t8A5xeKd015512>