Source-Changes-HG archive

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

[src/trunk]: src/sys Stop using m_copy(), use m_copym() directly...



details:   https://anonhg.NetBSD.org/src/rev/a5ce38c02b7b
branches:  trunk
changeset: 318487:a5ce38c02b7b
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Apr 26 19:50:09 2018 +0000
description:
Stop using m_copy(), use m_copym() directly. m_copy is useless,
undocumented and confusing.

diffstat:

 sys/kern/uipc_socket.c     |  10 +++++-----
 sys/netinet6/icmp6.c       |   6 +++---
 sys/netinet6/ip6_forward.c |   7 ++++---
 sys/netinet6/ip6_mroute.c  |  16 ++++++++--------
 sys/netinet6/ip6_output.c  |   8 ++++----
 sys/netinet6/raw_ip6.c     |   6 +++---
 sys/netipsec/keysock.c     |   8 ++++----
 7 files changed, 31 insertions(+), 30 deletions(-)

diffs (271 lines):

diff -r 6e3a9b7350f8 -r a5ce38c02b7b sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Thu Apr 26 19:33:02 2018 +0000
+++ b/sys/kern/uipc_socket.c    Thu Apr 26 19:50:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.262 2018/04/26 19:22:17 maxv Exp $   */
+/*     $NetBSD: uipc_socket.c,v 1.263 2018/04/26 19:50:09 maxv Exp $   */
 
 /*-
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.262 2018/04/26 19:22:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.263 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1316,7 +1316,7 @@
                orig_resid = 0;
                if (flags & MSG_PEEK) {
                        if (paddr)
-                               *paddr = m_copy(m, 0, m->m_len);
+                               *paddr = m_copym(m, 0, m->m_len, M_DONTWAIT);
                        m = m->m_next;
                } else {
                        sbfree(&so->so_rcv, m);
@@ -1341,7 +1341,7 @@
                        orig_resid = 0;
                        if (flags & MSG_PEEK) {
                                if (paddr)
-                                       *paddr = m_copy(m, 0, m->m_len);
+                                       *paddr = m_copym(m, 0, m->m_len, M_DONTWAIT);
                                m = m->m_next;
                        } else {
                                sbfree(&so->so_rcv, m);
@@ -1370,7 +1370,7 @@
                do {
                        if (flags & MSG_PEEK) {
                                if (controlp != NULL) {
-                                       *controlp = m_copy(m, 0, m->m_len);
+                                       *controlp = m_copym(m, 0, m->m_len, M_DONTWAIT);
                                        controlp = &(*controlp)->m_next;
                                }
                                m = m->m_next;
diff -r 6e3a9b7350f8 -r a5ce38c02b7b sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c      Thu Apr 26 19:33:02 2018 +0000
+++ b/sys/netinet6/icmp6.c      Thu Apr 26 19:50:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp6.c,v 1.231 2018/04/26 07:28:21 maxv Exp $ */
+/*     $NetBSD: icmp6.c,v 1.232 2018/04/26 19:50:09 maxv Exp $ */
 /*     $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.231 2018/04/26 07:28:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.232 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1967,7 +1967,7 @@
                        /* do not inject data into pcb */
                }
 #endif
