search for: tun_build_skb

Displaying 20 results from an estimated 21 matches for "tun_build_skb".

2018 Sep 06
2
[PATCH net-next 04/11] tuntap: simplify error handling in tun_build_skb()
...+++++++--------------------- > 1 file changed, 16 insertions(+), 21 deletions(-) > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index 372caf7d67d9..f8cdcfa392c3 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -1642,7 +1642,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > int len, int *skb_xdp) > { > struct page_frag *alloc_frag = &current->task_frag; > - struct sk_buff *skb; > + struct sk_buff *skb = NULL; > struct bpf_prog *xdp_prog; > int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info))...
2018 Sep 06
2
[PATCH net-next 04/11] tuntap: simplify error handling in tun_build_skb()
...+++++++--------------------- > 1 file changed, 16 insertions(+), 21 deletions(-) > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index 372caf7d67d9..f8cdcfa392c3 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -1642,7 +1642,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > int len, int *skb_xdp) > { > struct page_frag *alloc_frag = &current->task_frag; > - struct sk_buff *skb; > + struct sk_buff *skb = NULL; > struct bpf_prog *xdp_prog; > int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info))...
2018 Sep 06
0
[PATCH net-next 04/11] tuntap: simplify error handling in tun_build_skb()
...- drivers/net/tun.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 372caf7d67d9..f8cdcfa392c3 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1642,7 +1642,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, int len, int *skb_xdp) { struct page_frag *alloc_frag = &current->task_frag; - struct sk_buff *skb; + struct sk_buff *skb = NULL; struct bpf_prog *xdp_prog; int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); unsigned int delta = 0; @@ -166...
2018 Sep 06
1
[PATCH net-next 05/11] tuntap: tweak on the path of non-xdp case in tun_build_skb()
...vers/net/tun.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index f8cdcfa392c3..389aa0727cc6 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -1675,10 +1675,12 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > * of xdp_prog above, this should be rare and for simplicity > * we do XDP on skb in case the headroom is not enough. > */ > - if (hdr->gso_type || !xdp_prog) > + if (hdr->gso_type || !xdp_prog) { > *skb_xdp = 1; > - else > - *skb_...
2018 Sep 07
0
[PATCH net-next 04/11] tuntap: simplify error handling in tun_build_skb()
...>> 1 file changed, 16 insertions(+), 21 deletions(-) >> >> diff --git a/drivers/net/tun.c b/drivers/net/tun.c >> index 372caf7d67d9..f8cdcfa392c3 100644 >> --- a/drivers/net/tun.c >> +++ b/drivers/net/tun.c >> @@ -1642,7 +1642,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, >> int len, int *skb_xdp) >> { >> struct page_frag *alloc_frag = &current->task_frag; >> - struct sk_buff *skb; >> + struct sk_buff *skb = NULL; >> struct bpf_prog *xdp_prog; >> int buflen = SKB_DATA_ALIG...
2018 Sep 06
0
[PATCH net-next 05/11] tuntap: tweak on the path of non-xdp case in tun_build_skb()
...jasowang at redhat.com> --- drivers/net/tun.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index f8cdcfa392c3..389aa0727cc6 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1675,10 +1675,12 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, * of xdp_prog above, this should be rare and for simplicity * we do XDP on skb in case the headroom is not enough. */ - if (hdr->gso_type || !xdp_prog) + if (hdr->gso_type || !xdp_prog) { *skb_xdp = 1; - else - *skb_xdp = 0; + goto build; + } + + *skb_xdp...
2018 Sep 07
1
[PATCH net-next 04/11] tuntap: simplify error handling in tun_build_skb()
On Fri, Sep 07, 2018 at 11:22:00AM +0800, Jason Wang wrote: > > > @@ -1668,6 +1668,9 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > > > if (copied != len) > > > return ERR_PTR(-EFAULT); > > > + get_page(alloc_frag->page); > > > + alloc_frag->offset += buflen; > > > + > > This adds an atomic op on XDP_DROP which is a data path > > ope...
2018 Sep 06
2
[PATCH net-next 06/11] tuntap: split out XDP logic
..._head_page(xdp->data_hard_start)); put here because caller does get_page :( Not pretty. I'd move this out to the caller. > +out: > + return act; How about combining err and act? err is < 0 XDP_PASS is > 0. No need for pointers then. > +} > + > static struct sk_buff *tun_build_skb(struct tun_struct *tun, > struct tun_file *tfile, > struct iov_iter *from, > @@ -1645,10 +1683,10 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > struct sk_buff *skb = NULL; > struct bpf_prog *xdp_prog; > int buflen = SKB_DATA_ALIGN(size...
2018 Sep 06
2
[PATCH net-next 06/11] tuntap: split out XDP logic
..._head_page(xdp->data_hard_start)); put here because caller does get_page :( Not pretty. I'd move this out to the caller. > +out: > + return act; How about combining err and act? err is < 0 XDP_PASS is > 0. No need for pointers then. > +} > + > static struct sk_buff *tun_build_skb(struct tun_struct *tun, > struct tun_file *tfile, > struct iov_iter *from, > @@ -1645,10 +1683,10 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > struct sk_buff *skb = NULL; > struct bpf_prog *xdp_prog; > int buflen = SKB_DATA_ALIGN(size...
2018 Sep 06
0
[PATCH net-next 06/11] tuntap: split out XDP logic
...default: + bpf_warn_invalid_xdp_action(act); + /* fall through */ + case XDP_ABORTED: + trace_xdp_exception(tun->dev, xdp_prog, act); + /* fall through */ + case XDP_DROP: + break; + } + + put_page(virt_to_head_page(xdp->data_hard_start)); +out: + return act; +} + static struct sk_buff *tun_build_skb(struct tun_struct *tun, struct tun_file *tfile, struct iov_iter *from, @@ -1645,10 +1683,10 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, struct sk_buff *skb = NULL; struct bpf_prog *xdp_prog; int buflen = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); -...
2018 Sep 07
0
[PATCH net-next 06/11] tuntap: split out XDP logic
...out to the caller. Then we need a switch in the caller, not sure it's better. > >> +out: >> + return act; > How about combining err and act? err is < 0 XDP_PASS is > 0. > No need for pointers then. Ok. > >> +} >> + >> static struct sk_buff *tun_build_skb(struct tun_struct *tun, >> struct tun_file *tfile, >> struct iov_iter *from, >> @@ -1645,10 +1683,10 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, >> struct sk_buff *skb = NULL; >> struct bpf_prog *xdp_prog; >> int...
2018 Sep 06
22
[PATCH net-next 00/11] Vhost_net TX batching
...10% 65535/ 2/ 0%/ +8% 65535/ 4/ 0%/ +1% 65535/ 8/ 0%/ +3% Please review. Thanks Jason Wang (11): net: sock: introduce SOCK_XDP tuntap: switch to use XDP_PACKET_HEADROOM tuntap: enable bh early during processing XDP tuntap: simplify error handling in tun_build_skb() tuntap: tweak on the path of non-xdp case in tun_build_skb() tuntap: split out XDP logic tuntap: move XDP flushing out of tun_do_xdp() tun: switch to new type of msg_control tuntap: accept an array of XDP buffs through sendmsg() tap: accept an array of XDP buffs through sendmsg() vh...
2018 Sep 12
14
[PATCH net-next V2 00/11] vhost_net TX batching
...ce a new structure for storing metadata in the head of XDP packet - do not store batche XDP inside vhoet_net_virtqueue Jason Wang (11): net: sock: introduce SOCK_XDP tuntap: switch to use XDP_PACKET_HEADROOM tuntap: enable bh early during processing XDP tuntap: simplify error handling in tun_build_skb() tuntap: tweak on the path of skb XDP case in tun_build_skb() tuntap: split out XDP logic tuntap: move XDP flushing out of tun_do_xdp() tun: switch to new type of msg_control tuntap: accept an array of XDP buffs through sendmsg() tap: accept an array of XDP buffs through sendmsg() vh...
2018 Sep 12
14
[PATCH net-next V2 00/11] vhost_net TX batching
...ce a new structure for storing metadata in the head of XDP packet - do not store batche XDP inside vhoet_net_virtqueue Jason Wang (11): net: sock: introduce SOCK_XDP tuntap: switch to use XDP_PACKET_HEADROOM tuntap: enable bh early during processing XDP tuntap: simplify error handling in tun_build_skb() tuntap: tweak on the path of skb XDP case in tun_build_skb() tuntap: split out XDP logic tuntap: move XDP flushing out of tun_do_xdp() tun: switch to new type of msg_control tuntap: accept an array of XDP buffs through sendmsg() tap: accept an array of XDP buffs through sendmsg() vh...
2018 May 21
20
[RFC PATCH net-next 00/12] XDP batching for TUN/vhost_net
...net: introduce helper to initialize tx iov iter vhost_net: introduce vhost_exceeds_weight() vhost_net: introduce vhost_has_more_pkts() vhost_net: split out datacopy logic vhost_net: batch update used ring for datacopy TX tuntap: enable premmption early tuntap: simplify error handling in tun_build_skb() tuntap: tweak on the path of non-xdp case in tun_build_skb() tuntap: split out XDP logic vhost_net: build xdp buff vhost_net: passing raw xdp buff to tun vhost_net: batch submitting XDP buffers to underlayer sockets drivers/net/tun.c | 226 +++++++++++++++++++++++++++---------- d...
2018 May 21
0
[RFC PATCH net-next 06/12] tuntap: enable premmption early
...Jason Wang <jasowang at redhat.com> --- drivers/net/tun.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 44d4f3d..24ecd82 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1697,6 +1697,8 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, goto err_xdp; } } + rcu_read_unlock(); + preempt_enable(); skb = build_skb(buf, buflen); if (!skb) { @@ -1710,9 +1712,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, get_page(alloc_frag->page); alloc_frag->offset += buflen; - rcu_...
2018 Sep 06
1
[PATCH net-next 02/11] tuntap: switch to use XDP_PACKET_HEADROOM
...-- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -113,7 +113,6 @@ do { \ > } while (0) > #endif > > -#define TUN_HEADROOM 256 > #define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD) > > /* TUN device flags */ > @@ -1654,7 +1653,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > rcu_read_lock(); > xdp_prog = rcu_dereference(tun->xdp_prog); > if (xdp_prog) > - pad += TUN_HEADROOM; > + pad += XDP_PACKET_HEADROOM; > buflen += SKB_DATA_ALIGN(len + pad); > rcu_read_unlock(); > > -- > 2.17.1
2018 Sep 06
1
[PATCH net-next 07/11] tuntap: move XDP flushing out of tun_do_xdp()
...46,7 +1646,6 @@ static u32 tun_do_xdp(struct tun_struct *tun, > switch (act) { > case XDP_REDIRECT: > *err = xdp_do_redirect(tun->dev, xdp, xdp_prog); > - xdp_do_flush_map(); > if (*err) > break; > goto out; > @@ -1735,6 +1734,9 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, > act = tun_do_xdp(tun, tfile, xdp_prog, &xdp, &err); > if (err) > goto err_xdp; > + > + if (act == XDP_REDIRECT) > + xdp_do_flush_map(); > if (act != XDP_PASS) > goto out; At this point the switch statement which used to...
2018 Sep 06
0
[PATCH net-next 02/11] tuntap: switch to use XDP_PACKET_HEADROOM
...et/tun.c index 2c548bd20393..d3677a544b56 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -113,7 +113,6 @@ do { \ } while (0) #endif -#define TUN_HEADROOM 256 #define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD) /* TUN device flags */ @@ -1654,7 +1653,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, rcu_read_lock(); xdp_prog = rcu_dereference(tun->xdp_prog); if (xdp_prog) - pad += TUN_HEADROOM; + pad += XDP_PACKET_HEADROOM; buflen += SKB_DATA_ALIGN(len + pad); rcu_read_unlock(); -- 2.17.1
2018 Sep 06
0
[PATCH net-next 03/11] tuntap: enable bh early during processing XDP
...sowang at redhat.com> --- drivers/net/tun.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index d3677a544b56..372caf7d67d9 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1726,22 +1726,18 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, goto err_xdp; } } + rcu_read_unlock(); + local_bh_enable(); skb = build_skb(buf, buflen); - if (!skb) { - rcu_read_unlock(); - local_bh_enable(); + if (!skb) return ERR_PTR(-ENOMEM); - } skb_reserve(skb, pad - delta); skb_put(skb, len); get_page(all...