@@ -142,7 +142,7 @@ static struct mr_table *ipmr_mr_table_iter(struct net *net,
142
142
return ret ;
143
143
}
144
144
145
- static struct mr_table * ipmr_get_table (struct net * net , u32 id )
145
+ static struct mr_table * __ipmr_get_table (struct net * net , u32 id )
146
146
{
147
147
struct mr_table * mrt ;
148
148
@@ -153,6 +153,16 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)
153
153
return NULL ;
154
154
}
155
155
156
+ static struct mr_table * ipmr_get_table (struct net * net , u32 id )
157
+ {
158
+ struct mr_table * mrt ;
159
+
160
+ rcu_read_lock ();
161
+ mrt = __ipmr_get_table (net , id );
162
+ rcu_read_unlock ();
163
+ return mrt ;
164
+ }
165
+
156
166
static int ipmr_fib_lookup (struct net * net , struct flowi4 * flp4 ,
157
167
struct mr_table * * mrt )
158
168
{
@@ -194,7 +204,7 @@ static int ipmr_rule_action(struct fib_rule *rule, struct flowi *flp,
194
204
195
205
arg -> table = fib_rule_get_table (rule , arg );
196
206
197
- mrt = ipmr_get_table (rule -> fr_net , arg -> table );
207
+ mrt = __ipmr_get_table (rule -> fr_net , arg -> table );
198
208
if (!mrt )
199
209
return - EAGAIN ;
200
210
res -> mrt = mrt ;
@@ -325,6 +335,8 @@ static struct mr_table *ipmr_get_table(struct net *net, u32 id)
325
335
return net -> ipv4 .mrt ;
326
336
}
327
337
338
+ #define __ipmr_get_table ipmr_get_table
339
+
328
340
static int ipmr_fib_lookup (struct net * net , struct flowi4 * flp4 ,
329
341
struct mr_table * * mrt )
330
342
{
@@ -413,7 +425,7 @@ static struct mr_table *ipmr_new_table(struct net *net, u32 id)
413
425
if (id != RT_TABLE_DEFAULT && id >= 1000000000 )
414
426
return ERR_PTR (- EINVAL );
415
427
416
- mrt = ipmr_get_table (net , id );
428
+ mrt = __ipmr_get_table (net , id );
417
429
if (mrt )
418
430
return mrt ;
419
431
@@ -1388,7 +1400,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval,
1388
1400
goto out_unlock ;
1389
1401
}
1390
1402
1391
- mrt = ipmr_get_table (net , raw_sk (sk )-> ipmr_table ? : RT_TABLE_DEFAULT );
1403
+ mrt = __ipmr_get_table (net , raw_sk (sk )-> ipmr_table ? : RT_TABLE_DEFAULT );
1392
1404
if (!mrt ) {
1393
1405
ret = - ENOENT ;
1394
1406
goto out_unlock ;
@@ -2276,11 +2288,13 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb,
2276
2288
struct mr_table * mrt ;
2277
2289
int err ;
2278
2290
2279
- mrt = ipmr_get_table (net , RT_TABLE_DEFAULT );
2280
- if (!mrt )
2291
+ rcu_read_lock ();
2292
+ mrt = __ipmr_get_table (net , RT_TABLE_DEFAULT );
2293
+ if (!mrt ) {
2294
+ rcu_read_unlock ();
2281
2295
return - ENOENT ;
2296
+ }
2282
2297
2283
- rcu_read_lock ();
2284
2298
cache = ipmr_cache_find (mrt , saddr , daddr );
2285
2299
if (!cache && skb -> dev ) {
2286
2300
int vif = ipmr_find_vif (mrt , skb -> dev );
@@ -2564,7 +2578,7 @@ static int ipmr_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
2564
2578
grp = nla_get_in_addr_default (tb [RTA_DST ], 0 );
2565
2579
tableid = nla_get_u32_default (tb [RTA_TABLE ], 0 );
2566
2580
2567
- mrt = ipmr_get_table (net , tableid ? tableid : RT_TABLE_DEFAULT );
2581
+ mrt = __ipmr_get_table (net , tableid ? tableid : RT_TABLE_DEFAULT );
2568
2582
if (!mrt ) {
2569
2583
err = - ENOENT ;
2570
2584
goto errout_free ;
@@ -2618,7 +2632,7 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
2618
2632
if (filter .table_id ) {
2619
2633
struct mr_table * mrt ;
2620
2634
2621
- mrt = ipmr_get_table (sock_net (skb -> sk ), filter .table_id );
2635
+ mrt = __ipmr_get_table (sock_net (skb -> sk ), filter .table_id );
2622
2636
if (!mrt ) {
2623
2637
if (rtnl_msg_family (cb -> nlh ) != RTNL_FAMILY_IPMR )
2624
2638
return skb -> len ;
@@ -2726,7 +2740,7 @@ static int rtm_to_ipmr_mfcc(struct net *net, struct nlmsghdr *nlh,
2726
2740
break ;
2727
2741
}
2728
2742
}
2729
- mrt = ipmr_get_table (net , tblid );
2743
+ mrt = __ipmr_get_table (net , tblid );
2730
2744
if (!mrt ) {
2731
2745
ret = - ENOENT ;
2732
2746
goto out ;
@@ -2934,13 +2948,15 @@ static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)
2934
2948
struct net * net = seq_file_net (seq );
2935
2949
struct mr_table * mrt ;
2936
2950
2937
- mrt = ipmr_get_table (net , RT_TABLE_DEFAULT );
2938
- if (!mrt )
2951
+ rcu_read_lock ();
2952
+ mrt = __ipmr_get_table (net , RT_TABLE_DEFAULT );
2953
+ if (!mrt ) {
2954
+ rcu_read_unlock ();
2939
2955
return ERR_PTR (- ENOENT );
2956
+ }
2940
2957
2941
2958
iter -> mrt = mrt ;
2942
2959
2943
- rcu_read_lock ();
2944
2960
return mr_vif_seq_start (seq , pos );
2945
2961
}
2946
2962
0 commit comments