vhost_net: examine pointer types during un-producing
Subsystems (6)
PATCH 1/1 vhost_net: examine pointer types during un-producing
After commit 761876c857cb ("tap: XDP support"), we can actually queueing XDP pointers in the pointer ring, so we should examine the pointer type before freeing the pointer.
--- drivers/net/tun.c | 3 ++- drivers/vhost/net.c | 2 +- include/linux/if_tun.h | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/tun.c +2 -1
@@ -655,7 +655,7 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile)return tun; } -static void tun_ptr_free (void *ptr) +void tun_ptr_free (void *ptr) {if (!ptr)return ;
@@ -667,6 +667,7 @@ static void tun_ptr_free(void *ptr)__skb_array_destroy_skb (ptr); } } +EXPORT_SYMBOL_GPL (tun_ptr_free);static void tun_queue_purge (struct tun_file *tfile) {
drivers/vhost/net.c +1 -1
@@ -170,7 +170,7 @@ static void vhost_net_buf_unproduce(struct vhost_net_virtqueue *nvq)if (nvq->rx_ring && !vhost_net_buf_is_empty (rxq)) {ptr_ring_unconsume (nvq->rx_ring, rxq->queue + rxq->head,vhost_net_buf_get_size (rxq), - __skb_array_destroy_skb); + tun_ptr_free); rxq->head = rxq->tail =0 ; } }
include/linux/if_tun.h +4 -0
@@ -25,6 +25,7 @@ struct ptr_ring *tun_get_tx_ring(struct file *file);bool tun_is_xdp_buff (void *ptr);void *tun_xdp_to_ptr (void *ptr);void *tun_ptr_to_xdp (void *ptr); +void tun_ptr_free (void *ptr);#else #include <linux/err.h> #include <linux/errno.h>
@@ -50,5 +51,8 @@ static inline void *tun_ptr_to_xdp(void *ptr) {return NULL ; } +static inline void tun_ptr_free (void *ptr) +{ +}#endif /* CONFIG_TUN */ #endif /* __IF_TUN_H */
Signature · 1 line
2.7.4
Quoted 7 lines · Jason Wang
After commit
761876c857cb("tap: XDP support"), we can actually queueing XDP pointers in the pointer ring, so we should examine the pointer type before freeing the pointer.Fixes 761876c857cb ("tap: XDP support")Reported-by Michael S. Tsirkin <[email protected]>Signed-off-by Jason Wang <[email protected]>
Quoted 63 lines
--- drivers/net/tun.c | 3 ++- drivers/vhost/net.c | 2 +- include/linux/if_tun.h | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-)drivers/net/tun.c +2
-1@@ -655,7 +655,7 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile)return tun; } -static void tun_ptr_free (void *ptr) +void tun_ptr_free (void *ptr) {if (!ptr)return ;@@ -667,6 +667,7 @@ static void tun_ptr_free(void *ptr)__skb_array_destroy_skb (ptr); } } +EXPORT_SYMBOL_GPL (tun_ptr_free);static void tun_queue_purge (struct tun_file *tfile) {drivers/vhost/net.c +1
-1@@ -170,7 +170,7 @@ static void vhost_net_buf_unproduce(struct vhost_net_virtqueue *nvq)if (nvq->rx_ring && !vhost_net_buf_is_empty (rxq)) {ptr_ring_unconsume (nvq->rx_ring, rxq->queue + rxq->head,vhost_net_buf_get_size (rxq), - __skb_array_destroy_skb); + tun_ptr_free); rxq->head = rxq->tail =0 ; } }include/linux/if_tun.h +4
-0@@ -25,6 +25,7 @@ struct ptr_ring *tun_get_tx_ring(struct file *file);bool tun_is_xdp_buff (void *ptr);void *tun_xdp_to_ptr (void *ptr);void *tun_ptr_to_xdp (void *ptr); +void tun_ptr_free (void *ptr);#else #include <linux/err.h> #include <linux/errno.h> @@ -50,5 +51,8 @@ static inline void *tun_ptr_to_xdp(void *ptr) {return NULL ; } +static inline void tun_ptr_free (void *ptr) +{ +}#endif /* CONFIG_TUN */ #endif /* __IF_TUN_H */ Signature · 1 line
2.7.4
Quoted 5 lines · Jason Wang
After commit
761876c857cb("tap: XDP support"), we can actually queueing XDP pointers in the pointer ring, so we should examine the pointer type before freeing the pointer.Fixes 761876c857cb ("tap: XDP support")
Oops, the commit is wrong, let me repost.
Thanks
Quoted 63 lines
Reported-by Michael S. Tsirkin <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/tun.c | 3 ++- drivers/vhost/net.c | 2 +- include/linux/if_tun.h | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-)drivers/net/tun.c +2
-1@@ -655,7 +655,7 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile)return tun; } -static void tun_ptr_free (void *ptr) +void tun_ptr_free (void *ptr) {if (!ptr)return ;@@ -667,6 +667,7 @@ static void tun_ptr_free(void *ptr)__skb_array_destroy_skb (ptr); } } +EXPORT_SYMBOL_GPL (tun_ptr_free);static void tun_queue_purge (struct tun_file *tfile) {drivers/vhost/net.c +1
-1@@ -170,7 +170,7 @@ static void vhost_net_buf_unproduce(struct vhost_net_virtqueue *nvq)if (nvq->rx_ring && !vhost_net_buf_is_empty (rxq)) {ptr_ring_unconsume (nvq->rx_ring, rxq->queue + rxq->head,vhost_net_buf_get_size (rxq), - __skb_array_destroy_skb); + tun_ptr_free); rxq->head = rxq->tail =0 ; } }include/linux/if_tun.h +4
-0@@ -25,6 +25,7 @@ struct ptr_ring *tun_get_tx_ring(struct file *file);bool tun_is_xdp_buff (void *ptr);void *tun_xdp_to_ptr (void *ptr);void *tun_ptr_to_xdp (void *ptr); +void tun_ptr_free (void *ptr);#else #include <linux/err.h> #include <linux/errno.h> @@ -50,5 +51,8 @@ static inline void *tun_ptr_to_xdp(void *ptr) {return NULL ; } +static inline void tun_ptr_free (void *ptr) +{ +}#endif /* CONFIG_TUN */ #endif /* __IF_TUN_H */
Quoted 5 lines · Jason Wang
After commit
761876c857cb("tap: XDP support"), we can actually queueing XDP pointers in the pointer ring, so we should examine the pointer type before freeing the pointer.Fixes 761876c857cb ("tap: XDP support")
Oops, the commit is wrong, let me repost.
Thanks
Quoted 55 lines
Reported-by Michael S. Tsirkin <[email protected]>Signed-off-by Jason Wang <[email protected]>--- drivers/net/tun.c | 3 ++- drivers/vhost/net.c | 2 +- include/linux/if_tun.h | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-)drivers/net/tun.c +2
-1@@ -655,7 +655,7 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile)return tun; } -static void tun_ptr_free (void *ptr) +void tun_ptr_free (void *ptr) {if (!ptr)return ;@@ -667,6 +667,7 @@ static void tun_ptr_free(void *ptr)__skb_array_destroy_skb (ptr); } } +EXPORT_SYMBOL_GPL (tun_ptr_free);static void tun_queue_purge (struct tun_file *tfile) {drivers/vhost/net.c +1
-1@@ -170,7 +170,7 @@ static void vhost_net_buf_unproduce(struct vhost_net_virtqueue *nvq)if (nvq->rx_ring && !vhost_net_buf_is_empty (rxq)) {ptr_ring_unconsume (nvq->rx_ring, rxq->queue + rxq->head,vhost_net_buf_get_size (rxq), - __skb_array_destroy_skb); + tun_ptr_free); rxq->head = rxq->tail =0 ; } }include/linux/if_tun.h +1
-0@@ -25,6 +25,7 @@ struct ptr_ring *tun_get_tx_ring(struct file *file);bool tun_is_xdp_buff (void *ptr);void *tun_xdp_to_ptr (void *ptr);void *tun_ptr_to_xdp (void *ptr); +void tun_ptr_free (void *ptr);#else #include <linux/err.h> #include <linux/errno.h>
include/linux/if_tun.h static inline void *tun_ptr_to_xdp(void *ptr) · line 58
Quoted 8 lines
include/linux/if_tun.h +3
-0@@ -50,5 +51,8 @@ static inline void *tun_ptr_to_xdp(void *ptr) {return NULL ; } +static inline void tun_ptr_free (void *ptr) +{ +}#endif /* CONFIG_TUN */ #endif /* __IF_TUN_H */
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization