search for: kfree_skb

Displaying 20 results from an estimated 319 matches for "kfree_skb".

2014 Mar 21
2
[PATCH net] virtio-net: don't free skb immediately on kick failure
...virtio_net.c +++ b/drivers/net/virtio_net.c @@ -882,8 +882,10 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) if (net_ratelimit()) dev_warn(&dev->dev, "Unexpected TXQ (%d) queue failure: %d\n", qnum, err); - dev->stats.tx_dropped++; - kfree_skb(skb); + if (err) { + dev->stats.tx_dropped++; + kfree_skb(skb); + } return NETDEV_TX_OK; } -- 1.8.3.2
2014 Mar 21
2
[PATCH net] virtio-net: don't free skb immediately on kick failure
...virtio_net.c +++ b/drivers/net/virtio_net.c @@ -882,8 +882,10 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) if (net_ratelimit()) dev_warn(&dev->dev, "Unexpected TXQ (%d) queue failure: %d\n", qnum, err); - dev->stats.tx_dropped++; - kfree_skb(skb); + if (err) { + dev->stats.tx_dropped++; + kfree_skb(skb); + } return NETDEV_TX_OK; } -- 1.8.3.2
2017 Nov 29
4
[PATCH net,stable v2] vhost: fix skb leak in handle_rx()
..._consume(&nvq->rxq); + /* On overrun, truncate and discard */ + if (unlikely(headcount > UIO_MAXIOV)) { + iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); + err = sock->ops->recvmsg(sock, &msg, + 1, MSG_DONTWAIT | MSG_TRUNC); + if (unlikely(err != 1)) + kfree_skb((struct sk_buff *)msg.msg_control); + pr_debug("Discarded rx packet: len %zd\n", sock_len); + continue; + } /* We don't need to be notified again. */ iov_iter_init(&msg.msg_iter, READ, vq->iov, in, vhost_len); fixup = msg.msg_iter; @@ -818,6 +820,7 @@ static void...
2017 Nov 29
4
[PATCH net,stable v2] vhost: fix skb leak in handle_rx()
..._consume(&nvq->rxq); + /* On overrun, truncate and discard */ + if (unlikely(headcount > UIO_MAXIOV)) { + iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); + err = sock->ops->recvmsg(sock, &msg, + 1, MSG_DONTWAIT | MSG_TRUNC); + if (unlikely(err != 1)) + kfree_skb((struct sk_buff *)msg.msg_control); + pr_debug("Discarded rx packet: len %zd\n", sock_len); + continue; + } /* We don't need to be notified again. */ iov_iter_init(&msg.msg_iter, READ, vq->iov, in, vhost_len); fixup = msg.msg_iter; @@ -818,6 +820,7 @@ static void...
2017 Nov 30
2
[PATCH net,stable v2] vhost: fix skb leak in handle_rx()
...rr = sock->ops->recvmsg(sock, &msg, >> + 1, MSG_DONTWAIT | MSG_TRUNC); >> + if (unlikely(err != 1)) > Why 1? How is receiving 1 byte special or even possible? > Also, I wouldn't put an unlikely here. It's all error handling code anyway. > >> + kfree_skb((struct sk_buff *)msg.msg_control); > You do not need a cast here. > Also, is it really safe to refer to msg_control here? > I'd rather keep a copy of the skb pointer and use it than assume > caller did not change it. But also see below. > >> + pr_debug("Discarded rx...
2017 Nov 30
2
[PATCH net,stable v2] vhost: fix skb leak in handle_rx()
...rr = sock->ops->recvmsg(sock, &msg, >> + 1, MSG_DONTWAIT | MSG_TRUNC); >> + if (unlikely(err != 1)) > Why 1? How is receiving 1 byte special or even possible? > Also, I wouldn't put an unlikely here. It's all error handling code anyway. > >> + kfree_skb((struct sk_buff *)msg.msg_control); > You do not need a cast here. > Also, is it really safe to refer to msg_control here? > I'd rather keep a copy of the skb pointer and use it than assume > caller did not change it. But also see below. > >> + pr_debug("Discarded rx...
2017 Dec 01
1
[PATCH 2/3] tun: free skb in early errors
...ERRQUEUE) { ret = sock_recv_errqueue(sock->sk, m, total_len, @@ -2087,6 +2090,11 @@ static int tun_recvmsg(struct socket *sock, struct msghdr *m, size_t total_len, m->msg_flags |= MSG_TRUNC; ret = flags & MSG_TRUNC ? ret : total_len; } + goto out; + +out_free_skb: + if (skb) + kfree_skb(skb); out: tun_put(tun); return ret; -- 1.8.3.1
2011 Jan 06
2
Flow Control and Port Mirroring Revisited
...t the flow is "paced" by the slowest link. Unfortunately I'm unsure how to achieve that. One idea that I had was to skb_get() the original skb each time it is cloned - that is easy enough. But unfortunately it seems to me that approach would require some sort of callback mechanism in kfree_skb() so that the cloned skbs can kfree_skb() the original skb. Ideas would be greatly appreciated. [1] http://openvswitch.org/pipermail/dev_openvswitch.org/2010-October/003806.html [2] http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob;f=datapath/actions.c;h=5e16143ca402f7da0ee8fc18ee5eb...
2011 Jan 06
2
Flow Control and Port Mirroring Revisited
...t the flow is "paced" by the slowest link. Unfortunately I'm unsure how to achieve that. One idea that I had was to skb_get() the original skb each time it is cloned - that is easy enough. But unfortunately it seems to me that approach would require some sort of callback mechanism in kfree_skb() so that the cloned skbs can kfree_skb() the original skb. Ideas would be greatly appreciated. [1] http://openvswitch.org/pipermail/dev_openvswitch.org/2010-October/003806.html [2] http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob;f=datapath/actions.c;h=5e16143ca402f7da0ee8fc18ee5eb...
2008 May 26
7
[PATCH 1/3] virtio: fix virtio_net xmit of freed skb bug
...free_old_xmit_skbs(vi); /* If we has a buffer left over from last time, send it now. */ - if (vi->last_xmit_skb) { + if (unlikely(vi->last_xmit_skb)) { if (xmit_skb(vi, vi->last_xmit_skb) != 0) { /* Drop this skb: we only queue one. */ vi->dev->stats.tx_dropped++; kfree_skb(skb); + skb = NULL; goto stop_queue; } vi->last_xmit_skb = NULL; } /* Put new one in send queue and do transmit */ - __skb_queue_head(&vi->send, skb); - if (xmit_skb(vi, skb) != 0) { - vi->last_xmit_skb = skb; - goto stop_queue; + if (likely(skb)) { + __skb_queue_h...
2008 May 26
7
[PATCH 1/3] virtio: fix virtio_net xmit of freed skb bug
...free_old_xmit_skbs(vi); /* If we has a buffer left over from last time, send it now. */ - if (vi->last_xmit_skb) { + if (unlikely(vi->last_xmit_skb)) { if (xmit_skb(vi, vi->last_xmit_skb) != 0) { /* Drop this skb: we only queue one. */ vi->dev->stats.tx_dropped++; kfree_skb(skb); + skb = NULL; goto stop_queue; } vi->last_xmit_skb = NULL; } /* Put new one in send queue and do transmit */ - __skb_queue_head(&vi->send, skb); - if (xmit_skb(vi, skb) != 0) { - vi->last_xmit_skb = skb; - goto stop_queue; + if (likely(skb)) { + __skb_queue_h...
2014 Mar 24
1
[PATCH net] virtio-net: don't free skb immediately on kick failure
...@ -882,8 +882,10 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) >> if (net_ratelimit()) >> dev_warn(&dev->dev, >> "Unexpected TXQ (%d) queue failure: %d\n", qnum, err); >> - dev->stats.tx_dropped++; >> - kfree_skb(skb); >> + if (err) { >> + dev->stats.tx_dropped++; >> + kfree_skb(skb); >> + } >> return NETDEV_TX_OK; >> } >> >> -- >> 1.8.3.2 > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in &...
2014 Mar 24
1
[PATCH net] virtio-net: don't free skb immediately on kick failure
...@ -882,8 +882,10 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev) >> if (net_ratelimit()) >> dev_warn(&dev->dev, >> "Unexpected TXQ (%d) queue failure: %d\n", qnum, err); >> - dev->stats.tx_dropped++; >> - kfree_skb(skb); >> + if (err) { >> + dev->stats.tx_dropped++; >> + kfree_skb(skb); >> + } >> return NETDEV_TX_OK; >> } >> >> -- >> 1.8.3.2 > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in &...
2008 Jan 23
2
[PATCH 1/2] reset support: make net driver alloc/cleanup in probe and remove
...v_priv(dev); - struct sk_buff *skb; napi_disable(&vi->napi); - /* networking core has neutered skb_xmit_done/skb_recv_done, so don't - * worry about races vs. get(). */ - vi->rvq->vq_ops->shutdown(vi->rvq); - while ((skb = __skb_dequeue(&vi->recv)) != NULL) { - kfree_skb(skb); - vi->num--; - } - vi->svq->vq_ops->shutdown(vi->svq); - while ((skb = __skb_dequeue(&vi->send)) != NULL) - kfree_skb(skb); - - BUG_ON(vi->num != 0); return 0; } @@ -403,10 +384,22 @@ static int virtnet_probe(struct virtio_d pr_debug("virtio_net: regist...
2008 Jan 23
2
[PATCH 1/2] reset support: make net driver alloc/cleanup in probe and remove
...v_priv(dev); - struct sk_buff *skb; napi_disable(&vi->napi); - /* networking core has neutered skb_xmit_done/skb_recv_done, so don't - * worry about races vs. get(). */ - vi->rvq->vq_ops->shutdown(vi->rvq); - while ((skb = __skb_dequeue(&vi->recv)) != NULL) { - kfree_skb(skb); - vi->num--; - } - vi->svq->vq_ops->shutdown(vi->svq); - while ((skb = __skb_dequeue(&vi->send)) != NULL) - kfree_skb(skb); - - BUG_ON(vi->num != 0); return 0; } @@ -403,10 +384,22 @@ static int virtnet_probe(struct virtio_d pr_debug("virtio_net: regist...
2017 Dec 01
9
[PATCH net,stable v4 0/3] vhost: fix a few skb leaks
From: Wei Xu <wexu at redhat.com> Matthew found a roughly 40% tcp throughput regression with commit c67df11f(vhost_net: try batch dequing from skb array) as discussed in the following thread: https://www.mail-archive.com/netdev at vger.kernel.org/msg187936.html v4: - fix zero iov iterator count in tap/tap_do_read()(Jason) - don't put tun in case of EBADFD(Jason) - Replace
2017 Dec 01
9
[PATCH net,stable v4 0/3] vhost: fix a few skb leaks
From: Wei Xu <wexu at redhat.com> Matthew found a roughly 40% tcp throughput regression with commit c67df11f(vhost_net: try batch dequing from skb array) as discussed in the following thread: https://www.mail-archive.com/netdev at vger.kernel.org/msg187936.html v4: - fix zero iov iterator count in tap/tap_do_read()(Jason) - don't put tun in case of EBADFD(Jason) - Replace
2018 Sep 06
1
[PATCH net-next 10/11] tap: accept an array of XDP buffs through sendmsg()
...& > + __vlan_get_protocol(skb, skb->protocol, &depth) != 0) > + skb_set_network_header(skb, depth); > + > + rcu_read_lock(); > + tap = rcu_dereference(q->tap); > + if (tap) { > + skb->dev = tap->dev; > + dev_queue_xmit(skb); > + } else { > + kfree_skb(skb); > + } > + rcu_read_unlock(); > + > + return 0; > + > +err_kfree: > + kfree_skb(skb); > +err: > + rcu_read_lock(); > + tap = rcu_dereference(q->tap); > + if (tap && tap->count_tx_dropped) > + tap->count_tx_dropped(tap); > + rcu_read_unl...
2008 Jul 15
0
[PATCH 2/5] virtio: fix virtio_net xmit of freed skb bug
...* If we has a buffer left over from last time, send it now. */ > - if (vi->last_xmit_skb) { > + if (unlikely(vi->last_xmit_skb)) { > if (xmit_skb(vi, vi->last_xmit_skb) != 0) { > /* Drop this skb: we only queue one. */ > vi->dev->stats.tx_dropped++; > kfree_skb(skb); > + skb = NULL; > goto stop_queue; > } > vi->last_xmit_skb = NULL; With this, may drop an skb and then later in the function discover that we could have sent it after all. Poor wee skb :) How about the incremental patch below? Cheers, Mark. Currently we drop th...
2008 Jul 15
0
[PATCH 2/5] virtio: fix virtio_net xmit of freed skb bug
...* If we has a buffer left over from last time, send it now. */ > - if (vi->last_xmit_skb) { > + if (unlikely(vi->last_xmit_skb)) { > if (xmit_skb(vi, vi->last_xmit_skb) != 0) { > /* Drop this skb: we only queue one. */ > vi->dev->stats.tx_dropped++; > kfree_skb(skb); > + skb = NULL; > goto stop_queue; > } > vi->last_xmit_skb = NULL; With this, may drop an skb and then later in the function discover that we could have sent it after all. Poor wee skb :) How about the incremental patch below? Cheers, Mark. Currently we drop th...