Skip to content

Commit 2860583

Browse files
committed
ipv4: Kill rt->fi
It's not really needed. We only grabbed a reference to the fib_info for the sake of fib_info local metrics. However, fib_info objects are freed using RCU, as are therefore their private metrics (if any). We would have triggered a route cache flush if we eliminated a reference to a fib_info object in the routing tables. Therefore, any existing cached routes will first check and see that they have been invalidated before an errant reference to these metric values would occur. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9917e1e commit 2860583

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

include/net/route.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct rtable {
5656

5757
/* Miscellaneous cached information */
5858
u32 rt_pmtu;
59-
struct fib_info *fi; /* for client ref to shared metrics */
6059
};
6160

6261
static inline bool rt_is_input_route(const struct rtable *rt)

net/ipv4/route.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static int ip_rt_min_advmss __read_mostly = 256;
141141
static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie);
142142
static unsigned int ipv4_default_advmss(const struct dst_entry *dst);
143143
static unsigned int ipv4_mtu(const struct dst_entry *dst);
144-
static void ipv4_dst_destroy(struct dst_entry *dst);
145144
static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst);
146145
static void ipv4_link_failure(struct sk_buff *skb);
147146
static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
@@ -171,7 +170,6 @@ static struct dst_ops ipv4_dst_ops = {
171170
.default_advmss = ipv4_default_advmss,
172171
.mtu = ipv4_mtu,
173172
.cow_metrics = ipv4_cow_metrics,
174-
.destroy = ipv4_dst_destroy,
175173
.ifdown = ipv4_dst_ifdown,
176174
.negative_advice = ipv4_negative_advice,
177175
.link_failure = ipv4_link_failure,
@@ -1034,17 +1032,6 @@ static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie)
10341032
return dst;
10351033
}
10361034

1037-
static void ipv4_dst_destroy(struct dst_entry *dst)
1038-
{
1039-
struct rtable *rt = (struct rtable *) dst;
1040-
1041-
if (rt->fi) {
1042-
fib_info_put(rt->fi);
1043-
rt->fi = NULL;
1044-
}
1045-
}
1046-
1047-
10481035
static void ipv4_link_failure(struct sk_buff *skb)
10491036
{
10501037
struct rtable *rt;
@@ -1158,15 +1145,6 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
11581145
return mtu;
11591146
}
11601147

1161-
static void rt_init_metrics(struct rtable *rt, struct fib_info *fi)
1162-
{
1163-
if (fi->fib_metrics != (u32 *) dst_default_metrics) {
1164-
rt->fi = fi;
1165-
atomic_inc(&fi->fib_clntref);
1166-
}
1167-
dst_init_metrics(&rt->dst, fi->fib_metrics, true);
1168-
}
1169-
11701148
static struct fib_nh_exception *find_exception(struct fib_nh *nh, __be32 daddr)
11711149
{
11721150
struct fnhe_hash_bucket *hash = nh->nh_exceptions;
@@ -1261,7 +1239,7 @@ static void rt_set_nexthop(struct rtable *rt, __be32 daddr,
12611239
rt->rt_gateway = nh->nh_gw;
12621240
if (unlikely(fnhe))
12631241
rt_bind_exception(rt, fnhe, daddr);
1264-
rt_init_metrics(rt, fi);
1242+
dst_init_metrics(&rt->dst, fi->fib_metrics, true);
12651243
#ifdef CONFIG_IP_ROUTE_CLASSID
12661244
rt->dst.tclassid = nh->nh_tclassid;
12671245
#endif
@@ -1334,7 +1312,6 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
13341312
rth->rt_iif = dev->ifindex;
13351313
rth->rt_pmtu = 0;
13361314
rth->rt_gateway = 0;
1337-
rth->fi = NULL;
13381315
if (our) {
13391316
rth->dst.input= ip_local_deliver;
13401317
rth->rt_flags |= RTCF_LOCAL;
@@ -1464,7 +1441,6 @@ static int __mkroute_input(struct sk_buff *skb,
14641441
rth->rt_iif = in_dev->dev->ifindex;
14651442
rth->rt_pmtu = 0;
14661443
rth->rt_gateway = 0;
1467-
rth->fi = NULL;
14681444

14691445
rth->dst.input = ip_forward;
14701446
rth->dst.output = ip_output;
@@ -1642,7 +1618,6 @@ out: return err;
16421618
rth->rt_iif = dev->ifindex;
16431619
rth->rt_pmtu = 0;
16441620
rth->rt_gateway = 0;
1645-
rth->fi = NULL;
16461621
if (res.type == RTN_UNREACHABLE) {
16471622
rth->dst.input= ip_error;
16481623
rth->dst.error= -err;
@@ -1807,7 +1782,6 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
18071782
rth->rt_iif = orig_oif ? : dev_out->ifindex;
18081783
rth->rt_pmtu = 0;
18091784
rth->rt_gateway = 0;
1810-
rth->fi = NULL;
18111785

18121786
RT_CACHE_STAT_INC(out_slow_tot);
18131787

@@ -2052,7 +2026,6 @@ static u32 *ipv4_rt_blackhole_cow_metrics(struct dst_entry *dst,
20522026
static struct dst_ops ipv4_dst_blackhole_ops = {
20532027
.family = AF_INET,
20542028
.protocol = cpu_to_be16(ETH_P_IP),
2055-
.destroy = ipv4_dst_destroy,
20562029
.check = ipv4_blackhole_dst_check,
20572030
.mtu = ipv4_blackhole_mtu,
20582031
.default_advmss = ipv4_default_advmss,
@@ -2087,9 +2060,6 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
20872060
rt->rt_flags = ort->rt_flags;
20882061
rt->rt_type = ort->rt_type;
20892062
rt->rt_gateway = ort->rt_gateway;
2090-
rt->fi = ort->fi;
2091-
if (rt->fi)
2092-
atomic_inc(&rt->fi->fib_clntref);
20932063

20942064
dst_free(new);
20952065
}

0 commit comments

Comments
 (0)