Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp319807lqs; Tue, 5 Mar 2024 03:06:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVcHAHkKeLW0R9RA1ArMXmXKVv+tbzrkCY6Dmr63RoBbYP/HQuCPqZAC3bpofYekERAlKfJyXb7oZTpsF7WPalYkYJWClwQAoZIzkrb8w== X-Google-Smtp-Source: AGHT+IHUd6JjwQ3sqNSUgs0uu8+FtMIIY0gzspinLOLDevhlQLp35COcafrocMNhvb/LjPGJcC1A X-Received: by 2002:ac8:5a4d:0:b0:42e:d58e:82dd with SMTP id o13-20020ac85a4d000000b0042ed58e82ddmr1607205qta.27.1709636797872; Tue, 05 Mar 2024 03:06:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709636797; cv=pass; d=google.com; s=arc-20160816; b=Wg1BkWySnO50cIpTdeRCK+J2zrUBhKqb6mweEWim3Ql+pTK/lFA+LIqgujgNcJwxjl LCV4jrSGxzkTfDpEEB/9R7mdHr7dXM2KxEnEga7pv2okYj8bjz0dBcVzkNd/UxNwJRES GfNdxsjkMZQYsGX5p5Q/lNfDW/otOKl7N/uwEw+iaH7NmqRRP5TyEUhYWIvbNnFW1sxi frnYyuz6CpoJm9+tBIlagSurEiFd69ISDBGcxq/Ln2E7ROSl+3mw+IZ1cI+PAj35z5s2 Trk1cfTu0ynAvus2k76uobqbuHtByPMtoYfETo9fxTjrm/CydtqoN4PteSjo5fcAjDTv y6/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=JkRSc2M/zWBEYRvdzMjpBlOo19y04oPAiC91L0JFx/w=; fh=mSqpdfFg+JtRicDWyEuhzFxllnyh2czrFlr/MmTB+MY=; b=e889og6jSvkLv1IUv38hW27L//4j9H+QFtXXWio1xltVF3cizdxWmN1WRnhy1/udEp d3ef8ZF0ypii6bIKT5CBu9tVhOrIThtsgPGjIAoHr8IL9LMNPqEZfSW4guka/xOQvzxs Y/VZJe+0apPBY7OBHRnVq30ACsd4+gJWspN+z5rpqjYFdYPzI1Gd//BEU1mQSfmN1dZD ORCyjh704Ew5TruaE/np3ni2r7YZ6qXxkaYK2ikeSDPLe1aA35847vfvbf91Wch/Olgn ZzfQM+HNSkOXjpeGD4Ny2F+uaP338SJr/4Z6rNkGJWLEkw3/j4oPeARw7jd3hxYBB7Bp jwEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eXme+5hK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92215-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n22-20020a05622a11d600b0042eadbe014esi12289701qtk.89.2024.03.05.03.06.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:06:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eXme+5hK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92215-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9A09D1C20C39 for ; Tue, 5 Mar 2024 11:06:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5F9F5B5BA; Tue, 5 Mar 2024 11:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eXme+5hK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E6B835B20F; Tue, 5 Mar 2024 11:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709636690; cv=none; b=qT2ME+Nl+uw7paY9EKFF3Oi5ciJYUmmxPBP+EleUd7tNu9zb2SXFeL7KtcXjZQ5yNJRdsGC6dBU5jf2ODQhPw+K6C8mBqUTpFICiwYT1mPyK/joiIE/Q7pZ4drGtMg7IOQMtrtprXJM0AlQrfLlGaOQNhppJbXLxM6ttLWr4PVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709636690; c=relaxed/simple; bh=SR02P7ZjycQ0WA/qACfPhFmEuLcrv2LV85aCKTnWlH4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l29ckcQAYpK4sJlUH2RuNvtraAZvGEn/pBSSrmvjG2Rbc+a+2Ha0g8O+9dfOiM9a+3cdEgxIOsKWbB+p6f5KIsApH/ejsQlFCj/NVj+7866SnwgEKrv9oeBrp/COXqcLKVLFJMecd1FdjKkJuGyvw7AKalt6fpmmXfYMva1THpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eXme+5hK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12F26C433F1; Tue, 5 Mar 2024 11:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709636689; bh=SR02P7ZjycQ0WA/qACfPhFmEuLcrv2LV85aCKTnWlH4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eXme+5hKyN1CbU61OeHxp1d2p0O5RSx7DZMvgYo+Hqu/FTB7o9qiLCkPlnoBpld7S u/A4yhPVwEyhHsRXlK6l/ymSXixiEdE3udYKDkjsAYeR9mrHQULdZ7b7frdAi0+eCM Aekf0mY/Xwr+UvcvWGeScDhZ31P5c413e4d8SOwf6t0YFY8rgVkeaqSJibgMjpMn6a 5tTIEZXOpoK5sbBtQhit2fg23N2wflaBs8Ehxiwsv0WXvVtm35j12/q2ZIg4wiqefy E25YUUEUJBDHO+dz+iNsuGzlwdMuuq/CgwyqnCO1Z9GskxnRhQtx1u7J0yyDwTaS6n rGGXCVtdDZAhQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 05 Mar 2024 12:04:32 +0100 Subject: [PATCH net-next 3/4] mptcp: set error messages for set_flags Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240305-upstream-net-next-20240304-mptcp-misc-cleanup-v1-3-c436ba5e569b@kernel.org> References: <20240305-upstream-net-next-20240304-mptcp-misc-cleanup-v1-0-c436ba5e569b@kernel.org> In-Reply-To: <20240305-upstream-net-next-20240304-mptcp-misc-cleanup-v1-0-c436ba5e569b@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Geliang Tang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2584; i=matttbe@kernel.org; h=from:subject:message-id; bh=JweTqcXP1xdyvdf6NgU0IrJbdbJn8RoJdxUpyS0t0pM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl5vxDUoyU0GvJ2GdK9lieXgEEjzXeT0i5SznEP XWBPdoqfuGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeb8QwAKCRD2t4JPQmmg czFKEADHOui264xrXbXWVU5Q+NBiKp2u3AXg9P0PERZdK81hNtahMdUnuNtAgCi1+SdWGqXoIC9 R8SJCGB3MRd+KJS2xX+Qj++JhGcMrDVr3/DKjX2lOU0vF23NstPOkX00FvVqib3zVxyoIdsJcXl JPrgLiBpF8Ss7rtwT0ugnWHyWFw7nbh9djV1Y3O9LUaV762Mezr5bPJtOKaVLRCuHztuiRh4uSL fKTLTDHr4yfxg/rU0pZqqkFcbApJqkbe13h+CWDlNs5IofXpRemy0I7M/R7rfpRNZIop863Gs9K nuXMbBAKwun5bCrdSVF1YrfSowaGcwzb5Rd7oS50pQ0roAyhO04FEd/P92VJVwBs9Tf4BWmsFw7 +o42nl+79xiya4sNUphVWN0cIw1umGLMdwORBv+m/g/N6gS5siJm1SJjDc5Nsg33FI4cvUaGFXy H7qXTaeIF77Kc6vdmKfnZjtgd3vIJ3Wkb2aneRZ1QeUWJHTVOFNElx1EqcBp5IX+njGohXznueH cR3dlvWzAYCqm7JG9dC68ZsoJeDjRRPyvxFaFmS83nQMqTe2WCWPrZ6qjcGrjTx2Zs7040hnaua DpXXP2LIv+LHRtTYhP6fczjqL652SEwsy567q0e9QLYlqwxyQKEyI7zkglNsn//ITaMxzFibJq2 IWVF2dt8Vagf6PA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang In addition to returning the error value, this patch also sets an error messages with GENL_SET_ERR_MSG or NL_SET_ERR_MSG_ATTR both for pm_netlink.c and pm_userspace.c. It will help the userspace to identify the issue. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 6 +++++- net/mptcp/pm_userspace.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index c799fe84dfd3..354083b8386f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1908,8 +1908,10 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) if (addr.addr.family == AF_UNSPEC) { lookup_by_id = 1; - if (!addr.addr.id) + if (!addr.addr.id) { + GENL_SET_ERR_MSG(info, "missing required inputs"); return -EOPNOTSUPP; + } } if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) @@ -1919,11 +1921,13 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) entry = __lookup_addr(pernet, &addr.addr, lookup_by_id); if (!entry) { spin_unlock_bh(&pernet->lock); + GENL_SET_ERR_MSG(info, "address not found"); return -EINVAL; } if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { spin_unlock_bh(&pernet->lock); + GENL_SET_ERR_MSG(info, "invalid addr flags"); return -EINVAL; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 7ef3b69852f0..9f5d422d5ef6 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -563,13 +563,17 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) token_val = nla_get_u32(token); msk = mptcp_token_get_sock(net, token_val); - if (!msk) + if (!msk) { + NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token"); return ret; + } sk = (struct sock *)msk; - if (!mptcp_pm_is_userspace(msk)) + if (!mptcp_pm_is_userspace(msk)) { + GENL_SET_ERR_MSG(info, "userspace PM not selected"); goto set_flags_err; + } ret = mptcp_pm_parse_entry(attr, info, false, &loc); if (ret < 0) @@ -583,6 +587,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) if (loc.addr.family == AF_UNSPEC || rem.addr.family == AF_UNSPEC) { + GENL_SET_ERR_MSG(info, "invalid address families"); ret = -EINVAL; goto set_flags_err; } -- 2.43.0