Commit e8dfd42c authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

ipv6: introduce dst_rt6_info() helper



Instead of (struct rt6_info *)dst casts, we can use :

 #define dst_rt6_info(_ptr) \
         container_of_const(_ptr, struct rt6_info, dst)

Some places needed missing const qualifiers :

ip6_confirm_neigh(), ipv6_anycast_destination(),
ipv6_unicast_destination(), has_gateway()

v2: added missing parts (David Ahern)

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fac87d32
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -348,15 +348,15 @@ static int dst_fetch_ha(const struct dst_entry *dst,

static bool has_gateway(const struct dst_entry *dst, sa_family_t family)
{
	struct rtable *rt;
	struct rt6_info *rt6;
	const struct rtable *rt;
	const struct rt6_info *rt6;

	if (family == AF_INET) {
		rt = container_of(dst, struct rtable, dst);
		return rt->rt_uses_gateway;
	}

	rt6 = container_of(dst, struct rt6_info, dst);
	rt6 = dst_rt6_info(dst);
	return rt6->rt6i_flags & RTF_GATEWAY;
}

+1 −1
Original line number Diff line number Diff line
@@ -540,7 +540,7 @@ mlxsw_sp_span_gretap6_route(const struct net_device *to_dev,
	if (!dst || dst->error)
		goto out;

	rt6 = container_of(dst, struct rt6_info, dst);
	rt6 = dst_rt6_info(dst);

	dev = dst->dev;
	*saddrp = fl6.saddr;
+1 −1
Original line number Diff line number Diff line
@@ -653,7 +653,7 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,
	skb->dev = dev;

	rcu_read_lock();
	nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr);
	nexthop = rt6_nexthop(dst_rt6_info(dst), &ipv6_hdr(skb)->daddr);
	neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop);
	if (unlikely(!neigh))
		neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
+1 −1
Original line number Diff line number Diff line
@@ -2513,7 +2513,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
		}

		if (!info) {
			u32 rt6i_flags = ((struct rt6_info *)ndst)->rt6i_flags;
			u32 rt6i_flags = dst_rt6_info(ndst)->rt6i_flags;

			err = encap_bypass_if_local(skb, dev, vxlan, AF_INET6,
						    dst_port, ifindex, vni,
+2 −2
Original line number Diff line number Diff line
@@ -956,7 +956,7 @@ static inline struct dst_entry *qeth_dst_check_rcu(struct sk_buff *skb,
	struct dst_entry *dst = skb_dst(skb);
	struct rt6_info *rt;

	rt = (struct rt6_info *) dst;
	rt = dst_rt6_info(dst);
	if (dst) {
		if (proto == htons(ETH_P_IPV6))
			dst = dst_check(dst, rt6_get_cookie(rt));
@@ -978,7 +978,7 @@ static inline __be32 qeth_next_hop_v4_rcu(struct sk_buff *skb,
static inline struct in6_addr *qeth_next_hop_v6_rcu(struct sk_buff *skb,
						    struct dst_entry *dst)
{
	struct rt6_info *rt = (struct rt6_info *) dst;
	struct rt6_info *rt = dst_rt6_info(dst);

	if (rt && !ipv6_addr_any(&rt->rt6i_gateway))
		return &rt->rt6i_gateway;
Loading