Skip to content

Commit 1feeae0

Browse files
committed
netfilter: ctnetlink: fix compilation warning after data race fixes in ct mark
All warnings (new ones prefixed by >>): net/netfilter/nf_conntrack_netlink.c: In function '__ctnetlink_glue_build': >> net/netfilter/nf_conntrack_netlink.c:2674:13: warning: unused variable 'mark' [-Wunused-variable] 2674 | u32 mark; | ^~~~ Fixes: 52d1aa8 ("netfilter: conntrack: Fix data-races around ct mark") Reported-by: kernel test robot <[email protected]> Tested-by: Ivan Babrou <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 9464d0b commit 1feeae0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

net/netfilter/nf_conntrack_netlink.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,13 @@ ctnetlink_dump_timestamp(struct sk_buff *skb, const struct nf_conn *ct)
328328
}
329329

330330
#ifdef CONFIG_NF_CONNTRACK_MARK
331-
static int ctnetlink_dump_mark(struct sk_buff *skb, u32 mark)
331+
static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
332332
{
333+
u32 mark = READ_ONCE(ct->mark);
334+
335+
if (!mark)
336+
return 0;
337+
333338
if (nla_put_be32(skb, CTA_MARK, htonl(mark)))
334339
goto nla_put_failure;
335340
return 0;
@@ -543,7 +548,7 @@ static int ctnetlink_dump_extinfo(struct sk_buff *skb,
543548
static int ctnetlink_dump_info(struct sk_buff *skb, struct nf_conn *ct)
544549
{
545550
if (ctnetlink_dump_status(skb, ct) < 0 ||
546-
ctnetlink_dump_mark(skb, READ_ONCE(ct->mark)) < 0 ||
551+
ctnetlink_dump_mark(skb, ct) < 0 ||
547552
ctnetlink_dump_secctx(skb, ct) < 0 ||
548553
ctnetlink_dump_id(skb, ct) < 0 ||
549554
ctnetlink_dump_use(skb, ct) < 0 ||
@@ -722,7 +727,6 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
722727
struct sk_buff *skb;
723728
unsigned int type;
724729
unsigned int flags = 0, group;
725-
u32 mark;
726730
int err;
727731

728732
if (events & (1 << IPCT_DESTROY)) {
@@ -827,9 +831,8 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
827831
}
828832

829833
#ifdef CONFIG_NF_CONNTRACK_MARK
830-
mark = READ_ONCE(ct->mark);
831-
if ((events & (1 << IPCT_MARK) || mark) &&
832-
ctnetlink_dump_mark(skb, mark) < 0)
834+
if (events & (1 << IPCT_MARK) &&
835+
ctnetlink_dump_mark(skb, ct) < 0)
833836
goto nla_put_failure;
834837
#endif
835838
nlmsg_end(skb, nlh);
@@ -2671,7 +2674,6 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
26712674
{
26722675
const struct nf_conntrack_zone *zone;
26732676
struct nlattr *nest_parms;
2674-
u32 mark;
26752677

26762678
zone = nf_ct_zone(ct);
26772679

@@ -2733,8 +2735,7 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
27332735
goto nla_put_failure;
27342736

27352737
#ifdef CONFIG_NF_CONNTRACK_MARK
2736-
mark = READ_ONCE(ct->mark);
2737-
if (mark && ctnetlink_dump_mark(skb, mark) < 0)
2738+
if (ctnetlink_dump_mark(skb, ct) < 0)
27382739
goto nla_put_failure;
27392740
#endif
27402741
if (ctnetlink_dump_labels(skb, ct) < 0)

0 commit comments

Comments
 (0)