|
|
9ff721 |
From f47941faed177fd3943c7eaf9408e9e6481595f6 Mon Sep 17 00:00:00 2001
|
|
|
9ff721 |
From: Phil Sutter <phil@nwl.cc>
|
|
|
9ff721 |
Date: Mon, 13 Aug 2018 18:58:57 +0200
|
|
|
9ff721 |
Subject: [PATCH] evaluate: reject: Allow icmpx in inet/bridge families
|
|
|
9ff721 |
|
|
|
9ff721 |
Commit 3e6ab2b335142 added restraints on reject types for bridge and
|
|
|
9ff721 |
inet families but aparently those were too strict: If a rule in e.g.
|
|
|
9ff721 |
inet family contained a match which introduced a protocol dependency,
|
|
|
9ff721 |
icmpx type rejects were disallowed for no obvious reason.
|
|
|
9ff721 |
|
|
|
9ff721 |
Allow icmpx type rejects in inet family regardless of protocol
|
|
|
9ff721 |
dependency since we either have IPv4 or IPv6 traffic in there and for
|
|
|
9ff721 |
both icmpx is fine.
|
|
|
9ff721 |
|
|
|
9ff721 |
Merge restraints in bridge family with those for TCP reset since it
|
|
|
9ff721 |
already does what is needed, namely checking that ether proto is either
|
|
|
9ff721 |
IPv4 or IPv6.
|
|
|
9ff721 |
|
|
|
9ff721 |
Fixes: 3e6ab2b335142 ("evaluate: reject: check in bridge and inet the network context in reject")
|
|
|
9ff721 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
9ff721 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
9ff721 |
(cherry picked from commit 8d2c3c72935443228b5e0492c8d3e2e2048c0c5a)
|
|
|
9ff721 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
9ff721 |
---
|
|
|
9ff721 |
src/evaluate.c | 7 +----
|
|
|
9ff721 |
tests/py/bridge/reject.t | 5 ++++
|
|
|
9ff721 |
tests/py/bridge/reject.t.json | 44 +++++++++++++++++++++++++++++
|
|
|
9ff721 |
tests/py/bridge/reject.t.payload | 12 ++++++++
|
|
|
9ff721 |
tests/py/inet/reject.t | 3 ++
|
|
|
9ff721 |
tests/py/inet/reject.t.json | 42 +++++++++++++++++++++++++++
|
|
|
9ff721 |
tests/py/inet/reject.t.payload.inet | 12 ++++++++
|
|
|
9ff721 |
7 files changed, 119 insertions(+), 6 deletions(-)
|
|
|
9ff721 |
|
|
|
9ff721 |
diff --git a/src/evaluate.c b/src/evaluate.c
|
|
|
9ff721 |
index c4ee3cc94a3db..d18af34341b0d 100644
|
|
|
9ff721 |
--- a/src/evaluate.c
|
|
|
9ff721 |
+++ b/src/evaluate.c
|
|
|
9ff721 |
@@ -2130,9 +2130,7 @@ static int stmt_evaluate_reject_inet_family(struct eval_ctx *ctx,
|
|
|
9ff721 |
case NFT_REJECT_TCP_RST:
|
|
|
9ff721 |
break;
|
|
|
9ff721 |
case NFT_REJECT_ICMPX_UNREACH:
|
|
|
9ff721 |
- return stmt_binary_error(ctx, stmt->reject.expr,
|
|
|
9ff721 |
- &ctx->pctx.protocol[PROTO_BASE_NETWORK_HDR],
|
|
|
9ff721 |
- "conflicting network protocol specified");
|
|
|
9ff721 |
+ break;
|
|
|
9ff721 |
case NFT_REJECT_ICMP_UNREACH:
|
|
|
9ff721 |
base = ctx->pctx.protocol[PROTO_BASE_LL_HDR].desc;
|
|
|
9ff721 |
protocol = proto_find_num(base, desc);
|
|
|
9ff721 |
@@ -2183,9 +2181,6 @@ static int stmt_evaluate_reject_bridge_family(struct eval_ctx *ctx,
|
|
|
9ff721 |
|
|
|
9ff721 |
switch (stmt->reject.type) {
|
|
|
9ff721 |
case NFT_REJECT_ICMPX_UNREACH:
|
|
|
9ff721 |
- return stmt_binary_error(ctx, stmt->reject.expr,
|
|
|
9ff721 |
- &ctx->pctx.protocol[PROTO_BASE_NETWORK_HDR],
|
|
|
9ff721 |
- "conflicting network protocol specified");
|
|
|
9ff721 |
case NFT_REJECT_TCP_RST:
|
|
|
9ff721 |
base = ctx->pctx.protocol[PROTO_BASE_LL_HDR].desc;
|
|
|
9ff721 |
protocol = proto_find_num(base, desc);
|
|
|
9ff721 |
diff --git a/tests/py/bridge/reject.t b/tests/py/bridge/reject.t
|
|
|
9ff721 |
index 67deac8d3b5e4..13d65b115c3cb 100644
|
|
|
9ff721 |
--- a/tests/py/bridge/reject.t
|
|
|
9ff721 |
+++ b/tests/py/bridge/reject.t
|
|
|
9ff721 |
@@ -37,3 +37,8 @@ ether type arp reject;fail
|
|
|
9ff721 |
ether type vlan reject with tcp reset;fail
|
|
|
9ff721 |
ether type arp reject with tcp reset;fail
|
|
|
9ff721 |
ip protocol udp reject with tcp reset;fail
|
|
|
9ff721 |
+
|
|
|
9ff721 |
+ether type ip reject with icmpx type admin-prohibited;ok
|
|
|
9ff721 |
+ether type ip6 reject with icmpx type admin-prohibited;ok
|
|
|
9ff721 |
+ether type vlan reject with icmpx type admin-prohibited;fail
|
|
|
9ff721 |
+ether type arp reject with icmpx type admin-prohibited;fail
|
|
|
9ff721 |
diff --git a/tests/py/bridge/reject.t.json b/tests/py/bridge/reject.t.json
|
|
|
9ff721 |
index aa716f8070666..c0bed56e6ce41 100644
|
|
|
9ff721 |
--- a/tests/py/bridge/reject.t.json
|
|
|
9ff721 |
+++ b/tests/py/bridge/reject.t.json
|
|
|
9ff721 |
@@ -219,3 +219,47 @@
|
|
|
9ff721 |
}
|
|
|
9ff721 |
]
|
|
|
9ff721 |
|
|
|
9ff721 |
+# ether type ip reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+[
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "match": {
|
|
|
9ff721 |
+ "left": {
|
|
|
9ff721 |
+ "payload": {
|
|
|
9ff721 |
+ "field": "type",
|
|
|
9ff721 |
+ "protocol": "ether"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ "op": "==",
|
|
|
9ff721 |
+ "right": "ip"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "reject": {
|
|
|
9ff721 |
+ "expr": "admin-prohibited",
|
|
|
9ff721 |
+ "type": "icmpx"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
+# ether type ip6 reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+[
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "match": {
|
|
|
9ff721 |
+ "left": {
|
|
|
9ff721 |
+ "payload": {
|
|
|
9ff721 |
+ "field": "type",
|
|
|
9ff721 |
+ "protocol": "ether"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ "op": "==",
|
|
|
9ff721 |
+ "right": "ip6"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "reject": {
|
|
|
9ff721 |
+ "expr": "admin-prohibited",
|
|
|
9ff721 |
+ "type": "icmpx"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
diff --git a/tests/py/bridge/reject.t.payload b/tests/py/bridge/reject.t.payload
|
|
|
9ff721 |
index b984f6f8de4d6..888179df9c977 100644
|
|
|
9ff721 |
--- a/tests/py/bridge/reject.t.payload
|
|
|
9ff721 |
+++ b/tests/py/bridge/reject.t.payload
|
|
|
9ff721 |
@@ -106,3 +106,15 @@ bridge test-bridge input
|
|
|
9ff721 |
bridge test-bridge input
|
|
|
9ff721 |
[ reject type 2 code 1 ]
|
|
|
9ff721 |
|
|
|
9ff721 |
+# ether type ip reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+bridge test-bridge input
|
|
|
9ff721 |
+ [ payload load 2b @ link header + 12 => reg 1 ]
|
|
|
9ff721 |
+ [ cmp eq reg 1 0x00000008 ]
|
|
|
9ff721 |
+ [ reject type 2 code 3 ]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
+# ether type ip6 reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+bridge test-bridge input
|
|
|
9ff721 |
+ [ payload load 2b @ link header + 12 => reg 1 ]
|
|
|
9ff721 |
+ [ cmp eq reg 1 0x0000dd86 ]
|
|
|
9ff721 |
+ [ reject type 2 code 3 ]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
diff --git a/tests/py/inet/reject.t b/tests/py/inet/reject.t
|
|
|
9ff721 |
index 7679407e6f8d4..a88c5a4afae51 100644
|
|
|
9ff721 |
--- a/tests/py/inet/reject.t
|
|
|
9ff721 |
+++ b/tests/py/inet/reject.t
|
|
|
9ff721 |
@@ -34,3 +34,6 @@ meta nfproto ipv6 reject with icmp type host-unreachable;fail
|
|
|
9ff721 |
meta nfproto ipv4 ip protocol icmp reject with icmpv6 type no-route;fail
|
|
|
9ff721 |
meta nfproto ipv6 ip protocol icmp reject with icmp type host-unreachable;fail
|
|
|
9ff721 |
meta l4proto udp reject with tcp reset;fail
|
|
|
9ff721 |
+
|
|
|
9ff721 |
+meta nfproto ipv4 reject with icmpx type admin-prohibited;ok
|
|
|
9ff721 |
+meta nfproto ipv6 reject with icmpx type admin-prohibited;ok
|
|
|
9ff721 |
diff --git a/tests/py/inet/reject.t.json b/tests/py/inet/reject.t.json
|
|
|
9ff721 |
index 0939f4450509b..46d4857a57c99 100644
|
|
|
9ff721 |
--- a/tests/py/inet/reject.t.json
|
|
|
9ff721 |
+++ b/tests/py/inet/reject.t.json
|
|
|
9ff721 |
@@ -238,3 +238,45 @@
|
|
|
9ff721 |
}
|
|
|
9ff721 |
]
|
|
|
9ff721 |
|
|
|
9ff721 |
+# meta nfproto ipv4 reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+[
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "match": {
|
|
|
9ff721 |
+ "left": {
|
|
|
9ff721 |
+ "meta": {
|
|
|
9ff721 |
+ "key": "nfproto"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ "op": "==",
|
|
|
9ff721 |
+ "right": "ipv4"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "reject": {
|
|
|
9ff721 |
+ "expr": "admin-prohibited",
|
|
|
9ff721 |
+ "type": "icmpx"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
+# meta nfproto ipv6 reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+[
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "match": {
|
|
|
9ff721 |
+ "left": {
|
|
|
9ff721 |
+ "meta": {
|
|
|
9ff721 |
+ "key": "nfproto"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ "op": "==",
|
|
|
9ff721 |
+ "right": "ipv6"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ },
|
|
|
9ff721 |
+ {
|
|
|
9ff721 |
+ "reject": {
|
|
|
9ff721 |
+ "expr": "admin-prohibited",
|
|
|
9ff721 |
+ "type": "icmpx"
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+ }
|
|
|
9ff721 |
+]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
diff --git a/tests/py/inet/reject.t.payload.inet b/tests/py/inet/reject.t.payload.inet
|
|
|
9ff721 |
index 7a6468e81f9e7..ee1aae02f1e1d 100644
|
|
|
9ff721 |
--- a/tests/py/inet/reject.t.payload.inet
|
|
|
9ff721 |
+++ b/tests/py/inet/reject.t.payload.inet
|
|
|
9ff721 |
@@ -220,3 +220,15 @@ inet test-inet input
|
|
|
9ff721 |
[ cmp eq reg 1 0x0000000a ]
|
|
|
9ff721 |
[ reject type 0 code 0 ]
|
|
|
9ff721 |
|
|
|
9ff721 |
+# meta nfproto ipv4 reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+inet test-inet input
|
|
|
9ff721 |
+ [ meta load nfproto => reg 1 ]
|
|
|
9ff721 |
+ [ cmp eq reg 1 0x00000002 ]
|
|
|
9ff721 |
+ [ reject type 2 code 3 ]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
+# meta nfproto ipv6 reject with icmpx type admin-prohibited
|
|
|
9ff721 |
+inet test-inet input
|
|
|
9ff721 |
+ [ meta load nfproto => reg 1 ]
|
|
|
9ff721 |
+ [ cmp eq reg 1 0x0000000a ]
|
|
|
9ff721 |
+ [ reject type 2 code 3 ]
|
|
|
9ff721 |
+
|
|
|
9ff721 |
--
|
|
|
bacbc8 |
2.21.0
|
|
|
9ff721 |
|