Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2077642ybl; Thu, 5 Dec 2019 11:35:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzd6vH+XtPApNQO7nEXdr4aJGEmuIQhbzsfmXmh6G05vHVXx5fWVzrBPktNr5w2zQ35RIZ/ X-Received: by 2002:a9d:4789:: with SMTP id b9mr8346476otf.110.1575574513114; Thu, 05 Dec 2019 11:35:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575574513; cv=none; d=google.com; s=arc-20160816; b=L2HhORPGEMnDV4XtCIKU6l2PG9uhK8Bn7u1oS3qGTxP/BHp32uAJQ2512LSfhjyUc2 RybPzRmPNjs6/QgiovGCXzIWi0SVQEeet0NoVJwpnx67XrNehMUFYVPwBXg+zrNBb0rU od99EI1tn7mbmeceYMNPoliC/Oi3DjC10jtOq0tJIdTCx+CRRCzYbJK/x5me1aWMRbOT lXYNwZgH3+0rMnM/foxvNumcoPgT8yb9ZTnh6iSxHokiwCA8uf3eUBgE8OxiXKA8YBrX nGdXsR1pzGh9XOtgRMvp9cJgkWGUpmCLTAwrU49NLYu7xnzrkmk6xY7QjSnpn8q5OLOf 8T2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=HOF5G9qgWC4dJfxrWQ2lROjBvucxvYFOJhe3eJU34R4=; b=wSVxvPUU+N30EZGie62wU4Bz2K1mO2NuXXWQW92YLeasovRgzcUwnXiAtgKac4J1LB +ey5h/KsGKaq0A5Cy2Ebo7p0iJNotWLqkJtoBfOYftm+2rRcsogALl5yESG7LlwGS0+Z m8EyYk7gE617lNOhfoUQsoW7FYfYlQKSHM1CaXo/4olnSPisDcs65ZZVhFpQQhQukBGa 0spVKNLhNlgDvzGYrMaduuJYdHcpkyb57ycorBllxJBBe1gMi5wpptpaYZuCnAG+YywD Al2iseNmNnDfiQKDS8E1Uo9f1aO49TpC7it1YcAmHvmvRJlYZ18IGKPLmIpAt6DqdGng kjfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=kgIfiUIE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k130si5689528oih.135.2019.12.05.11.35.00; Thu, 05 Dec 2019 11:35:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=kgIfiUIE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729776AbfLETeZ (ORCPT + 99 others); Thu, 5 Dec 2019 14:34:25 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36685 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbfLETeX (ORCPT ); Thu, 5 Dec 2019 14:34:23 -0500 Received: by mail-lf1-f67.google.com with SMTP id n12so3399073lfe.3 for ; Thu, 05 Dec 2019 11:34:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=HOF5G9qgWC4dJfxrWQ2lROjBvucxvYFOJhe3eJU34R4=; b=kgIfiUIEb6kHLBnQNu3ixiIIg2vRiiTZuWa5n5p0f3P/9BU7ZUZOkuXKi9kXMoiapc l4Ey1iB3O5ZsSa1Q8p04lP4KewQEoKZcBj2sXNP8sK2yWNH4fc1tpnSUIwvvu3WfmZNA 0SIFUnkO4gVNb7ZKJLeq6HINI9VHfireQJDgQafqwm1kHz4Bq/kCZJJQf4IVDuHy0Q5R U/jVQfScZULqoEXNO17fiiakAq0MnRYxEsEw4PKWkOfppzjavnqCaWagy+OWHQlm+oXO rkDula/i64Y1eYYMCv21Mre1eR+Gu1M4eb0wsfMRkqRZhNqGdKWr2gy1gM86+gaF9Ccy U79Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=HOF5G9qgWC4dJfxrWQ2lROjBvucxvYFOJhe3eJU34R4=; b=LcFRPtAYmHVcb46rBeO+qg0+DZTqKSohLipLkHEO11oAhGkHTwYLo9jKHAWbsu2Zrt Uo3jc7POHnea9hIRU+jom/GZOlbVQS9jx/QGMkbZVi7ZySrxy1l7yJ9sOEmoRR9z1Vm8 3AywH3plED0I7Yoa8WKDjgUOBsDVJ3SxkMiNWFM3OUxreT3EisyVjP9seUOOlHICqfow mB/DptH+czgv4Dh3vYiPVTMTWCQy34bGbPTvUSA0Z9Rq+uLHGAQ953TKYn30ifRbWgWi w1VfOVqXT4WmqKXValBjfpOwFNsahdzui1McL5QLsfvdwsESOy7b4fbJzH5cctJxSGyD WBYw== X-Gm-Message-State: APjAAAXuYPsuHlbWIZ8nTHm/J1rRY9PmpjqkmFOlMBaYXMMpuBsW+LmA EXQlgVJxbXQ7aC8R1oukqcKTcQ== X-Received: by 2002:ac2:455c:: with SMTP id j28mr6419747lfm.184.1575574460288; Thu, 05 Dec 2019 11:34:20 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id t9sm5406063lfl.51.2019.12.05.11.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 11:34:20 -0800 (PST) Date: Thu, 5 Dec 2019 11:34:11 -0800 From: Jakub Kicinski To: Valentin Vidic Cc: Willem de Bruijn , Boris Pismenny , Aviad Yehezkel , John Fastabend , Daniel Borkmann , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] net/tls: Fix return values to avoid ENOTSUPP Message-ID: <20191205113411.5e672807@cakuba.netronome.com> In-Reply-To: <20191205064118.8299-1-vvidic@valentin-vidic.from.hr> References: <20191204.165528.1483577978366613524.davem@davemloft.net> <20191205064118.8299-1-vvidic@valentin-vidic.from.hr> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Dec 2019 07:41:18 +0100, Valentin Vidic wrote: > ENOTSUPP is not available in userspace, for example: > > setsockopt failed, 524, Unknown error 524 > > Signed-off-by: Valentin Vidic > diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c > index 0683788bbef0..cd91ad812291 100644 > --- a/net/tls/tls_device.c > +++ b/net/tls/tls_device.c > @@ -429,7 +429,7 @@ static int tls_push_data(struct sock *sk, > > if (flags & > ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SENDPAGE_NOTLAST)) > - return -ENOTSUPP; > + return -EOPNOTSUPP; > > if (unlikely(sk->sk_err)) > return -sk->sk_err; > @@ -571,7 +571,7 @@ int tls_device_sendpage(struct sock *sk, struct page *page, > lock_sock(sk); > > if (flags & MSG_OOB) { > - rc = -ENOTSUPP; > + rc = -EOPNOTSUPP; Perhaps the flag checks should return EINVAL? Willem any opinions? > goto out; > } > > @@ -1023,7 +1023,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) > } > > if (!(netdev->features & NETIF_F_HW_TLS_TX)) { > - rc = -ENOTSUPP; > + rc = -EOPNOTSUPP; > goto release_netdev; > } > > @@ -1098,7 +1098,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx) > } > > if (!(netdev->features & NETIF_F_HW_TLS_RX)) { > - rc = -ENOTSUPP; > + rc = -EOPNOTSUPP; > goto release_netdev; > } > > diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c > index bdca31ffe6da..5830b8e02a36 100644 > --- a/net/tls/tls_main.c > +++ b/net/tls/tls_main.c > @@ -496,7 +496,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval, > /* check version */ > if (crypto_info->version != TLS_1_2_VERSION && > crypto_info->version != TLS_1_3_VERSION) { > - rc = -ENOTSUPP; > + rc = -EINVAL; This one I think Willem asked to be EOPNOTSUPP OTOH. > goto err_crypto_info; > } > > @@ -723,7 +723,7 @@ static int tls_init(struct sock *sk) > * share the ulp context. > */ > if (sk->sk_state != TCP_ESTABLISHED) > - return -ENOTSUPP; > + return -ENOTCONN; > > /* allocate tls context */ > write_lock_bh(&sk->sk_callback_lock); > diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c > index da9f9ce51e7b..2969dc30e4e0 100644 > --- a/net/tls/tls_sw.c > +++ b/net/tls/tls_sw.c > @@ -900,7 +900,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) > int ret = 0; > > if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL)) > - return -ENOTSUPP; > + return -EOPNOTSUPP; > > mutex_lock(&tls_ctx->tx_lock); > lock_sock(sk); > @@ -1215,7 +1215,7 @@ int tls_sw_sendpage_locked(struct sock *sk, struct page *page, > if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | > MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY | > MSG_NO_SHARED_FRAGS)) > - return -ENOTSUPP; > + return -EOPNOTSUPP; > > return tls_sw_do_sendpage(sk, page, offset, size, flags); > } > @@ -1228,7 +1228,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page, > > if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | > MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY)) > - return -ENOTSUPP; > + return -EOPNOTSUPP; Same suggestion for flags checks in tls_sw.c > > mutex_lock(&tls_ctx->tx_lock); > lock_sock(sk); > @@ -1927,7 +1927,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, > > /* splice does not support reading control messages */ > if (ctx->control != TLS_RECORD_TYPE_DATA) { > - err = -ENOTSUPP; > + err = -EINVAL; > goto splice_read_end; > } >