Flowtable is destroyed when system boot

In my test, lan and wan will up successively, so openwrt call "fw4 -q reload" twice, which calls
NFT_MSG_NEWFLOWTABLE/NFT_MSG_DELFLOWTABLE/NFT_MSG_NEWFLOWTABLE in the kernel as the following log shows.

But "NFT_MSG_DELFLOWTABLE" is committed after all msgs have been processed, which will call "nf_tables_trans_destroy_work" to destroy flowtable, then serial functions will be called, such as "nf_flow_table_offload_setup" will unbind lan1/lan2/lan3/lan4/wan finally.

Is this a bug or do I misunderstand the code ?

Thanks a lot

[   19.623963] [nfnetlink_find_client(147)] warning:cb_id=22, NFT_MSG_NEWFLOWTABLE
[   19.633808] [nf_tables_newflowtable(6791)] warning:flowtable->name=ft, type->family=1
[   19.672675] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=wan, bind
[   19.722649] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan4
[   19.768874] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan3
[   19.824991] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan2
[   19.863884] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan1
[   21.603257] [nfnetlink_find_client(147)] warning:cb_id=24, NFT_MSG_DELFLOWTABLE
[   21.608752] [nf_tables_delflowtable(6947)] warning:flowtable->name=ft
[   21.615466] [nfnetlink_find_client(147)] warning:cb_id=22, NFT_MSG_NEWFLOWTABLE
[   21.620851] [nf_tables_newflowtable(6791)] warning:flowtable->name=ft, type->family=1
[   21.628798] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=wlan1, bind
[   21.638441] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=wlan0
[   21.648064] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=wan
[   21.657538] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan4
[   21.667111] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan3
[   21.676580] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan2
[   21.686269] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=0, dev->name=lan1
[   21.734706] [nf_tables_trans_destroy_work(7591)] warning: commit NFT_MSG_DELFLOWTABLE
[   21.742531] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=1, dev->name=wan, unbind
[   21.764593] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=1, dev->name=lan4
[   21.774149] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=1, dev->name=lan3
[   21.783774] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=1, dev->name=lan2
[   21.793260] [nf_flow_table_offload_setup(1102)] warning:flowtable->type->family=1, cmd=1, dev->name=lan1

I think I have found the answer from "build_dir\target-aarch64_cortex-a53_musl\linux-mediatek_mt7622\linux-5.10.138\drivers\net\ethernet\mediatek\mtk_ppe_offload.c"

In the function mtk_eth_setup_tc_block, bind will increase the refcnt, and unbind will decrease it.
So in the log, we bind twice and unbind once, the refcnt still be 1, so the flowtable still work.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.