-               else if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
+               else if ((n = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT)) != NULL) {
                        if (last->in6p_flags & IN6P_CONTROLOPTS)
                                ip6_savecontrol(last, &opts, ip6, n);
                        /* strip intermediate headers */
diff -r 6e3a9b7350f8 -r a5ce38c02b7b sys/netinet6/ip6_forward.c
--- a/sys/netinet6/ip6_forward.c        Thu Apr 26 19:33:02 2018 +0000
+++ b/sys/netinet6/ip6_forward.c        Thu Apr 26 19:50:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_forward.c,v 1.93 2018/04/18 07:17:49 maxv Exp $    */
+/*     $NetBSD: ip6_forward.c,v 1.94 2018/04/26 19:50:09 maxv Exp $    */
 /*     $KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $   */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.93 2018/04/18 07:17:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.94 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -177,7 +177,8 @@
         * It is important to save it before IPsec processing as IPsec
         * processing may modify the mbuf.
         */
-       mcopy = m_copy(m, 0, imin(m->m_pkthdr.len, ICMPV6_PLD_MAXLEN));
+       mcopy = m_copym(m, 0, imin(m->m_pkthdr.len, ICMPV6_PLD_MAXLEN),
+           M_DONTWAIT);
 
 #ifdef IPSEC
        if (ipsec_used) {
diff -r 6e3a9b7350f8 -r a5ce38c02b7b sys/netinet6/ip6_mroute.c
--- a/sys/netinet6/ip6_mroute.c Thu Apr 26 19:33:02 2018 +0000
+++ b/sys/netinet6/ip6_mroute.c Thu Apr 26 19:50:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_mroute.c,v 1.124 2018/04/26 07:28:21 maxv Exp $    */
+/*     $NetBSD: ip6_mroute.c,v 1.125 2018/04/26 19:50:09 maxv Exp $    */
 /*     $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $     */
 
 /*
@@ -117,7 +117,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.124 2018/04/26 07:28:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.125 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1125,7 +1125,7 @@
                        splx(s);
                        return ENOBUFS;
                }
-               mb0 = m_copy(m, 0, M_COPYALL);
+               mb0 = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
 
                /*
                 * Pullup packet header if needed before storing it,
@@ -1167,7 +1167,7 @@
                         * Make a copy of the header to send to the user
                         * level process
                         */
-                       mm = m_copy(mb0, 0, sizeof(struct ip6_hdr));
+                       mm = m_copym(mb0, 0, sizeof(struct ip6_hdr), M_DONTWAIT);
 
                        if (mm == NULL) {
                                free(rte, M_MRTABLE);
@@ -1414,7 +1414,7 @@
                                struct mrt6msg *im;
                                struct omrt6msg *oim;
 
-                               mm = m_copy(m, 0, sizeof(struct ip6_hdr));
+                               mm = m_copym(m, 0, sizeof(struct ip6_hdr), M_DONTWAIT);
                                if (mm && M_UNWRITABLE(mm, sizeof(struct ip6_hdr)))
                                        mm = m_pullup(mm, sizeof(struct ip6_hdr));
                                if (mm == NULL)
@@ -1548,7 +1548,7 @@
         * the IPv6 header is actually copied, not just referenced,
         * so that ip6_output() only scribbles on the copy.
         */
-       mb_copy = m_copy(m, 0, M_COPYALL);
+       mb_copy = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
        if (mb_copy && M_UNWRITABLE(mb_copy, sizeof(struct ip6_hdr)))
                mb_copy = m_pullup(mb_copy, sizeof(struct ip6_hdr));
        if (mb_copy == NULL) {
@@ -1668,7 +1668,7 @@
        mm->m_data += max_linkhdr;
        mm->m_len = sizeof(struct ip6_hdr);
 
-       if ((mm->m_next = m_copy(m, 0, M_COPYALL)) == NULL) {
+       if ((mm->m_next = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
                m_freem(mm);
                return ENOBUFS;
        }
@@ -1895,7 +1895,7 @@
                /*
                 * make a copy of the whole header to pass to the daemon later.
                 */
-               mcp = m_copy(m, 0, off + PIM6_REG_MINLEN);
+               mcp = m_copym(m, 0, off + PIM6_REG_MINLEN, M_DONTWAIT);
                if (mcp == NULL) {
 #ifdef MRT6DEBUG
                        log(LOG_ERR,
diff -r 6e3a9b7350f8 -r a5ce38c02b7b sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Thu Apr 26 19:33:02 2018 +0000
+++ b/sys/netinet6/ip6_output.c Thu Apr 26 19:50:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_output.c,v 1.205 2018/04/23 07:22:54 maxv Exp $    */
+/*     $NetBSD: ip6_output.c,v 1.206 2018/04/26 19:50:09 maxv Exp $    */
 /*     $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $    */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.205 2018/04/23 07:22:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.206 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -988,7 +988,7 @@
 
                        mhip6->ip6_plen = htons((u_int16_t)(len + hlen +
                            sizeof(*ip6f) - sizeof(struct ip6_hdr)));
-                       if ((m_frgpart = m_copy(m0, off, len)) == NULL) {
+                       if ((m_frgpart = m_copym(m0, off, len, M_DONTWAIT)) == NULL) {
                                error = ENOBUFS;
                                IP6_STATINC(IP6_STAT_ODROPPED);
                                goto sendorfree;
@@ -3260,7 +3260,7 @@
        struct mbuf *copym;
        struct ip6_hdr *ip6;
 
-       copym = m_copy(m, 0, M_COPYALL);
+       copym = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
        if (copym == NULL)
                return;
 
diff -r 6e3a9b7350f8 -r a5ce38c02b7b sys/netinet6/raw_ip6.c
--- a/sys/netinet6/raw_ip6.c    Thu Apr 26 19:33:02 2018 +0000
+++ b/sys/netinet6/raw_ip6.c    Thu Apr 26 19:50:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raw_ip6.c,v 1.168 2018/04/12 07:28:10 maxv Exp $       */
+/*     $NetBSD: raw_ip6.c,v 1.169 2018/04/26 19:50:09 maxv Exp $       */
 /*     $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $        */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.168 2018/04/12 07:28:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.169 2018/04/26 19:50:09 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -198,7 +198,7 @@
                        /* do not inject data into pcb */
                }
 #endif
-               else if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
+               else if ((n = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT)) != NULL) {
                        if (last->in6p_flags & IN6P_CONTROLOPTS)
                                ip6_savecontrol(last, &opts, ip6, n);
                        /* strip intermediate headers */
diff -r 6e3a9b7350f8 -r a5ce38c02b7b sys/netipsec/keysock.c
--- a/sys/netipsec/keysock.c    Thu Apr 26 19:33:02 2018 +0000
+++ b/sys/netipsec/keysock.c    Thu Apr 26 19:50:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: keysock.c,v 1.64 2018/04/19 08:27:38 maxv Exp $        */
+/*     $NetBSD: keysock.c,v 1.65 2018/04/26 19:50:09 maxv Exp $        */
 /*     $FreeBSD: keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $     */
 /*     $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $        */
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.64 2018/04/19 08:27:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.65 2018/04/26 19:50:09 maxv Exp $");
 
 /* This code has derived from sys/net/rtsock.c on FreeBSD2.2.5 */
 
@@ -379,7 +379,7 @@
                 * (based on pf_key%inner.net@localhost message on 14 Oct 1998)
                 */
                if (((struct keycb *)rp)->kp_promisc) {
-                       if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
+                       if ((n = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT)) != NULL) {
                                (void)key_sendup0(rp, n, 1, 0);
                                n = NULL;
                        }
@@ -417,7 +417,7 @@
                if (!sendup)
                        continue;
 
-               if ((n = m_copy(m, 0, (int)M_COPYALL)) == NULL) {
+               if ((n = m_copym(m, 0, (int)M_COPYALL, M_DONTWAIT)) == NULL) {
                        m_freem(m);
                        PFKEY_STATINC(PFKEY_STAT_IN_NOMEM);
                        return ENOBUFS;



Home | Main Index | Thread Index | Old Index