Remove the 4.3BSD compatible macro m_copy(), use m_copym() instead.

Reviewed by:	gnn
Differential Revision:	https://reviews.freebsd.org/D7878
This commit is contained in:
Kevin Lo 2016-09-15 07:41:48 +00:00
parent 6c6e388929
commit c3bef61e58
21 changed files with 39 additions and 37 deletions

View File

@ -3226,7 +3226,7 @@ ipf_check(ctx, ip, hlen, ifp, out
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);
}

View File

@ -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)

View File

@ -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;

View File

@ -1640,7 +1640,8 @@ soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio,
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;

View File

@ -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) {

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -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().

View File

@ -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);
}

View File

@ -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 */

View File

@ -1049,7 +1049,7 @@ tcp_output(struct tcpcb *tp)
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);

View File

@ -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,

View File

@ -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 */

View File

@ -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 */

View File

@ -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");

View File

@ -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;

View File

@ -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
/*

View File

@ -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);

View File

@ -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);

View File

@ -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 */