Messages in this thread Patch in this message |  | | From | Jason Wang <> | Subject | [RFC PATCH net-next V2 1/6] net: core: factor out generic XDP check and process routine | Date | Mon, 13 Aug 2018 11:17:25 +0800 |
| |
Signed-off-by: Jason Wang <jasowang@redhat.com> --- net/core/dev.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c index f68122f..605c66e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4392,13 +4392,9 @@ int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb) } EXPORT_SYMBOL_GPL(do_xdp_generic); -static int netif_rx_internal(struct sk_buff *skb) +static int netif_do_generic_xdp(struct sk_buff *skb) { - int ret; - - net_timestamp_check(netdev_tstamp_prequeue, skb); - - trace_netif_rx(skb); + int ret = XDP_PASS; if (static_branch_unlikely(&generic_xdp_needed_key)) { int ret; @@ -4408,15 +4404,28 @@ static int netif_rx_internal(struct sk_buff *skb) ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb); rcu_read_unlock(); preempt_enable(); - - /* Consider XDP consuming the packet a success from - * the netdev point of view we do not want to count - * this as an error. - */ - if (ret != XDP_PASS) - return NET_RX_SUCCESS; } + return ret; +} + +static int netif_rx_internal(struct sk_buff *skb) +{ + int ret; + + net_timestamp_check(netdev_tstamp_prequeue, skb); + + trace_netif_rx(skb); + + ret = netif_do_generic_xdp(skb); + + /* Consider XDP consuming the packet a success from + * the netdev point of view we do not want to count + * this as an error. + */ + if (ret != XDP_PASS) + return NET_RX_SUCCESS; + #ifdef CONFIG_RPS if (static_key_false(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; -- 2.7.4
|  |