@@ -188,24 +188,6 @@ static void nft_netdev_unregister_hooks(struct net *net,
188
188
nf_unregister_net_hook (net , & hook -> ops );
189
189
}
190
190
191
- static int nft_register_basechain_hooks (struct net * net , int family ,
192
- struct nft_base_chain * basechain )
193
- {
194
- if (family == NFPROTO_NETDEV )
195
- return nft_netdev_register_hooks (net , & basechain -> hook_list );
196
-
197
- return nf_register_net_hook (net , & basechain -> ops );
198
- }
199
-
200
- static void nft_unregister_basechain_hooks (struct net * net , int family ,
201
- struct nft_base_chain * basechain )
202
- {
203
- if (family == NFPROTO_NETDEV )
204
- nft_netdev_unregister_hooks (net , & basechain -> hook_list );
205
- else
206
- nf_unregister_net_hook (net , & basechain -> ops );
207
- }
208
-
209
191
static int nf_tables_register_hook (struct net * net ,
210
192
const struct nft_table * table ,
211
193
struct nft_chain * chain )
@@ -223,7 +205,10 @@ static int nf_tables_register_hook(struct net *net,
223
205
if (basechain -> type -> ops_register )
224
206
return basechain -> type -> ops_register (net , ops );
225
207
226
- return nft_register_basechain_hooks (net , table -> family , basechain );
208
+ if (table -> family == NFPROTO_NETDEV )
209
+ return nft_netdev_register_hooks (net , & basechain -> hook_list );
210
+
211
+ return nf_register_net_hook (net , & basechain -> ops );
227
212
}
228
213
229
214
static void nf_tables_unregister_hook (struct net * net ,
@@ -242,7 +227,10 @@ static void nf_tables_unregister_hook(struct net *net,
242
227
if (basechain -> type -> ops_unregister )
243
228
return basechain -> type -> ops_unregister (net , ops );
244
229
245
- nft_unregister_basechain_hooks (net , table -> family , basechain );
230
+ if (table -> family == NFPROTO_NETDEV )
231
+ nft_netdev_unregister_hooks (net , & basechain -> hook_list );
232
+ else
233
+ nf_unregister_net_hook (net , & basechain -> ops );
246
234
}
247
235
248
236
static int nft_trans_table_add (struct nft_ctx * ctx , int msg_type )
@@ -832,8 +820,7 @@ static void nft_table_disable(struct net *net, struct nft_table *table, u32 cnt)
832
820
if (cnt && i ++ == cnt )
833
821
break ;
834
822
835
- nft_unregister_basechain_hooks (net , table -> family ,
836
- nft_base_chain (chain ));
823
+ nf_tables_unregister_hook (net , table , chain );
837
824
}
838
825
}
839
826
@@ -848,8 +835,7 @@ static int nf_tables_table_enable(struct net *net, struct nft_table *table)
848
835
if (!nft_is_base_chain (chain ))
849
836
continue ;
850
837
851
- err = nft_register_basechain_hooks (net , table -> family ,
852
- nft_base_chain (chain ));
838
+ err = nf_tables_register_hook (net , table , chain );
853
839
if (err < 0 )
854
840
goto err_register_hooks ;
855
841
@@ -894,11 +880,12 @@ static int nf_tables_updtable(struct nft_ctx *ctx)
894
880
nft_trans_table_enable (trans ) = false;
895
881
} else if (!(flags & NFT_TABLE_F_DORMANT ) &&
896
882
ctx -> table -> flags & NFT_TABLE_F_DORMANT ) {
883
+ ctx -> table -> flags &= ~NFT_TABLE_F_DORMANT ;
897
884
ret = nf_tables_table_enable (ctx -> net , ctx -> table );
898
- if (ret >= 0 ) {
899
- ctx -> table -> flags &= ~NFT_TABLE_F_DORMANT ;
885
+ if (ret >= 0 )
900
886
nft_trans_table_enable (trans ) = true;
901
- }
887
+ else
888
+ ctx -> table -> flags |= NFT_TABLE_F_DORMANT ;
902
889
}
903
890
if (ret < 0 )
904
891
goto err ;
0 commit comments