hyperv/hn: Don't hold txdesc, if no BPFs are attached.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8675
This commit is contained in:
Sepherosa Ziehau 2016-12-01 03:39:34 +00:00
parent 7f67614061
commit 8e7d313625
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=309348

View File

@ -1924,17 +1924,20 @@ hn_encap(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd,
static int static int
hn_txpkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd) hn_txpkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd)
{ {
int error, send_failed = 0; int error, send_failed = 0, has_bpf;
again: again:
/* has_bpf = bpf_peers_present(ifp->if_bpf);
* Make sure that this txd and any aggregated txds are not freed if (has_bpf) {
* before ETHER_BPF_MTAP. /*
*/ * Make sure that this txd and any aggregated txds are not
hn_txdesc_hold(txd); * freed before ETHER_BPF_MTAP.
*/
hn_txdesc_hold(txd);
}
error = txr->hn_sendpkt(txr, txd); error = txr->hn_sendpkt(txr, txd);
if (!error) { if (!error) {
if (bpf_peers_present(ifp->if_bpf)) { if (has_bpf) {
const struct hn_txdesc *tmp_txd; const struct hn_txdesc *tmp_txd;
ETHER_BPF_MTAP(ifp, txd->m); ETHER_BPF_MTAP(ifp, txd->m);
@ -1957,7 +1960,8 @@ hn_txpkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd)
txr->hn_pkts += txr->hn_stat_pkts; txr->hn_pkts += txr->hn_stat_pkts;
txr->hn_sends++; txr->hn_sends++;
} }
hn_txdesc_put(txr, txd); if (has_bpf)
hn_txdesc_put(txr, txd);
if (__predict_false(error)) { if (__predict_false(error)) {
int freed; int freed;