aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_gif.c
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2015-07-29 14:07:43 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2015-07-29 14:07:43 +0000
commit10a0e0bf0a5ee749abbdc29555147b75d0746b81 (patch)
tree706ee2ecb477c426b004b82543a2b8735b3775d5 /sys/net/if_gif.c
parent4446a47a6f0fdff4ac678d816a1638702fd4970d (diff)
downloadsrc-10a0e0bf0a5ee749abbdc29555147b75d0746b81.tar.gz
src-10a0e0bf0a5ee749abbdc29555147b75d0746b81.zip
Eliminate the use of m_copydata() in gif_encapcheck().
ip_encap already has inspected mbuf's data, at least an IP header. And it is safe to use mtod() and do direct access to needed fields. Add M_ASSERTPKTHDR() to gif_encapcheck(), since the code expects that mbuf has a packet header. Move the code from gif_validate[46] into in[6]_gif_encapcheck(), also remove "martian filters" checks. According to RFC 4213 it is enough to verify that the source address is the address of the encapsulator, as configured on the decapsulator. Reviewed by: melifaro Obtained from: Yandex LLC Sponsored by: Yandex LLC
Notes
Notes: svn path=/head/; revision=286013
Diffstat (limited to 'sys/net/if_gif.c')
-rw-r--r--sys/net/if_gif.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 48a842a9dd93..78b4d9da4430 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -280,9 +280,9 @@ int
gif_encapcheck(const struct mbuf *m, int off, int proto, void *arg)
{
GIF_RLOCK_TRACKER;
+ const struct ip *ip;
struct gif_softc *sc;
int ret;
- uint8_t ver;
sc = (struct gif_softc *)arg;
if (sc == NULL || (GIF2IFP(sc)->if_flags & IFF_UP) == 0)
@@ -309,11 +309,12 @@ gif_encapcheck(const struct mbuf *m, int off, int proto, void *arg)
}
/* Bail on short packets */
+ M_ASSERTPKTHDR(m);
if (m->m_pkthdr.len < sizeof(struct ip))
goto done;
- m_copydata(m, 0, 1, &ver);
- switch (ver >> 4) {
+ ip = mtod(m, const struct ip *);
+ switch (ip->ip_v) {
#ifdef INET
case 4:
if (sc->gif_family != AF_INET)