From patchwork Wed Mar 12 01:38:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 14012806 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp-fw-80006.amazon.com (smtp-fw-80006.amazon.com [99.78.197.217]) (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 479D4A31 for ; Wed, 12 Mar 2025 01:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=99.78.197.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741743556; cv=none; b=ESAqwiHnR1RcynA/FQBUog4YZwCrm2Pax5IZhUQKjxLRw3FbvqFGi5RiExurBGUInxOzU4Tj+D/7NgOLMWL64y+UrDgPo9tm99knJmP/wrRlCzvpxZDIYlSfbaanPjVGaz8pFZXFDcSxzzfTrs2r7HdOEbH89w1SDEKOyi5Vp5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741743556; c=relaxed/simple; bh=Jlsma3wIhZPAQnUzqxZ4TB1b4KFGtSg+uyFNYWA/ulg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=uAH77TPgMCDceFZswDuJNTc1WPmJfyWTX4UPrrJBDxwW8fGVqIuacqNvoTv5lO+C8xW8uTmDduKHGCw01gGzhXGiQbN7IEmLlQU6DnMr+hltR+dD2c6CyQgjrg9KG9dPHj3TiysLpL1gGZNTlQ7E6NeI1rMDnC2SpADoISCMS3o= 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=Ejdohutu; arc=none smtp.client-ip=99.78.197.217 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="Ejdohutu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1741743553; x=1773279553; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=vZfPsVMwxypSEG+zutJKV+0qgxxpfdY8t/MLoIGY3iI=; b=EjdohutuRpIqLX8cVJUwdqjvZ9sQvlXLmfqUc45JN+pYA7Z/sUXj50MH LOK5g9aRuMDLsxNrZ6EqVFRAohQswJx2Dco9XPEyytDffcAjn9D5tHinP 7imY3mOYgOiYtlN1+tXFgyqYr1N2KDlHS6woRhmvwRxcTqqelzbCb/VfM 8=; X-IronPort-AV: E=Sophos;i="6.14,240,1736812800"; d="scan'208";a="31122537" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.214]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2025 01:39:11 +0000 Received: from EX19MTAUWA001.ant.amazon.com [10.0.38.20:42991] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.52.235:2525] with esmtp (Farcaster) id 8236a439-c458-439a-bf31-4ef2efba2c7a; Wed, 12 Mar 2025 01:39:10 +0000 (UTC) X-Farcaster-Flow-ID: 8236a439-c458-439a-bf31-4ef2efba2c7a Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWA001.ant.amazon.com (10.250.64.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Wed, 12 Mar 2025 01:39:07 +0000 Received: from 6c7e67bfbae3.amazon.com (10.88.128.133) 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.1544.14; Wed, 12 Mar 2025 01:39:04 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Simon Horman CC: Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 net] ipv6: Set errno after ip_fib_metrics_init() in ip6_route_info_create(). Date: Tue, 11 Mar 2025 18:38:48 -0700 Message-ID: <20250312013854.61125-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D038UWB003.ant.amazon.com (10.13.139.157) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Patchwork-Delegate: kuba@kernel.org While creating a new IPv6, we could get a weird -ENOMEM when RTA_NH_ID is set and either of the conditions below is true: 1) CONFIG_IPV6_SUBTREES is enabled and rtm_src_len is specified 2) nexthop_get() fails e.g.) # strace ip -6 route add fe80::dead:beef:dead:beef nhid 1 from :: recvmsg(3, {msg_iov=[{iov_base=[...[ {error=-ENOMEM, msg=[... [...]]}, [{nla_len=49, nla_type=NLMSGERR_ATTR_MSG}, "Nexthops can not be used with so"...] ]], iov_len=32768}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 148 Let's set err explicitly after ip_fib_metrics_init() in ip6_route_info_create(). Fixes: f88d8ea67fbd ("ipv6: Plumb support for nexthop object in a fib6_info") Signed-off-by: Kuniyuki Iwashima Reviewed-by: David Ahern --- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index bc6bcf5d7133..15ce21afc8c6 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3803,10 +3803,12 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, if (nh) { if (rt->fib6_src.plen) { NL_SET_ERR_MSG(extack, "Nexthops can not be used with source routing"); + err = -EINVAL; goto out_free; } if (!nexthop_get(nh)) { NL_SET_ERR_MSG(extack, "Nexthop has been deleted"); + err = -ENOENT; goto out_free; } rt->nh = nh;