@@ -36,8 +36,8 @@ static const struct fib_kuid_range fib_kuid_range_unset = {
36
36
37
37
bool fib_rule_matchall (const struct fib_rule * rule )
38
38
{
39
- if (rule -> iifindex || rule -> oifindex || rule -> mark || rule -> tun_id ||
40
- rule -> flags )
39
+ if (READ_ONCE ( rule -> iifindex ) || READ_ONCE ( rule -> oifindex ) ||
40
+ rule -> mark || rule -> tun_id || rule -> flags )
41
41
return false;
42
42
if (rule -> suppress_ifgroup != -1 || rule -> suppress_prefixlen != -1 )
43
43
return false;
@@ -259,12 +259,14 @@ static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
259
259
struct flowi * fl , int flags ,
260
260
struct fib_lookup_arg * arg )
261
261
{
262
- int ret = 0 ;
262
+ int iifindex , oifindex , ret = 0 ;
263
263
264
- if (rule -> iifindex && (rule -> iifindex != fl -> flowi_iif ))
264
+ iifindex = READ_ONCE (rule -> iifindex );
265
+ if (iifindex && (iifindex != fl -> flowi_iif ))
265
266
goto out ;
266
267
267
- if (rule -> oifindex && (rule -> oifindex != fl -> flowi_oif ))
268
+ oifindex = READ_ONCE (rule -> oifindex );
269
+ if (oifindex && (oifindex != fl -> flowi_oif ))
268
270
goto out ;
269
271
270
272
if ((rule -> mark ^ fl -> flowi_mark ) & rule -> mark_mask )
@@ -1036,14 +1038,14 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
1036
1038
if (rule -> iifname [0 ]) {
1037
1039
if (nla_put_string (skb , FRA_IIFNAME , rule -> iifname ))
1038
1040
goto nla_put_failure ;
1039
- if (rule -> iifindex == -1 )
1041
+ if (READ_ONCE ( rule -> iifindex ) == -1 )
1040
1042
frh -> flags |= FIB_RULE_IIF_DETACHED ;
1041
1043
}
1042
1044
1043
1045
if (rule -> oifname [0 ]) {
1044
1046
if (nla_put_string (skb , FRA_OIFNAME , rule -> oifname ))
1045
1047
goto nla_put_failure ;
1046
- if (rule -> oifindex == -1 )
1048
+ if (READ_ONCE ( rule -> oifindex ) == -1 )
1047
1049
frh -> flags |= FIB_RULE_OIF_DETACHED ;
1048
1050
}
1049
1051
@@ -1216,10 +1218,10 @@ static void attach_rules(struct list_head *rules, struct net_device *dev)
1216
1218
list_for_each_entry (rule , rules , list ) {
1217
1219
if (rule -> iifindex == -1 &&
1218
1220
strcmp (dev -> name , rule -> iifname ) == 0 )
1219
- rule -> iifindex = dev -> ifindex ;
1221
+ WRITE_ONCE ( rule -> iifindex , dev -> ifindex ) ;
1220
1222
if (rule -> oifindex == -1 &&
1221
1223
strcmp (dev -> name , rule -> oifname ) == 0 )
1222
- rule -> oifindex = dev -> ifindex ;
1224
+ WRITE_ONCE ( rule -> oifindex , dev -> ifindex ) ;
1223
1225
}
1224
1226
}
1225
1227
@@ -1229,9 +1231,9 @@ static void detach_rules(struct list_head *rules, struct net_device *dev)
1229
1231
1230
1232
list_for_each_entry (rule , rules , list ) {
1231
1233
if (rule -> iifindex == dev -> ifindex )
1232
- rule -> iifindex = -1 ;
1234
+ WRITE_ONCE ( rule -> iifindex , -1 ) ;
1233
1235
if (rule -> oifindex == dev -> ifindex )
1234
- rule -> oifindex = -1 ;
1236
+ WRITE_ONCE ( rule -> oifindex , -1 ) ;
1235
1237
}
1236
1238
}
1237
1239
0 commit comments