6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yang Li [ Upstream commit 67059b61597c004e23b074547b40604222bee3a0 ] The code that uses nft_net has been removed, and the nft_pernet function is merely obtaining a reference to shared data through the net pointer. The content of the net pointer is not modified or changed, so both of them should be removed. silence the warning: net/netfilter/nft_set_rbtree.c:627:26: warning: variable ‘nft_net’ set but not used Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7103 Signed-off-by: Yang Li Reviewed-by: Simon Horman Signed-off-by: Pablo Neira Ayuso Stable-dep-of: 7904b94768e9 ("netfilter: nf_tables: don't queue packet path object notifications") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 28 +++++++++++++++------------- net/netfilter/nft_set_rbtree.c | 2 -- 2 files changed, 15 insertions(+), 15 deletions(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -922,11 +922,11 @@ nf_tables_chain_type_lookup(struct net * return ERR_PTR(-ENOENT); } -static __be16 nft_base_seq(const struct net *net) +static unsigned int nft_base_seq(const struct net *net) { struct nftables_pernet *nft_net = nft_pernet(net); - return htons(nft_net->base_seq & 0xffff); + return READ_ONCE(nft_net->base_seq); } static const struct nla_policy nft_table_policy[NFTA_TABLE_MAX + 1] = { @@ -946,7 +946,7 @@ static int nf_tables_fill_table_info(str event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, event, flags, family, - NFNETLINK_V0, nft_base_seq(net)); + NFNETLINK_V0, htons(nft_base_seq(net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -1789,7 +1789,7 @@ static int nf_tables_fill_chain_info(str event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, event, flags, family, - NFNETLINK_V0, nft_base_seq(net)); + NFNETLINK_V0, htons(nft_base_seq(net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -3398,7 +3398,7 @@ static int nf_tables_fill_rule_info(stru u16 type = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, type, flags, family, NFNETLINK_V0, - nft_base_seq(net)); + htons(nft_base_seq(net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -4593,7 +4593,8 @@ static int nf_tables_fill_set(struct sk_ event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, event, flags, ctx->family, - NFNETLINK_V0, nft_base_seq(ctx->net)); + NFNETLINK_V0, + htons(nft_base_seq(ctx->net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -5938,7 +5939,8 @@ static int nf_tables_dump_set(struct sk_ seq = cb->nlh->nlmsg_seq; nlh = nfnl_msg_put(skb, portid, seq, event, NLM_F_MULTI, - table->family, NFNETLINK_V0, nft_base_seq(net)); + table->family, NFNETLINK_V0, + htons(nft_base_seq(net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -6018,7 +6020,8 @@ static int nf_tables_fill_setelem_info(s event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, event, flags, ctx->family, - NFNETLINK_V0, nft_base_seq(ctx->net)); + NFNETLINK_V0, + htons(nft_base_seq(ctx->net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -7838,7 +7841,7 @@ static int nf_tables_fill_obj_info(struc event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, event, flags, family, - NFNETLINK_V0, nft_base_seq(net)); + NFNETLINK_V0, htons(nft_base_seq(net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -8205,9 +8208,8 @@ void nft_obj_notify(struct net *net, con struct nft_object *obj, u32 portid, u32 seq, int event, u16 flags, int family, int report, gfp_t gfp) { - struct nftables_pernet *nft_net = nft_pernet(net); char *buf = kasprintf(gfp, "%s:%u", - table->name, nft_net->base_seq); + table->name, nft_base_seq(net)); audit_log_nfcfg(buf, family, @@ -8872,7 +8874,7 @@ static int nf_tables_fill_flowtable_info event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event); nlh = nfnl_msg_put(skb, portid, seq, event, flags, family, - NFNETLINK_V0, nft_base_seq(net)); + NFNETLINK_V0, htons(nft_base_seq(net) & 0xffff)); if (!nlh) goto nla_put_failure; @@ -9119,7 +9121,7 @@ static int nf_tables_fill_gen_info(struc int event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, NFT_MSG_NEWGEN); nlh = nfnl_msg_put(skb, portid, seq, event, 0, AF_UNSPEC, - NFNETLINK_V0, nft_base_seq(net)); + NFNETLINK_V0, htons(nft_base_seq(net) & 0xffff)); if (!nlh) goto nla_put_failure; --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c @@ -653,7 +653,6 @@ static void nft_rbtree_gc(struct nft_set { struct nft_rbtree *priv = nft_set_priv(set); struct nft_rbtree_elem *rbe, *rbe_end = NULL; - struct nftables_pernet *nft_net; struct net *net = read_pnet(&set->net); u64 tstamp = nft_net_tstamp(net); struct rb_node *node, *next; @@ -661,7 +660,6 @@ static void nft_rbtree_gc(struct nft_set set = nft_set_container_of(priv); net = read_pnet(&set->net); - nft_net = nft_pernet(net); gc = nft_trans_gc_alloc(set, 0, GFP_KERNEL); if (!gc)