Skip to contentSkip to conversation

rule: revisit standard bridge filter and raw priorities

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 26 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 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.

---
 doc/nft.txt |  4 ++--
 src/rule.c  | 14 +++++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
doc/nft.txt +2 -2
index a7ef9a7183b5..09d5193890fd 100644
@@ -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
index d232582b6080..c1f6da763676 100644
@@ -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