diff options
author | Phil Sutter <phil@nwl.cc> | 2025-01-09 18:31:33 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-01-19 16:41:53 +0100 |
commit | b7c2d793c28cda7dbb67d6b427e3280b7c1e601a (patch) | |
tree | dbb4ff3cf5a2bd60c692a91d1b9e760de2c20b49 /net | |
parent | 2a67414a143e120527e17f8372f13d3b31eeb5a3 (diff) | |
download | linux-b7c2d793c28cda7dbb67d6b427e3280b7c1e601a.tar.gz linux-b7c2d793c28cda7dbb67d6b427e3280b7c1e601a.tar.bz2 linux-b7c2d793c28cda7dbb67d6b427e3280b7c1e601a.zip |
netfilter: nf_tables: Store user-defined hook ifname
Prepare for hooks with NULL ops.dev pointer (due to non-existent device)
and store the interface name and length as specified by the user upon
creation. No functional change intended.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nf_tables_api.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index e41c77e5eefd..95d8d33589b1 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -2276,7 +2276,6 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net, const struct nlattr *attr) { struct net_device *dev; - char ifname[IFNAMSIZ]; struct nft_hook *hook; int err; @@ -2286,12 +2285,17 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net, goto err_hook_alloc; } - nla_strscpy(ifname, attr, IFNAMSIZ); + err = nla_strscpy(hook->ifname, attr, IFNAMSIZ); + if (err < 0) + goto err_hook_dev; + + hook->ifnamelen = nla_len(attr); + /* nf_tables_netdev_event() is called under rtnl_mutex, this is * indirectly serializing all the other holders of the commit_mutex with * the rtnl_mutex. */ - dev = __dev_get_by_name(net, ifname); + dev = __dev_get_by_name(net, hook->ifname); if (!dev) { err = -ENOENT; goto err_hook_dev; |