Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80bde36

Browse files
Paolo Abenidavem330
authored andcommitted
ipv6: factor out protocol delivery helper
So that we can re-use it at the UDP level in the next patch rfc v3 -> v1: - add the helper declaration into the ipv6 header Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 68cb7d5 commit 80bde36

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

include/net/ipv6.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb);
975975
int ip6_forward(struct sk_buff *skb);
976976
int ip6_input(struct sk_buff *skb);
977977
int ip6_mc_input(struct sk_buff *skb);
978+
void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
979+
bool have_final);
978980

979981
int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);
980982
int ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb);

net/ipv6/ip6_input.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,28 +319,26 @@ void ipv6_list_rcv(struct list_head *head, struct packet_type *pt,
319319
/*
320320
* Deliver the packet to the host
321321
*/
322-
323-
324-
static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
322+
void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
323+
bool have_final)
325324
{
326325
const struct inet6_protocol *ipprot;
327326
struct inet6_dev *idev;
328327
unsigned int nhoff;
329-
int nexthdr;
330328
bool raw;
331-
bool have_final = false;
332329

333330
/*
334331
* Parse extension headers
335332
*/
336333

337-
rcu_read_lock();
338334
resubmit:
339335
idev = ip6_dst_idev(skb_dst(skb));
340-
if (!pskb_pull(skb, skb_transport_offset(skb)))
341-
goto discard;
342336
nhoff = IP6CB(skb)->nhoff;
343-
nexthdr = skb_network_header(skb)[nhoff];
337+
if (!have_final) {
338+
if (!pskb_pull(skb, skb_transport_offset(skb)))
339+
goto discard;
340+
nexthdr = skb_network_header(skb)[nhoff];
341+
}
344342

345343
resubmit_final:
346344
raw = raw6_local_deliver(skb, nexthdr);
@@ -423,13 +421,19 @@ static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *sk
423421
consume_skb(skb);
424422
}
425423
}
426-
rcu_read_unlock();
427-
return 0;
424+
return;
428425

429426
discard:
430427
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
431-
rcu_read_unlock();
432428
kfree_skb(skb);
429+
}
430+
431+
static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
432+
{
433+
rcu_read_lock();
434+
ip6_protocol_deliver_rcu(net, skb, 0, false);
435+
rcu_read_unlock();
436+
433437
return 0;
434438
}
435439

0 commit comments

Comments
 (0)