Skip to content

Commit 3b6761d

Browse files
dsaherndavem330
authored andcommitted
net/ipv6: Move dst flags to booleans in fib entries
Continuing to wean FIB paths off of dst_entry, use a bool to hold requests for certain dst settings. Add a helper to convert the flags to DST flags when a FIB entry is converted to a dst_entry. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dec9b0e commit 3b6761d

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

include/net/ip6_fib.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ struct rt6_info {
177177
u8 fib6_type;
178178
u8 exception_bucket_flushed:1,
179179
should_flush:1,
180-
unused:6;
180+
dst_nocount:1,
181+
dst_nopolicy:1,
182+
dst_host:1,
183+
unused:3;
181184

182185
unsigned long expires;
183186
struct dst_metrics *fib6_metrics;

net/ipv6/addrconf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
10461046

10471047
if (net->ipv6.devconf_all->disable_policy ||
10481048
idev->cnf.disable_policy)
1049-
rt->dst.flags |= DST_NOPOLICY;
1049+
rt->dst_nopolicy = true;
10501050

10511051
neigh_parms_data_state_setall(idev->nd_parms);
10521052

@@ -5981,7 +5981,7 @@ void addrconf_disable_policy_idev(struct inet6_dev *idev, int val)
59815981
int cpu;
59825982

59835983
rcu_read_lock();
5984-
addrconf_set_nopolicy(ifa->rt, val);
5984+
ifa->rt->dst_nopolicy = val ? true : false;
59855985
if (rt->rt6i_pcpu) {
59865986
for_each_possible_cpu(cpu) {
59875987
struct rt6_info **rtp;

net/ipv6/route.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,20 @@ static int ip6_rt_type_to_error(u8 fib6_type)
937937
return fib6_prop[fib6_type];
938938
}
939939

940+
static unsigned short fib6_info_dst_flags(struct rt6_info *rt)
941+
{
942+
unsigned short flags = 0;
943+
944+
if (rt->dst_nocount)
945+
flags |= DST_NOCOUNT;
946+
if (rt->dst_nopolicy)
947+
flags |= DST_NOPOLICY;
948+
if (rt->dst_host)
949+
flags |= DST_HOST;
950+
951+
return flags;
952+
}
953+
940954
static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct rt6_info *ort)
941955
{
942956
rt->dst.error = ip6_rt_type_to_error(ort->fib6_type);
@@ -961,6 +975,8 @@ static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct rt6_info *ort)
961975

962976
static void ip6_rt_init_dst(struct rt6_info *rt, struct rt6_info *ort)
963977
{
978+
rt->dst.flags |= fib6_info_dst_flags(ort);
979+
964980
if (ort->rt6i_flags & RTF_REJECT) {
965981
ip6_rt_init_dst_reject(rt, ort);
966982
return;
@@ -970,7 +986,6 @@ static void ip6_rt_init_dst(struct rt6_info *rt, struct rt6_info *ort)
970986
rt->dst.output = ip6_output;
971987

972988
if (ort->fib6_type == RTN_LOCAL) {
973-
rt->dst.flags |= DST_HOST;
974989
rt->dst.input = ip6_input;
975990
} else if (ipv6_addr_type(&ort->rt6i_dst.addr) & IPV6_ADDR_MULTICAST) {
976991
rt->dst.input = ip6_mc_input;
@@ -1058,10 +1073,11 @@ static bool ip6_hold_safe(struct net *net, struct rt6_info **prt,
10581073
/* called with rcu_lock held */
10591074
static struct rt6_info *ip6_create_rt_rcu(struct rt6_info *rt)
10601075
{
1076+
unsigned short flags = fib6_info_dst_flags(rt);
10611077
struct net_device *dev = rt->fib6_nh.nh_dev;
10621078
struct rt6_info *nrt;
10631079

1064-
nrt = __ip6_dst_alloc(dev_net(dev), dev, 0);
1080+
nrt = __ip6_dst_alloc(dev_net(dev), dev, flags);
10651081
if (nrt)
10661082
ip6_rt_copy_init(nrt, rt);
10671083

@@ -1229,12 +1245,13 @@ static struct rt6_info *ip6_rt_cache_alloc(struct rt6_info *ort,
12291245

12301246
static struct rt6_info *ip6_rt_pcpu_alloc(struct rt6_info *rt)
12311247
{
1248+
unsigned short flags = fib6_info_dst_flags(rt);
12321249
struct net_device *dev;
12331250
struct rt6_info *pcpu_rt;
12341251

12351252
rcu_read_lock();
12361253
dev = ip6_rt_get_dev_rcu(rt);
1237-
pcpu_rt = __ip6_dst_alloc(dev_net(dev), dev, rt->dst.flags);
1254+
pcpu_rt = __ip6_dst_alloc(dev_net(dev), dev, flags);
12381255
rcu_read_unlock();
12391256
if (!pcpu_rt)
12401257
return NULL;
@@ -2965,7 +2982,7 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,
29652982
ipv6_addr_prefix(&rt->rt6i_dst.addr, &cfg->fc_dst, cfg->fc_dst_len);
29662983
rt->rt6i_dst.plen = cfg->fc_dst_len;
29672984
if (rt->rt6i_dst.plen == 128)
2968-
rt->dst.flags |= DST_HOST;
2985+
rt->dst_host = true;
29692986

29702987
#ifdef CONFIG_IPV6_SUBTREES
29712988
ipv6_addr_prefix(&rt->rt6i_src.addr, &cfg->fc_src, cfg->fc_src_len);
@@ -3626,10 +3643,12 @@ struct rt6_info *addrconf_dst_alloc(struct net *net,
36263643
if (!rt)
36273644
return ERR_PTR(-ENOMEM);
36283645

3646+
rt->dst_nocount = true;
3647+
36293648
in6_dev_hold(idev);
36303649
rt->rt6i_idev = idev;
36313650

3632-
rt->dst.flags |= DST_HOST;
3651+
rt->dst_host = true;
36333652
rt->rt6i_protocol = RTPROT_KERNEL;
36343653
rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
36353654
if (anycast) {

0 commit comments

Comments
 (0)