File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -195,23 +195,29 @@ static const struct nf_hook_ops ila_nf_hook_ops[] = {
195
195
},
196
196
};
197
197
198
+ static DEFINE_MUTEX (ila_mutex );
199
+
198
200
static int ila_add_mapping (struct net * net , struct ila_xlat_params * xp )
199
201
{
200
202
struct ila_net * ilan = net_generic (net , ila_net_id );
201
203
struct ila_map * ila , * head ;
202
204
spinlock_t * lock = ila_get_lock (ilan , xp -> ip .locator_match );
203
205
int err = 0 , order ;
204
206
205
- if (!ilan -> xlat .hooks_registered ) {
207
+ if (!READ_ONCE ( ilan -> xlat .hooks_registered ) ) {
206
208
/* We defer registering net hooks in the namespace until the
207
209
* first mapping is added.
208
210
*/
209
- err = nf_register_net_hooks (net , ila_nf_hook_ops ,
210
- ARRAY_SIZE (ila_nf_hook_ops ));
211
+ mutex_lock (& ila_mutex );
212
+ if (!ilan -> xlat .hooks_registered ) {
213
+ err = nf_register_net_hooks (net , ila_nf_hook_ops ,
214
+ ARRAY_SIZE (ila_nf_hook_ops ));
215
+ if (!err )
216
+ WRITE_ONCE (ilan -> xlat .hooks_registered , true);
217
+ }
218
+ mutex_unlock (& ila_mutex );
211
219
if (err )
212
220
return err ;
213
-
214
- ilan -> xlat .hooks_registered = true;
215
221
}
216
222
217
223
ila = kzalloc (sizeof (* ila ), GFP_KERNEL );
You can’t perform that action at this time.
0 commit comments