From c3bef61e584084a8f86fba71cb344f15fc20491c Mon Sep 17 00:00:00 2001 From: Kevin Lo Date: Thu, 15 Sep 2016 07:41:48 +0000 Subject: [PATCH] Remove the 4.3BSD compatible macro m_copy(), use m_copym() instead. Reviewed by: gnn Differential Revision: https://reviews.freebsd.org/D7878 --- sys/contrib/ipfilter/netinet/fil.c | 2 +- sys/contrib/ipfilter/netinet/ip_compat.h | 4 ++-- sys/contrib/ipfilter/netinet/ip_fil_freebsd.c | 2 +- sys/kern/uipc_socket.c | 3 ++- sys/net/if_arcsubr.c | 2 +- sys/net/if_fddisubr.c | 2 +- sys/net/if_iso88025subr.c | 2 +- sys/net/raw_usrreq.c | 2 +- sys/netinet/ip_input.c | 2 +- sys/netinet/ip_mroute.c | 8 ++++---- sys/netinet/raw_ip.c | 4 ++-- sys/netinet/tcp_output.c | 2 +- sys/netinet/udp_usrreq.c | 3 ++- sys/netinet6/icmp6.c | 6 +++--- sys/netinet6/ip6_forward.c | 3 ++- sys/netinet6/ip6_mroute.c | 13 +++++++------ sys/netinet6/ip6_output.c | 4 ++-- sys/netinet6/raw_ip6.c | 2 +- sys/netinet6/udp6_usrreq.c | 3 ++- sys/netipsec/keysock.c | 4 ++-- sys/sys/mbuf.h | 3 --- 21 files changed, 39 insertions(+), 37 deletions(-) diff --git a/sys/contrib/ipfilter/netinet/fil.c b/sys/contrib/ipfilter/netinet/fil.c index 0aeb44bb3619..38a2496df7d3 100644 --- a/sys/contrib/ipfilter/netinet/fil.c +++ b/sys/contrib/ipfilter/netinet/fil.c @@ -3226,7 +3226,7 @@ filterdone: fdp = fin->fin_dif; if ((fdp != NULL) && (fdp->fd_ptr != NULL) && (fdp->fd_ptr != (void *)-1)) { - mc = M_COPY(fin->fin_m); + mc = M_COPYM(fin->fin_m); if (mc != NULL) ipf_fastroute(mc, &mc, fin, fdp); } diff --git a/sys/contrib/ipfilter/netinet/ip_compat.h b/sys/contrib/ipfilter/netinet/ip_compat.h index a6897717b12a..20ae38ee71bc 100644 --- a/sys/contrib/ipfilter/netinet/ip_compat.h +++ b/sys/contrib/ipfilter/netinet/ip_compat.h @@ -211,7 +211,7 @@ struct ether_addr { # define MSGDSIZE(m) mbufchainlen(m) # define M_LEN(m) (m)->m_len # define M_ADJ(m,x) m_adj(m, x) -# define M_COPY(x) m_copy((x), 0, M_COPYALL) +# define M_COPYM(x) m_copym((x), 0, M_COPYALL, M_NOWAIT) # define M_DUP(m) m_dup(m, M_NOWAIT) # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); } typedef struct mbuf mb_t; @@ -366,7 +366,7 @@ typedef struct mb_s { # define MSGDSIZE(m) msgdsize(m) # define M_LEN(m) (m)->mb_len # define M_ADJ(m,x) (m)->mb_len += x -# define M_COPY(m) dupmbt(m) +# define M_COPYM(m) dupmbt(m) # define M_DUP(m) dupmbt(m) # define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) # define MTOD(m, t) ((t)(m)->mb_data) diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c index 779d8457ea4d..9ce4d41f2e99 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c +++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c @@ -920,7 +920,7 @@ ipf_fastroute(m0, mpp, fin, fdp) mhip->ip_off |= IP_MF; mhip->ip_len = htons((u_short)(len + mhlen)); *mnext = m; - m->m_next = m_copy(m0, off, len); + m->m_next = m_copym(m0, off, len, M_NOWAIT); if (m->m_next == 0) { error = ENOBUFS; /* ??? */ goto sendorfree; diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 81174183215f..dec63d54033a 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1640,7 +1640,8 @@ dontblock: 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_NOWAIT); controlp = &(*controlp)->m_next; } m = m->m_next; diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index 3bf372baba6c..6296e2e267dd 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -225,7 +225,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) { if ((m->m_flags & M_BCAST) || (loop_copy > 0)) { - struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); + struct mbuf *n = m_copym(m, 0, M_COPYALL, M_NOWAIT); (void) if_simloop(ifp, n, dst->sa_family, ARC_HDRLEN); } else if (ah->arc_dhost == ah->arc_shost) { diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index b02901ffab8e..682a37caaea7 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -275,7 +275,7 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) { if ((m->m_flags & M_BCAST) || (loop_copy > 0)) { struct mbuf *n; - n = m_copy(m, 0, (int)M_COPYALL); + n = m_copym(m, 0, M_COPYALL, M_NOWAIT); (void) if_simloop(ifp, n, dst->sa_family, FDDI_HDR_LEN); } else if (bcmp(fh->fddi_dhost, fh->fddi_shost, diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index 8306154e5675..e5d5166d60c4 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -364,7 +364,7 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) { if ((m->m_flags & M_BCAST) || (loop_copy > 0)) { struct mbuf *n; - n = m_copy(m, 0, (int)M_COPYALL); + n = m_copym(m, 0, M_COPYALL, M_NOWAIT); (void) if_simloop(ifp, n, dst->sa_family, ISO88025_HDR_LEN); } else if (bcmp(th->iso88025_dhost, th->iso88025_shost, diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index 9e22528b7e98..2649d667d436 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -95,7 +95,7 @@ raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, continue; if (last) { struct mbuf *n; - n = m_copy(m, 0, (int)M_COPYALL); + n = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (n) { if (sbappendaddr(&last->so_rcv, src, n, (struct mbuf *)0) == 0) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 3a07ad89d102..1d86242e761d 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1000,7 +1000,7 @@ ip_forward(struct mbuf *m, int srcrt) * because unnecessary, or because rate limited), so we are * really we are wasting a lot of work here. * - * We don't use m_copy() because it might return a reference + * We don't use m_copym() because it might return a reference * to a shared cluster. Both this function and ip_output() * assume exclusive access to the IP header in `m', so any * data in a cluster may change before we reach icmp_error(). diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index d6164ef90626..c0730caca8f4 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1344,7 +1344,7 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m, goto fail; /* Make a copy of the header to send to the user level process */ - mm = m_copy(mb0, 0, hlen); + mm = m_copym(mb0, 0, hlen, M_NOWAIT); if (mm == NULL) goto fail1; @@ -1542,7 +1542,7 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif) struct sockaddr_in k_igmpsrc = { sizeof k_igmpsrc, AF_INET }; struct igmpmsg *im; int hlen = ip->ip_hl << 2; - struct mbuf *mm = m_copy(m, 0, hlen); + struct mbuf *mm = m_copym(m, 0, hlen, M_NOWAIT); if (mm && (!M_WRITABLE(mm) || mm->m_len < hlen)) mm = m_pullup(mm, hlen); @@ -2734,9 +2734,9 @@ pim_input(struct mbuf **mp, int *offp, int proto) * actions (e.g., send back PIM_REGISTER_STOP). * XXX: here m->m_data points to the outer IP header. */ - mcp = m_copy(m, 0, iphlen + PIM_REG_MINLEN); + mcp = m_copym(m, 0, iphlen + PIM_REG_MINLEN, M_NOWAIT); if (mcp == NULL) { - CTR1(KTR_IPMF, "%s: m_copy() failed", __func__); + CTR1(KTR_IPMF, "%s: m_copym() failed", __func__); m_freem(m); return (IPPROTO_DONE); } diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 6d409547029b..d741cc7f8511 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -322,7 +322,7 @@ rip_input(struct mbuf **mp, int *offp, int proto) if (last != NULL) { struct mbuf *n; - n = m_copy(m, 0, (int)M_COPYALL); + n = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (n != NULL) (void) rip_append(last, ip, n, &ripsrc); /* XXX count dropped packet */ @@ -400,7 +400,7 @@ rip_input(struct mbuf **mp, int *offp, int proto) if (last != NULL) { struct mbuf *n; - n = m_copy(m, 0, (int)M_COPYALL); + n = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (n != NULL) (void) rip_append(last, ip, n, &ripsrc); /* XXX count dropped packet */ diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index e1d9488a7b9b..454405149fe0 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1049,7 +1049,7 @@ send: mtod(m, caddr_t) + hdrlen); m->m_len += len; } else { - m->m_next = m_copy(mb, moff, (int)len); + m->m_next = m_copym(mb, moff, len, M_NOWAIT); if (m->m_next == NULL) { SOCKBUF_UNLOCK(&so->so_snd); (void) m_free(m); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index ce8847d40592..04d116d82243 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -597,7 +597,8 @@ udp_input(struct mbuf **mp, int *offp, int proto) if (last != NULL) { struct mbuf *n; - if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { + if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != + NULL) { UDP_PROBE(receive, NULL, last, ip, last, uh); if (udp_append(last, ip, n, iphlen, diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 6b6c92e2539f..0d040e4b0f7c 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -554,7 +554,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) icmp6_ifstat_inc(ifp, ifs6_in_echo); if (code != 0) goto badcode; - if ((n = m_copy(m, 0, M_COPYALL)) == NULL) { + if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) { /* Give up remote */ break; } @@ -651,7 +651,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) IP6_EXTHDR_CHECK(m, off, sizeof(struct icmp6_nodeinfo), IPPROTO_DONE); #endif - n = m_copy(m, 0, M_COPYALL); + n = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (n) n = ni6_input(n, off); /* XXX meaningless if n == NULL */ @@ -2039,7 +2039,7 @@ icmp6_rip6_input(struct mbuf **mp, int off) } } if (n != NULL || - (n = m_copy(m, 0, (int)M_COPYALL)) != NULL) { + (n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != NULL) { if (last->inp_flags & INP_CONTROLOPTS) ip6_savecontrol(last, n, &opts); /* strip intermediate headers */ diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c index 83d42dfe29e2..1a3e5f4dee27 100644 --- a/sys/netinet6/ip6_forward.c +++ b/sys/netinet6/ip6_forward.c @@ -166,7 +166,8 @@ ip6_forward(struct mbuf *m, int srcrt) * 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_NOWAIT); #ifdef IPSEC /* get a security policy for this packet */ diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 3ae900d6a7ac..66586c933be9 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1145,7 +1145,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m) MFC6_UNLOCK(); return (ENOBUFS); } - mb0 = m_copy(m, 0, M_COPYALL); + mb0 = m_copym(m, 0, M_COPYALL, M_NOWAIT); /* * Pullup packet header if needed before storing it, * as other references may modify it in the meantime. @@ -1185,7 +1185,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m) * 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_NOWAIT); if (mm == NULL) { free(rte, M_MRTABLE6); m_freem(mb0); @@ -1417,7 +1417,8 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt) struct omrt6msg *oim; #endif - mm = m_copy(m, 0, sizeof(struct ip6_hdr)); + mm = m_copym(m, 0, sizeof(struct ip6_hdr), + M_NOWAIT); if (mm && (!M_WRITABLE(mm) || mm->m_len < sizeof(struct ip6_hdr))) @@ -1547,7 +1548,7 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) * 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_NOWAIT); if (mb_copy && (!M_WRITABLE(mb_copy) || mb_copy->m_len < sizeof(struct ip6_hdr))) mb_copy = m_pullup(mb_copy, sizeof(struct ip6_hdr)); @@ -1651,7 +1652,7 @@ register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m) 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_NOWAIT)) == NULL) { m_freem(mm); return (ENOBUFS); } @@ -1870,7 +1871,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto) /* * 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_NOWAIT); if (mcp == NULL) { MRT6_DLOG(DEBUG_ANY | DEBUG_ERR, "pim register: " "could not copy register head"); diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 2b0e50d7be3e..7b71abd4657a 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -259,7 +259,7 @@ ip6_fragment(struct ifnet *ifp, struct mbuf *m0, int hlen, u_char nextproto, ip6f->ip6f_offlg |= IP6F_MORE_FRAG; mhip6->ip6_plen = htons((u_short)(mtu + hlen + sizeof(*ip6f) - sizeof(struct ip6_hdr))); - if ((m_frgpart = m_copy(m0, off, mtu)) == NULL) { + if ((m_frgpart = m_copym(m0, off, mtu, M_NOWAIT)) == NULL) { IP6STAT_INC(ip6s_odropped); return (ENOBUFS); } @@ -3003,7 +3003,7 @@ ip6_mloopback(struct ifnet *ifp, struct mbuf *m) struct mbuf *copym; struct ip6_hdr *ip6; - copym = m_copy(m, 0, M_COPYALL); + copym = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (copym == NULL) return; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 2b95e4811fec..e827057c31c8 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -256,7 +256,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto) } } if (last != NULL) { - struct mbuf *n = m_copy(m, 0, (int)M_COPYALL); + struct mbuf *n = m_copym(m, 0, M_COPYALL, M_NOWAIT); #ifdef IPSEC /* diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index b44fb9ecb5f1..144989445a0d 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -366,7 +366,8 @@ udp6_input(struct mbuf **mp, int *offp, int proto) if (last != NULL) { struct mbuf *n; - if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { + if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != + NULL) { INP_RLOCK(last); UDP_PROBE(receive, NULL, last, ip6, last, uh); diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index c3092e42f685..fffdd60fdf1d 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -301,7 +301,7 @@ key_sendup_mbuf(struct socket *so, struct mbuf *m, int target) * (based on pf_key@inner.net 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, M_COPYALL, M_NOWAIT)) != NULL) { (void)key_sendup0(rp, n, 1); n = NULL; } @@ -331,7 +331,7 @@ key_sendup_mbuf(struct socket *so, struct mbuf *m, int target) if (!sendup) continue; - if ((n = m_copy(m, 0, (int)M_COPYALL)) == NULL) { + if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) { m_freem(m); PFKEYSTAT_INC(in_nomem); mtx_unlock(&rawcb_mtx); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 5df745af36c8..fdd9931515da 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -979,9 +979,6 @@ m_align(struct mbuf *m, int len) /* Length to m_copy to copy all. */ #define M_COPYALL 1000000000 -/* Compatibility with 4.3. */ -#define m_copy(m, o, l) m_copym((m), (o), (l), M_NOWAIT) - extern int max_datalen; /* MHLEN - max_hdr */ extern int max_hdr; /* Largest link + protocol header */ extern int max_linkhdr; /* Largest link-level header */