summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2021-11-30 00:50:53 +0100
committerFlorian Westphal <fw@strlen.de>2021-11-30 13:51:24 +0100
commit443503f53530c3829e7805018b3f7b55e6dcd3c4 (patch)
tree0b65dfdca5cd23d2d08dc633080a0e3defa1f7f3 /src
parent3847fccf004525ceb97db6fbc681835b0ac9a61a (diff)
exthdr: fix type number saved in udata
This should store the index of the protocol template, but &x[i] - &x[0] is always i, so remove the divide. Also add test case. Fixes: 01fbc1574b9e ("exthdr: add parse and build userdata interface") Signed-off-by: Florian Westphal <fw@strlen.de> Acked-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src')
-rw-r--r--src/exthdr.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/exthdr.c b/src/exthdr.c
index 22a08b0c..00d338f0 100644
--- a/src/exthdr.c
+++ b/src/exthdr.c
@@ -165,9 +165,7 @@ static struct expr *exthdr_expr_parse_udata(const struct nftnl_udata *attr)
static unsigned int expr_exthdr_type(const struct exthdr_desc *desc,
const struct proto_hdr_template *tmpl)
{
- unsigned int offset = (unsigned int)(tmpl - &desc->templates[0]);
-
- return offset / sizeof(*tmpl);
+ return (unsigned int)(tmpl - &desc->templates[0]);
}
static int exthdr_expr_build_udata(struct nftnl_udata_buf *udbuf,