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;
 }
 
 
        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;
 
        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);
 
                }
 
                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,
 
        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));
 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;
 
        for (rt = (w)->leaf; rt;                                        \
             rt = rcu_dereference_protected(rt->fib6_next, 1))
 
-static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
+#define dst_rt6_info(_ptr) container_of_const(_ptr, struct rt6_info, dst)
+
+static inline struct inet6_dev *ip6_dst_idev(const struct dst_entry *dst)
 {
-       return ((struct rt6_info *)dst)->rt6i_idev;
+       return dst_rt6_info(dst)->rt6i_idev;
 }
 
 static inline bool fib6_requires_src(const struct fib6_info *rt)
 
 static inline const struct rt6_info *skb_rt6_info(const struct sk_buff *skb)
 {
        const struct dst_entry *dst = skb_dst(skb);
-       const struct rt6_info *rt6 = NULL;
 
        if (dst)
-               rt6 = container_of(dst, struct rt6_info, dst);
+               return dst_rt6_info(dst);
 
-       return rt6;
+       return NULL;
 }
 
 /*
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
 
-       np->dst_cookie = rt6_get_cookie((struct rt6_info *)dst);
+       np->dst_cookie = rt6_get_cookie(dst_rt6_info(dst));
        sk_setup_caps(sk, dst);
        np->daddr_cache = daddr;
 #ifdef CONFIG_IPV6_SUBTREES
 
 static inline bool ipv6_unicast_destination(const struct sk_buff *skb)
 {
-       struct rt6_info *rt = (struct rt6_info *) skb_dst(skb);
+       const struct rt6_info *rt = dst_rt6_info(skb_dst(skb));
 
        return rt->rt6i_flags & RTF_LOCAL;
 }
 static inline bool ipv6_anycast_destination(const struct dst_entry *dst,
                                            const struct in6_addr *daddr)
 {
-       struct rt6_info *rt = (struct rt6_info *)dst;
+       const struct rt6_info *rt = dst_rt6_info(dst);
 
        return rt->rt6i_flags & RTF_ANYCAST ||
                (rt->rt6i_dst.plen < 127 &&
 
                                                  struct in6_addr *daddr,
                                                  struct sk_buff *skb)
 {
-       struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
+       struct rt6_info *rt = dst_rt6_info(skb_dst(skb));
        int count = atomic_read(&dev->peer_count);
        const struct in6_addr *nexthop;
        struct lowpan_peer *peer;
 
 
        idst = this_cpu_ptr(dst_cache->cache);
        dst_cache_per_cpu_dst_set(this_cpu_ptr(dst_cache->cache), dst,
-                                 rt6_get_cookie((struct rt6_info *)dst));
+                                 rt6_get_cookie(dst_rt6_info(dst)));
        idst->in6_saddr = *saddr;
 }
 EXPORT_SYMBOL_GPL(dst_cache_set_ip6);
 
        rcu_read_lock();
        if (!nh) {
                dst = skb_dst(skb);
-               nexthop = rt6_nexthop(container_of(dst, struct rt6_info, dst),
+               nexthop = rt6_nexthop(dst_rt6_info(dst),
                                      &ipv6_hdr(skb)->daddr);
        } else {
                nexthop = &nh->ipv6_nh;
 
                struct rt6_info *rt6;
                __be32 daddr;
 
-               rt6 = skb_valid_dst(skb) ? (struct rt6_info *)skb_dst(skb) :
+               rt6 = skb_valid_dst(skb) ? dst_rt6_info(skb_dst(skb)) :
                                           NULL;
                daddr = md ? dst : tunnel->parms.iph.daddr;
 
 
        } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) {
                res = true;
        } else {
-               struct rt6_info *rt = (struct rt6_info *)dst;
+               struct rt6_info *rt = dst_rt6_info(dst);
                int tmo = net->ipv6.sysctl.icmpv6_time;
                struct inet_peer *peer;
 
 
        dst = ip6_route_output(net, sk, fl6);
        if (!dst->error) {
-               struct rt6_info *rt = (struct rt6_info *)dst;
+               struct rt6_info *rt = dst_rt6_info(dst);
                struct in6_addr prefsrc;
 
                rt6_get_prefsrc(rt, &prefsrc);
        if (ip6_append_data(sk, icmpv6_getfrag, &msg,
                            len + sizeof(struct icmp6hdr),
                            sizeof(struct icmp6hdr),
-                           &ipc6, &fl6, (struct rt6_info *)dst,
+                           &ipc6, &fl6, dst_rt6_info(dst),
                            MSG_DONTWAIT)) {
                ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTERRORS);
                ip6_flush_pending_frames(sk);
        if (ip6_append_data(sk, icmpv6_getfrag, &msg,
                            skb->len + sizeof(struct icmp6hdr),
                            sizeof(struct icmp6hdr), &ipc6, &fl6,
-                           (struct rt6_info *)dst, MSG_DONTWAIT)) {
+                           dst_rt6_info(dst), MSG_DONTWAIT)) {
                __ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTERRORS);
                ip6_flush_pending_frames(sk);
        } else {
 
 static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        struct dst_entry *orig_dst = skb_dst(skb);
-       struct rt6_info *rt = (struct rt6_info *)orig_dst;
+       struct rt6_info *rt = dst_rt6_info(orig_dst);
        struct ila_lwt *ilwt = ila_lwt_lwtunnel(orig_dst->lwtstate);
        struct dst_entry *dst;
        int err = -EINVAL;
                memset(&fl6, 0, sizeof(fl6));
                fl6.flowi6_oif = orig_dst->dev->ifindex;
                fl6.flowi6_iif = LOOPBACK_IFINDEX;
-               fl6.daddr = *rt6_nexthop((struct rt6_info *)orig_dst,
+               fl6.daddr = *rt6_nexthop(dst_rt6_info(orig_dst),
                                         &ip6h->daddr);
 
                dst = ip6_route_output(net, NULL, &fl6);
 
        IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, skb->len);
 
        rcu_read_lock();
-       nexthop = rt6_nexthop((struct rt6_info *)dst, daddr);
+       nexthop = rt6_nexthop(dst_rt6_info(dst), daddr);
        neigh = __ipv6_neigh_lookup_noref(dev, nexthop);
 
        if (unlikely(IS_ERR_OR_NULL(neigh))) {
                 *      send a redirect.
                 */
 
