aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_options.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-05-11 19:19:48 -0400
committerDavid S. Miller <davem@davemloft.net>2010-05-17 20:18:50 -0400
commit7fee226ad2397b635e2fd565a59ca3ae08a164cd (patch)
tree0bcd26150ad74ec1a237109de87a3d214a07fc22 /net/ipv4/ip_options.c
parentebda37c27d0c768947e9b058332d7ea798210cf8 (diff)
net: add a noref bit on skb dst
Use low order bit of skb->_skb_dst to tell dst is not refcounted. Change _skb_dst to _skb_refdst to make sure all uses are catched. skb_dst() returns the dst, regardless of noref bit set or not, but with a lockdep check to make sure a noref dst is not given if current user is not rcu protected. New skb_dst_set_noref() helper to set an notrefcounted dst on a skb. (with lockdep check) skb_dst_drop() drops a reference only if skb dst was refcounted. skb_dst_force() helper is used to force a refcount on dst, when skb is queued and not anymore RCU protected. Use skb_dst_force() in __sk_add_backlog(), __dev_xmit_skb() if !IFF_XMIT_DST_RELEASE or skb enqueued on qdisc queue, in sock_queue_rcv_skb(), in __nf_queue(). Use skb_dst_force() in dev_requeue_skb(). Note: dst_use_noref() still dirties dst, we might transform it later to do one dirtying per jiffies. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_options.c')
-rw-r--r--net/ipv4/ip_options.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index 4c09a31fd140..3244133c24f6 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -601,6 +601,7 @@ int ip_options_rcv_srr(struct sk_buff *skb)
601 unsigned char *optptr = skb_network_header(skb) + opt->srr; 601 unsigned char *optptr = skb_network_header(skb) + opt->srr;
602 struct rtable *rt = skb_rtable(skb); 602 struct rtable *rt = skb_rtable(skb);
603 struct rtable *rt2; 603 struct rtable *rt2;
604 unsigned long orefdst;
604 int err; 605 int err;
605 606
606 if (!opt->srr) 607 if (!opt->srr)
@@ -624,16 +625,16 @@ int ip_options_rcv_srr(struct sk_buff *skb)
624 } 625 }
625 memcpy(&nexthop, &optptr[srrptr-1], 4); 626 memcpy(&nexthop, &optptr[srrptr-1], 4);
626 627
627 rt = skb_rtable(skb); 628 orefdst = skb->_skb_refdst;
628 skb_dst_set(skb, NULL); 629 skb_dst_set(skb, NULL);
629 err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev); 630 err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev);
630 rt2 = skb_rtable(skb); 631 rt2 = skb_rtable(skb);
631 if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) { 632 if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
632 ip_rt_put(rt2); 633 skb_dst_drop(skb);
633 skb_dst_set(skb, &rt->u.dst); 634 skb->_skb_refdst = orefdst;
634 return -EINVAL; 635 return -EINVAL;
635 } 636 }
636 ip_rt_put(rt); 637 refdst_drop(orefdst);
637 if (rt2->rt_type != RTN_LOCAL) 638 if (rt2->rt_type != RTN_LOCAL)
638 break; 639 break;
639 /* Superfast 8) loopback forward */ 640 /* Superfast 8) loopback forward */