@@ -1401,6 +1401,10 @@ static int nf_tables_deltable(struct sk_buff *skb, const struct nfnl_info *info,
1401
1401
}
1402
1402
1403
1403
if (IS_ERR (table )) {
1404
+ if (PTR_ERR (table ) == - ENOENT &&
1405
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYTABLE )
1406
+ return 0 ;
1407
+
1404
1408
NL_SET_BAD_ATTR (extack , attr );
1405
1409
return PTR_ERR (table );
1406
1410
}
@@ -2639,6 +2643,10 @@ static int nf_tables_delchain(struct sk_buff *skb, const struct nfnl_info *info,
2639
2643
chain = nft_chain_lookup (net , table , attr , genmask );
2640
2644
}
2641
2645
if (IS_ERR (chain )) {
2646
+ if (PTR_ERR (chain ) == - ENOENT &&
2647
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYCHAIN )
2648
+ return 0 ;
2649
+
2642
2650
NL_SET_BAD_ATTR (extack , attr );
2643
2651
return PTR_ERR (chain );
2644
2652
}
@@ -3716,6 +3724,10 @@ static int nf_tables_delrule(struct sk_buff *skb, const struct nfnl_info *info,
3716
3724
chain = nft_chain_lookup (net , table , nla [NFTA_RULE_CHAIN ],
3717
3725
genmask );
3718
3726
if (IS_ERR (chain )) {
3727
+ if (PTR_ERR (rule ) == - ENOENT &&
3728
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYRULE )
3729
+ return 0 ;
3730
+
3719
3731
NL_SET_BAD_ATTR (extack , nla [NFTA_RULE_CHAIN ]);
3720
3732
return PTR_ERR (chain );
3721
3733
}
@@ -3729,6 +3741,10 @@ static int nf_tables_delrule(struct sk_buff *skb, const struct nfnl_info *info,
3729
3741
if (nla [NFTA_RULE_HANDLE ]) {
3730
3742
rule = nft_rule_lookup (chain , nla [NFTA_RULE_HANDLE ]);
3731
3743
if (IS_ERR (rule )) {
3744
+ if (PTR_ERR (rule ) == - ENOENT &&
3745
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYRULE )
3746
+ return 0 ;
3747
+
3732
3748
NL_SET_BAD_ATTR (extack , nla [NFTA_RULE_HANDLE ]);
3733
3749
return PTR_ERR (rule );
3734
3750
}
@@ -4808,6 +4824,10 @@ static int nf_tables_delset(struct sk_buff *skb, const struct nfnl_info *info,
4808
4824
}
4809
4825
4810
4826
if (IS_ERR (set )) {
4827
+ if (PTR_ERR (set ) == - ENOENT &&
4828
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYSET )
4829
+ return 0 ;
4830
+
4811
4831
NL_SET_BAD_ATTR (extack , attr );
4812
4832
return PTR_ERR (set );
4813
4833
}
@@ -6690,6 +6710,10 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
6690
6710
6691
6711
nla_for_each_nested (attr , nla [NFTA_SET_ELEM_LIST_ELEMENTS ], rem ) {
6692
6712
err = nft_del_setelem (& ctx , set , attr );
6713
+ if (err == - ENOENT &&
6714
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYSETELEM )
6715
+ continue ;
6716
+
6693
6717
if (err < 0 ) {
6694
6718
NL_SET_BAD_ATTR (extack , attr );
6695
6719
break ;
@@ -7334,6 +7358,10 @@ static int nf_tables_delobj(struct sk_buff *skb, const struct nfnl_info *info,
7334
7358
}
7335
7359
7336
7360
if (IS_ERR (obj )) {
7361
+ if (PTR_ERR (obj ) == - ENOENT &&
7362
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYOBJ )
7363
+ return 0 ;
7364
+
7337
7365
NL_SET_BAD_ATTR (extack , attr );
7338
7366
return PTR_ERR (obj );
7339
7367
}
@@ -7964,6 +7992,10 @@ static int nf_tables_delflowtable(struct sk_buff *skb,
7964
7992
}
7965
7993
7966
7994
if (IS_ERR (flowtable )) {
7995
+ if (PTR_ERR (flowtable ) == - ENOENT &&
7996
+ NFNL_MSG_TYPE (info -> nlh -> nlmsg_type ) == NFT_MSG_DESTROYFLOWTABLE )
7997
+ return 0 ;
7998
+
7967
7999
NL_SET_BAD_ATTR (extack , attr );
7968
8000
return PTR_ERR (flowtable );
7969
8001
}
@@ -8373,6 +8405,12 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
8373
8405
.attr_count = NFTA_TABLE_MAX ,
8374
8406
.policy = nft_table_policy ,
8375
8407
},
8408
+ [NFT_MSG_DESTROYTABLE ] = {
8409
+ .call = nf_tables_deltable ,
8410
+ .type = NFNL_CB_BATCH ,
8411
+ .attr_count = NFTA_TABLE_MAX ,
8412
+ .policy = nft_table_policy ,
8413
+ },
8376
8414
[NFT_MSG_NEWCHAIN ] = {
8377
8415
.call = nf_tables_newchain ,
8378
8416
.type = NFNL_CB_BATCH ,
@@ -8391,6 +8429,12 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
8391
8429
.attr_count = NFTA_CHAIN_MAX ,
8392
8430
.policy = nft_chain_policy ,
8393
8431
},
8432
+ [NFT_MSG_DESTROYCHAIN ] = {
8433
+ .call = nf_tables_delchain ,
8434
+ .type = NFNL_CB_BATCH ,
8435
+ .attr_count = NFTA_CHAIN_MAX ,
8436
+ .policy = nft_chain_policy ,
8437
+ },
8394
8438
[NFT_MSG_NEWRULE ] = {
8395
8439
.call = nf_tables_newrule ,
8396
8440
.type = NFNL_CB_BATCH ,
@@ -8415,6 +8459,12 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
8415
8459
.attr_count = NFTA_RULE_MAX ,
8416
8460
.policy = nft_rule_policy ,
8417
8461
},
8462
+ [NFT_MSG_DESTROYRULE ] = {
8463
+ .call = nf_tables_delrule ,
8464
+ .type = NFNL_CB_BATCH ,
8465
+ .attr_count = NFTA_RULE_MAX ,
8466
+ .policy = nft_rule_policy ,
8467
+ },
8418
8468
[NFT_MSG_NEWSET ] = {
8419
8469
.call = nf_tables_newset ,
8420
8470
.type = NFNL_CB_BATCH ,
@@ -8433,6 +8483,12 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
8433
8483
.attr_count = NFTA_SET_MAX ,
8434
8484
.policy = nft_set_policy ,
8435
8485
},
8486
+ [NFT_MSG_DESTROYSET ] = {
8487
+ .call = nf_tables_delset ,
8488
+ .type = NFNL_CB_BATCH ,
8489
+ .attr_count = NFTA_SET_MAX ,
8490
+ .policy = nft_set_policy ,
8491
+ },
8436
8492
[NFT_MSG_NEWSETELEM ] = {
8437
8493
.call = nf_tables_newsetelem ,
8438
8494
.type = NFNL_CB_BATCH ,
@@ -8451,6 +8507,12 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
8451
8507
.attr_count = NFTA_SET_ELEM_LIST_MAX ,
8452
8508
.policy = nft_set_elem_list_policy ,
8453
8509
},
8510
+ [NFT_MSG_DESTROYSETELEM ] = {
8511
+ .call = nf_tables_delsetelem ,
8512
+ .type = NFNL_CB_BATCH ,
8513
+ .attr_count = NFTA_SET_ELEM_LIST_MAX ,
8514
+ .policy = nft_set_elem_list_policy ,
8515
+ },
8454
8516
[NFT_MSG_GETGEN ] = {
8455
8517
.call = nf_tables_getgen ,
8456
8518
.type = NFNL_CB_RCU ,
@@ -8473,6 +8535,12 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
8473
8535
.attr_count = NFTA_OBJ_MAX ,
8474
8536
.policy = nft_obj_policy ,
8475
8537
},
8538
+ [NFT_MSG_DESTROYOBJ ] = {
8539
+ .call = nf_tables_delobj ,
8540
+ .type = NFNL_CB_BATCH ,
8541
+ .attr_count = NFTA_OBJ_MAX ,
8542
+ .policy = nft_obj_policy ,
8543
+ },
8476
8544
[NFT_MSG_GETOBJ_RESET ] = {
8477
8545
.call = nf_tables_getobj ,
8478
8546
.type = NFNL_CB_RCU ,
@@ -8497,6 +8565,12 @@ static const struct nfnl_callback nf_tables_cb[NFT_MSG_MAX] = {
8497
8565
.attr_count = NFTA_FLOWTABLE_MAX ,
8498
8566
.policy = nft_flowtable_policy ,
8499
8567
},
8568
+ [NFT_MSG_DESTROYFLOWTABLE ] = {
8569
+ .call = nf_tables_delflowtable ,
8570
+ .type = NFNL_CB_BATCH ,
8571
+ .attr_count = NFTA_FLOWTABLE_MAX ,
8572
+ .policy = nft_flowtable_policy ,
8573
+ },
8500
8574
};
8501
8575
8502
8576
static int nf_tables_validate (struct net * net )
@@ -8590,30 +8664,37 @@ static void nft_commit_release(struct nft_trans *trans)
8590
8664
{
8591
8665
switch (trans -> msg_type ) {
8592
8666
case NFT_MSG_DELTABLE :
8667
+ case NFT_MSG_DESTROYTABLE :
8593
8668
nf_tables_table_destroy (& trans -> ctx );
8594
8669
break ;
8595
8670
case NFT_MSG_NEWCHAIN :
8596
8671
free_percpu (nft_trans_chain_stats (trans ));
8597
8672
kfree (nft_trans_chain_name (trans ));
8598
8673
break ;
8599
8674
case NFT_MSG_DELCHAIN :
8675
+ case NFT_MSG_DESTROYCHAIN :
8600
8676
nf_tables_chain_destroy (& trans -> ctx );
8601
8677
break ;
8602
8678
case NFT_MSG_DELRULE :
8679
+ case NFT_MSG_DESTROYRULE :
8603
8680
nf_tables_rule_destroy (& trans -> ctx , nft_trans_rule (trans ));
8604
8681
break ;
8605
8682
case NFT_MSG_DELSET :
8683
+ case NFT_MSG_DESTROYSET :
8606
8684
nft_set_destroy (& trans -> ctx , nft_trans_set (trans ));
8607
8685
break ;
8608
8686
case NFT_MSG_DELSETELEM :
8687
+ case NFT_MSG_DESTROYSETELEM :
8609
8688
nf_tables_set_elem_destroy (& trans -> ctx ,
8610
8689
nft_trans_elem_set (trans ),
8611
8690
nft_trans_elem (trans ).priv );
8612
8691
break ;
8613
8692
case NFT_MSG_DELOBJ :
8693
+ case NFT_MSG_DESTROYOBJ :
8614
8694
nft_obj_destroy (& trans -> ctx , nft_trans_obj (trans ));
8615
8695
break ;
8616
8696
case NFT_MSG_DELFLOWTABLE :
8697
+ case NFT_MSG_DESTROYFLOWTABLE :
8617
8698
if (nft_trans_flowtable_update (trans ))
8618
8699
nft_flowtable_hooks_destroy (& nft_trans_flowtable_hooks (trans ));
8619
8700
else
@@ -9065,8 +9146,9 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9065
9146
nft_trans_destroy (trans );
9066
9147
break ;
9067
9148
case NFT_MSG_DELTABLE :
9149
+ case NFT_MSG_DESTROYTABLE :
9068
9150
list_del_rcu (& trans -> ctx .table -> list );
9069
- nf_tables_table_notify (& trans -> ctx , NFT_MSG_DELTABLE );
9151
+ nf_tables_table_notify (& trans -> ctx , trans -> msg_type );
9070
9152
break ;
9071
9153
case NFT_MSG_NEWCHAIN :
9072
9154
if (nft_trans_chain_update (trans )) {
@@ -9081,8 +9163,9 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9081
9163
}
9082
9164
break ;
9083
9165
case NFT_MSG_DELCHAIN :
9166
+ case NFT_MSG_DESTROYCHAIN :
9084
9167
nft_chain_del (trans -> ctx .chain );
9085
- nf_tables_chain_notify (& trans -> ctx , NFT_MSG_DELCHAIN );
9168
+ nf_tables_chain_notify (& trans -> ctx , trans -> msg_type );
9086
9169
nf_tables_unregister_hook (trans -> ctx .net ,
9087
9170
trans -> ctx .table ,
9088
9171
trans -> ctx .chain );
@@ -9098,10 +9181,11 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9098
9181
nft_trans_destroy (trans );
9099
9182
break ;
9100
9183
case NFT_MSG_DELRULE :
9184
+ case NFT_MSG_DESTROYRULE :
9101
9185
list_del_rcu (& nft_trans_rule (trans )-> list );
9102
9186
nf_tables_rule_notify (& trans -> ctx ,
9103
9187
nft_trans_rule (trans ),
9104
- NFT_MSG_DELRULE );
9188
+ trans -> msg_type );
9105
9189
nft_rule_expr_deactivate (& trans -> ctx ,
9106
9190
nft_trans_rule (trans ),
9107
9191
NFT_TRANS_COMMIT );
@@ -9129,9 +9213,10 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9129
9213
nft_trans_destroy (trans );
9130
9214
break ;
9131
9215
case NFT_MSG_DELSET :
9216
+ case NFT_MSG_DESTROYSET :
9132
9217
list_del_rcu (& nft_trans_set (trans )-> list );
9133
9218
nf_tables_set_notify (& trans -> ctx , nft_trans_set (trans ),
9134
- NFT_MSG_DELSET , GFP_KERNEL );
9219
+ trans -> msg_type , GFP_KERNEL );
9135
9220
break ;
9136
9221
case NFT_MSG_NEWSETELEM :
9137
9222
te = (struct nft_trans_elem * )trans -> data ;
@@ -9143,11 +9228,12 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9143
9228
nft_trans_destroy (trans );
9144
9229
break ;
9145
9230
case NFT_MSG_DELSETELEM :
9231
+ case NFT_MSG_DESTROYSETELEM :
9146
9232
te = (struct nft_trans_elem * )trans -> data ;
9147
9233
9148
9234
nf_tables_setelem_notify (& trans -> ctx , te -> set ,
9149
9235
& te -> elem ,
9150
- NFT_MSG_DELSETELEM );
9236
+ trans -> msg_type );
9151
9237
nft_setelem_remove (net , te -> set , & te -> elem );
9152
9238
if (!nft_setelem_is_catchall (te -> set , & te -> elem )) {
9153
9239
atomic_dec (& te -> set -> nelems );
@@ -9169,9 +9255,10 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9169
9255
}
9170
9256
break ;
9171
9257
case NFT_MSG_DELOBJ :
9258
+ case NFT_MSG_DESTROYOBJ :
9172
9259
nft_obj_del (nft_trans_obj (trans ));
9173
9260
nf_tables_obj_notify (& trans -> ctx , nft_trans_obj (trans ),
9174
- NFT_MSG_DELOBJ );
9261
+ trans -> msg_type );
9175
9262
break ;
9176
9263
case NFT_MSG_NEWFLOWTABLE :
9177
9264
if (nft_trans_flowtable_update (trans )) {
@@ -9193,19 +9280,20 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9193
9280
nft_trans_destroy (trans );
9194
9281
break ;
9195
9282
case NFT_MSG_DELFLOWTABLE :
9283
+ case NFT_MSG_DESTROYFLOWTABLE :
9196
9284
if (nft_trans_flowtable_update (trans )) {
9197
9285
nf_tables_flowtable_notify (& trans -> ctx ,
9198
9286
nft_trans_flowtable (trans ),
9199
9287
& nft_trans_flowtable_hooks (trans ),
9200
- NFT_MSG_DELFLOWTABLE );
9288
+ trans -> msg_type );
9201
9289
nft_unregister_flowtable_net_hooks (net ,
9202
9290
& nft_trans_flowtable_hooks (trans ));
9203
9291
} else {
9204
9292
list_del_rcu (& nft_trans_flowtable (trans )-> list );
9205
9293
nf_tables_flowtable_notify (& trans -> ctx ,
9206
9294
nft_trans_flowtable (trans ),
9207
9295
& nft_trans_flowtable (trans )-> hook_list ,
9208
- NFT_MSG_DELFLOWTABLE );
9296
+ trans -> msg_type );
9209
9297
nft_unregister_flowtable_net_hooks (net ,
9210
9298
& nft_trans_flowtable (trans )-> hook_list );
9211
9299
}
@@ -9301,6 +9389,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
9301
9389
}
9302
9390
break ;
9303
9391
case NFT_MSG_DELTABLE :
9392
+ case NFT_MSG_DESTROYTABLE :
9304
9393
nft_clear (trans -> ctx .net , trans -> ctx .table );
9305
9394
nft_trans_destroy (trans );
9306
9395
break ;
@@ -9322,6 +9411,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
9322
9411
}
9323
9412
break ;
9324
9413
case NFT_MSG_DELCHAIN :
9414
+ case NFT_MSG_DESTROYCHAIN :
9325
9415
trans -> ctx .table -> use ++ ;
9326
9416
nft_clear (trans -> ctx .net , trans -> ctx .chain );
9327
9417
nft_trans_destroy (trans );
@@ -9336,6 +9426,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
9336
9426
nft_flow_rule_destroy (nft_trans_flow_rule (trans ));
9337
9427
break ;
9338
9428
case NFT_MSG_DELRULE :
9429
+ case NFT_MSG_DESTROYRULE :
9339
9430
trans -> ctx .chain -> use ++ ;
9340
9431
nft_clear (trans -> ctx .net , nft_trans_rule (trans ));
9341
9432
nft_rule_expr_activate (& trans -> ctx , nft_trans_rule (trans ));
@@ -9357,6 +9448,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
9357
9448
list_del_rcu (& nft_trans_set (trans )-> list );
9358
9449
break ;
9359
9450
case NFT_MSG_DELSET :
9451
+ case NFT_MSG_DESTROYSET :
9360
9452
trans -> ctx .table -> use ++ ;
9361
9453
nft_clear (trans -> ctx .net , nft_trans_set (trans ));
9362
9454
nft_trans_destroy (trans );
@@ -9372,6 +9464,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
9372
9464
atomic_dec (& te -> set -> nelems );
9373
9465
break ;
9374
9466
case NFT_MSG_DELSETELEM :
9467
+ case NFT_MSG_DESTROYSETELEM :
9375
9468
te = (struct nft_trans_elem * )trans -> data ;
9376
9469
9377
9470
nft_setelem_data_activate (net , te -> set , & te -> elem );
@@ -9391,6 +9484,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
9391
9484
}
9392
9485
break ;
9393
9486
case NFT_MSG_DELOBJ :
9487
+ case NFT_MSG_DESTROYOBJ :
9394
9488
trans -> ctx .table -> use ++ ;
9395
9489
nft_clear (trans -> ctx .net , nft_trans_obj (trans ));
9396
9490
nft_trans_destroy (trans );
@@ -9407,6 +9501,7 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
9407
9501
}
9408
9502
break ;
9409
9503
case NFT_MSG_DELFLOWTABLE :
9504
+ case NFT_MSG_DESTROYFLOWTABLE :
9410
9505
if (nft_trans_flowtable_update (trans )) {
9411
9506
list_splice (& nft_trans_flowtable_hooks (trans ),
9412
9507
& nft_trans_flowtable (trans )-> hook_list );
0 commit comments