Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94e187c0 authored by Amerigo Wang's avatar Amerigo Wang Committed by David S. Miller
Browse files

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: default avatarCong Wang <amwang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6da025fa
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -213,6 +213,15 @@ static inline void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
	dst_hold(new);
}

static inline void ip6_rt_put(struct rt6_info *rt)
{
	/* dst_release() accepts a NULL parameter.
	 * We rely on dst being first structure in struct rt6_info
	 */
	BUILD_BUG_ON(offsetof(struct rt6_info, dst) != 0);
	dst_release(&rt->dst);
}

struct fib6_walker_t {
	struct list_head lh;
	struct fib6_node *root, *node;
+3 −4
Original line number Diff line number Diff line
@@ -699,7 +699,7 @@ void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
		pr_warn("Freeing alive inet6 address %p\n", ifp);
		return;
	}
	dst_release(&ifp->rt->dst);
	ip6_rt_put(ifp->rt);

	kfree_rcu(ifp, rcu);
}
@@ -951,7 +951,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
				rt6_set_expires(rt, expires);
			}
		}
		dst_release(&rt->dst);
		ip6_rt_put(rt);
	}

	/* clean up prefsrc entries */
@@ -2027,8 +2027,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
			addrconf_prefix_route(&pinfo->prefix, pinfo->prefix_len,
					      dev, expires, flags);
		}
		if (rt)
			dst_release(&rt->dst);
		ip6_rt_put(rt);
	}

	/* Try to figure out our local address for this prefix */
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
		rt = rt6_lookup(net, addr, NULL, 0, 0);
		if (rt) {
			dev = rt->dst.dev;
			dst_release(&rt->dst);
			ip6_rt_put(rt);
		} else if (ishost) {
			err = -EADDRNOTAVAIL;
			goto error;
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
		goto out;
	}
again:
	dst_release(&rt->dst);
	ip6_rt_put(rt);
	rt = NULL;
	goto out;

+1 −1
Original line number Diff line number Diff line
@@ -1069,7 +1069,7 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
					dev->mtu = IPV6_MIN_MTU;
			}
		}
		dst_release(&rt->dst);
		ip6_rt_put(rt);
	}

	t->hlen = addend;
Loading