Date: Mon, 12 Oct 2015 04:30:39 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289164 - in head/sys: dev/iwn net80211 Message-ID: <201510120430.t9C4Udjr021345@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: adrian Date: Mon Oct 12 04:30:38 2015 New Revision: 289164 URL: https://svnweb.freebsd.org/changeset/base/289164 Log: net80211: free node reference in the ieee80211_parent_xmitpkt() when error happened. Move error handling into ieee80211_parent_xmitpkt() instead of spreading it between functions. Submitted by: <s3erios@gmail.com> Differential Revision: https://reviews.freebsd.org/D3772 Modified: head/sys/dev/iwn/if_iwn.c head/sys/net80211/ieee80211_freebsd.c head/sys/net80211/ieee80211_hostap.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_output.c head/sys/net80211/ieee80211_power.c head/sys/net80211/ieee80211_superg.c head/sys/net80211/ieee80211_wds.c Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/dev/iwn/if_iwn.c Mon Oct 12 04:30:38 2015 (r289164) @@ -4950,9 +4950,7 @@ iwn_transmit(struct ieee80211com *ic, st } error = iwn_tx_data(sc, m, ni); - if (error) { - if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); - } else + if (!error) sc->sc_tx_timer = 5; IWN_UNLOCK(sc); return (error); Modified: head/sys/net80211/ieee80211_freebsd.c ============================================================================== --- head/sys/net80211/ieee80211_freebsd.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/net80211/ieee80211_freebsd.c Mon Oct 12 04:30:38 2015 (r289164) @@ -529,9 +529,6 @@ ieee80211_get_rx_params(struct mbuf *m, /* * Transmit a frame to the parent interface. - * - * TODO: if the transmission fails, make sure the parent node is freed - * (the callers will first need modifying.) */ int ieee80211_parent_xmitpkt(struct ieee80211com *ic, struct mbuf *m) @@ -544,8 +541,16 @@ ieee80211_parent_xmitpkt(struct ieee8021 */ IEEE80211_TX_LOCK_ASSERT(ic); error = ic->ic_transmit(ic, m); - if (error) + if (error) { + struct ieee80211_node *ni; + + ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; + + /* XXX number of fragments */ + if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); + ieee80211_free_node(ni); ieee80211_free_mbuf(m); + } return (error); } Modified: head/sys/net80211/ieee80211_hostap.c ============================================================================== --- head/sys/net80211/ieee80211_hostap.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/net80211/ieee80211_hostap.c Mon Oct 12 04:30:38 2015 (r289164) @@ -2327,12 +2327,11 @@ ieee80211_recv_pspoll(struct ieee80211_n /* * Do the right thing; if it's an encap'ed frame then - * call ieee80211_parent_xmitpkt() (and free the ref) else + * call ieee80211_parent_xmitpkt() else * call ieee80211_vap_xmitpkt(). */ if (m->m_flags & M_ENCAP) { - if (ieee80211_parent_xmitpkt(ic, m) != 0) - ieee80211_free_node(ni); + (void) ieee80211_parent_xmitpkt(ic, m); } else { (void) ieee80211_vap_xmitpkt(vap, m); } Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/net80211/ieee80211_mesh.c Mon Oct 12 04:30:38 2015 (r289164) @@ -1239,12 +1239,8 @@ mesh_forward(struct ieee80211vap *vap, s IEEE80211_TX_LOCK(ic); err = ieee80211_parent_xmitpkt(ic, mcopy); IEEE80211_TX_UNLOCK(ic); - if (err != 0) { - /* NB: IFQ_HANDOFF reclaims mbuf */ - ieee80211_free_node(ni); - } else { + if (!err) if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - } } static struct mbuf * Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/net80211/ieee80211_output.c Mon Oct 12 04:30:38 2015 (r289164) @@ -132,7 +132,7 @@ ieee80211_vap_pkt_send_dest(struct ieee8 { struct ieee80211com *ic = vap->iv_ic; struct ifnet *ifp = vap->iv_ifp; - int error, len, mcast; + int len, mcast; if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && (m->m_flags & M_PWR_SAV) == 0) { @@ -264,18 +264,13 @@ ieee80211_vap_pkt_send_dest(struct ieee8 return (ENOBUFS); } } - error = ieee80211_parent_xmitpkt(ic, m); + (void) ieee80211_parent_xmitpkt(ic, m); /* * Unlock at this point - no need to hold it across * ieee80211_free_node() (ie, the comlock) */ IEEE80211_TX_UNLOCK(ic); - if (error != 0) { - /* NB: IFQ_HANDOFF reclaims mbuf */ - ieee80211_free_node(ni); - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - } ic->ic_lastdata = ticks; return (0); Modified: head/sys/net80211/ieee80211_power.c ============================================================================== --- head/sys/net80211/ieee80211_power.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/net80211/ieee80211_power.c Mon Oct 12 04:30:38 2015 (r289164) @@ -457,12 +457,7 @@ pwrsave_flushq(struct ieee80211_node *ni KASSERT((m->m_flags & M_ENCAP), ("%s: parentq with non-M_ENCAP frame!\n", __func__)); - /* - * For encaped frames, we need to free the node - * reference upon failure. - */ - if (ieee80211_parent_xmitpkt(ic, m) != 0) - ieee80211_free_node(ni); + (void) ieee80211_parent_xmitpkt(ic, m); } /* VAP frames, aren't encapsulated */ Modified: head/sys/net80211/ieee80211_superg.c ============================================================================== --- head/sys/net80211/ieee80211_superg.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/net80211/ieee80211_superg.c Mon Oct 12 04:30:38 2015 (r289164) @@ -475,13 +475,9 @@ ff_transmit(struct ieee80211_node *ni, s if (m != NULL) { struct ifnet *ifp = vap->iv_ifp; - error = ieee80211_parent_xmitpkt(ic, m);; - if (error != 0) { - /* NB: IFQ_HANDOFF reclaims mbuf */ - ieee80211_free_node(ni); - } else { + error = ieee80211_parent_xmitpkt(ic, m); + if (!error) if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - } } else ieee80211_free_node(ni); } Modified: head/sys/net80211/ieee80211_wds.c ============================================================================== --- head/sys/net80211/ieee80211_wds.c Mon Oct 12 04:05:12 2015 (r289163) +++ head/sys/net80211/ieee80211_wds.c Mon Oct 12 04:30:38 2015 (r289164) @@ -298,11 +298,7 @@ ieee80211_dwds_mcast(struct ieee80211vap mcopy->m_pkthdr.rcvif = (void *) ni; err = ieee80211_parent_xmitpkt(ic, mcopy); - if (err) { - /* NB: IFQ_HANDOFF reclaims mbuf */ - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - ieee80211_free_node(ni); - } else { + if (!err) { if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); if_inc_counter(ifp, IFCOUNTER_OBYTES,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510120430.t9C4Udjr021345>