Skip to content

Commit b7c2d79

Browse files
Phil Sutterummakynes
authored andcommitted
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 <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 2a67414 commit b7c2d79

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,8 @@ struct nft_hook {
12011201
struct list_head list;
12021202
struct nf_hook_ops ops;
12031203
struct rcu_head rcu;
1204+
char ifname[IFNAMSIZ];
1205+
u8 ifnamelen;
12041206
};
12051207

12061208
/**

net/netfilter/nf_tables_api.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,7 +2276,6 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net,
22762276
const struct nlattr *attr)
22772277
{
22782278
struct net_device *dev;
2279-
char ifname[IFNAMSIZ];
22802279
struct nft_hook *hook;
22812280
int err;
22822281

@@ -2286,12 +2285,17 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net,
22862285
goto err_hook_alloc;
22872286
}
22882287

2289-
nla_strscpy(ifname, attr, IFNAMSIZ);
2288+
err = nla_strscpy(hook->ifname, attr, IFNAMSIZ);
2289+
if (err < 0)
2290+
goto err_hook_dev;
2291+
2292+
hook->ifnamelen = nla_len(attr);
2293+
22902294
/* nf_tables_netdev_event() is called under rtnl_mutex, this is
22912295
* indirectly serializing all the other holders of the commit_mutex with
22922296
* the rtnl_mutex.
22932297
*/
2294-
dev = __dev_get_by_name(net, ifname);
2298+
dev = __dev_get_by_name(net, hook->ifname);
22952299
if (!dev) {
22962300
err = -ENOENT;
22972301
goto err_hook_dev;

0 commit comments

Comments
 (0)