rule: revisit standard bridge filter and raw priorities
Pablo Neira Ayuso
maintainerPATCH v2 1/1 rule: revisit standard bridge filter and raw priorities
Commit c8a0e8c90e2d ("src: Set/print standard chain prios with textual names)" introduces legacy standard priorities for the bridge which have been never documented.
Use 0 as the filter priority for parity with existing families, currently this uses -200 which is exactly the prerouting/conntrack hook. Behaviour of hooks registered at the same priority is undefined, ie. it depends on whether the basechain or conntrack registers first.
While at this, add the raw priority at -300 just like the same existing families.
The remaining priorities are related to br_netfilter, so still allow to parse them for backwards compatibility, but let's only print filter and raw.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- doc/nft.txt | 4 ++-- src/rule.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-)
doc/nft.txt +2 -2
@@ -487,10 +487,10 @@ the others. See the following tables that describe the values and compatibility. [options="header"] |================== | Name | Value | Families | Hooks -| raw | -300 | ip, ip6, inet | all +| raw | -300 | ip, ip6, inet, bridge | all | mangle | -150 | ip, ip6, inet | all | dstnat | -100 | ip, ip6, inet | prerouting -| filter | 0 | ip, ip6, inet, arp, netdev | all +| filter | 0 | ip, ip6, inet, arp, netdev, bridge | all | security | 50 | ip, ip6, inet | all | srcnat | 100 | ip, ip6, inet | postrouting |===================
src/rule.c +11 -3
@@ -902,18 +902,26 @@ static const struct prio_tag std_prios[] = { };static const struct prio_tag bridge_std_prios[] = { + {NF_IP_PRI_RAW ,"raw" }, {NF_BR_PRI_NAT_DST_BRIDGED ,"dstnat" }, - {NF_BR_PRI_FILTER_BRIDGED ,"filter" }, + {NF_IP_PRI_FILTER ,"filter" }, {NF_BR_PRI_NAT_DST_OTHER ,"out" }, {NF_BR_PRI_NAT_SRC ,"srcnat" }, }; +static const struct prio_tag new_bridge_std_prios[] = { + {NF_IP_PRI_RAW ,"raw" }, + {NF_IP_PRI_FILTER ,"filter" }, +}; +static bool std_prio_family_hook_compat (int prio,int family,int hook) {/* bridge family has different values */ if (family ==NFPROTO_BRIDGE ) {switch (prio) { -case NF_BR_PRI_NAT_DST_BRIDGED : +case NF_IP_PRI_FILTER : +return true; +case NF_IP_PRI_RAW :/* NF_BR_PRI_NAT_DST_BRIDGED */ if (hook ==NF_BR_PRE_ROUTING )return true;break ;
@@ -1007,7 +1015,7 @@ static const char *prio2str(const struct output_ctx *octx,mpz_export_data (&prio, expr->value,BYTEORDER_HOST_ENDIAN ,sizeof (int ));if (family ==NFPROTO_BRIDGE ) { - prio_arr = bridge_std_prios; + prio_arr = new_bridge_std_prios; arr_size =array_size (bridge_std_prios); }else { prio_arr = std_prios;
Signature · 1 line
2.47.3