diff options
author | hrs <hrs@FreeBSD.org> | 2015-09-13 01:35:40 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2015-09-13 01:35:40 +0000 |
commit | 349e17a73ab9f1415dc275e5744890410e114ab2 (patch) | |
tree | f7576d129ba04c9f0ec5b49ef84b614b742a5f34 /sys/net | |
parent | 7b44e2b6d4ba3809536e09ae415b8d3566e5407a (diff) | |
download | FreeBSD-src-349e17a73ab9f1415dc275e5744890410e114ab2.zip FreeBSD-src-349e17a73ab9f1415dc275e5744890410e114ab2.tar.gz |
MFC 287607:
- Remove GIF_{SEND,ACCEPT}_REVETHIP.
- Simplify EADDRNOTAVAIL and EAFNOSUPPORT conditions.
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_gif.c | 76 | ||||
-rw-r--r-- | sys/net/if_gif.h | 5 |
2 files changed, 25 insertions, 56 deletions
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 66669ca..f2a38c1 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -419,13 +419,8 @@ gif_transmit(struct ifnet *ifp, struct mbuf *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; @@ -633,19 +628,10 @@ gif_input(struct mbuf *m, struct ifnet *ifp, int proto, uint8_t ecn) 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)); @@ -766,50 +752,32 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 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)) @@ -825,8 +793,12 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 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: diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h index ed143e8..b71c8e8 100644 --- a/sys/net/if_gif.h +++ b/sys/net/if_gif.h @@ -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_ */ |