From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E24C0BA41 for ; Thu, 3 Oct 2024 20:59:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=99.78.197.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727989183; cv=none; b=pL6cOmbRX1MHoVm4gHo5kRcfFo/5+agScYuj5z2MDnXzx5H2LdCN9T2zX3acqFxm7kErQd9iojYn8Tn/FU9qt4OhaxlQRr/AfxtASP0cgfsAu1P1JawU095w3PszGn+oufk5XrJza0nPctG81CooM5fT5b3Fvk+kfk3cfZAtE/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727989183; c=relaxed/simple; bh=NY22pid3HCXxCIj/1IGFv3Tr+qHCbmOKbapuFit7Zrw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q1QiO0V+KBizRuS3KroVpY3fBNRJk56ed6rwRwOBLc27TFTdLxLRXZcbcbFEKFv3DSwOqGreAK5+otKpGF3t8+s4w6+jgILs/vNRYtT1XH6qylLCJTiwmYXEigFTAPB05DH+9bvKVMrP6DrRGe5ZsIPTYGmkp1ETzsaRyOC1IHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=C/3RdY92; arc=none smtp.client-ip=99.78.197.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="C/3RdY92" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1727989182; x=1759525182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PLSfPFBVZvMGJqC5yh1/Qa5hnsbwA8Ea18CHwsSjSBQ=; b=C/3RdY92tlHE32Xj0Sge6VZ2fEExfEfRgRgrUubN2O2+QJgY7rKsPQHh gllYMdA/fCBlPdUIQ42D97PG3jGjy4zLvUjoVI51xodui6GXy3ecSWnAE EJHKKnF4+qJwG0xA6UOMQ4XKueXkotmGOYpPUjaDDGCLFiuu5tg7aQVzP 4=; X-IronPort-AV: E=Sophos;i="6.11,175,1725321600"; d="scan'208";a="339352287" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2024 20:59:42 +0000 Received: from EX19MTAUWC002.ant.amazon.com [10.0.38.20:51524] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.57.100:2525] with esmtp (Farcaster) id 360a1209-3e0a-46ce-a143-bc1f963db33d; Thu, 3 Oct 2024 20:59:41 +0000 (UTC) X-Farcaster-Flow-ID: 360a1209-3e0a-46ce-a143-bc1f963db33d Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWC002.ant.amazon.com (10.250.64.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Thu, 3 Oct 2024 20:59:40 +0000 Received: from 88665a182662.ant.amazon.com (10.187.171.32) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.35; Thu, 3 Oct 2024 20:59:37 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni CC: Kuniyuki Iwashima , Kuniyuki Iwashima , , "Eric W. Biederman" Subject: [PATCH v1 net 5/6] mpls: Handle error of rtnl_register_module(). Date: Thu, 3 Oct 2024 13:57:24 -0700 Message-ID: <20241003205725.5612-6-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241003205725.5612-1-kuniyu@amazon.com> References: <20241003205725.5612-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D038UWC002.ant.amazon.com (10.13.139.238) To EX19D004ANA001.ant.amazon.com (10.37.240.138) Since introduced, mpls_init() has been ignoring the returned value of rtnl_register_module(), which could fail. Let's handle the errors by rtnl_register_module_many(). Fixes: 03c0566542f4 ("mpls: Netlink commands to add, remove, and dump routes") Signed-off-by: Kuniyuki Iwashima --- Cc: "Eric W. Biederman" --- net/mpls/af_mpls.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index aba983531ed3..653897327165 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -2728,6 +2728,15 @@ static struct rtnl_af_ops mpls_af_ops __read_mostly = { .get_stats_af_size = mpls_get_stats_af_size, }; +static struct rtnl_msg_handler mpls_rtnl_msg_handlers[] = { + {PF_MPLS, RTM_NEWROUTE, mpls_rtm_newroute, NULL, 0}, + {PF_MPLS, RTM_DELROUTE, mpls_rtm_delroute, NULL, 0}, + {PF_MPLS, RTM_GETROUTE, mpls_getroute, mpls_dump_routes, 0}, + {PF_MPLS, RTM_GETNETCONF, + mpls_netconf_get_devconf, mpls_netconf_dump_devconf, + RTNL_FLAG_DUMP_UNLOCKED}, +}; + static int __init mpls_init(void) { int err; @@ -2746,24 +2755,25 @@ static int __init mpls_init(void) rtnl_af_register(&mpls_af_ops); - rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_NEWROUTE, - mpls_rtm_newroute, NULL, 0); - rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_DELROUTE, - mpls_rtm_delroute, NULL, 0); - rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_GETROUTE, - mpls_getroute, mpls_dump_routes, 0); - rtnl_register_module(THIS_MODULE, PF_MPLS, RTM_GETNETCONF, - mpls_netconf_get_devconf, - mpls_netconf_dump_devconf, - RTNL_FLAG_DUMP_UNLOCKED); - err = ipgre_tunnel_encap_add_mpls_ops(); + err = rtnl_register_module_many(mpls_rtnl_msg_handlers); if (err) + goto out_unregister_rtnl_af; + + err = ipgre_tunnel_encap_add_mpls_ops(); + if (err) { pr_err("Can't add mpls over gre tunnel ops\n"); + goto out_unregister_rtnl; + } err = 0; out: return err; +out_unregister_rtnl: + rtnl_unregister_many(mpls_rtnl_msg_handlers); +out_unregister_rtnl_af: + rtnl_af_unregister(&mpls_af_ops); + dev_remove_pack(&mpls_packet_type); out_unregister_pernet: unregister_pernet_subsys(&mpls_net_ops); goto out; -- 2.30.2