From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Abeni Subject: [RFC PATCH v3 05/10] ipv6: factor out protocol delivery helper Date: Tue, 30 Oct 2018 18:24:38 +0100 Message-ID: <92fdbccaacb712e656fc1014b5adeaca0ef257da.1540920083.git.pabeni@redhat.com> References: Cc: "David S. Miller" , Willem de Bruijn , Steffen Klassert , Subash Abhinov Kasiviswanathan To: netdev@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51042 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727566AbeJaCT1 (ORCPT ); Tue, 30 Oct 2018 22:19:27 -0400 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: So that we can re-use it at the UDP lavel in the next patch Signed-off-by: Paolo Abeni --- net/ipv6/ip6_input.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 96577e742afd..3065226bdc57 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -319,28 +319,26 @@ void ipv6_list_rcv(struct list_head *head, struct packet_type *pt, /* * Deliver the packet to the host */ - - -static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb) +void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr, + bool have_final) { const struct inet6_protocol *ipprot; struct inet6_dev *idev; unsigned int nhoff; - int nexthdr; bool raw; - bool have_final = false; /* * Parse extension headers */ - rcu_read_lock(); resubmit: idev = ip6_dst_idev(skb_dst(skb)); - if (!pskb_pull(skb, skb_transport_offset(skb))) - goto discard; nhoff = IP6CB(skb)->nhoff; - nexthdr = skb_network_header(skb)[nhoff]; + if (!have_final) { + if (!pskb_pull(skb, skb_transport_offset(skb))) + goto discard; + nexthdr = skb_network_header(skb)[nhoff]; + } resubmit_final: raw = raw6_local_deliver(skb, nexthdr); @@ -411,13 +409,19 @@ static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *sk consume_skb(skb); } } - rcu_read_unlock(); - return 0; + return; discard: __IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS); - rcu_read_unlock(); kfree_skb(skb); +} + +static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb) +{ + rcu_read_lock(); + ip6_protocol_deliver_rcu(net, skb, 0, false); + rcu_read_unlock(); + return 0; } -- 2.17.2