- Fix VLAN_INPUT_TAG() macro, so that it doesn't touch mtag in

case if memory allocation failed.
- Remove fourth argument from VLAN_INPUT_TAG(), that was used
  incorrectly in almost all drivers. Indicate failure with
  mbuf value of NULL.

In collaboration with:	yongari, ru, sam
This commit is contained in:
Gleb Smirnoff 2005-12-18 18:24:27 +00:00
parent bd6b217753
commit d147662cd3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153512
10 changed files with 38 additions and 23 deletions

View File

@ -2623,8 +2623,11 @@ bge_rxeof(sc)
* If we received a packet with a vlan tag,
* attach that information to the packet.
*/
if (have_tag)
VLAN_INPUT_TAG(ifp, m, vlan_tag, continue);
if (have_tag) {
VLAN_INPUT_TAG(ifp, m, vlan_tag);
if (m == NULL)
continue;
}
BGE_UNLOCK(sc);
(*ifp->if_input)(ifp, m);

View File

@ -2970,8 +2970,7 @@ em_process_receive_interrupts(struct adapter * adapter, int count)
if (current_desc->status & E1000_RXD_STAT_VP)
VLAN_INPUT_TAG(ifp, adapter->fmp,
(le16toh(current_desc->special) &
E1000_RXD_SPC_VLAN_MASK),
adapter->fmp = NULL);
E1000_RXD_SPC_VLAN_MASK));
#ifndef __NO_STRICT_ALIGNMENT
skip:
#endif

View File

@ -2153,8 +2153,7 @@ ixgb_process_receive_interrupts(struct adapter * adapter, int count)
adapter->fmp);
if (current_desc->status & IXGB_RX_DESC_STATUS_VP)
VLAN_INPUT_TAG(ifp, adapter->fmp,
current_desc->special,
adapter->fmp = NULL);
current_desc->special);
if (adapter->fmp != NULL) {
IXGB_UNLOCK(adapter);

View File

@ -1229,7 +1229,9 @@ nge_rxeof(sc)
*/
if (extsts & NGE_RXEXTSTS_VLANPKT) {
VLAN_INPUT_TAG(ifp, m,
ntohs(extsts & NGE_RXEXTSTS_VTCI), continue);
ntohs(extsts & NGE_RXEXTSTS_VTCI));
if (m == NULL)
continue;
}
NGE_UNLOCK(sc);
(*ifp->if_input)(ifp, m);

View File

@ -1671,9 +1671,12 @@ re_rxeof(sc)
}
}
if (rxvlan & RL_RDESC_VLANCTL_TAG)
if (rxvlan & RL_RDESC_VLANCTL_TAG) {
VLAN_INPUT_TAG(ifp, m,
ntohs((rxvlan & RL_RDESC_VLANCTL_DATA)), continue);
ntohs((rxvlan & RL_RDESC_VLANCTL_DATA)));
if (m == NULL)
continue;
}
RL_UNLOCK(sc);
(*ifp->if_input)(ifp, m);
RL_LOCK(sc);

View File

@ -2727,8 +2727,11 @@ ti_rxeof(sc)
* If we received a packet with a vlan tag,
* tag it before passing the packet upward.
*/
if (have_tag)
VLAN_INPUT_TAG(ifp, m, vlan_tag, continue);
if (have_tag) {
VLAN_INPUT_TAG(ifp, m, vlan_tag);
if (m == NULL)
continue;
}
TI_UNLOCK(sc);
(*ifp->if_input)(ifp, m);
TI_LOCK(sc);

View File

@ -766,8 +766,9 @@ txp_rx_reclaim(sc, r)
}
if (rxd->rx_stat & RX_STAT_VLAN) {
VLAN_INPUT_TAG(ifp,
m, htons(rxd->rx_vlan >> 16), goto next);
VLAN_INPUT_TAG(ifp, m, htons(rxd->rx_vlan >> 16));
if (m == NULL)
goto next;
}
TXP_UNLOCK(sc);

View File

@ -1490,9 +1490,12 @@ vge_rxeof(sc)
}
}
if (rxstat & VGE_RDSTS_VTAG)
if (rxstat & VGE_RDSTS_VTAG) {
VLAN_INPUT_TAG(ifp, m,
ntohs((rxctl & VGE_RDCTL_VLANID)), continue);
ntohs((rxctl & VGE_RDCTL_VLANID)));
if (m == NULL)
continue;
}
VGE_UNLOCK(sc);
(*ifp->if_input)(ifp, m);

View File

@ -102,18 +102,19 @@ struct vlanreq {
*/
#define VLAN_TAG_VALUE(_mt) (*(u_int *)((_mt) + 1))
#define VLAN_INPUT_TAG(_ifp, _m, _t, _errcase) do { \
#define VLAN_INPUT_TAG(_ifp, _m, _t) do { \
struct m_tag *mtag; \
mtag = m_tag_alloc(MTAG_VLAN, MTAG_VLAN_TAG, \
sizeof (u_int), M_NOWAIT); \
if (mtag == NULL) { \
if (mtag != NULL) { \
VLAN_TAG_VALUE(mtag) = (_t); \
m_tag_prepend((_m), mtag); \
(_m)->m_flags |= M_VLANTAG; \
} else { \
(_ifp)->if_ierrors++; \
m_freem(_m); \
_errcase; \
_m = NULL; \
} \
VLAN_TAG_VALUE(mtag) = (_t); \
m_tag_prepend((_m), mtag); \
(_m)->m_flags |= M_VLANTAG; \
} while (0)
#define VLAN_OUTPUT_TAG(_ifp, _m) \

View File

@ -710,8 +710,9 @@ ieee80211_deliver_data(struct ieee80211com *ic,
if (m != NULL) {
if (ni->ni_vlan != 0) {
/* attach vlan tag */
/* XXX goto err? */
VLAN_INPUT_TAG(ifp, m, ni->ni_vlan, goto out);
VLAN_INPUT_TAG(ifp, m, ni->ni_vlan);
if (m == NULL)
goto out; /* XXX goto err? */
}
(*ifp->if_input)(ifp, m);
}