summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2019-04-16 17:36:04 -0400
committerDavid S. Miller <davem@davemloft.net>2019-04-18 02:10:46 -0400
commit0d16158149ab6b02fcd945b2f5a5cf31262a445b (patch)
tree74d7e7fa1629823cc6b123c04e00bcbaefe28632 /net
parentdb3fedee0cb7a0ea52450137d48b9e41be53ec14 (diff)
ipv6: Pass fib6_result to ip6_rt_get_dev_rcu and ip6_rt_copy_init
Now that all callers are update to have a fib6_result, pass it down to ip6_rt_get_dev_rcu, ip6_rt_copy_init, and ip6_rt_init_dst. In the process, change ort to f6i in ip6_rt_copy_init to make it clear it is a reference to a fib6_info. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/route.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9611b935eb7d..80a23da08f65 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -871,17 +871,18 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
871 */ 871 */
872 872
873/* called with rcu_lock held */ 873/* called with rcu_lock held */
874static struct net_device *ip6_rt_get_dev_rcu(struct fib6_info *rt) 874static struct net_device *ip6_rt_get_dev_rcu(const struct fib6_result *res)
875{ 875{
876 struct net_device *dev = rt->fib6_nh.fib_nh_dev; 876 struct net_device *dev = res->nh->fib_nh_dev;
877 const struct fib6_info *f6i = res->f6i;
877 878
878 if (rt->fib6_flags & (RTF_LOCAL | RTF_ANYCAST)) { 879 if (f6i->fib6_flags & (RTF_LOCAL | RTF_ANYCAST)) {
879 /* for copies of local routes, dst->dev needs to be the 880 /* for copies of local routes, dst->dev needs to be the
880 * device if it is a master device, the master device if 881 * device if it is a master device, the master device if
881 * device is enslaved, and the loopback as the default 882 * device is enslaved, and the loopback as the default
882 */ 883 */
883 if (netif_is_l3_slave(dev) && 884 if (netif_is_l3_slave(dev) &&
884 !rt6_need_strict(&rt->fib6_dst.addr)) 885 !rt6_need_strict(&f6i->fib6_dst.addr))
885 dev = l3mdev_master_dev_rcu(dev); 886 dev = l3mdev_master_dev_rcu(dev);
886 else if (!netif_is_l3_master(dev)) 887 else if (!netif_is_l3_master(dev))
887 dev = dev_net(dev)->loopback_dev; 888 dev = dev_net(dev)->loopback_dev;
@@ -949,8 +950,10 @@ static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct fib6_info *ort)
949 } 950 }
950} 951}
951 952
952static void ip6_rt_init_dst(struct rt6_info *rt, struct fib6_info *ort) 953static void ip6_rt_init_dst(struct rt6_info *rt, const struct fib6_result *res)
953{ 954{
955 struct fib6_info *ort = res->f6i;
956
954 if (ort->fib6_flags & RTF_REJECT) { 957 if (ort->fib6_flags & RTF_REJECT) {
955 ip6_rt_init_dst_reject(rt, ort); 958 ip6_rt_init_dst_reject(rt, ort);
956 return; 959 return;
@@ -967,8 +970,8 @@ static void ip6_rt_init_dst(struct rt6_info *rt, struct fib6_info *ort)
967 rt->dst.input = ip6_forward; 970 rt->dst.input = ip6_forward;
968 } 971 }
969 972
970 if (ort->fib6_nh.fib_nh_lws) { 973 if (res->nh->fib_nh_lws) {
971 rt->dst.lwtstate = lwtstate_get(ort->fib6_nh.fib_nh_lws); 974 rt->dst.lwtstate = lwtstate_get(res->nh->fib_nh_lws);
972 lwtunnel_set_redirect(&rt->dst); 975 lwtunnel_set_redirect(&rt->dst);
973 } 976 }
974 977
@@ -983,23 +986,25 @@ static void rt6_set_from(struct rt6_info *rt, struct fib6_info *from)
983 ip_dst_init_metrics(&rt->dst, from->fib6_metrics); 986 ip_dst_init_metrics(&rt->dst, from->fib6_metrics);
984} 987}
985 988
986/* Caller must already hold reference to @ort */ 989/* Caller must already hold reference to f6i in result */
987static void ip6_rt_copy_init(struct rt6_info *rt, struct fib6_info *ort) 990static void ip6_rt_copy_init(struct rt6_info *rt, const struct fib6_result *res)
988{ 991{
989 struct net_device *dev = fib6_info_nh_dev(ort); 992 const struct fib6_nh *nh = res->nh;
993 const struct net_device *dev = nh->fib_nh_dev;
994 struct fib6_info *f6i = res->f6i;
990 995
991 ip6_rt_init_dst(rt, ort); 996 ip6_rt_init_dst(rt, res);
992 997
993 rt->rt6i_dst = ort->fib6_dst; 998 rt->rt6i_dst = f6i->fib6_dst;
994 rt->rt6i_idev = dev ? in6_dev_get(dev) : NULL; 999 rt->rt6i_idev = dev ? in6_dev_get(dev) : NULL;
995 rt->rt6i_flags = ort->fib6_flags; 1000 rt->rt6i_flags = f6i->fib6_flags;
996 if (ort->fib6_nh.fib_nh_gw_family) { 1001 if (nh->fib_nh_gw_family) {
997 rt->rt6i_gateway = ort->fib6_nh.fib_nh_gw6; 1002 rt->rt6i_gateway = nh->fib_nh_gw6;
998 rt->rt6i_flags |= RTF_GATEWAY; 1003 rt->rt6i_flags |= RTF_GATEWAY;
999 } 1004 }
1000 rt6_set_from(rt, ort); 1005 rt6_set_from(rt, f6i);
1001#ifdef CONFIG_IPV6_SUBTREES 1006#ifdef CONFIG_IPV6_SUBTREES
1002 rt->rt6i_src = ort->fib6_src; 1007 rt->rt6i_src = f6i->fib6_src;
1003#endif 1008#endif
1004} 1009}
1005 1010
@@ -1055,7 +1060,7 @@ static struct rt6_info *ip6_create_rt_rcu(const struct fib6_result *res)
1055 goto fallback; 1060 goto fallback;
1056 } 1061 }
1057 1062
1058 ip6_rt_copy_init(nrt, f6i); 1063 ip6_rt_copy_init(nrt, res);
1059 return nrt; 1064 return nrt;
1060 1065
1061fallback: 1066fallback:
@@ -1192,14 +1197,14 @@ static struct rt6_info *ip6_rt_cache_alloc(const struct fib6_result *res,
1192 if (!fib6_info_hold_safe(f6i)) 1197 if (!fib6_info_hold_safe(f6i))
1193 return NULL; 1198 return NULL;
1194 1199
1195 dev = ip6_rt_get_dev_rcu(f6i); 1200 dev = ip6_rt_get_dev_rcu(res);
1196 rt = ip6_dst_alloc(dev_net(dev), dev, 0); 1201 rt = ip6_dst_alloc(dev_net(dev), dev, 0);
1197 if (!rt) { 1202 if (!rt) {
1198 fib6_info_release(f6i); 1203 fib6_info_release(f6i);
1199 return NULL; 1204 return NULL;
1200 } 1205 }
1201 1206
1202 ip6_rt_copy_init(rt, res->f6i); 1207 ip6_rt_copy_init(rt, res);
1203 rt->rt6i_flags |= RTF_CACHE; 1208 rt->rt6i_flags |= RTF_CACHE;
1204 rt->dst.flags |= DST_HOST; 1209 rt->dst.flags |= DST_HOST;
1205 rt->rt6i_dst.addr = *daddr; 1210 rt->rt6i_dst.addr = *daddr;
@@ -1231,14 +1236,14 @@ static struct rt6_info *ip6_rt_pcpu_alloc(const struct fib6_result *res)
1231 return NULL; 1236 return NULL;
1232 1237
1233 rcu_read_lock(); 1238 rcu_read_lock();
1234 dev = ip6_rt_get_dev_rcu(f6i); 1239 dev = ip6_rt_get_dev_rcu(res);
1235 pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags); 1240 pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags);
1236 rcu_read_unlock(); 1241 rcu_read_unlock();
1237 if (!pcpu_rt) { 1242 if (!pcpu_rt) {
1238 fib6_info_release(f6i); 1243 fib6_info_release(f6i);
1239 return NULL; 1244 return NULL;
1240 } 1245 }
1241 ip6_rt_copy_init(pcpu_rt, f6i); 1246 ip6_rt_copy_init(pcpu_rt, res);
1242 pcpu_rt->rt6i_flags |= RTF_PCPU; 1247 pcpu_rt->rt6i_flags |= RTF_PCPU;
1243 return pcpu_rt; 1248 return pcpu_rt;
1244} 1249}