Change m_uiotombuf so it will accept offset at which data should be copied
to the mbuf. Offset cannot exceed MHLEN bytes. This is currently used to fix Ethernet header alignment problem on alpha and sparc64. Also change all users of m_uiotombuf to pass proper offset. Reviewed by: jmg, sam Tested by: Sten Spans "sten AT blinkenlights DOT nl" MFC after: 1 week
This commit is contained in:
parent
15ec3fe2f0
commit
75ae257016
@ -1333,7 +1333,7 @@ nospace:
|
||||
#endif
|
||||
|
||||
struct mbuf *
|
||||
m_uiotombuf(struct uio *uio, int how, int len)
|
||||
m_uiotombuf(struct uio *uio, int how, int len, int align)
|
||||
{
|
||||
struct mbuf *m_new = NULL, *m_final = NULL;
|
||||
int progress = 0, error = 0, length, total;
|
||||
@ -1342,12 +1342,15 @@ m_uiotombuf(struct uio *uio, int how, int len)
|
||||
total = min(uio->uio_resid, len);
|
||||
else
|
||||
total = uio->uio_resid;
|
||||
if (total > MHLEN)
|
||||
if (align >= MHLEN)
|
||||
goto nospace;
|
||||
if (total + align > MHLEN)
|
||||
m_final = m_getcl(how, MT_DATA, M_PKTHDR);
|
||||
else
|
||||
m_final = m_gethdr(how, MT_DATA);
|
||||
if (m_final == NULL)
|
||||
goto nospace;
|
||||
m_final->m_data += align;
|
||||
m_new = m_final;
|
||||
while (progress < total) {
|
||||
length = total - progress;
|
||||
|
@ -1796,7 +1796,7 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
|
||||
hdr_uio->uio_td = td;
|
||||
hdr_uio->uio_rw = UIO_WRITE;
|
||||
if (hdr_uio->uio_resid > 0) {
|
||||
m_header = m_uiotombuf(hdr_uio, M_DONTWAIT, 0);
|
||||
m_header = m_uiotombuf(hdr_uio, M_DONTWAIT, 0, 0);
|
||||
if (m_header == NULL)
|
||||
goto done;
|
||||
headersize = m_header->m_pkthdr.len;
|
||||
|
@ -827,7 +827,7 @@ tapwrite(dev, uio, flag)
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
if ((m = m_uiotombuf(uio, M_DONTWAIT, 0)) == NULL) {
|
||||
if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, ETHER_ALIGN)) == NULL) {
|
||||
ifp->if_ierrors ++;
|
||||
return (error);
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ tunwrite(struct cdev *dev, struct uio *uio, int flag)
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
if ((m = m_uiotombuf(uio, M_DONTWAIT, 0)) == NULL) {
|
||||
if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, 0)) == NULL) {
|
||||
ifp->if_ierrors++;
|
||||
return (error);
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ ngdwrite(struct cdev *dev, struct uio *uio, int flag)
|
||||
if (uio->uio_resid < 0 || uio->uio_resid > IP_MAXPACKET)
|
||||
return (EIO);
|
||||
|
||||
if ((m = m_uiotombuf(uio, M_DONTWAIT, 0)) == NULL)
|
||||
if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, 0)) == NULL)
|
||||
return (ENOBUFS);
|
||||
|
||||
NG_SEND_DATA_ONLY(error, priv->hook, m);
|
||||
|
@ -582,7 +582,7 @@ void m_print(const struct mbuf *, int);
|
||||
struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
|
||||
struct mbuf *m_pullup(struct mbuf *, int);
|
||||
struct mbuf *m_split(struct mbuf *, int, int);
|
||||
struct mbuf *m_uiotombuf(struct uio *, int, int);
|
||||
struct mbuf *m_uiotombuf(struct uio *, int, int, int);
|
||||
|
||||
/*-
|
||||
* Network packets may have annotations attached by affixing a list
|
||||
|
Loading…
x
Reference in New Issue
Block a user