From 8697599b2b01aac0886db1a19f0c407f4dfc3a3e Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sun, 15 Mar 2009 17:40:24 +0800 Subject: [PATCH] Add M_LENCHECKED mbuf flag. This flag indicates that various protocol length fields of the packet are checked. It is only used by IPv4 currently (ip_lengthcheck()). --- sys/net/if_ethersubr.c | 6 +++++- sys/netinet/ip_demux.c | 1 + sys/sys/mbuf.h | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 33628f208d..9a7429987b 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -72,7 +72,7 @@ #if defined(INET) || defined(INET6) #include -#include +#include #include #include #include @@ -1176,6 +1176,10 @@ post_stats: switch (ether_type) { #ifdef INET case ETHERTYPE_IP: + if ((m->m_flags & M_LENCHECKED) == 0) { + if (!ip_lengthcheck(&m)) + return; + } if (ipflow_fastforward(m)) return; isr = NETISR_IP; diff --git a/sys/netinet/ip_demux.c b/sys/netinet/ip_demux.c index ab8ccac61e..33f9ab995e 100644 --- a/sys/netinet/ip_demux.c +++ b/sys/netinet/ip_demux.c @@ -254,6 +254,7 @@ ipcheckonly: break; } + m->m_flags |= M_LENCHECKED; *mp = m; return TRUE; diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index dae8b5a94f..eef99fab19 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -206,13 +206,15 @@ struct mbuf { #define M_NOTIFICATION 0x10000 /* notification event */ #define M_VLANTAG 0x20000 /* ether_vlantag is valid */ #define M_MPLSLABELED 0x40000 /* packet is mpls labeled */ +#define M_LENCHECKED 0x80000 /* packet proto lengths are checked */ /* * Flags copied when copying m_pkthdr. */ #define M_COPYFLAGS (M_PKTHDR|M_EOR|M_PROTO1|M_PROTO2|M_PROTO3 | \ M_PROTO4|M_PROTO5|M_BCAST|M_MCAST|M_FRAG | \ - M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_MPLSLABELED) + M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_MPLSLABELED | \ + M_LENCHECKED) /* * Flags indicating hw checksum support and sw checksum requirements. -- 2.41.0