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:
Maksim Yevmenkin 2005-05-04 18:55:03 +00:00
parent 15ec3fe2f0
commit 75ae257016
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=145883
6 changed files with 10 additions and 7 deletions

View File

@ -1333,7 +1333,7 @@ m_fragment(struct mbuf *m0, int how, int length)
#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;

View File

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

View File

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

View File

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

View File

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

View File

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