-               rt = (struct rt6_info *) dst;
+               rt = dst_rt6_info(dst);
                if (rt->rt6i_flags & RTF_GATEWAY)
                        target = &rt->rt6i_gateway;
                else
                 int (*output)(struct net *, struct sock *, struct sk_buff *))
 {
        struct sk_buff *frag;
-       struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
+       struct rt6_info *rt = dst_rt6_info(skb_dst(skb));
        struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
                                inet6_sk(skb->sk) : NULL;
        bool mono_delivery_time = skb->mono_delivery_time;
                return NULL;
        }
 
-       rt = (struct rt6_info *)dst;
+       rt = dst_rt6_info(dst);
        /* Yes, checking route validity in not connected
         * case is not very simple. Take into account,
         * that we do not support routing by source, TOS,
                struct rt6_info *rt;
 
                *dst = ip6_route_output(net, sk, fl6);
-               rt = (*dst)->error ? NULL : (struct rt6_info *)*dst;
+               rt = (*dst)->error ? NULL : dst_rt6_info(*dst);
 
                rcu_read_lock();
                from = rt ? rcu_dereference(rt->from) : NULL;
         * dst entry and replace it instead with the
         * dst entry of the nexthop router
         */
-       rt = (struct rt6_info *) *dst;
+       rt = dst_rt6_info(*dst);
        rcu_read_lock();
        n = __ipv6_neigh_lookup_noref(rt->dst.dev,
                                      rt6_nexthop(rt, &fl6->daddr));
        int offset = 0;
        bool zc = false;
        u32 tskey = 0;
-       struct rt6_info *rt = (struct rt6_info *)cork->dst;
+       struct rt6_info *rt = dst_rt6_info(cork->dst);
        bool paged, hold_tskey, extra_uref = false;
        struct ipv6_txoptions *opt = v6_cork->opt;
        int csummode = CHECKSUM_NONE;
        struct net *net = sock_net(sk);
        struct ipv6hdr *hdr;
        struct ipv6_txoptions *opt = v6_cork->opt;
