Skip to content

Commit ae90d86

Browse files
dsaherndavem330
authored andcommitted
net/ipv6: Move support functions up in route.c
Code move only. Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent afb1d4b commit ae90d86

File tree

1 file changed

+59
-60
lines changed

1 file changed

+59
-60
lines changed

net/ipv6/route.c

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ enum rt6_nud_state {
7878
RT6_NUD_SUCCEED = 1
7979
};
8080

81-
static void ip6_rt_copy_init(struct rt6_info *rt, struct rt6_info *ort);
8281
static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie);
8382
static unsigned int ip6_default_advmss(const struct dst_entry *dst);
8483
static unsigned int ip6_mtu(const struct dst_entry *dst);
@@ -879,6 +878,65 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
879878
}
880879
#endif
881880

881+
/*
882+
* Misc support functions
883+
*/
884+
885+
/* called with rcu_lock held */
886+
static struct net_device *ip6_rt_get_dev_rcu(struct rt6_info *rt)
887+
{
888+
struct net_device *dev = rt->dst.dev;
889+
890+
if (rt->rt6i_flags & (RTF_LOCAL | RTF_ANYCAST)) {
891+
/* for copies of local routes, dst->dev needs to be the
892+
* device if it is a master device, the master device if
893+
* device is enslaved, and the loopback as the default
894+
*/
895+
if (netif_is_l3_slave(dev) &&
896+
!rt6_need_strict(&rt->rt6i_dst.addr))
897+
dev = l3mdev_master_dev_rcu(dev);
898+
else if (!netif_is_l3_master(dev))
899+
dev = dev_net(dev)->loopback_dev;
900+
/* last case is netif_is_l3_master(dev) is true in which
901+
* case we want dev returned to be dev
902+
*/
903+
}
904+
905+
return dev;
906+
}
907+
908+
static void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
909+
{
910+
BUG_ON(from->from);
911+
912+
rt->rt6i_flags &= ~RTF_EXPIRES;
913+
dst_hold(&from->dst);
914+
rt->from = from;
915+
dst_init_metrics(&rt->dst, dst_metrics_ptr(&from->dst), true);
916+
}
917+
918+
static void ip6_rt_copy_init(struct rt6_info *rt, struct rt6_info *ort)
919+
{
920+
rt->dst.input = ort->dst.input;
921+
rt->dst.output = ort->dst.output;
922+
rt->rt6i_dst = ort->rt6i_dst;
923+
rt->dst.error = ort->dst.error;
924+
rt->rt6i_idev = ort->rt6i_idev;
925+
if (rt->rt6i_idev)
926+
in6_dev_hold(rt->rt6i_idev);
927+
rt->dst.lastuse = jiffies;
928+
rt->rt6i_gateway = ort->rt6i_gateway;
929+
rt->rt6i_flags = ort->rt6i_flags;
930+
rt6_set_from(rt, ort);
931+
rt->rt6i_metric = ort->rt6i_metric;
932+
#ifdef CONFIG_IPV6_SUBTREES
933+
rt->rt6i_src = ort->rt6i_src;
934+
#endif
935+
rt->rt6i_prefsrc = ort->rt6i_prefsrc;
936+
rt->rt6i_table = ort->rt6i_table;
937+
rt->dst.lwtstate = lwtstate_get(ort->dst.lwtstate);
938+
}
939+
882940
static struct fib6_node* fib6_backtrack(struct fib6_node *fn,
883941
struct in6_addr *saddr)
884942
{
@@ -1024,29 +1082,6 @@ int ip6_ins_rt(struct net *net, struct rt6_info *rt)
10241082
return __ip6_ins_rt(rt, &info, &mxc, NULL);
10251083
}
10261084

1027-
/* called with rcu_lock held */
1028-
static struct net_device *ip6_rt_get_dev_rcu(struct rt6_info *rt)
1029-
{
1030-
struct net_device *dev = rt->dst.dev;
1031-
1032-
if (rt->rt6i_flags & (RTF_LOCAL | RTF_ANYCAST)) {
1033-
/* for copies of local routes, dst->dev needs to be the
1034-
* device if it is a master device, the master device if
1035-
* device is enslaved, and the loopback as the default
1036-
*/
1037-
if (netif_is_l3_slave(dev) &&
1038-
!rt6_need_strict(&rt->rt6i_dst.addr))
1039-
dev = l3mdev_master_dev_rcu(dev);
1040-
else if (!netif_is_l3_master(dev))
1041-
dev = dev_net(dev)->loopback_dev;
1042-
/* last case is netif_is_l3_master(dev) is true in which
1043-
* case we want dev returned to be dev
1044-
*/
1045-
}
1046-
1047-
return dev;
1048-
}
1049-
10501085
static struct rt6_info *ip6_rt_cache_alloc(struct rt6_info *ort,
10511086
const struct in6_addr *daddr,
10521087
const struct in6_addr *saddr)
@@ -3270,42 +3305,6 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
32703305
neigh_release(neigh);
32713306
}
32723307

3273-
/*
3274-
* Misc support functions
3275-
*/
3276-
3277-
static void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
3278-
{
3279-
BUG_ON(from->from);
3280-
3281-
rt->rt6i_flags &= ~RTF_EXPIRES;
3282-
dst_hold(&from->dst);
3283-
rt->from = from;
3284-
dst_init_metrics(&rt->dst, dst_metrics_ptr(&from->dst), true);
3285-
}
3286-
3287-
static void ip6_rt_copy_init(struct rt6_info *rt, struct rt6_info *ort)
3288-
{
3289-
rt->dst.input = ort->dst.input;
3290-
rt->dst.output = ort->dst.output;
3291-
rt->rt6i_dst = ort->rt6i_dst;
3292-
rt->dst.error = ort->dst.error;
3293-
rt->rt6i_idev = ort->rt6i_idev;
3294-
if (rt->rt6i_idev)
3295-
in6_dev_hold(rt->rt6i_idev);
3296-
rt->dst.lastuse = jiffies;
3297-
rt->rt6i_gateway = ort->rt6i_gateway;
3298-
rt->rt6i_flags = ort->rt6i_flags;
3299-
rt6_set_from(rt, ort);
3300-
rt->rt6i_metric = ort->rt6i_metric;
3301-
#ifdef CONFIG_IPV6_SUBTREES
3302-
rt->rt6i_src = ort->rt6i_src;
3303-
#endif
3304-
rt->rt6i_prefsrc = ort->rt6i_prefsrc;
3305-
rt->rt6i_table = ort->rt6i_table;
3306-
rt->dst.lwtstate = lwtstate_get(ort->dst.lwtstate);
3307-
}
3308-
33093308
#ifdef CONFIG_IPV6_ROUTE_INFO
33103309
static struct rt6_info *rt6_get_route_info(struct net *net,
33113310
const struct in6_addr *prefix, int prefixlen,

0 commit comments

Comments
 (0)