Skip to content

Commit b42664f

Browse files
NicolasDichteldavem330
authored andcommitted
netns: move net->ipv4.rt_genid to net->rt_genid
This commit prepares the use of rt_genid by both IPv4 and IPv6. Initialization is left in IPv4 part. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2885da7 commit b42664f

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎include/net/net_namespace.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct net {
102102
#endif
103103
struct netns_ipvs *ipvs;
104104
struct sock *diag_nlsk;
105+
atomic_t rt_genid;
105106
};
106107

107108

@@ -300,5 +301,14 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
300301
}
301302
#endif
302303

304+
static inline int rt_genid(struct net *net)
305+
{
306+
return atomic_read(&net->rt_genid);
307+
}
308+
309+
static inline void rt_genid_bump(struct net *net)
310+
{
311+
atomic_inc(&net->rt_genid);
312+
}
303313

304314
#endif /* __NET_NET_NAMESPACE_H */

‎include/net/netns/ipv4.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ struct netns_ipv4 {
6565
unsigned int sysctl_ping_group_range[2];
6666
long sysctl_tcp_mem[3];
6767

68-
atomic_t rt_genid;
6968
atomic_t dev_addr_genid;
7069

7170
#ifdef CONFIG_IP_MROUTE

‎net/ipv4/route.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,6 @@ EXPORT_SYMBOL(ip_tos2prio);
202202
static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
203203
#define RT_CACHE_STAT_INC(field) __this_cpu_inc(rt_cache_stat.field)
204204

205-
static inline int rt_genid(struct net *net)
206-
{
207-
return atomic_read(&net->ipv4.rt_genid);
208-
}
209-
210205
#ifdef CONFIG_PROC_FS
211206
static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
212207
{
@@ -449,7 +444,7 @@ static inline bool rt_is_expired(const struct rtable *rth)
449444

450445
void rt_cache_flush(struct net *net)
451446
{
452-
atomic_inc(&net->ipv4.rt_genid);
447+
rt_genid_bump(net);
453448
}
454449

455450
static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
@@ -2506,7 +2501,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
25062501

25072502
static __net_init int rt_genid_init(struct net *net)
25082503
{
2509-
atomic_set(&net->ipv4.rt_genid, 0);
2504+
atomic_set(&net->rt_genid, 0);
25102505
get_random_bytes(&net->ipv4.dev_addr_genid,
25112506
sizeof(net->ipv4.dev_addr_genid));
25122507
return 0;

0 commit comments

Comments
 (0)