aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorAmerigo Wang <amwang@redhat.com>2012-10-28 20:13:19 -0400
committerDavid S. Miller <davem@davemloft.net>2012-11-03 14:59:05 -0400
commit94e187c01512c9cf29e2ff54bf1a1b045f38293d (patch)
tree2149f4652fb0fc997ce5728f9574e1ab5351f0e5 /net/ipv6
parent6da025fa23bb10c82f80de319c837ed2b02306e4 (diff)
ipv6: introduce ip6_rt_put()
As suggested by Eric, we could introduce a helper function for ipv6 too, to avoid checking if rt is NULL before dst_release(). Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <amwang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/addrconf.c7
-rw-r--r--net/ipv6/anycast.c2
-rw-r--r--net/ipv6/fib6_rules.c2
-rw-r--r--net/ipv6/ip6_gre.c2
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/ipv6/ip6_tunnel.c5
-rw-r--r--net/ipv6/mcast.c4
-rw-r--r--net/ipv6/ndisc.c7
-rw-r--r--net/ipv6/netfilter/ip6t_rpfilter.c2
-rw-r--r--net/ipv6/route.c14
10 files changed, 23 insertions, 26 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index ced58e1d91b6..fab23db8ee73 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -699,7 +699,7 @@ void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
699 pr_warn("Freeing alive inet6 address %p\n", ifp); 699 pr_warn("Freeing alive inet6 address %p\n", ifp);
700 return; 700 return;
701 } 701 }
702 dst_release(&ifp->rt->dst); 702 ip6_rt_put(ifp->rt);
703 703
704 kfree_rcu(ifp, rcu); 704 kfree_rcu(ifp, rcu);
705} 705}
@@ -951,7 +951,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
951 rt6_set_expires(rt, expires); 951 rt6_set_expires(rt, expires);
952 } 952 }
953 } 953 }
954 dst_release(&rt->dst); 954 ip6_rt_put(rt);
955 } 955 }
956 956
957 /* clean up prefsrc entries */ 957 /* clean up prefsrc entries */
@@ -2027,8 +2027,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
2027 addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len, 2027 addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
2028 dev, expires, flags); 2028 dev, expires, flags);
2029 } 2029 }
2030 if (rt) 2030 ip6_rt_put(rt);
2031 dst_release(&rt->dst);
2032 } 2031 }
2033 2032
2034 /* Try to figure out our local address for this prefix */ 2033 /* Try to figure out our local address for this prefix */
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index cdf02be5f191..4963c769a13f 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -84,7 +84,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
84 rt = rt6_lookup(net, addr, NULL, 0, 0); 84 rt = rt6_lookup(net, addr, NULL, 0, 0);
85 if (rt) { 85 if (rt) {
86 dev = rt->dst.dev; 86 dev = rt->dst.dev;
87 dst_release(&rt->dst); 87 ip6_rt_put(rt);
88 } else if (ishost) { 88 } else if (ishost) {
89 err = -EADDRNOTAVAIL; 89 err = -EADDRNOTAVAIL;
90 goto error; 90 goto error;
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index d9fb9110f607..2e1a432867c0 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -100,7 +100,7 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
100 goto out; 100 goto out;
101 } 101 }
102again: 102again:
103 dst_release(&rt->dst); 103 ip6_rt_put(rt);
104 rt = NULL; 104 rt = NULL;
105 goto out; 105 goto out;
106 106
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 0185679c5f53..bbe2e7b538b4 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1069,7 +1069,7 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
1069 dev->mtu = IPV6_MIN_MTU; 1069 dev->mtu = IPV6_MIN_MTU;
1070 } 1070 }
1071 } 1071 }
1072 dst_release(&rt->dst); 1072 ip6_rt_put(rt);
1073 } 1073 }
1074 1074
1075 t->hlen = addend; 1075 t->hlen = addend;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index e10c77b4fbec..3deaa4e2e8e2 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -755,7 +755,7 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
755 if (err == 0) { 755 if (err == 0) {
756 IP6_INC_STATS(net, ip6_dst_idev(&rt->dst), 756 IP6_INC_STATS(net, ip6_dst_idev(&rt->dst),
757 IPSTATS_MIB_FRAGOKS); 757 IPSTATS_MIB_FRAGOKS);
758 dst_release(&rt->dst); 758 ip6_rt_put(rt);
759 return 0; 759 return 0;
760 } 760 }
761 761
@@ -767,7 +767,7 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
767 767
768 IP6_INC_STATS(net, ip6_dst_idev(&rt->dst), 768 IP6_INC_STATS(net, ip6_dst_idev(&rt->dst),
769 IPSTATS_MIB_FRAGFAILS); 769 IPSTATS_MIB_FRAGFAILS);
770 dst_release(&rt->dst); 770 ip6_rt_put(rt);
771 return err; 771 return err;
772 772
773slow_path_clean: 773slow_path_clean:
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index cb7e2ded6f08..09482f723064 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -663,8 +663,7 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
663 663
664 icmpv6_send(skb2, rel_type, rel_code, rel_info); 664 icmpv6_send(skb2, rel_type, rel_code, rel_info);
665 665
666 if (rt) 666 ip6_rt_put(rt);
667 dst_release(&rt->dst);
668 667
669 kfree_skb(skb2); 668 kfree_skb(skb2);
670 } 669 }
@@ -1208,7 +1207,7 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
1208 if (dev->mtu < IPV6_MIN_MTU) 1207 if (dev->mtu < IPV6_MIN_MTU)
1209 dev->mtu = IPV6_MIN_MTU; 1208 dev->mtu = IPV6_MIN_MTU;
1210 } 1209 }
1211 dst_release(&rt->dst); 1210 ip6_rt_put(rt);
1212 } 1211 }
1213} 1212}
1214 1213
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 92f8e48e4ba4..b19ed51a45bb 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -163,7 +163,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
163 rt = rt6_lookup(net, addr, NULL, 0, 0); 163 rt = rt6_lookup(net, addr, NULL, 0, 0);
164 if (rt) { 164 if (rt) {
165 dev = rt->dst.dev; 165 dev = rt->dst.dev;
166 dst_release(&rt->dst); 166 ip6_rt_put(rt);
167 } 167 }
168 } else 168 } else
169 dev = dev_get_by_index_rcu(net, ifindex); 169 dev = dev_get_by_index_rcu(net, ifindex);
@@ -260,7 +260,7 @@ static struct inet6_dev *ip6_mc_find_dev_rcu(struct net *net,
260 260
261 if (rt) { 261 if (rt) {
262 dev = rt->dst.dev; 262 dev = rt->dst.dev;
263 dst_release(&rt->dst); 263 ip6_rt_put(rt);
264 } 264 }
265 } else 265 } else
266 dev = dev_get_by_index_rcu(net, ifindex); 266 dev = dev_get_by_index_rcu(net, ifindex);
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index ff36194a71aa..ae0cf818a8f0 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1145,7 +1145,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1145 ND_PRINTK(0, err, 1145 ND_PRINTK(0, err,
1146 "RA: %s got default router without neighbour\n", 1146 "RA: %s got default router without neighbour\n",
1147 __func__); 1147 __func__);
1148 dst_release(&rt->dst); 1148 ip6_rt_put(rt);
1149 return; 1149 return;
1150 } 1150 }
1151 } 1151 }
@@ -1170,7 +1170,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1170 ND_PRINTK(0, err, 1170 ND_PRINTK(0, err,
1171 "RA: %s got default router without neighbour\n", 1171 "RA: %s got default router without neighbour\n",
1172 __func__); 1172 __func__);
1173 dst_release(&rt->dst); 1173 ip6_rt_put(rt);
1174 return; 1174 return;
1175 } 1175 }
1176 neigh->flags |= NTF_ROUTER; 1176 neigh->flags |= NTF_ROUTER;
@@ -1326,8 +1326,7 @@ skip_routeinfo:
1326 ND_PRINTK(2, warn, "RA: invalid RA options\n"); 1326 ND_PRINTK(2, warn, "RA: invalid RA options\n");
1327 } 1327 }
1328out: 1328out:
1329 if (rt) 1329 ip6_rt_put(rt);
1330 dst_release(&rt->dst);
1331 if (neigh) 1330 if (neigh)
1332 neigh_release(neigh); 1331 neigh_release(neigh);
1333} 1332}
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index 5d1d8b04d694..5060d54199ab 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -67,7 +67,7 @@ static bool rpfilter_lookup_reverse6(const struct sk_buff *skb,
67 if (rt->rt6i_idev->dev == dev || (flags & XT_RPFILTER_LOOSE)) 67 if (rt->rt6i_idev->dev == dev || (flags & XT_RPFILTER_LOOSE))
68 ret = true; 68 ret = true;
69 out: 69 out:
70 dst_release(&rt->dst); 70 ip6_rt_put(rt);
71 return ret; 71 return ret;
72} 72}
73 73
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9c7b5d800495..c1cfcb7e5632 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -732,7 +732,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
732 else 732 else
733 rt6_set_expires(rt, jiffies + HZ * lifetime); 733 rt6_set_expires(rt, jiffies + HZ * lifetime);
734 734
735 dst_release(&rt->dst); 735 ip6_rt_put(rt);
736 } 736 }
737 return 0; 737 return 0;
738} 738}
@@ -948,7 +948,7 @@ restart:
948 else 948 else
949 goto out2; 949 goto out2;
950 950
951 dst_release(&rt->dst); 951 ip6_rt_put(rt);
952 rt = nrt ? : net->ipv6.ip6_null_entry; 952 rt = nrt ? : net->ipv6.ip6_null_entry;
953 953
954 dst_hold(&rt->dst); 954 dst_hold(&rt->dst);
@@ -965,7 +965,7 @@ restart:
965 * Race condition! In the gap, when table->tb6_lock was 965 * Race condition! In the gap, when table->tb6_lock was
966 * released someone could insert this route. Relookup. 966 * released someone could insert this route. Relookup.
967 */ 967 */
968 dst_release(&rt->dst); 968 ip6_rt_put(rt);
969 goto relookup; 969 goto relookup;
970 970
971out: 971out:
@@ -1576,7 +1576,7 @@ int ip6_route_add(struct fib6_config *cfg)
1576 goto out; 1576 goto out;
1577 if (dev) { 1577 if (dev) {
1578 if (dev != grt->dst.dev) { 1578 if (dev != grt->dst.dev) {
1579 dst_release(&grt->dst); 1579 ip6_rt_put(grt);
1580 goto out; 1580 goto out;
1581 } 1581 }
1582 } else { 1582 } else {
@@ -1587,7 +1587,7 @@ int ip6_route_add(struct fib6_config *cfg)
1587 } 1587 }
1588 if (!(grt->rt6i_flags & RTF_GATEWAY)) 1588 if (!(grt->rt6i_flags & RTF_GATEWAY))
1589 err = 0; 1589 err = 0;
1590 dst_release(&grt->dst); 1590 ip6_rt_put(grt);
1591 1591
1592 if (err) 1592 if (err)
1593 goto out; 1593 goto out;
@@ -1673,7 +1673,7 @@ static int __ip6_del_rt(struct rt6_info *rt, struct nl_info *info)
1673 write_unlock_bh(&table->tb6_lock); 1673 write_unlock_bh(&table->tb6_lock);
1674 1674
1675out: 1675out:
1676 dst_release(&rt->dst); 1676 ip6_rt_put(rt);
1677 return err; 1677 return err;
1678} 1678}
1679 1679
@@ -2732,7 +2732,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2732 2732
2733 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); 2733 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
2734 if (!skb) { 2734 if (!skb) {
2735 dst_release(&rt->dst); 2735 ip6_rt_put(rt);
2736 err = -ENOBUFS; 2736 err = -ENOBUFS;
2737 goto errout; 2737 goto errout;
2738 } 2738 }