Skip to contentSkip to conversation

payload: fix transport matching with no network layer info in bridge family

PATCH In review Pablo Neira Ayuso 3 participants 4 messages Jun 26, 2015 – Jun 29, 2015 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 payload: fix transport matching with no network layer info in bridge family

 # nft --debug=netlink add rule bridge filter input tcp dport 22
 bridge filter input
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00001600 ]
---
 src/payload.c |    3 +++
 1 file changed, 3 insertions(+)
src/payload.c +3 -0
index 08578fd..e67ef17 100644
@@ -219,6 +219,9 @@ int payload_gen_dependency(struct eval_ctx *ctx, const struct expr *expr,
 			case PROTO_BASE_LL_HDR:
 				desc = &proto_eth;
 				break;
+			case PROTO_BASE_TRANSPORT_HDR:
+				desc = &proto_inet_service;
+				break;
 			default:
 				break;
 			}
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 18 lines · Pablo Neira Ayuso
 # nft --debug=netlink add rule bridge filter input tcp dport 22
 bridge filter input
  [ meta load l4proto => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 2b @ transport header + 2 => reg 1 ]
  [ cmp eq reg 1 0x00001600 ]
---
 src/payload.c |    3 +++
 1 file changed, 3 insertions(+)
src/payload.c +0 -0
index 08578fd..e67ef17 100644

src/payload.c int payload_gen_dependency(struct eval_ctx *ctx, const struct expr *expr, · line 224

Quoted 6 lines
src/payload.c +3 -0
@@ -219,6 +219,9 @@ int payload_gen_dependency(struct eval_ctx *ctx, const struct expr *expr,
 			case PROTO_BASE_LL_HDR:
 				desc = &proto_eth;
 				break;
+			case PROTO_BASE_TRANSPORT_HDR:
+				desc = &proto_inet_service;
+				break;

Just a very minor issue - the switch statement for NFPROTO_INET just above uses the opposite ordering. Would increase readbility to use the same for both, and I actually LL then TRANSPORT.

Quoted 6 lines
src/payload.c +0 -0
 			default:
 				break;
 			}
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 1/1 payload: reorder case in a switch for consistency

As pointed out by Patrick McHardy the order in the inet switch in payload_gen_dependency was not consistent.

---
 src/payload.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/payload.c +3 -3
index e67ef17..5f8c4fe 100644
@@ -204,12 +204,12 @@ int payload_gen_dependency(struct eval_ctx *ctx, const struct expr *expr,
 		switch (ctx->pctx.family) {
 		case NFPROTO_INET:
 			switch (expr->payload.base) {
-			case PROTO_BASE_TRANSPORT_HDR:
-				desc = &proto_inet_service;
-				break;
 			case PROTO_BASE_LL_HDR:
 				desc = &proto_inet;
 				break;
+			case PROTO_BASE_TRANSPORT_HDR:
+				desc = &proto_inet_service;
+				break;
 			default:
 				break;
 			}
Signature · 1 line
2.1.4
author maintainer Applied
#3 lore raw

Re: [PATCH nft] payload: reorder case in a switch for consistency

Quoted 2 lines · Eric Leblond

As pointed out by Patrick McHardy the order in the inet switch in payload_gen_dependency was not consistent.

Applied, thanks.