Doubt about CTA_EXPECT_* values passed to ctnetlink_parse_tuple()
Subsystems (2)
Hi,
While working on clang support for kernel builds I came across at what at first sight looks like an enum mismatch in the netfilter conntrack code:
In multiple occasions CTA_EXPECT_* values (of type enum ctattr_expect) are passed to ctnetlink_parse_tuple(), which expects an 'enum ctattr_type' as type argument.
In other cases unintentional use of a wrong enum type maybe be obvious, in this case however it isn't clear to me which 'enum ctattr_type' should be passed instead, so I wonder if the use of the different type is intended.
Could someone please briefly clarify? My background on netfilter internals is zero, so please forgive my probably naive question.
Thanks
Matthias
Pablo Neira Ayuso
maintainerHi Mattias,
Quoted 9 lines · Matthias Kaehlcke
Hi,
While working on clang support for kernel builds I came across at what at first sight looks like an enum mismatch in the netfilter conntrack code:
In multiple occasions CTA_EXPECT_* values (of type enum
ctattr_expect) are passed toctnetlink_parse_tuple(), which expects an 'enumctattr_type' as type argument.
Are you refering to this? See patch.
net/netfilter/nf_conntrack_netlink.c +2 -3
@@ -1006,9 +1006,8 @@ static const struct nla_policy tuple_nla_policy[CTA_TUPLE_MAX+1] = {static int ctnetlink_parse_tuple (const struct nlattr *const cda[], -struct nf_conntrack_tuple *tuple, -enum ctattr_type type,u_int8_t l3num, -struct nf_conntrack_zone *zone) +struct nf_conntrack_tuple *tuple,u32 type, +u_int8_t l3num,struct nf_conntrack_zone *zone) {struct nlattr *tb[CTA_TUPLE_MAX +1 ];int err;
Hi Pablo,
Thanks for your reply!
El Tue, Apr 18, 2017 at 10:39:47AM +0200 Pablo Neira Ayuso ha dit:
Quoted 7 lines · Matthias Kaehlcke
Quoted 6 lines
Hi,
While working on clang support for kernel builds I came across at what at first sight looks like an enum mismatch in the netfilter conntrack code:
Quoted 5 lines
Quoted 3 lines
In multiple occasions CTA_EXPECT_* values (of type enum
ctattr_expect) are passed toctnetlink_parse_tuple(), which expects an 'enumctattr_type' as type argument.Are you refering to this? See patch.
Almost, see patch :)
I interpret that passing the different enum types is intentional and changing the parameter type an acceptable solution.
Cheers
Matthias
El Tue, Apr 18, 2017 at 12:41:16PM -0700 Matthias Kaehlcke ha dit:
Quoted 13 lines
Hi Pablo,
Thanks for your reply!
El Tue, Apr 18, 2017 at 10:39:47AM +0200 Pablo Neira Ayuso ha dit:
Quoted 7 lines · Matthias Kaehlcke
Quoted 6 lines
Hi,
While working on clang support for kernel builds I came across at what at first sight looks like an enum mismatch in the netfilter conntrack code:
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
In multiple occasions CTA_EXPECT_* values (of type enum
ctattr_expect) are passed toctnetlink_parse_tuple(), which expects an 'enumctattr_type' as type argument.Are you refering to this? See patch.
Almost, see patch :)
This time with patch
net/netfilter/nf_conntrack_netlink.c +3 -4
@@ -1006,9 +1006,8 @@ static const struct nla_policy tuple_nla_policy[CTA_TUPLE_MAX+1] = {static int ctnetlink_parse_tuple (const struct nlattr *const cda[], -struct nf_conntrack_tuple *tuple, -enum ctattr_type type,u_int8_t l3num, -struct nf_conntrack_zone *zone) +struct nf_conntrack_tuple *tuple,u32 type, +u_int8_t l3num,struct nf_conntrack_zone *zone) {struct nlattr *tb[CTA_TUPLE_MAX +1 ];int err;
@@ -2405,7 +2404,7 @@ static struct nfnl_ct_hook ctnetlink_glue_hook = {static int ctnetlink_exp_dump_tuple (struct sk_buff *skb,const struct nf_conntrack_tuple *tuple, -enum ctattr_expect type) +uint32_t type) {struct nlattr *nest_parms;
Pablo Neira Ayuso
maintainerQuoted 42 lines · Matthias Kaehlcke
El Tue, Apr 18, 2017 at 12:41:16PM -0700 Matthias Kaehlcke ha dit:
Quoted 13 lines
Hi Pablo,
Thanks for your reply!
El Tue, Apr 18, 2017 at 10:39:47AM +0200 Pablo Neira Ayuso ha dit:
Quoted 7 lines · Matthias Kaehlcke
Quoted 6 lines
Hi,
While working on clang support for kernel builds I came across at what at first sight looks like an enum mismatch in the netfilter conntrack code:
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
In multiple occasions CTA_EXPECT_* values (of type enum
ctattr_expect) are passed toctnetlink_parse_tuple(), which expects an 'enumctattr_type' as type argument.Are you refering to this? See patch.
Almost, see patch :)
This time with patch
net/netfilter/nf_conntrack_netlink.c +2
-3@@ -1006,9 +1006,8 @@ static const struct nla_policy tuple_nla_policy[CTA_TUPLE_MAX+1] = {static int ctnetlink_parse_tuple (const struct nlattr *const cda[], -struct nf_conntrack_tuple *tuple, -enum ctattr_type type,u_int8_t l3num, -struct nf_conntrack_zone *zone) +struct nf_conntrack_tuple *tuple,u32 type, +u_int8_t l3num,struct nf_conntrack_zone *zone) {struct nlattr *tb[CTA_TUPLE_MAX +1 ];int err;
net/netfilter/nf_conntrack_netlink.c static struct nfnl_ct_hook ctnetlink_glue_hook = { · line 2410
Quoted 8 lines
net/netfilter/nf_conntrack_netlink.c +1
-1@@ -2405,7 +2404,7 @@ static struct nfnl_ct_hook ctnetlink_glue_hook = {static int ctnetlink_exp_dump_tuple (struct sk_buff *skb,const struct nf_conntrack_tuple *tuple, -enum ctattr_expect type) +uint32_t type) {struct nlattr *nest_parms;
Looks fine. Please, add title, description and Signed-off-by tag, I'll take it :)