@@ -819,12 +819,20 @@ static int nf_tables_fill_table_info(struct sk_buff *skb, struct net *net,
819
819
goto nla_put_failure ;
820
820
821
821
if (nla_put_string (skb , NFTA_TABLE_NAME , table -> name ) ||
822
- nla_put_be32 (skb , NFTA_TABLE_FLAGS ,
823
- htonl (table -> flags & NFT_TABLE_F_MASK )) ||
824
822
nla_put_be32 (skb , NFTA_TABLE_USE , htonl (table -> use )) ||
825
823
nla_put_be64 (skb , NFTA_TABLE_HANDLE , cpu_to_be64 (table -> handle ),
826
824
NFTA_TABLE_PAD ))
827
825
goto nla_put_failure ;
826
+
827
+ if (event == NFT_MSG_DELTABLE ) {
828
+ nlmsg_end (skb , nlh );
829
+ return 0 ;
830
+ }
831
+
832
+ if (nla_put_be32 (skb , NFTA_TABLE_FLAGS ,
833
+ htonl (table -> flags & NFT_TABLE_F_MASK )))
834
+ goto nla_put_failure ;
835
+
828
836
if (nft_table_has_owner (table ) &&
829
837
nla_put_be32 (skb , NFTA_TABLE_OWNER , htonl (table -> nlpid )))
830
838
goto nla_put_failure ;
@@ -1626,13 +1634,16 @@ static int nf_tables_fill_chain_info(struct sk_buff *skb, struct net *net,
1626
1634
if (!nlh )
1627
1635
goto nla_put_failure ;
1628
1636
1629
- if (nla_put_string (skb , NFTA_CHAIN_TABLE , table -> name ))
1630
- goto nla_put_failure ;
1631
- if ( nla_put_be64 (skb , NFTA_CHAIN_HANDLE , cpu_to_be64 (chain -> handle ),
1637
+ if (nla_put_string (skb , NFTA_CHAIN_TABLE , table -> name ) ||
1638
+ nla_put_string ( skb , NFTA_CHAIN_NAME , chain -> name ) ||
1639
+ nla_put_be64 (skb , NFTA_CHAIN_HANDLE , cpu_to_be64 (chain -> handle ),
1632
1640
NFTA_CHAIN_PAD ))
1633
1641
goto nla_put_failure ;
1634
- if (nla_put_string (skb , NFTA_CHAIN_NAME , chain -> name ))
1635
- goto nla_put_failure ;
1642
+
1643
+ if (event == NFT_MSG_DELCHAIN ) {
1644
+ nlmsg_end (skb , nlh );
1645
+ return 0 ;
1646
+ }
1636
1647
1637
1648
if (nft_is_base_chain (chain )) {
1638
1649
const struct nft_base_chain * basechain = nft_base_chain (chain );
@@ -4150,6 +4161,12 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
4150
4161
if (nla_put_be64 (skb , NFTA_SET_HANDLE , cpu_to_be64 (set -> handle ),
4151
4162
NFTA_SET_PAD ))
4152
4163
goto nla_put_failure ;
4164
+
4165
+ if (event == NFT_MSG_DELSET ) {
4166
+ nlmsg_end (skb , nlh );
4167
+ return 0 ;
4168
+ }
4169
+
4153
4170
if (set -> flags != 0 )
4154
4171
if (nla_put_be32 (skb , NFTA_SET_FLAGS , htonl (set -> flags )))
4155
4172
goto nla_put_failure ;
@@ -7154,13 +7171,20 @@ static int nf_tables_fill_obj_info(struct sk_buff *skb, struct net *net,
7154
7171
7155
7172
if (nla_put_string (skb , NFTA_OBJ_TABLE , table -> name ) ||
7156
7173
nla_put_string (skb , NFTA_OBJ_NAME , obj -> key .name ) ||
7157
- nla_put_be32 (skb , NFTA_OBJ_TYPE , htonl (obj -> ops -> type -> type )) ||
7158
- nla_put_be32 (skb , NFTA_OBJ_USE , htonl (obj -> use )) ||
7159
- nft_object_dump (skb , NFTA_OBJ_DATA , obj , reset ) ||
7160
7174
nla_put_be64 (skb , NFTA_OBJ_HANDLE , cpu_to_be64 (obj -> handle ),
7161
7175
NFTA_OBJ_PAD ))
7162
7176
goto nla_put_failure ;
7163
7177
7178
+ if (event == NFT_MSG_DELOBJ ) {
7179
+ nlmsg_end (skb , nlh );
7180
+ return 0 ;
7181
+ }
7182
+
7183
+ if (nla_put_be32 (skb , NFTA_OBJ_TYPE , htonl (obj -> ops -> type -> type )) ||
7184
+ nla_put_be32 (skb , NFTA_OBJ_USE , htonl (obj -> use )) ||
7185
+ nft_object_dump (skb , NFTA_OBJ_DATA , obj , reset ))
7186
+ goto nla_put_failure ;
7187
+
7164
7188
if (obj -> udata &&
7165
7189
nla_put (skb , NFTA_OBJ_USERDATA , obj -> udlen , obj -> udata ))
7166
7190
goto nla_put_failure ;
@@ -8089,9 +8113,16 @@ static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net,
8089
8113
8090
8114
if (nla_put_string (skb , NFTA_FLOWTABLE_TABLE , flowtable -> table -> name ) ||
8091
8115
nla_put_string (skb , NFTA_FLOWTABLE_NAME , flowtable -> name ) ||
8092
- nla_put_be32 (skb , NFTA_FLOWTABLE_USE , htonl (flowtable -> use )) ||
8093
8116
nla_put_be64 (skb , NFTA_FLOWTABLE_HANDLE , cpu_to_be64 (flowtable -> handle ),
8094
- NFTA_FLOWTABLE_PAD ) ||
8117
+ NFTA_FLOWTABLE_PAD ))
8118
+ goto nla_put_failure ;
8119
+
8120
+ if (event == NFT_MSG_DELFLOWTABLE && !hook_list ) {
8121
+ nlmsg_end (skb , nlh );
8122
+ return 0 ;
8123
+ }
8124
+
8125
+ if (nla_put_be32 (skb , NFTA_FLOWTABLE_USE , htonl (flowtable -> use )) ||
8095
8126
nla_put_be32 (skb , NFTA_FLOWTABLE_FLAGS , htonl (flowtable -> data .flags )))
8096
8127
goto nla_put_failure ;
8097
8128
@@ -8106,6 +8137,9 @@ static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net,
8106
8137
if (!nest_devs )
8107
8138
goto nla_put_failure ;
8108
8139
8140
+ if (!hook_list )
8141
+ hook_list = & flowtable -> hook_list ;
8142
+
8109
8143
list_for_each_entry_rcu (hook , hook_list , list ) {
8110
8144
if (nla_put_string (skb , NFTA_DEVICE_NAME , hook -> ops .dev -> name ))
8111
8145
goto nla_put_failure ;
@@ -8162,8 +8196,7 @@ static int nf_tables_dump_flowtable(struct sk_buff *skb,
8162
8196
NFT_MSG_NEWFLOWTABLE ,
8163
8197
NLM_F_MULTI | NLM_F_APPEND ,
8164
8198
table -> family ,
8165
- flowtable ,
8166
- & flowtable -> hook_list ) < 0 )
8199
+ flowtable , NULL ) < 0 )
8167
8200
goto done ;
8168
8201
8169
8202
nl_dump_check_consistent (cb , nlmsg_hdr (skb ));
@@ -8258,7 +8291,7 @@ static int nf_tables_getflowtable(struct sk_buff *skb,
8258
8291
err = nf_tables_fill_flowtable_info (skb2 , net , NETLINK_CB (skb ).portid ,
8259
8292
info -> nlh -> nlmsg_seq ,
8260
8293
NFT_MSG_NEWFLOWTABLE , 0 , family ,
8261
- flowtable , & flowtable -> hook_list );
8294
+ flowtable , NULL );
8262
8295
if (err < 0 )
8263
8296
goto err_fill_flowtable_info ;
8264
8297
@@ -8271,8 +8304,7 @@ static int nf_tables_getflowtable(struct sk_buff *skb,
8271
8304
8272
8305
static void nf_tables_flowtable_notify (struct nft_ctx * ctx ,
8273
8306
struct nft_flowtable * flowtable ,
8274
- struct list_head * hook_list ,
8275
- int event )
8307
+ struct list_head * hook_list , int event )
8276
8308
{
8277
8309
struct nftables_pernet * nft_net = nft_pernet (ctx -> net );
8278
8310
struct sk_buff * skb ;
@@ -9333,7 +9365,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9333
9365
nft_clear (net , nft_trans_flowtable (trans ));
9334
9366
nf_tables_flowtable_notify (& trans -> ctx ,
9335
9367
nft_trans_flowtable (trans ),
9336
- & nft_trans_flowtable ( trans ) -> hook_list ,
9368
+ NULL ,
9337
9369
NFT_MSG_NEWFLOWTABLE );
9338
9370
}
9339
9371
nft_trans_destroy (trans );
@@ -9351,7 +9383,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
9351
9383
list_del_rcu (& nft_trans_flowtable (trans )-> list );
9352
9384
nf_tables_flowtable_notify (& trans -> ctx ,
9353
9385
nft_trans_flowtable (trans ),
9354
- & nft_trans_flowtable ( trans ) -> hook_list ,
9386
+ NULL ,
9355
9387
trans -> msg_type );
9356
9388
nft_unregister_flowtable_net_hooks (net ,
9357
9389
& nft_trans_flowtable (trans )-> hook_list );
0 commit comments