Skip to content

Commit 880ccec

Browse files
Phil Sutterummakynes
authored andcommitted
netfilter: nf_tables: Use stored ifname in netdev hook dumps
The stored ifname and ops.dev->name may deviate after creation due to interface name changes. Prefer the more deterministic stored name in dumps which also helps avoiding inadvertent changes to stored ruleset dumps. Signed-off-by: Phil Sutter <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent b7c2d79 commit 880ccec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,15 +1956,16 @@ static int nft_dump_basechain_hook(struct sk_buff *skb,
19561956
if (!first)
19571957
first = hook;
19581958

1959-
if (nla_put_string(skb, NFTA_DEVICE_NAME,
1960-
hook->ops.dev->name))
1959+
if (nla_put(skb, NFTA_DEVICE_NAME,
1960+
hook->ifnamelen, hook->ifname))
19611961
goto nla_put_failure;
19621962
n++;
19631963
}
19641964
nla_nest_end(skb, nest_devs);
19651965

19661966
if (n == 1 &&
1967-
nla_put_string(skb, NFTA_HOOK_DEV, first->ops.dev->name))
1967+
nla_put(skb, NFTA_HOOK_DEV,
1968+
first->ifnamelen, first->ifname))
19681969
goto nla_put_failure;
19691970
}
19701971
nla_nest_end(skb, nest);
@@ -9324,7 +9325,8 @@ static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net,
93249325

93259326
list_for_each_entry_rcu(hook, hook_list, list,
93269327
lockdep_commit_lock_is_held(net)) {
9327-
if (nla_put_string(skb, NFTA_DEVICE_NAME, hook->ops.dev->name))
9328+
if (nla_put(skb, NFTA_DEVICE_NAME,
9329+
hook->ifnamelen, hook->ifname))
93289330
goto nla_put_failure;
93299331
}
93309332
nla_nest_end(skb, nest_devs);

0 commit comments

Comments
 (0)