From f5eece3fb99157ec3643100faf15515097904f54 Mon Sep 17 00:00:00 2001 From: Bosko Milekic Date: Wed, 20 Jun 2001 19:48:35 +0000 Subject: Change m_devget()'s outdated and unused `offset' argument to actually mean something: offset into the first mbuf of the target chain before copying the source data over. Make drivers using m_devget() with a first argument "data - ETHER_ALIGN" to use the offset argument to pass ETHER_ALIGN in. The way it was previously done is potentially dangerous if the source data was at the top of a page and the offset caused the previous page to be copied (if the previous page has not yet been appropriately mapped). The old `offset' argument in m_devget() is not used anywhere (it's always 0) and dates back to ~1995 (and earlier?) when support for ethernet trailers existed. With that support gone, it was merely collecting dust. Tested on alpha by: jlemon Partially submitted by: jlemon Reviewed by: jlemon MFC after: 3 weeks --- sys/dev/dc/if_dc.c | 5 ++--- sys/dev/lge/if_lge.c | 5 ++--- sys/dev/nge/if_nge.c | 5 ++--- sys/dev/sf/if_sf.c | 5 ++--- sys/dev/sk/if_sk.c | 5 ++--- sys/dev/vr/if_vr.c | 5 ++--- sys/dev/vx/if_vx.c | 5 +---- 7 files changed, 13 insertions(+), 22 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index 83eb65ecf0ec..0ef88c33b7de 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2502,15 +2502,14 @@ static void dc_rxeof(sc) /* No errors; receive the packet. */ total_len -= ETHER_CRC_LEN; - m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, - total_len + ETHER_ALIGN, 0, ifp, NULL); + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp, + NULL); dc_newbuf(sc, i, m); DC_INC(i, DC_RX_LIST_CNT); if (m0 == NULL) { ifp->if_ierrors++; continue; } - m_adj(m0, ETHER_ALIGN); m = m0; ifp->if_ipackets++; diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c index d6f9e8090f7d..155800415952 100644 --- a/sys/dev/lge/if_lge.c +++ b/sys/dev/lge/if_lge.c @@ -993,8 +993,8 @@ static void lge_rxeof(sc, cnt) } if (lge_newbuf(sc, &LGE_RXTAIL(sc), NULL) == ENOBUFS) { - m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, - total_len + ETHER_ALIGN, 0, ifp, NULL); + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, + ifp, NULL); lge_newbuf(sc, &LGE_RXTAIL(sc), m); if (m0 == NULL) { printf("lge%d: no receive buffers " @@ -1003,7 +1003,6 @@ static void lge_rxeof(sc, cnt) ifp->if_ierrors++; continue; } - m_adj(m0, ETHER_ALIGN); m = m0; } else { m->m_pkthdr.rcvif = ifp; diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c index 9c15beb79441..65dd7187e824 100644 --- a/sys/dev/nge/if_nge.c +++ b/sys/dev/nge/if_nge.c @@ -1278,8 +1278,8 @@ static void nge_rxeof(sc) * only gigE chip I know of with alignment constraints * on receive buffers. RX buffers must be 64-bit aligned. */ - m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, - total_len + ETHER_ALIGN, 0, ifp, NULL); + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp, + NULL); nge_newbuf(sc, cur_rx, m); if (m0 == NULL) { printf("nge%d: no receive buffers " @@ -1288,7 +1288,6 @@ static void nge_rxeof(sc) ifp->if_ierrors++; continue; } - m_adj(m0, ETHER_ALIGN); m = m0; ifp->if_ipackets++; diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c index dd26fca1e7af..e0d0149cc193 100644 --- a/sys/dev/sf/if_sf.c +++ b/sys/dev/sf/if_sf.c @@ -989,14 +989,13 @@ static void sf_rxeof(sc) continue; } - m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, - cur_rx->sf_len + ETHER_ALIGN, 0, ifp, NULL); + m0 = m_devget(mtod(m, char *), cur_rx->sf_len, ETHER_ALIGN, + ifp, NULL); sf_newbuf(sc, desc, m); if (m0 == NULL) { ifp->if_ierrors++; continue; } - m_adj(m0, ETHER_ALIGN); m = m0; eh = mtod(m, struct ether_header *); diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 83d5720f7fc8..6c9ec6a433e7 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1579,8 +1579,8 @@ static void sk_rxeof(sc_if) */ if (sk_newbuf(sc_if, cur_rx, NULL) == ENOBUFS) { struct mbuf *m0; - m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, - total_len + ETHER_ALIGN, 0, ifp, NULL); + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, + ifp, NULL); sk_newbuf(sc_if, cur_rx, m); if (m0 == NULL) { printf("sk%d: no receive buffers " @@ -1589,7 +1589,6 @@ static void sk_rxeof(sc_if) ifp->if_ierrors++; continue; } - m_adj(m0, ETHER_ALIGN); m = m0; } else { m->m_pkthdr.rcvif = ifp; diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 93fba3ec9afe..9ed0266ba448 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -1029,14 +1029,13 @@ static void vr_rxeof(sc) */ total_len -= ETHER_CRC_LEN; - m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, - total_len + ETHER_ALIGN, 0, ifp, NULL); + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp, + NULL); vr_newbuf(sc, cur_rx, m); if (m0 == NULL) { ifp->if_ierrors++; continue; } - m_adj(m0, ETHER_ALIGN); m = m0; ifp->if_ipackets++; diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c index e1fa7605b54b..f47508026d12 100644 --- a/sys/dev/vx/if_vx.c +++ b/sys/dev/vx/if_vx.c @@ -691,15 +691,12 @@ again: { struct mbuf *m0; - m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, - m->m_pkthdr.len + ETHER_ALIGN, 0, ifp, NULL); - + m0 = m_devget(mtod(m, char *), m->m_pkthdr.len, ETHER_ALIGN, ifp, NULL); if (m0 == NULL) { ifp->if_ierrors++; goto abort; } - m_adj(m0, ETHER_ALIGN); m_freem(m); m = m0; } -- cgit v1.3