For the sake of simplicity, treat them like consecutive NETDEV_REGISTER and NETDEV_UNREGISTER events. If the new name matches a hook spec and registration fails, escalate the error and keep things as they are. Signed-off-by: Phil Sutter <phil@xxxxxx> --- Changes since v3: - Register first and handle errors to avoid having unregistered the device but registration fails. --- net/netfilter/nf_tables_api.c | 5 +++++ net/netfilter/nft_chain_filter.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 2684990dd3dc..4d40c1905735 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -9371,6 +9371,11 @@ static int nf_tables_flowtable_event(struct notifier_block *this, struct nft_table *table; struct net *net; + if (event == NETDEV_CHANGENAME) { + if (nf_tables_flowtable_event(this, NETDEV_REGISTER, ptr)) + return NOTIFY_BAD; + event = NETDEV_UNREGISTER; + } if (event != NETDEV_REGISTER && event != NETDEV_UNREGISTER) return NOTIFY_DONE; diff --git a/net/netfilter/nft_chain_filter.c b/net/netfilter/nft_chain_filter.c index 562af2773a66..0f5706addfcb 100644 --- a/net/netfilter/nft_chain_filter.c +++ b/net/netfilter/nft_chain_filter.c @@ -373,6 +373,11 @@ static int nf_tables_netdev_event(struct notifier_block *this, .net = dev_net(dev), }; + if (event == NETDEV_CHANGENAME) { + if (nf_tables_netdev_event(this, NETDEV_REGISTER, ptr)) + return NOTIFY_BAD; + event = NETDEV_UNREGISTER; + } if (event != NETDEV_REGISTER && event != NETDEV_UNREGISTER) return NOTIFY_DONE; -- 2.43.0