Commit b8088dda authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: nf_tables: use dev->name directly

no need to store the name in separate area.

Furthermore, it uses kmalloc but not kfree and most accesses seem to treat
it as char[IFNAMSIZ] not char *.

Remove this and use dev->name instead.

In case event zeroed dev, just omit the name in the dump.

Fixes: d92191aa ("netfilter: nf_tables: cache device name in flowtable object")
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent c293ac95
...@@ -1124,7 +1124,6 @@ struct nft_flowtable { ...@@ -1124,7 +1124,6 @@ struct nft_flowtable {
u32 genmask:2, u32 genmask:2,
use:30; use:30;
u64 handle; u64 handle;
char *dev_name[NFT_FLOWTABLE_DEVICE_MAX];
/* runtime data below here */ /* runtime data below here */
struct nf_hook_ops *ops ____cacheline_aligned; struct nf_hook_ops *ops ____cacheline_aligned;
struct nf_flowtable data; struct nf_flowtable data;
......
...@@ -5324,8 +5324,6 @@ static int nf_tables_flowtable_parse_hook(const struct nft_ctx *ctx, ...@@ -5324,8 +5324,6 @@ static int nf_tables_flowtable_parse_hook(const struct nft_ctx *ctx,
flowtable->ops[i].priv = &flowtable->data; flowtable->ops[i].priv = &flowtable->data;
flowtable->ops[i].hook = flowtable->data.type->hook; flowtable->ops[i].hook = flowtable->data.type->hook;
flowtable->ops[i].dev = dev_array[i]; flowtable->ops[i].dev = dev_array[i];
flowtable->dev_name[i] = kstrdup(dev_array[i]->name,
GFP_KERNEL);
} }
return err; return err;
...@@ -5483,10 +5481,8 @@ static int nf_tables_newflowtable(struct net *net, struct sock *nlsk, ...@@ -5483,10 +5481,8 @@ static int nf_tables_newflowtable(struct net *net, struct sock *nlsk,
err6: err6:
i = flowtable->ops_len; i = flowtable->ops_len;
err5: err5:
for (k = i - 1; k >= 0; k--) { for (k = i - 1; k >= 0; k--)
kfree(flowtable->dev_name[k]);
nf_unregister_net_hook(net, &flowtable->ops[k]); nf_unregister_net_hook(net, &flowtable->ops[k]);
}
kfree(flowtable->ops); kfree(flowtable->ops);
err4: err4:
...@@ -5585,9 +5581,10 @@ static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net, ...@@ -5585,9 +5581,10 @@ static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net,
goto nla_put_failure; goto nla_put_failure;
for (i = 0; i < flowtable->ops_len; i++) { for (i = 0; i < flowtable->ops_len; i++) {
if (flowtable->dev_name[i][0] && const struct net_device *dev = READ_ONCE(flowtable->ops[i].dev);
nla_put_string(skb, NFTA_DEVICE_NAME,
flowtable->dev_name[i])) if (dev &&
nla_put_string(skb, NFTA_DEVICE_NAME, dev->name))
goto nla_put_failure; goto nla_put_failure;
} }
nla_nest_end(skb, nest_devs); nla_nest_end(skb, nest_devs);
...@@ -5829,7 +5826,6 @@ static void nft_flowtable_event(unsigned long event, struct net_device *dev, ...@@ -5829,7 +5826,6 @@ static void nft_flowtable_event(unsigned long event, struct net_device *dev,
continue; continue;
nf_unregister_net_hook(dev_net(dev), &flowtable->ops[i]); nf_unregister_net_hook(dev_net(dev), &flowtable->ops[i]);
flowtable->dev_name[i][0] = '\0';
flowtable->ops[i].dev = NULL; flowtable->ops[i].dev = NULL;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment