Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
e8dfd42c fac87d32

+77 -86
+3 -3
drivers/infiniband/core/addr.c
··· 348 348 349 349 static bool has_gateway(const struct dst_entry *dst, sa_family_t family) 350 350 { 351 - struct rtable *rt; 352 - struct rt6_info *rt6; 351 + const struct rtable *rt; 352 + const struct rt6_info *rt6; 353 353 354 354 if (family == AF_INET) { 355 355 rt = container_of(dst, struct rtable, dst); 356 356 return rt->rt_uses_gateway; 357 357 } 358 358 359 - rt6 = container_of(dst, struct rt6_info, dst); 359 + rt6 = dst_rt6_info(dst); 360 360 return rt6->rt6i_flags & RTF_GATEWAY; 361 361 } 362 362
+1 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
··· 540 540 if (!dst || dst->error) 541 541 goto out; 542 542 543 - rt6 = container_of(dst, struct rt6_info, dst); 543 + rt6 = dst_rt6_info(dst); 544 544 545 545 dev = dst->dev; 546 546 *saddrp = fl6.saddr;
+1 -1
drivers/net/vrf.c
··· 653 653 skb->dev = dev; 654 654 655 655 rcu_read_lock(); 656 - nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr); 656 + nexthop = rt6_nexthop(dst_rt6_info(dst), &ipv6_hdr(skb)->daddr); 657 657 neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop); 658 658 if (unlikely(!neigh)) 659 659 neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
+1 -1
drivers/net/vxlan/vxlan_core.c
··· 2513 2513 } 2514 2514 2515 2515 if (!info) { 2516 - u32 rt6i_flags = ((struct rt6_info *)ndst)->rt6i_flags; 2516 + u32 rt6i_flags = dst_rt6_info(ndst)->rt6i_flags; 2517 2517 2518 2518 err = encap_bypass_if_local(skb, dev, vxlan, AF_INET6, 2519 2519 dst_port, ifindex, vni,
+2 -2
drivers/s390/net/qeth_core.h
··· 956 956 struct dst_entry *dst = skb_dst(skb); 957 957 struct rt6_info *rt; 958 958 959 - rt = (struct rt6_info *) dst; 959 + rt = dst_rt6_info(dst); 960 960 if (dst) { 961 961 if (proto == htons(ETH_P_IPV6)) 962 962 dst = dst_check(dst, rt6_get_cookie(rt)); ··· 978 978 static inline struct in6_addr *qeth_next_hop_v6_rcu(struct sk_buff *skb, 979 979 struct dst_entry *dst) 980 980 { 981 - struct rt6_info *rt = (struct rt6_info *) dst; 981 + struct rt6_info *rt = dst_rt6_info(dst); 982 982 983 983 if (rt && !ipv6_addr_any(&rt->rt6i_gateway)) 984 984 return &rt->rt6i_gateway;
+4 -2
include/net/ip6_fib.h
··· 234 234 for (rt = (w)->leaf; rt; \ 235 235 rt = rcu_dereference_protected(rt->fib6_next, 1)) 236 236 237 - static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst) 237 + #define dst_rt6_info(_ptr) container_of_const(_ptr, struct rt6_info, dst) 238 + 239 + static inline struct inet6_dev *ip6_dst_idev(const struct dst_entry *dst) 238 240 { 239 - return ((struct rt6_info *)dst)->rt6i_idev; 241 + return dst_rt6_info(dst)->rt6i_idev; 240 242 } 241 243 242 244 static inline bool fib6_requires_src(const struct fib6_info *rt)
+5 -6
include/net/ip6_route.h
··· 210 210 static inline const struct rt6_info *skb_rt6_info(const struct sk_buff *skb) 211 211 { 212 212 const struct dst_entry *dst = skb_dst(skb); 213 - const struct rt6_info *rt6 = NULL; 214 213 215 214 if (dst) 216 - rt6 = container_of(dst, struct rt6_info, dst); 215 + return dst_rt6_info(dst); 217 216 218 - return rt6; 217 + return NULL; 219 218 } 220 219 221 220 /* ··· 226 227 { 227 228 struct ipv6_pinfo *np = inet6_sk(sk); 228 229 229 - np->dst_cookie = rt6_get_cookie((struct rt6_info *)dst); 230 + np->dst_cookie = rt6_get_cookie(dst_rt6_info(dst)); 230 231 sk_setup_caps(sk, dst); 231 232 np->daddr_cache = daddr; 232 233 #ifdef CONFIG_IPV6_SUBTREES ··· 239 240 240 241 static inline bool ipv6_unicast_destination(const struct sk_buff *skb) 241 242 { 242 - struct rt6_info *rt = (struct rt6_info *) skb_dst(skb); 243 + const struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); 243 244 244 245 return rt->rt6i_flags & RTF_LOCAL; 245 246 } ··· 247 248 static inline bool ipv6_anycast_destination(const struct dst_entry *dst, 248 249 const struct in6_addr *daddr) 249 250 { 250 - struct rt6_info *rt = (struct rt6_info *)dst; 251 + const struct rt6_info *rt = dst_rt6_info(dst); 251 252 252 253 return rt->rt6i_flags & RTF_ANYCAST || 253 254 (rt->rt6i_dst.plen < 127 &&
+1 -1
net/bluetooth/6lowpan.c
··· 133 133 struct in6_addr *daddr, 134 134 struct sk_buff *skb) 135 135 { 136 - struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); 136 + struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); 137 137 int count = atomic_read(&dev->peer_count); 138 138 const struct in6_addr *nexthop; 139 139 struct lowpan_peer *peer;
+1 -1
net/core/dst_cache.c
··· 112 112 113 113 idst = this_cpu_ptr(dst_cache->cache); 114 114 dst_cache_per_cpu_dst_set(this_cpu_ptr(dst_cache->cache), dst, 115 - rt6_get_cookie((struct rt6_info *)dst)); 115 + rt6_get_cookie(dst_rt6_info(dst))); 116 116 idst->in6_saddr = *saddr; 117 117 } 118 118 EXPORT_SYMBOL_GPL(dst_cache_set_ip6);
+1 -1
net/core/filter.c
··· 2215 2215 rcu_read_lock(); 2216 2216 if (!nh) { 2217 2217 dst = skb_dst(skb); 2218 - nexthop = rt6_nexthop(container_of(dst, struct rt6_info, dst), 2218 + nexthop = rt6_nexthop(dst_rt6_info(dst), 2219 2219 &ipv6_hdr(skb)->daddr); 2220 2220 } else { 2221 2221 nexthop = &nh->ipv6_nh;
+1 -1
net/ipv4/ip_tunnel.c
··· 543 543 struct rt6_info *rt6; 544 544 __be32 daddr; 545 545 546 - rt6 = skb_valid_dst(skb) ? (struct rt6_info *)skb_dst(skb) : 546 + rt6 = skb_valid_dst(skb) ? dst_rt6_info(skb_dst(skb)) : 547 547 NULL; 548 548 daddr = md ? dst : tunnel->parms.iph.daddr; 549 549
+4 -4
net/ipv6/icmp.c
··· 212 212 } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) { 213 213 res = true; 214 214 } else { 215 - struct rt6_info *rt = (struct rt6_info *)dst; 215 + struct rt6_info *rt = dst_rt6_info(dst); 216 216 int tmo = net->ipv6.sysctl.icmpv6_time; 217 217 struct inet_peer *peer; 218 218 ··· 241 241 242 242 dst = ip6_route_output(net, sk, fl6); 243 243 if (!dst->error) { 244 - struct rt6_info *rt = (struct rt6_info *)dst; 244 + struct rt6_info *rt = dst_rt6_info(dst); 245 245 struct in6_addr prefsrc; 246 246 247 247 rt6_get_prefsrc(rt, &prefsrc); ··· 616 616 if (ip6_append_data(sk, icmpv6_getfrag, &msg, 617 617 len + sizeof(struct icmp6hdr), 618 618 sizeof(struct icmp6hdr), 619 - &ipc6, &fl6, (struct rt6_info *)dst, 619 + &ipc6, &fl6, dst_rt6_info(dst), 620 620 MSG_DONTWAIT)) { 621 621 ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTERRORS); 622 622 ip6_flush_pending_frames(sk); ··· 803 803 if (ip6_append_data(sk, icmpv6_getfrag, &msg, 804 804 skb->len + sizeof(struct icmp6hdr), 805 805 sizeof(struct icmp6hdr), &ipc6, &fl6, 806 - (struct rt6_info *)dst, MSG_DONTWAIT)) { 806 + dst_rt6_info(dst), MSG_DONTWAIT)) { 807 807 __ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTERRORS); 808 808 ip6_flush_pending_frames(sk); 809 809 } else {
+2 -2
net/ipv6/ila/ila_lwt.c
··· 38 38 static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb) 39 39 { 40 40 struct dst_entry *orig_dst = skb_dst(skb); 41 - struct rt6_info *rt = (struct rt6_info *)orig_dst; 41 + struct rt6_info *rt = dst_rt6_info(orig_dst); 42 42 struct ila_lwt *ilwt = ila_lwt_lwtunnel(orig_dst->lwtstate); 43 43 struct dst_entry *dst; 44 44 int err = -EINVAL; ··· 70 70 memset(&fl6, 0, sizeof(fl6)); 71 71 fl6.flowi6_oif = orig_dst->dev->ifindex; 72 72 fl6.flowi6_iif = LOOPBACK_IFINDEX; 73 - fl6.daddr = *rt6_nexthop((struct rt6_info *)orig_dst, 73 + fl6.daddr = *rt6_nexthop(dst_rt6_info(orig_dst), 74 74 &ip6h->daddr); 75 75 76 76 dst = ip6_route_output(net, NULL, &fl6);
+9 -9
net/ipv6/ip6_output.c
··· 120 120 IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, skb->len); 121 121 122 122 rcu_read_lock(); 123 - nexthop = rt6_nexthop((struct rt6_info *)dst, daddr); 123 + nexthop = rt6_nexthop(dst_rt6_info(dst), daddr); 124 124 neigh = __ipv6_neigh_lookup_noref(dev, nexthop); 125 125 126 126 if (unlikely(IS_ERR_OR_NULL(neigh))) { ··· 599 599 * send a redirect. 600 600 */ 601 601 602 - rt = (struct rt6_info *) dst; 602 + rt = dst_rt6_info(dst); 603 603 if (rt->rt6i_flags & RTF_GATEWAY) 604 604 target = &rt->rt6i_gateway; 605 605 else ··· 856 856 int (*output)(struct net *, struct sock *, struct sk_buff *)) 857 857 { 858 858 struct sk_buff *frag; 859 - struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); 859 + struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); 860 860 struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? 861 861 inet6_sk(skb->sk) : NULL; 862 862 bool mono_delivery_time = skb->mono_delivery_time; ··· 1063 1063 return NULL; 1064 1064 } 1065 1065 1066 - rt = (struct rt6_info *)dst; 1066 + rt = dst_rt6_info(dst); 1067 1067 /* Yes, checking route validity in not connected 1068 1068 * case is not very simple. Take into account, 1069 1069 * that we do not support routing by source, TOS, ··· 1118 1118 struct rt6_info *rt; 1119 1119 1120 1120 *dst = ip6_route_output(net, sk, fl6); 1121 - rt = (*dst)->error ? NULL : (struct rt6_info *)*dst; 1121 + rt = (*dst)->error ? NULL : dst_rt6_info(*dst); 1122 1122 1123 1123 rcu_read_lock(); 1124 1124 from = rt ? rcu_dereference(rt->from) : NULL; ··· 1159 1159 * dst entry and replace it instead with the 1160 1160 * dst entry of the nexthop router 1161 1161 */ 1162 - rt = (struct rt6_info *) *dst; 1162 + rt = dst_rt6_info(*dst); 1163 1163 rcu_read_lock(); 1164 1164 n = __ipv6_neigh_lookup_noref(rt->dst.dev, 1165 1165 rt6_nexthop(rt, &fl6->daddr)); ··· 1423 1423 int offset = 0; 1424 1424 bool zc = false; 1425 1425 u32 tskey = 0; 1426 - struct rt6_info *rt = (struct rt6_info *)cork->dst; 1426 + struct rt6_info *rt = dst_rt6_info(cork->dst); 1427 1427 bool paged, hold_tskey, extra_uref = false; 1428 1428 struct ipv6_txoptions *opt = v6_cork->opt; 1429 1429 int csummode = CHECKSUM_NONE; ··· 1877 1877 struct net *net = sock_net(sk); 1878 1878 struct ipv6hdr *hdr; 1879 1879 struct ipv6_txoptions *opt = v6_cork->opt; 1880 - struct rt6_info *rt = (struct rt6_info *)cork->base.dst; 1880 + struct rt6_info *rt = dst_rt6_info(cork->base.dst); 1881 1881 struct flowi6 *fl6 = &cork->fl.u.ip6; 1882 1882 unsigned char proto = fl6->flowi6_proto; 1883 1883 ··· 1949 1949 int ip6_send_skb(struct sk_buff *skb) 1950 1950 { 1951 1951 struct net *net = sock_net(skb->sk); 1952 - struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); 1952 + struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); 1953 1953 int err; 1954 1954 1955 1955 err = ip6_local_out(net, skb->sk, skb);
+1 -1
net/ipv6/ip6mr.c
··· 2273 2273 int err; 2274 2274 struct mr_table *mrt; 2275 2275 struct mfc6_cache *cache; 2276 - struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); 2276 + struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); 2277 2277 2278 2278 mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); 2279 2279 if (!mrt)
+1 -1
net/ipv6/ndisc.c
··· 1722 1722 if (IS_ERR(dst)) 1723 1723 return; 1724 1724 1725 - rt = (struct rt6_info *) dst; 1725 + rt = dst_rt6_info(dst); 1726 1726 1727 1727 if (rt->rt6i_flags & RTF_GATEWAY) { 1728 1728 ND_PRINTK(2, warn,
+1 -1
net/ipv6/ping.c
··· 154 154 dst = ip6_sk_dst_lookup_flow(sk, &fl6, daddr, false); 155 155 if (IS_ERR(dst)) 156 156 return PTR_ERR(dst); 157 - rt = (struct rt6_info *) dst; 157 + rt = dst_rt6_info(dst); 158 158 159 159 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) 160 160 fl6.flowi6_oif = READ_ONCE(np->mcast_oif);
+2 -2
net/ipv6/raw.c
··· 598 598 struct ipv6hdr *iph; 599 599 struct sk_buff *skb; 600 600 int err; 601 - struct rt6_info *rt = (struct rt6_info *)*dstp; 601 + struct rt6_info *rt = dst_rt6_info(*dstp); 602 602 int hlen = LL_RESERVED_SPACE(rt->dst.dev); 603 603 int tlen = rt->dst.dev->needed_tailroom; 604 604 ··· 917 917 ipc6.opt = opt; 918 918 lock_sock(sk); 919 919 err = ip6_append_data(sk, raw6_getfrag, &rfv, 920 - len, 0, &ipc6, &fl6, (struct rt6_info *)dst, 920 + len, 0, &ipc6, &fl6, dst_rt6_info(dst), 921 921 msg->msg_flags); 922 922 923 923 if (err)
+14 -14
net/ipv6/route.c
··· 226 226 struct sk_buff *skb, 227 227 const void *daddr) 228 228 { 229 - const struct rt6_info *rt = container_of(dst, struct rt6_info, dst); 229 + const struct rt6_info *rt = dst_rt6_info(dst); 230 230 231 231 return ip6_neigh_lookup(rt6_nexthop(rt, &in6addr_any), 232 232 dst->dev, skb, daddr); ··· 234 234 235 235 static void ip6_confirm_neigh(const struct dst_entry *dst, const void *daddr) 236 236 { 237 + const struct rt6_info *rt = dst_rt6_info(dst); 237 238 struct net_device *dev = dst->dev; 238 - struct rt6_info *rt = (struct rt6_info *)dst; 239 239 240 240 daddr = choose_neigh_daddr(rt6_nexthop(rt, &in6addr_any), NULL, daddr); 241 241 if (!daddr) ··· 354 354 355 355 static void ip6_dst_destroy(struct dst_entry *dst) 356 356 { 357 - struct rt6_info *rt = (struct rt6_info *)dst; 357 + struct rt6_info *rt = dst_rt6_info(dst); 358 358 struct fib6_info *from; 359 359 struct inet6_dev *idev; 360 360 ··· 373 373 374 374 static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev) 375 375 { 376 - struct rt6_info *rt = (struct rt6_info *)dst; 376 + struct rt6_info *rt = dst_rt6_info(dst); 377 377 struct inet6_dev *idev = rt->rt6i_idev; 378 378 379 379 if (idev && idev->dev != blackhole_netdev) { ··· 1288 1288 1289 1289 dst = fib6_rule_lookup(net, &fl6, skb, flags, ip6_pol_route_lookup); 1290 1290 if (dst->error == 0) 1291 - return (struct rt6_info *) dst; 1291 + return dst_rt6_info(dst); 1292 1292 1293 1293 dst_release(dst); 1294 1294 ··· 2647 2647 2648 2648 rcu_read_lock(); 2649 2649 dst = ip6_route_output_flags_noref(net, sk, fl6, flags); 2650 - rt6 = (struct rt6_info *)dst; 2650 + rt6 = dst_rt6_info(dst); 2651 2651 /* For dst cached in uncached_list, refcnt is already taken. */ 2652 2652 if (list_empty(&rt6->dst.rt_uncached) && !dst_hold_safe(dst)) { 2653 2653 dst = &net->ipv6.ip6_null_entry->dst; ··· 2661 2661 2662 2662 struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig) 2663 2663 { 2664 - struct rt6_info *rt, *ort = (struct rt6_info *) dst_orig; 2664 + struct rt6_info *rt, *ort = dst_rt6_info(dst_orig); 2665 2665 struct net_device *loopback_dev = net->loopback_dev; 2666 2666 struct dst_entry *new = NULL; 2667 2667 ··· 2744 2744 struct fib6_info *from; 2745 2745 struct rt6_info *rt; 2746 2746 2747 - rt = container_of(dst, struct rt6_info, dst); 2747 + rt = dst_rt6_info(dst); 2748 2748 2749 2749 if (rt->sernum) 2750 2750 return rt6_is_valid(rt) ? dst : NULL; ··· 2772 2772 2773 2773 static struct dst_entry *ip6_negative_advice(struct dst_entry *dst) 2774 2774 { 2775 - struct rt6_info *rt = (struct rt6_info *) dst; 2775 + struct rt6_info *rt = dst_rt6_info(dst); 2776 2776 2777 2777 if (rt) { 2778 2778 if (rt->rt6i_flags & RTF_CACHE) { ··· 2796 2796 2797 2797 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0); 2798 2798 2799 - rt = (struct rt6_info *) skb_dst(skb); 2799 + rt = dst_rt6_info(skb_dst(skb)); 2800 2800 if (rt) { 2801 2801 rcu_read_lock(); 2802 2802 if (rt->rt6i_flags & RTF_CACHE) { ··· 2852 2852 bool confirm_neigh) 2853 2853 { 2854 2854 const struct in6_addr *daddr, *saddr; 2855 - struct rt6_info *rt6 = (struct rt6_info *)dst; 2855 + struct rt6_info *rt6 = dst_rt6_info(dst); 2856 2856 2857 2857 /* Note: do *NOT* check dst_metric_locked(dst, RTAX_MTU) 2858 2858 * IPv6 pmtu discovery isn't optional, so 'mtu lock' cannot disable it. ··· 4174 4174 } 4175 4175 } 4176 4176 4177 - rt = (struct rt6_info *) dst; 4177 + rt = dst_rt6_info(dst); 4178 4178 if (rt->rt6i_flags & RTF_REJECT) { 4179 4179 net_dbg_ratelimited("rt6_redirect: source isn't a valid nexthop for redirect target\n"); 4180 4180 return; ··· 5608 5608 int iif, int type, u32 portid, u32 seq, 5609 5609 unsigned int flags) 5610 5610 { 5611 - struct rt6_info *rt6 = (struct rt6_info *)dst; 5611 + struct rt6_info *rt6 = dst_rt6_info(dst); 5612 5612 struct rt6key *rt6_dst, *rt6_src; 5613 5613 u32 *pmetrics, table, rt6_flags; 5614 5614 unsigned char nh_flags = 0; ··· 6111 6111 } 6112 6112 6113 6113 6114 - rt = container_of(dst, struct rt6_info, dst); 6114 + rt = dst_rt6_info(dst); 6115 6115 if (rt->dst.error) { 6116 6116 err = rt->dst.error; 6117 6117 ip6_rt_put(rt);
+1 -3
net/ipv6/tcp_ipv6.c
··· 97 97 struct dst_entry *dst = skb_dst(skb); 98 98 99 99 if (dst && dst_hold_safe(dst)) { 100 - const struct rt6_info *rt = (const struct rt6_info *)dst; 101 - 102 100 rcu_assign_pointer(sk->sk_rx_dst, dst); 103 101 sk->sk_rx_dst_ifindex = skb->skb_iif; 104 - sk->sk_rx_dst_cookie = rt6_get_cookie(rt); 102 + sk->sk_rx_dst_cookie = rt6_get_cookie(dst_rt6_info(dst)); 105 103 } 106 104 } 107 105
+4 -7
net/ipv6/udp.c
··· 910 910 911 911 static void udp6_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) 912 912 { 913 - if (udp_sk_rx_dst_set(sk, dst)) { 914 - const struct rt6_info *rt = (const struct rt6_info *)dst; 915 - 916 - sk->sk_rx_dst_cookie = rt6_get_cookie(rt); 917 - } 913 + if (udp_sk_rx_dst_set(sk, dst)) 914 + sk->sk_rx_dst_cookie = rt6_get_cookie(dst_rt6_info(dst)); 918 915 } 919 916 920 917 /* wrapper for udp_queue_rcv_skb tacking care of csum conversion and ··· 1582 1585 1583 1586 skb = ip6_make_skb(sk, getfrag, msg, ulen, 1584 1587 sizeof(struct udphdr), &ipc6, 1585 - (struct rt6_info *)dst, 1588 + dst_rt6_info(dst), 1586 1589 msg->msg_flags, &cork); 1587 1590 err = PTR_ERR(skb); 1588 1591 if (!IS_ERR_OR_NULL(skb)) ··· 1609 1612 ipc6.dontfrag = inet6_test_bit(DONTFRAG, sk); 1610 1613 up->len += ulen; 1611 1614 err = ip6_append_data(sk, getfrag, msg, ulen, sizeof(struct udphdr), 1612 - &ipc6, fl6, (struct rt6_info *)dst, 1615 + &ipc6, fl6, dst_rt6_info(dst), 1613 1616 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); 1614 1617 if (err) 1615 1618 udp_v6_flush_pending_frames(sk);
+1 -1
net/ipv6/xfrm6_policy.c
··· 70 70 static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, 71 71 const struct flowi *fl) 72 72 { 73 - struct rt6_info *rt = (struct rt6_info *)xdst->route; 73 + struct rt6_info *rt = dst_rt6_info(xdst->route); 74 74 75 75 xdst->u.dst.dev = dev; 76 76 netdev_hold(dev, &xdst->u.dst.dev_tracker, GFP_ATOMIC);
+1 -1
net/l2tp/l2tp_ip6.c
··· 630 630 ulen = len + (skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0); 631 631 err = ip6_append_data(sk, ip_generic_getfrag, msg, 632 632 ulen, transhdrlen, &ipc6, 633 - &fl6, (struct rt6_info *)dst, 633 + &fl6, dst_rt6_info(dst), 634 634 msg->msg_flags); 635 635 if (err) 636 636 ip6_flush_pending_frames(sk);
+1 -1
net/mpls/mpls_iptunnel.c
··· 90 90 ttl = net->mpls.default_ttl; 91 91 else 92 92 ttl = ipv6_hdr(skb)->hop_limit; 93 - rt6 = (struct rt6_info *)dst; 93 + rt6 = dst_rt6_info(dst); 94 94 } else { 95 95 goto drop; 96 96 }
+7 -7
net/netfilter/ipvs/ip_vs_xmit.c
··· 180 180 (!skb->dev || skb->dev->flags & IFF_LOOPBACK) && 181 181 (addr_type & IPV6_ADDR_LOOPBACK); 182 182 old_rt_is_local = __ip_vs_is_local_route6( 183 - (struct rt6_info *)skb_dst(skb)); 183 + dst_rt6_info(skb_dst(skb))); 184 184 } else 185 185 #endif 186 186 { ··· 481 481 if (dest) { 482 482 dest_dst = __ip_vs_dst_check(dest); 483 483 if (likely(dest_dst)) 484 - rt = (struct rt6_info *) dest_dst->dst_cache; 484 + rt = dst_rt6_info(dest_dst->dst_cache); 485 485 else { 486 486 u32 cookie; 487 487 ··· 501 501 ip_vs_dest_dst_free(dest_dst); 502 502 goto err_unreach; 503 503 } 504 - rt = (struct rt6_info *) dst; 504 + rt = dst_rt6_info(dst); 505 505 cookie = rt6_get_cookie(rt); 506 506 __ip_vs_dst_set(dest, dest_dst, &rt->dst, cookie); 507 507 spin_unlock_bh(&dest->dst_lock); ··· 517 517 rt_mode); 518 518 if (!dst) 519 519 goto err_unreach; 520 - rt = (struct rt6_info *) dst; 520 + rt = dst_rt6_info(dst); 521 521 } 522 522 523 523 local = __ip_vs_is_local_route6(rt); ··· 862 862 IP_VS_RT_MODE_RDR); 863 863 if (local < 0) 864 864 goto tx_error; 865 - rt = (struct rt6_info *) skb_dst(skb); 865 + rt = dst_rt6_info(skb_dst(skb)); 866 866 /* 867 867 * Avoid duplicate tuple in reply direction for NAT traffic 868 868 * to local address when connection is sync-ed ··· 1288 1288 if (local) 1289 1289 return ip_vs_send_or_cont(NFPROTO_IPV6, skb, cp, 1); 1290 1290 1291 - rt = (struct rt6_info *) skb_dst(skb); 1291 + rt = dst_rt6_info(skb_dst(skb)); 1292 1292 tdev = rt->dst.dev; 1293 1293 1294 1294 /* ··· 1590 1590 &cp->daddr.in6, NULL, ipvsh, 0, rt_mode); 1591 1591 if (local < 0) 1592 1592 goto tx_error; 1593 - rt = (struct rt6_info *) skb_dst(skb); 1593 + rt = dst_rt6_info(skb_dst(skb)); 1594 1594 /* 1595 1595 * Avoid duplicate tuple in reply direction for NAT traffic 1596 1596 * to local address when connection is sync-ed
+2 -6
net/netfilter/nf_flow_table_core.c
··· 77 77 78 78 static u32 flow_offload_dst_cookie(struct flow_offload_tuple *flow_tuple) 79 79 { 80 - const struct rt6_info *rt; 81 - 82 - if (flow_tuple->l3proto == NFPROTO_IPV6) { 83 - rt = (const struct rt6_info *)flow_tuple->dst_cache; 84 - return rt6_get_cookie(rt); 85 - } 80 + if (flow_tuple->l3proto == NFPROTO_IPV6) 81 + return rt6_get_cookie(dst_rt6_info(flow_tuple->dst_cache)); 86 82 87 83 return 0; 88 84 }
+2 -2
net/netfilter/nf_flow_table_ip.c
··· 729 729 return NF_ACCEPT; 730 730 731 731 if (unlikely(tuplehash->tuple.xmit_type == FLOW_OFFLOAD_XMIT_XFRM)) { 732 - rt = (struct rt6_info *)tuplehash->tuple.dst_cache; 732 + rt = dst_rt6_info(tuplehash->tuple.dst_cache); 733 733 memset(skb->cb, 0, sizeof(struct inet6_skb_parm)); 734 734 IP6CB(skb)->iif = skb->dev->ifindex; 735 735 IP6CB(skb)->flags = IP6SKB_FORWARDED; ··· 741 741 742 742 switch (tuplehash->tuple.xmit_type) { 743 743 case FLOW_OFFLOAD_XMIT_NEIGH: 744 - rt = (struct rt6_info *)tuplehash->tuple.dst_cache; 744 + rt = dst_rt6_info(tuplehash->tuple.dst_cache); 745 745 outdev = rt->dst.dev; 746 746 skb->dev = outdev; 747 747 nexthop = rt6_nexthop(rt, &flow->tuplehash[!dir].tuple.src_v6);
+1 -1
net/netfilter/nft_rt.c
··· 80 80 if (nft_pf(pkt) != NFPROTO_IPV6) 81 81 goto err; 82 82 83 - memcpy(dest, rt6_nexthop((struct rt6_info *)dst, 83 + memcpy(dest, rt6_nexthop(dst_rt6_info(dst), 84 84 &ipv6_hdr(skb)->daddr), 85 85 sizeof(struct in6_addr)); 86 86 break;
+1 -1
net/sctp/ipv6.c
··· 415 415 if (!IS_ERR_OR_NULL(dst)) { 416 416 struct rt6_info *rt; 417 417 418 - rt = (struct rt6_info *)dst; 418 + rt = dst_rt6_info(dst); 419 419 t->dst_cookie = rt6_get_cookie(rt); 420 420 pr_debug("rt6_dst:%pI6/%d rt6_src:%pI6\n", 421 421 &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
+1 -2
net/xfrm/xfrm_policy.c
··· 2598 2598 int nfheader_len) 2599 2599 { 2600 2600 if (dst->ops->family == AF_INET6) { 2601 - struct rt6_info *rt = (struct rt6_info *)dst; 2602 - path->path_cookie = rt6_get_cookie(rt); 2601 + path->path_cookie = rt6_get_cookie(dst_rt6_info(dst)); 2603 2602 path->u.rt6.rt6i_nfheader_len = nfheader_len; 2604 2603 } 2605 2604 }