Module Name:    src
Committed By:   maxv
Date:           Fri May 18 18:52:17 UTC 2018

Modified Files:
        src/sys/netinet: ip6.h
        src/sys/sys: mbuf.h

Log Message:
IP6_EXTHDR_GET performs a basic mbuf operation, which has nothing to do
with IPv6. So declare an IP-independent M_REGION_GET, and make
IP6_EXTHDR_GET an alias to it.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/netinet/ip6.h
cvs rdiff -u -r1.205 -r1.206 src/sys/sys/mbuf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/ip6.h
diff -u src/sys/netinet/ip6.h:1.24 src/sys/netinet/ip6.h:1.25
--- src/sys/netinet/ip6.h:1.24	Fri May 18 18:28:40 2018
+++ src/sys/netinet/ip6.h	Fri May 18 18:52:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6.h,v 1.24 2018/05/18 18:28:40 maxv Exp $	*/
+/*	$NetBSD: ip6.h,v 1.25 2018/05/18 18:52:17 maxv Exp $	*/
 /*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
 
 /*
@@ -266,30 +266,8 @@ struct ip6_frag {
 #define IPV6_MAXPACKET	65535	/* ip6 max packet size without Jumbo payload*/
 
 #ifdef _KERNEL
-/*
- * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
- * "len") is located in single mbuf, on contiguous memory region.
- * The pointer to the region will be returned to pointer variable "val",
- * with type "typ".
- */
 #define IP6_EXTHDR_GET(val, typ, m, off, len) \
-do {									\
-	struct mbuf *_t;						\
-	int _tmp;							\
-	if ((m)->m_len >= (off) + (len))				\
-		(val) = (typ)(mtod((m), char *) + (off));		\
-	else {								\
-		_t = m_pulldown((m), (off), (len), &_tmp);		\
-		if (_t) {						\
-			if (_t->m_len < _tmp + (len))			\
-				panic("m_pulldown malfunction");	\
-			(val) = (typ)(mtod(_t, char *) + _tmp);	\
-		} else {						\
-			(val) = (typ)NULL;				\
-			(m) = NULL;					\
-		}							\
-	}								\
-} while (/*CONSTCOND*/ 0)
+	M_REGION_GET(val, typ, m, off, len)
 #endif /*_KERNEL*/
 
 #endif /* !_NETINET_IP6_H_ */

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.205 src/sys/sys/mbuf.h:1.206
--- src/sys/sys/mbuf.h:1.205	Thu May  3 21:37:29 2018
+++ src/sys/sys/mbuf.h	Fri May 18 18:52:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.205 2018/05/03 21:37:29 christos Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.206 2018/05/18 18:52:17 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -644,6 +644,31 @@ do {									\
 #define	M_SETCTX(m, c)		((void)((m)->m_pkthdr._rcvif.ctx = (void *)(c)))
 #define	M_CLEARCTX(m)		M_SETCTX((m), NULL)
 
+/*
+ * M_REGION_GET ensures that the "len"-sized region of type "typ" starting
+ * from "off" within "m" is located in a single mbuf, contiguously.
+ *
+ * The pointer to the region will be returned to pointer variable "val".
+ */
+#define M_REGION_GET(val, typ, m, off, len) \
+do {									\
+	struct mbuf *_t;						\
+	int _tmp;							\
+	if ((m)->m_len >= (off) + (len))				\
+		(val) = (typ)(mtod((m), char *) + (off));		\
+	else {								\
+		_t = m_pulldown((m), (off), (len), &_tmp);		\
+		if (_t) {						\
+			if (_t->m_len < _tmp + (len))			\
+				panic("m_pulldown malfunction");	\
+			(val) = (typ)(mtod(_t, char *) + _tmp);	\
+		} else {						\
+			(val) = (typ)NULL;				\
+			(m) = NULL;					\
+		}							\
+	}								\
+} while (/*CONSTCOND*/ 0)
+
 #endif /* defined(_KERNEL) */
 
 /*

Reply via email to