From c17509c6d1948f28f8cda71fef79447ec273573d Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Tue, 7 Feb 2017 03:14:13 +0100 Subject: payload: insert implicit meta tcp dependency when matching tcp options nft add rule inet filter input tcp option sack 4 left 1 :1:28-49: Error: Cannot generate dependency: no network layer protocol specified Users can avoid this via 'meta l4proto tcp', this enables implicit dependency injection for the inet/bridge/netdev families. Reviewed-by: Manuel Messner Signed-off-by: Florian Westphal --- src/payload.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/payload.c') diff --git a/src/payload.c b/src/payload.c index efd19602..0207296e 100644 --- a/src/payload.c +++ b/src/payload.c @@ -323,12 +323,26 @@ int exthdr_gen_dependency(struct eval_ctx *ctx, const struct expr *expr, const struct proto_desc *desc; desc = ctx->pctx.protocol[pb].desc; - if (desc == NULL) + if (desc == NULL) { + if (expr->exthdr.op == NFT_EXTHDR_OP_TCPOPT) { + switch (ctx->pctx.family) { + case NFPROTO_NETDEV: + case NFPROTO_BRIDGE: + case NFPROTO_INET: + desc = &proto_inet_service; + goto found; + default: + break; + } + } + return expr_error(ctx->msgs, expr, "Cannot generate dependency: " "no %s protocol specified", proto_base_names[pb]); + } + found: return payload_add_dependency(ctx, desc, dependency, expr, res); } -- cgit v1.2.3