Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys IP6_EXTHDR_GET performs a basic mbuf operat...



details:   https://anonhg.NetBSD.org/src/rev/43822943577d
branches:  trunk
changeset: 319132:43822943577d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri May 18 18:52:17 2018 +0000

description:
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.

diffstat:

 sys/netinet/ip6.h |  26 ++------------------------
 sys/sys/mbuf.h    |  27 ++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 25 deletions(-)

diffs (82 lines):

diff -r 3d852ec9804a -r 43822943577d sys/netinet/ip6.h
--- a/sys/netinet/ip6.h Fri May 18 18:28:40 2018 +0000
+++ b/sys/netinet/ip6.h Fri May 18 18:52:17 2018 +0000
@@ -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 @@
 #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_ */
diff -r 3d852ec9804a -r 43822943577d sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Fri May 18 18:28:40 2018 +0000
+++ b/sys/sys/mbuf.h    Fri May 18 18:52:17 2018 +0000
@@ -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 @@
 #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) */
 
 /*



Home | Main Index | Thread Index | Old Index