From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDCC2C6FD1F for ; Thu, 16 Mar 2023 22:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbjCPWCm (ORCPT ); Thu, 16 Mar 2023 18:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCPWCk (ORCPT ); Thu, 16 Mar 2023 18:02:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A73F56A9E4; Thu, 16 Mar 2023 15:02:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 42AC6620F9; Thu, 16 Mar 2023 22:02:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45240C433D2; Thu, 16 Mar 2023 22:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679004158; bh=kpHgwiAqIDraPVYtTQGcOgmprbnNh5n+bh7bORuwKUs=; h=From:To:Cc:Subject:Date:From; b=VALRbTK1xosyl1FEm3VF2DRvYFJmrP0fecPjaGvb6KsLZ54OTYl/6uF0sJGgvsrul YgwXA+drdIGKtMMzOZkc7cxAVekxHJJ1V4rdaQNm522Epnms4omex0MdIhbI6vPtTy q6DKJZXNW5zl8Vp/BHW5/boUl77zY4qnPodpl80Z34vUxAWRAeCckIPoXRI2+yLinw vL+gUyvB82qEGzcGVD+HDz5eCSkIYr0CB77U/kI9E2JUX2aS6RCHkbQe9AzRx9J0aV ZjKsqQYcNKGiLQ6QZhy6aMX8NUyIIQJqKsdh6nYNGPPDFcJ+Q4dgBA0zTCS8P4SkdF qe4P4JVocGLew== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, Jakub Kicinski , ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, lorenzo@kernel.org, tariqt@nvidia.com, bpf@vger.kernel.org Subject: [PATCH net v2] net: xdp: don't call notifiers during driver init Date: Thu, 16 Mar 2023 15:02:34 -0700 Message-Id: <20230316220234.598091-1-kuba@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Drivers will commonly perform feature setting during init, if they use the xdp_set_features_flag() helper they'll likely run into an ASSERT_RTNL() inside call_netdevice_notifiers_info(). Don't call the notifier until the device is actually registered. Nothing should be tracking the device until its registered and after its unregistration has started. Fixes: 4d5ab0ad964d ("net/mlx5e: take into account device reconfiguration for xdp_features flag") Signed-off-by: Jakub Kicinski --- v2: only call for REGISTERED devices, not dead ones v1: https://lore.kernel.org/all/20230316002903.492497-1-kuba@kernel.org/ CC: ast@kernel.org CC: daniel@iogearbox.net CC: hawk@kernel.org CC: john.fastabend@gmail.com CC: lorenzo@kernel.org CC: tariqt@nvidia.com CC: bpf@vger.kernel.org --- net/core/xdp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/core/xdp.c b/net/core/xdp.c index 87e654b7d06c..b5737e47ec41 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -781,7 +781,9 @@ void xdp_set_features_flag(struct net_device *dev, xdp_features_t val) return; dev->xdp_features = val; - call_netdevice_notifiers(NETDEV_XDP_FEAT_CHANGE, dev); + + if (dev->reg_state == NETREG_REGISTERED) + call_netdevice_notifiers(NETDEV_XDP_FEAT_CHANGE, dev); } EXPORT_SYMBOL_GPL(xdp_set_features_flag); -- 2.39.2