-       struct rt6_info *rt = (struct rt6_info *)cork->base.dst;
+       struct rt6_info *rt = dst_rt6_info(cork->base.dst);
        struct flowi6 *fl6 = &cork->fl.u.ip6;
        unsigned char proto = fl6->flowi6_proto;
 
 int ip6_send_skb(struct sk_buff *skb)
 {
        struct net *net = sock_net(skb->sk);
-       struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
+       struct rt6_info *rt = dst_rt6_info(skb_dst(skb));
        int err;
 
        err = ip6_local_out(net, skb->sk, skb);
 
        int err;
        struct mr_table *mrt;
        struct mfc6_cache *cache;
-       struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
+       struct rt6_info *rt = dst_rt6_info(skb_dst(skb));
 
        mrt = ip6mr_get_table(net, RT6_TABLE_DFLT);
        if (!mrt)
 
        if (IS_ERR(dst))
                return;
 
-       rt = (struct rt6_info *) dst;
+       rt = dst_rt6_info(dst);
 
        if (rt->rt6i_flags & RTF_GATEWAY) {
                ND_PRINTK(2, warn,
 
        dst = ip6_sk_dst_lookup_flow(sk, &fl6, daddr, false);
        if (IS_ERR(dst))
                return PTR_ERR(dst);
-       rt = (struct rt6_info *) dst;
+       rt = dst_rt6_info(dst);
 
        if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
                fl6.flowi6_oif = READ_ONCE(np->mcast_oif);
 
        struct ipv6hdr *iph;
        struct sk_buff *skb;
        int err;
-       struct rt6_info *rt = (struct rt6_info *)*dstp;
+       struct rt6_info *rt = dst_rt6_info(*dstp);
        int hlen = LL_RESERVED_SPACE(rt->dst.dev);
        int tlen = rt->dst.dev->needed_tailroom;
 
                ipc6.opt = opt;
                lock_sock(sk);
                err = ip6_append_data(sk, raw6_getfrag, &rfv,
-                       len, 0, &ipc6, &fl6, (struct rt6_info *)dst,
+                       len, 0, &ipc6, &fl6, dst_rt6_info(dst),
                        msg->msg_flags);
 
                if (err)
 
                                              struct sk_buff *skb,
                                              const void *daddr)
 {
-       const struct rt6_info *rt = container_of(dst, struct rt6_info, dst);
+       const struct rt6_info *rt = dst_rt6_info(dst);
 
        return ip6_neigh_lookup(rt6_nexthop(rt, &in6addr_any),
                                dst->dev, skb, daddr);
 
 static void ip6_confirm_neigh(const struct dst_entry *dst, const void *daddr)
 {
+       const struct rt6_info *rt = dst_rt6_info(dst);
        struct net_device *dev = dst->dev;
-       struct rt6_info *rt = (struct rt6_info *)dst;
 
        daddr = choose_neigh_daddr(rt6_nexthop(rt, &in6addr_any), NULL, daddr);
        if (!daddr)
 
 static void ip6_dst_destroy(struct dst_entry *dst)
 {
-       struct rt6_info *rt = (struct rt6_info *)dst;
+       struct rt6_info *rt = dst_rt6_info(dst);
        struct fib6_info *from;
        struct inet6_dev *idev;
 
 
 static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev)
 {
-       struct rt6_info *rt = (struct rt6_info *)dst;
+       struct rt6_info *rt = dst_rt6_info(dst);
        struct inet6_dev *idev = rt->rt6i_idev;
 
        if (idev && idev->dev != blackhole_netdev) {
 
        dst = fib6_rule_lookup(net, &fl6, skb, flags, ip6_pol_route_lookup);
        if (dst->error == 0)
-               return (struct rt6_info *) dst;
+               return dst_rt6_info(dst);
 
        dst_release(dst);
 
 
        rcu_read_lock();
        dst = ip6_route_output_flags_noref(net, sk, fl6, flags);
-       rt6 = (struct rt6_info *)dst;
+       rt6 = dst_rt6_info(dst);
        /* For dst cached in uncached_list, refcnt is already taken. */
        if (list_empty(&rt6->dst.rt_uncached) && !dst_hold_safe(dst)) {
                dst = &net->ipv6.ip6_null_entry->dst;
 
 struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig)
 {
-       struct rt6_info *rt, *ort = (struct rt6_info *) dst_orig;
+       struct rt6_info *rt, *ort = dst_rt6_info(dst_orig);
        struct net_device *loopback_dev = net->loopback_dev;
        struct dst_entry *new = NULL;
 
        struct fib6_info *from;
        struct rt6_info *rt;
 
-       rt = container_of(dst, struct rt6_info, dst);
+       rt = dst_rt6_info(dst);
 
        if (rt->sernum)
                return rt6_is_valid(rt) ? dst : NULL;
 
 static struct dst_entry *ip6_negative_advice(struct dst_entry *dst)
 {
-       struct rt6_info *rt = (struct rt6_info *) dst;
+       struct rt6_info *rt = dst_rt6_info(dst);
 
        if (rt) {
                if (rt->rt6i_flags & RTF_CACHE) {
 
        icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0);
 
-       rt = (struct rt6_info *) skb_dst(skb);
+       rt = dst_rt6_info(skb_dst(skb));
        if (rt) {
                rcu_read_lock();
                if (rt->rt6i_flags & RTF_CACHE) {
                                 bool confirm_neigh)
 {
        const struct in6_addr *daddr, *saddr;
-       struct rt6_info *rt6 = (struct rt6_info *)dst;
+       struct rt6_info *rt6 = dst_rt6_info(dst);
 
        /* Note: do *NOT* check dst_metric_locked(dst, RTAX_MTU)
         * IPv6 pmtu discovery isn't optional, so 'mtu lock' cannot disable it.
                }
        }
 
-       rt = (struct rt6_info *) dst;
+       rt = dst_rt6_info(dst);
        if (rt->rt6i_flags & RTF_REJECT) {
                net_dbg_ratelimited("rt6_redirect: source isn't a valid nexthop for redirect target\n");
                return;
                         int iif, int type, u32 portid, u32 seq,
                         unsigned int flags)
 {
-       struct rt6_info *rt6 = (struct rt6_info *)dst;
+       struct rt6_info *rt6 = dst_rt6_info(dst);
        struct rt6key *rt6_dst, *rt6_src;
        u32 *pmetrics, table, rt6_flags;
        unsigned char nh_flags = 0;
        }
 
 
-       rt = container_of(dst, struct rt6_info, dst);
+       rt = dst_rt6_info(dst);
        if (rt->dst.error) {
                err = rt->dst.error;
                ip6_rt_put(rt);
 
        struct dst_entry *dst = skb_dst(skb);
 
        if (dst && dst_hold_safe(dst)) {
-               const struct rt6_info *rt = (const struct rt6_info *)dst;
-
                rcu_assign_pointer(sk->sk_rx_dst, dst);
                sk->sk_rx_dst_ifindex = skb->skb_iif;
-               sk->sk_rx_dst_cookie = rt6_get_cookie(rt);
+               sk->sk_rx_dst_cookie = rt6_get_cookie(dst_rt6_info(dst));
        }
 }
 
 
 
 static void udp6_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
 {
-       if (udp_sk_rx_dst_set(sk, dst)) {
-               const struct rt6_info *rt = (const struct rt6_info *)dst;
-
-               sk->sk_rx_dst_cookie = rt6_get_cookie(rt);
-       }
+       if (udp_sk_rx_dst_set(sk, dst))
+               sk->sk_rx_dst_cookie = rt6_get_cookie(dst_rt6_info(dst));
 }
 
 /* wrapper for udp_queue_rcv_skb tacking care of csum conversion and
 
                skb = ip6_make_skb(sk, getfrag, msg, ulen,
                                   sizeof(struct udphdr), &ipc6,
-                                  (struct rt6_info *)dst,
+                                  dst_rt6_info(dst),
                                   msg->msg_flags, &cork);
                err = PTR_ERR(skb);
                if (!IS_ERR_OR_NULL(skb))
                ipc6.dontfrag = inet6_test_bit(DONTFRAG, sk);
        up->len += ulen;
        err = ip6_append_data(sk, getfrag, msg, ulen, sizeof(struct udphdr),
-                             &ipc6, fl6, (struct rt6_info *)dst,
+                             &ipc6, fl6, dst_rt6_info(dst),
                              corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags);
        if (err)
                udp_v6_flush_pending_frames(sk);
 
 static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
                          const struct flowi *fl)
 {
-       struct rt6_info *rt = (struct rt6_info *)xdst->route;
+       struct rt6_info *rt = dst_rt6_info(xdst->route);
 
        xdst->u.dst.dev = dev;
        netdev_hold(dev, &xdst->u.dst.dev_tracker, GFP_ATOMIC);
 
        ulen = len + (skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0);
        err = ip6_append_data(sk, ip_generic_getfrag, msg,
                              ulen, transhdrlen, &ipc6,
-                             &fl6, (struct rt6_info *)dst,
+                             &fl6, dst_rt6_info(dst),
                              msg->msg_flags);
        if (err)
                ip6_flush_pending_frames(sk);
 
                        ttl = net->mpls.default_ttl;
                else
                        ttl = ipv6_hdr(skb)->hop_limit;
-               rt6 = (struct rt6_info *)dst;
+               rt6 = dst_rt6_info(dst);
        } else {
                goto drop;
        }
 
                        (!skb->dev || skb->dev->flags & IFF_LOOPBACK) &&
                        (addr_type & IPV6_ADDR_LOOPBACK);
                old_rt_is_local = __ip_vs_is_local_route6(
-                       (struct rt6_info *)skb_dst(skb));
+                       dst_rt6_info(skb_dst(skb)));
        } else
 #endif
        {
        if (dest) {
                dest_dst = __ip_vs_dst_check(dest);
                if (likely(dest_dst))
-                       rt = (struct rt6_info *) dest_dst->dst_cache;
+                       rt = dst_rt6_info(dest_dst->dst_cache);
                else {
                        u32 cookie;
 
                                ip_vs_dest_dst_free(dest_dst);
                                goto err_unreach;
                        }
-                       rt = (struct rt6_info *) dst;
+                       rt = dst_rt6_info(dst);
                        cookie = rt6_get_cookie(rt);
                        __ip_vs_dst_set(dest, dest_dst, &rt->dst, cookie);
                        spin_unlock_bh(&dest->dst_lock);
                                              rt_mode);
                if (!dst)
                        goto err_unreach;
-               rt = (struct rt6_info *) dst;
+               rt = dst_rt6_info(dst);
        }
 
        local = __ip_vs_is_local_route6(rt);
                                      IP_VS_RT_MODE_RDR);
        if (local < 0)
                goto tx_error;
-       rt = (struct rt6_info *) skb_dst(skb);
+       rt = dst_rt6_info(skb_dst(skb));
        /*
         * Avoid duplicate tuple in reply direction for NAT traffic
         * to local address when connection is sync-ed
        if (local)
                return ip_vs_send_or_cont(NFPROTO_IPV6, skb, cp, 1);
 
-       rt = (struct rt6_info *) skb_dst(skb);
+       rt = dst_rt6_info(skb_dst(skb));
        tdev = rt->dst.dev;
 
        /*
                                      &cp->daddr.in6, NULL, ipvsh, 0, rt_mode);
        if (local < 0)
                goto tx_error;
-       rt = (struct rt6_info *) skb_dst(skb);
+       rt = dst_rt6_info(skb_dst(skb));
        /*
         * Avoid duplicate tuple in reply direction for NAT traffic
         * to local address when connection is sync-ed
 
 
 static u32 flow_offload_dst_cookie(struct flow_offload_tuple *flow_tuple)
 {
-       const struct rt6_info *rt;
-
-       if (flow_tuple->l3proto == NFPROTO_IPV6) {
-               rt = (const struct rt6_info *)flow_tuple->dst_cache;
-               return rt6_get_cookie(rt);
-       }
+       if (flow_tuple->l3proto == NFPROTO_IPV6)
+               return rt6_get_cookie(dst_rt6_info(flow_tuple->dst_cache));
 
        return 0;
 }
 
                return NF_ACCEPT;
 
        if (unlikely(tuplehash->tuple.xmit_type == FLOW_OFFLOAD_XMIT_XFRM)) {
-               rt = (struct rt6_info *)tuplehash->tuple.dst_cache;
+               rt = dst_rt6_info(tuplehash->tuple.dst_cache);
                memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
                IP6CB(skb)->iif = skb->dev->ifindex;
                IP6CB(skb)->flags = IP6SKB_FORWARDED;
 
        switch (tuplehash->tuple.xmit_type) {
        case FLOW_OFFLOAD_XMIT_NEIGH:
-               rt = (struct rt6_info *)tuplehash->tuple.dst_cache;
+               rt = dst_rt6_info(tuplehash->tuple.dst_cache);
                outdev = rt->dst.dev;
                skb->dev = outdev;
                nexthop = rt6_nexthop(rt, &flow->tuplehash[!dir].tuple.src_v6);
 
                if (nft_pf(pkt) != NFPROTO_IPV6)
                        goto err;
 
-               memcpy(dest, rt6_nexthop((struct rt6_info *)dst,
+               memcpy(dest, rt6_nexthop(dst_rt6_info(dst),
                                         &ipv6_hdr(skb)->daddr),
                       sizeof(struct in6_addr));
                break;
 
        if (!IS_ERR_OR_NULL(dst)) {
                struct rt6_info *rt;
 
-               rt = (struct rt6_info *)dst;
+               rt = dst_rt6_info(dst);
                t->dst_cookie = rt6_get_cookie(rt);
                pr_debug("rt6_dst:%pI6/%d rt6_src:%pI6\n",
                         &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
 
                           int nfheader_len)
 {
        if (dst->ops->family == AF_INET6) {
-               struct rt6_info *rt = (struct rt6_info *)dst;
-               path->path_cookie = rt6_get_cookie(rt);
+               path->path_cookie = rt6_get_cookie(dst_rt6_info(dst));
                path->u.rt6.rt6i_nfheader_len = nfheader_len;
        }
 }