From patchwork Fri Jul 7 16:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13305089 X-Patchwork-Delegate: pabeni@redhat.com Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56E87107A5 for ; Fri, 7 Jul 2023 16:00:27 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-4fb761efa7aso3200158e87.0 for ; Fri, 07 Jul 2023 09:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1688745625; x=1691337625; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zs40Wv0SyhVUhbgcdeM7Gg6KzSx5ZB7NtkjcYXBnZZw=; b=KlkYl9N9/Itd0nGuIW0XAKhRux5HVXj+x/kI/n/6svqCb5rkZDsaUSqWqPL2AqCYAA EOLl8UKJSxI9HXSxx5m6lG//RCTcf5zMp7WFNXDtEwiTVuJRKQxLjI3jCeUOTDhUretb 8VP+S0GQi5feUZMtoEllbbLsR/hOcaLbm+NFMHP8M7dPzF6Dc/ck7mBY7OAuNBG8H5kq C84VS1zUvX+YcWM6Sa5yR1NE8li8cCgesMCNHsPnqiPVofMtqN4zYgNDfq8MDyp8QzNe ZJU07HsvJeNh3QjXZmzSVDj363Qt100PheIBpRqnlBI49s9Lblo6CtiBNWuUxgBJywwW 4rAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688745625; x=1691337625; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zs40Wv0SyhVUhbgcdeM7Gg6KzSx5ZB7NtkjcYXBnZZw=; b=diTYh4KhtgglZMU3evlbliTr61bEw2VmtBorJ3B8n1smdC9nmzFEJhbWbcNdErPzEn 0M/lgCC4LMNEBHLh57GTmuFuda/F79WUUcipUE68LwDtsk6QkCt7+XLHDZzV21V9IrA6 mSnLoUT4zPaYdb3nb9v5uNKy1SeF4nT+37iv16YH1L64m4fb3i+I/xQ0CeJTXV2TnX0G U0vr53aix3lympNJ/0PB8l9mJk2Roj2W9SKUfq/XNmoSTLk2vs3Hw3wcq0un7suo1A3c p4CLx61B5rbEUkv6syYuaGYRFoY9J0jD7T85jrMuAsrVktPX6mSXpBMgWshFpaNdu19F xJJQ== X-Gm-Message-State: ABy/qLaOyd6ZWz/0TiWD209YAwtB+wC5PYtUvVBdzqTPn7oe646Nz6rv 7Tv/ztB8WX7x7voaxdqbWgqYKNRxKC064KCuupy3Xw== X-Google-Smtp-Source: APBJJlGW5iU5E7kFwkawcnW3KsV6FX/Bi3GixO0iq29EivD2i9Lhhws2lqvkuEa3e2NDj26ZpAN1Hw== X-Received: by 2002:ac2:5f9c:0:b0:4dd:9f86:859d with SMTP id r28-20020ac25f9c000000b004dd9f86859dmr4176907lfe.13.1688745625407; Fri, 07 Jul 2023 09:00:25 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id e11-20020a05600c108b00b003fba137857esm2829186wmd.14.2023.07.07.09.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 09:00:25 -0700 (PDT) From: Matthieu Baerts Date: Fri, 07 Jul 2023 18:00:11 +0200 Subject: [PATCH mptcp-next 1/6] mptcp: sockopt: move tcp_inq code to a dedicated function Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230707-mptcp-unify-sockopt-issue-353-v1-1-693e15c06646@tessares.net> References: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> In-Reply-To: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1804; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=SeAojrZHb4JIp44g9i/MxXtEYOj9Oyes8H0LveEFbH8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkqDaXidBu86G2caeF3DGj+dnEBA1jB5u2yZQrd /3R468H3eGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZKg2lwAKCRD2t4JPQmmg c9YnEADr3EeMQ/P0O9LFLOR/gPsZfLYOEf+xnVqMdd98PR1vV/4Y8lD2uWanGXBEPzVN/3HeXJ3 e441x2Hsb5OEyNEi7xBjrvUjPGrQMpe5xe+fFkNdTDUwNyU7br8Nb1NxaWHjc6JbIyf9bzhJPbm aD77e8CyTpR8DLG/zigKCTCoZ3iDKJj4hSPrdsVloTd1DgQ4YdbrFXz4sV0fmdQEXidMqJKUfCt qA0Y4WsImi2kM1yA3afTXdnfWNyQ4cX60pd3vaXWzZd5UyPkwPs83smRl+AFcr8iUiR+K2qr7XT 7NUMd7/7wTunZ6yKGWVUHTA81G2BiZzxaUQZKxo+oub5z3C8w6MDszt7LTwz21ehw9ExW+58nPL /AIoXwQ2glptPkmDAEFCMjZiFJWr4E5O0Kquj7ZhagMwfFjGh/s25Ye51HbHNvR6Tye/HpGwJHG nLgglJwlidAUyOln0M88dAuhzbpNUiTqhqkPpFMxebBq1aEscGsI6/hjwFeQz0/1j1Gf8OtBZTB MQFgEOObYoB5E/jrAJiKH0rG9xhmIxtF06Lajf0SnkZL0lrRe7LHcL1Pl2FrUDFmYInYCEfhn4k 24+N5ITCezlwyBmXFXsQ3/oRpVmOGLWaP8mHaJO4DHow3ZvozFLdQWWs7U99pKjf2kOX76JFrtF vAxj8p52BFoKoXQ== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Similar to what we have with the other TCP socket options where each of them are in a dedicated function. It is clearer like that. Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 63f7a09335c5..a46a00bf0f08 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -577,6 +577,25 @@ static bool mptcp_supported_sockopt(int level, int optname) return false; } +static int mptcp_setsockopt_sol_tcp_inq(struct mptcp_sock *msk, sockptr_t optval, + unsigned int optlen) +{ + struct sock *sk = (struct sock *)msk; + int ret, val; + + ret = mptcp_get_int_option(msk, optval, optlen, &val); + if (ret) + return ret; + if (val < 0 || val > 1) + return -EINVAL; + + lock_sock(sk); + msk->recvmsg_inq = !!val; + release_sock(sk); + + return 0; +} + static int mptcp_setsockopt_sol_tcp_congestion(struct mptcp_sock *msk, sockptr_t optval, unsigned int optlen) { @@ -784,21 +803,9 @@ static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname, sockptr_t optval, unsigned int optlen) { - struct sock *sk = (void *)msk; - int ret, val; - switch (optname) { case TCP_INQ: - ret = mptcp_get_int_option(msk, optval, optlen, &val); - if (ret) - return ret; - if (val < 0 || val > 1) - return -EINVAL; - - lock_sock(sk); - msk->recvmsg_inq = !!val; - release_sock(sk); - return 0; + return mptcp_setsockopt_sol_tcp_inq(msk, optval, optlen); case TCP_ULP: return -EOPNOTSUPP; case TCP_CONGESTION: From patchwork Fri Jul 7 16:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13305091 X-Patchwork-Delegate: pabeni@redhat.com Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5F67107A9 for ; Fri, 7 Jul 2023 16:00:27 +0000 (UTC) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-3fbc59de0e2so22164845e9.3 for ; Fri, 07 Jul 2023 09:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1688745626; x=1691337626; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ug/zyg7QTtmZV359llzk0qUpc7JObIf2czDUKOFfuzc=; b=ezNHVWRmON+S7I/PaG2ThIEEtnA5zZKbgGbBJz7krrAQvTrDgMbP0kyFgyH/qv1vyK wtT7vlzqOrb0cUzjlEUOdu+J1aNYCBmnEkPqfjWmp/BMpE5vLEjqs1wl0jdOGd48tqCM Wrh3pUiqpeOPz5FZYppT5XMqtjuYWr5JYmToG7a1Dn4sy1ZULCbAHrIYy9yZhBoB2qCn FTkrDAPiswoOT7aDdIYesWkxjTAga+YzkAStUoxF+hrGjStOqCyqmXC87srdtOupmEwn z4zpsbBIzH9Kh/maBm0m1ioTQcPzR/vEKRkGpZ5UHyYwoQSfiwSOegQ5Mm1+he+l9wx8 djQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688745626; x=1691337626; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ug/zyg7QTtmZV359llzk0qUpc7JObIf2czDUKOFfuzc=; b=VTOCyOBuHCVSnE8E74JLMeVxLS9ZHN/Q1iI6t4NjjB9K3LuTlaWSEvsJzWK3FQsmDl xQEu6/8QS9rnKrrho1vtaw9ZkOty9tGvL8S4e6BPidQk/fzQsGfAj0q+x3fTAqARSbWa 3jbyW5IahOLp2OjIijIaNYt7MVPEc7sTZmpVrGFWm9Pgvf3Bhe1Xe//1VPLO7HOyk8F9 EGoInHh+tc6LEKwEFr2dc0fqM9r9hrB17MT5OE+gPgzqQnLgorRX6MVbt1+E6k+jMdvD wiJj4l15cTAJY9O1SidgsgoRMN6ciYdQz6OBXi0hRIXcdfTEeMXyhIZ/AZZz92U1UghH wNqQ== X-Gm-Message-State: ABy/qLbgnm2kmujgXa4IpZIPKoZs7SZ1tp3IMwyByYZRGJ0NQMG2zSeq 3jh4LiYXDHkIW7yBZhvZMXwwOtTzcR8IrQO1lJL/8Q== X-Google-Smtp-Source: APBJJlELClgw2KHfHQmhnIZQ1GZ96PGbUJZuZPHEUrDw6/CoQK5QTxHXEDSA5OZnYuFo7LNECstSCA== X-Received: by 2002:a7b:c8c9:0:b0:3fb:ff51:1328 with SMTP id f9-20020a7bc8c9000000b003fbff511328mr2371444wml.35.1688745626068; Fri, 07 Jul 2023 09:00:26 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id e11-20020a05600c108b00b003fba137857esm2829186wmd.14.2023.07.07.09.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 09:00:25 -0700 (PDT) From: Matthieu Baerts Date: Fri, 07 Jul 2023 18:00:12 +0200 Subject: [PATCH mptcp-next 2/6] mptcp: sockopt: update supported list Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230707-mptcp-unify-sockopt-issue-353-v1-2-693e15c06646@tessares.net> References: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> In-Reply-To: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1561; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=cnP8PAdTaVpKe5tWeuLP8jdG5bJlJpdcbL9GEMfAih4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkqDaXOFA8SaYB7GmcDza4G94zbYLY73QQIA7q9 RN5OEvzKDKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZKg2lwAKCRD2t4JPQmmg c7hhD/4gyxlt4JahkUZ95jp/ZoF6M28WaLAX+gPsISq2PyEhZbRfLd7qJiJiFyWTJE9PyzOm13o 1jueP0cSJhMdecq+zseXjlwYUn+CwbaenJiDlhVD4asFQEyOFFq6DVBrjqkaUqYmsqqfNblUZfl IhNK/AdTPavQXJSYb23niQ8ZIwzj1sptIhcwtkXh6b4cOoGMT5shKBpLKzZ6nKnP27DQ8cXIJ6v ytUuNJD2qN7Uc6hBIQBofTwSjMBYmcUvNSuhHH0nJpmow62tfrIreNDRt3zMaIUzCR6wcE3/drI 4Wkk9k5LZobgzGV03aYuLrdappP0tV2syuBgupdTc2bMQGPlwg+8iJwlr7ey7zcUHzzdWabtYHN yH5CCPMuPrh+0dv9INe++l1Yh9RzZyPJWtSy57NsFqtdhUQccseJcdGENKVuUP8iYRuOmm7r+FO jqCLOLrA88vl9HgdleRfKv2ygG/hy9mk0dYy6ByVuYrL+kPRDNFe6FW7pWdk0iDqTPALypmM/MK NutLe7Vykf20tIEtNdQssSRZxznH/3Jeq5fXA4iaLwR/8an6GAVPwYgmX+h4FVCT56nrJWs3pw5 JkjoL80+Sb8466oC+WtQ8HUltMniRyBOnQy2TO+lL9Z3oKF03iI9+fOIi684BS4H1jJaorGOJ7H QZ5CqsXByF1QA8Q== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 IP_TOS, IPV6_TRANSPARENT and IPV6_FREEBIND are fully supported but we forgot to move them to the "should work fine" section. Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index a46a00bf0f08..af1d30c8832d 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -437,6 +437,7 @@ static bool mptcp_supported_sockopt(int level, int optname) /* should work fine */ case IP_FREEBIND: case IP_TRANSPARENT: + case IP_TOS: /* the following are control cmsg related */ case IP_PKTINFO: @@ -450,7 +451,6 @@ static bool mptcp_supported_sockopt(int level, int optname) case IP_RECVFRAGSIZE: /* common stuff that need some love */ - case IP_TOS: case IP_TTL: case IP_BIND_ADDRESS_NO_PORT: case IP_MTU_DISCOVER: @@ -479,7 +479,10 @@ static bool mptcp_supported_sockopt(int level, int optname) } if (level == SOL_IPV6) { switch (optname) { + /* should work fine */ case IPV6_V6ONLY: + case IPV6_TRANSPARENT: + case IPV6_FREEBIND: /* the following are control cmsg related */ case IPV6_RECVPKTINFO: @@ -500,8 +503,6 @@ static bool mptcp_supported_sockopt(int level, int optname) /* the following ones need some love but are quite common */ case IPV6_TCLASS: - case IPV6_TRANSPARENT: - case IPV6_FREEBIND: case IPV6_PKTINFO: case IPV6_2292PKTOPTIONS: case IPV6_UNICAST_HOPS: From patchwork Fri Jul 7 16:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13305093 X-Patchwork-Delegate: pabeni@redhat.com Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BF38107AC for ; Fri, 7 Jul 2023 16:00:28 +0000 (UTC) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-3fbfcc6dae4so11842495e9.0 for ; Fri, 07 Jul 2023 09:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1688745627; x=1691337627; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zTtNxIjGCHHZxGVoyP0zNo6ljtr4ROBSIXD5hnl6EPI=; b=GBFDIZuqZ+k1SLJS2+t/+b9zYpst+cZSILhxGbnwI6AOKAIdkGNRjwK7Phu0ZiYZm0 WVSz9orpOJp7F1yfM5LZUrYVBShILcBIZ57nqdPOcmS8PqaKF9FD/UlV4qbfqrAnqlXs x1U0qDVS6pF42w/kuP43Bh0gmlGUXLWxnhdxrbUaRXG6Sz0jg27iRZWTGJ0IR5qMQt94 6FbsSitWZJ2oAF7StBCLfHB0OnBfJrllADSBanGgiwV5QQcyoaCca5VN7LKG1p6+vbG7 u3cCeiTRlfqfmTTpXajKj16d27vhG0/MWvPlHZCVWYHhwTgB/HvAxGEcwwB+EO/JMEEW tdiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688745627; x=1691337627; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zTtNxIjGCHHZxGVoyP0zNo6ljtr4ROBSIXD5hnl6EPI=; b=H/VE8s/FfRcXUfaN+5Zq+zh+nA2Ol6ojtwXjzOnDJaZBZUUhcGUZJBCN/1WE8Vy4A6 3ANQTjoEE+hwaGBN5h7hp18tEjyGJP4TsRFSbf2bj8uWro4vakbXeucPt2y7NzRexd5F +IRitybNHJMgcOWKkuSmybU03vYV3fwQMDK0whD1rK6UjxNGlGcxjGkShViALt9zwbZo ep1JEKVcQGQI4oDn/mJoc676gEgP/9+cZYLbIC2mkUgktRQdjVB7EvVCEASKjrJLDw8Q VpPwoyNdcC3ZNeCKJ1cXFYSgY/9WDgL4fBpp9wkWGpD3G/DtOnFRmQSBkbYVz9BOgmAW Wi7Q== X-Gm-Message-State: ABy/qLZn5AOKonfvmdF+oL+M9JiFNaiUY1a/Tnts8FjPNltiMhdL3t5N 0GOPGtcBdv8bjm5JPiL5ixS8pvxACCKqX6OOFj0EPg== X-Google-Smtp-Source: APBJJlExj8YAReO6RN4hHglYl7vdQkLGPbAPjfH53gxHOPcCrzgjORIi49fhqdivUTqHv8/K+WRqtQ== X-Received: by 2002:a05:600c:21d0:b0:3f9:b17a:cb61 with SMTP id x16-20020a05600c21d000b003f9b17acb61mr2541672wmj.13.1688745626892; Fri, 07 Jul 2023 09:00:26 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id e11-20020a05600c108b00b003fba137857esm2829186wmd.14.2023.07.07.09.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 09:00:26 -0700 (PDT) From: Matthieu Baerts Date: Fri, 07 Jul 2023 18:00:13 +0200 Subject: [PATCH mptcp-next 3/6] mptcp: sockopt: get val in a generic way Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230707-mptcp-unify-sockopt-issue-353-v1-3-693e15c06646@tessares.net> References: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> In-Reply-To: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2305; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=e0iLFva+PCw1OnhEGzXFnqH/h3e1CqRZUxCBW8KwsTg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkqDaYoMc+hNmFWHvnOGlLm+PalYz37wsMVmlgI ZiZpOupmeyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZKg2mAAKCRD2t4JPQmmg c19tEAC313B4d3jnAU+ROFcUNX/KU6Dkio0C8AcyIDWibXEIw3jWpV3SwPHiY/hPiDrNCm+AEuA zw4j/TyCnYC2vrZJxN0phPRBCc4mdfyYW+1X4FM+63DPheP01ZlfE2gRCWJ8UZFGsCAqnfcEKw+ hLEXygSnTtdTlO2uTglUHTw2J95wzsdy5tML9I/qXWbkop/3K9tuZlnUxZ9VcAaOw/XOouRqRyF FOCxxR96ZbkOj6pDYzomcoODlW7zgtf39VKk0oUxg7MH3sMBKCwn2Jq4w1Jo/s3aH2FDK7+8PmS GtFsIZZ+4m0oRdrb9mhesSKeMG6zjCpOFU8gxsVYn/38ZFGuAf6LE2nMKbAy39LqeBkcALUeW5P kRPnbgGAO0JFLb0Grq3Bas4VjnHRBqPmwGBvQETKwfHkX3Z1X8CODycFyKgeT5iIsPdKXAAV5L9 tWkQFPYdEXWHUUxFf/er+OIi4wSsXl56nQwb98Nk2bgdeEbnaoimDKqAofnj2U0z0lDxFljqSwH uHiOYxhRCtsXPwjXZqfvi3PsmlOSs8kuVvxZLlbyambGpDyEPVHFwWD3b9n7ZdSdzGrMS9lQYuO HszLi2T/W4i/DuiyFB6fwR19HQRn9vGs8OVs6LzrIWWAkNRMsk4cYSnoVTlmO8InCAQ0pWM0DH/ +7+Zp4rAR+56eSA== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Currently, to get socket option, we deal with them case by case by looking at the field that has been set and copying what is done elsewhere in SOL_IP(V6). That's probably why there is only one being supported here with IP_TOS. Instead, we can use ip(v6)_getsockopt() to retrieve the value. By doing that, we can also go through the BPF et Netlink hooks if needed and we can easily support new options later. While at it, also fix the variable declaration order to respect the reverse xmas tree convention. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/353 Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index af1d30c8832d..673bcf8a97f0 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -868,13 +868,31 @@ int mptcp_setsockopt(struct sock *sk, int level, int optname, return -EOPNOTSUPP; } +static int mptcp_getsockopt_msk(struct mptcp_sock *msk, int level, int optname, + char __user *optval, int __user *optlen) +{ + struct sock *sk = (struct sock *)msk; + + /* We cannot use tcp_getsockopt() with the msk */ + if (level == SOL_IP) + return ip_getsockopt(sk, level, optname, optval, optlen); + + if (level == SOL_IPV6) + return ipv6_getsockopt(sk, level, optname, optval, optlen); + + if (level == SOL_TCP) + return 0; + + return -EOPNOTSUPP; +} + static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int optname, char __user *optval, int __user *optlen) { struct sock *sk = (struct sock *)msk; struct socket *ssock; - int ret; struct sock *ssk; + int ret; lock_sock(sk); ssk = msk->first; @@ -1348,11 +1366,9 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname, static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname, char __user *optval, int __user *optlen) { - struct sock *sk = (void *)msk; - switch (optname) { case IP_TOS: - return mptcp_put_int_option(msk, optval, optlen, inet_sk(sk)->tos); + return mptcp_getsockopt_msk(msk, SOL_IP, optname, optval, optlen); } return -EOPNOTSUPP; From patchwork Fri Jul 7 16:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13305090 X-Patchwork-Delegate: pabeni@redhat.com Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE43F107AD for ; Fri, 7 Jul 2023 16:00:29 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-3fbc54cab6fso21928765e9.0 for ; Fri, 07 Jul 2023 09:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1688745627; x=1691337627; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WkHge0rkKG2/PW/SMFkc+m6KHSEISwSWDC4wQW6IX18=; b=M0beoubqsabjPathcuROd0UUVMo5zRbE+07kmzMGMpCh6qDRMXOu0o1Uwh/wqlAL/N wUndvZIEGvF7QeDstQbflHQxOh/Q4L8dyIxu+nzx01iPXpWw2izqFQsG6C6Cp9bhlmCX ZE8neS6akneQzD8pVKBb2hDkgWogYGcm9X2rqA3DwqtEqV3+tINSv8r1uPqjvAD0dKMQ JlyTfzv0ZweQhJj9d0HxcGQCTbcXX3sJfvj/OTX4Pu+WoavSG4Q4ql+7oWloiNl4pSBG oHReyYm+mnGcp6KgMusB0j6ZY7V6zRdv19KbehZTJmfDLVQepEbPoibU9SgSFTDtckbf Tr1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688745627; x=1691337627; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WkHge0rkKG2/PW/SMFkc+m6KHSEISwSWDC4wQW6IX18=; b=XZPhUJKmB7Iuwx02uitbvfJw73HNbqmeRqjGa3xnbUWtr+MxZkEwk2Z+pWHBZZArIc 2fcvplyV2zJ2z9z+9b2MuyAsUPd0hjRl2Qix5TEUbHCLM+NyKRVw073Cur/sxhqiAUZS EMqSNPskRDM+unLRWo0EgrTYxEilPGxwehtOVPmnaCD3TsSc2e3n8dcMZP7jk68DVAAc daGeJwaDXoMRyMIKWdK4ZJXa/9qgNe64dIwMR80C8EEHa13paq/5kiQb5gN7srFXQ0bK B2gF98NMjLr/Lc7yIT/u1g+8h8xVpySeXuA5rxsh43xAuFtht4vnJsXvfM6K6F+aUuIL C97g== X-Gm-Message-State: ABy/qLZODNbfHiEDW9A3DHUeChUzemr44Ktik9YP3ApyhddSX7ECSc1E l1klfZzrRqNT8uKhJapwNS0oeITSGz8eqrRmNdY6oA== X-Google-Smtp-Source: APBJJlGETLsw/PtI5b6cfazfsWCHuHf+5dqeRuHn1JErjT0tB389F0Tt2R6v3Q+jt2hxpbyux+vuXw== X-Received: by 2002:a7b:c387:0:b0:3fb:ac9c:e6f with SMTP id s7-20020a7bc387000000b003fbac9c0e6fmr4319300wmj.38.1688745627637; Fri, 07 Jul 2023 09:00:27 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id e11-20020a05600c108b00b003fba137857esm2829186wmd.14.2023.07.07.09.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 09:00:27 -0700 (PDT) From: Matthieu Baerts Date: Fri, 07 Jul 2023 18:00:14 +0200 Subject: [PATCH mptcp-next 4/6] mptcp: sockopt: add missing getsockopt() options Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230707-mptcp-unify-sockopt-issue-353-v1-4-693e15c06646@tessares.net> References: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> In-Reply-To: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1824; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=93zTB91dpZB/7U3jGgselwKSU+2REzhYoE2Isk/cmqg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkqDaYaiNwYan5ESnNJIuWVThZWCYnxs8c0DoAa aEfpSquI8SJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZKg2mAAKCRD2t4JPQmmg c9ZGD/9bsl1Idzznh7LSfziwmpf1ahZgc8Y8bF79PpyX8lsNqIA42KABoZKyNk2zIBakOId51Nu NzoiB//Y4tBfL/9o6LWE+opyObBTdUNKVVFL37sde97IaTbPNSAxrGt7yK34EHosRAfCDuvm4aw 6Qllhk87BzsJyyhp0QLcnOvt57k6rPBmwFZK27OSV+DoAjUZPxDfbJGuumhMICgrS26MIBB1b8s I6J7qu1KleAsrWB5GNK29RmmaBaVX+/d+JTmXXWxZ530rkk//xmAt8u5khjBowQvgyL+gcHUMhE QvwEKOWB5q33fg4Vgl4i11adggSwEYwiWQYSmGVdHGMi9Ygke/iZi/ojMo16z+rIqSi62KJA9ns FaP107v3NCdaW4SDVuUIfhxwrVReZu48tWxKryo9lKmhuezcKkEaL88EowZFLGKEev7aLmbdtBc b26Lqnu0NudiAggQLc6B3/AUKr5TibZP/Un8VsigycNHW9I06U+j2gngGqcXRNq3wgtUojyOYSa hYHp3k8kc/1WvOhMWup41eJjDEtx/dXFklyyqztsuKQfexmZkbMpmHgxmFVpDQUc9GNeYPZXAXJ VyjftAe++YeluWF/fQkv/XbCAy2tBw4GRW1/PwFQt9UT13QA+6XlHoww3UIcKsWZ7mEsRoEIe9v fzOiBfS6FYDbUwQ== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Some socket options had a support for the "set" part but not the "get" one: - IP_FREEBIND - IP_TRANSPARENT - IPV6_V6ONLY - IPV6_TRANSPARENT - IPV6_FREEBIND Thanks to the previous commit, we can easily support them. Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 673bcf8a97f0..f0007fa7a0a8 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1367,6 +1367,8 @@ static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname, char __user *optval, int __user *optlen) { switch (optname) { + case IP_FREEBIND: + case IP_TRANSPARENT: case IP_TOS: return mptcp_getsockopt_msk(msk, SOL_IP, optname, optval, optlen); } @@ -1374,6 +1376,19 @@ static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname, return -EOPNOTSUPP; } +static int mptcp_getsockopt_v6(struct mptcp_sock *msk, int optname, + char __user *optval, int __user *optlen) +{ + switch (optname) { + case IPV6_V6ONLY: + case IPV6_TRANSPARENT: + case IPV6_FREEBIND: + return mptcp_getsockopt_msk(msk, SOL_IPV6, optname, optval, optlen); + } + + return -EOPNOTSUPP; +} + static int mptcp_getsockopt_sol_mptcp(struct mptcp_sock *msk, int optname, char __user *optval, int __user *optlen) { @@ -1413,6 +1428,8 @@ int mptcp_getsockopt(struct sock *sk, int level, int optname, if (level == SOL_IP) return mptcp_getsockopt_v4(msk, optname, optval, option); + if (level == SOL_IPV6) + return mptcp_getsockopt_v6(msk, optname, optval, option); if (level == SOL_TCP) return mptcp_getsockopt_sol_tcp(msk, optname, optval, option); if (level == SOL_MPTCP) From patchwork Fri Jul 7 16:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13305094 X-Patchwork-Delegate: pabeni@redhat.com Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF10B107A5 for ; Fri, 7 Jul 2023 16:00:30 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-4f4b2bc1565so3321793e87.2 for ; Fri, 07 Jul 2023 09:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1688745628; x=1691337628; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ozaSL6NFtj3AcYIJZsMxs9Hvazt74//pXRN9PG5JK4c=; b=3aSOnEuaJMEKLuyEQqoQBPc04c3K3AP/10wIMSb1pMOS5wqvCpkFaIqVXwPu9w2Q1Z TZ6zL6rO+NG3joIiJgtZm9HFhZZ0KuXe1m44nNaFjPk5oVqfMkTbtXRLrlNq2PLYZ/rh XywdPsYYvJLE+9fRjfyoHc2JO73ZRoSfyqgKpRSq+wJ+6bIVBSciby41LoOM4+EaHqaK 0/XO5OlQ7EKa/W+9Wu4mAZ9qzFA1fFLFS9bPtSzAoDHDdRuu8RYhJHSci4saz6Wiv90I G/pFrjZ9+x5E0d5c2g2JL6sAgFKBImUEwGrVPfxKZANkYMYKGnZOfOXEuzYACS1Ilt+G Di3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688745628; x=1691337628; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ozaSL6NFtj3AcYIJZsMxs9Hvazt74//pXRN9PG5JK4c=; b=e/hFK/1a+pKQRQfgDgwE0uECoYtDh6QGutfqfsctY8Ywaxnd1DSfCHRkbth63TUk6D +0qZGCnDeM48Rs+hAe22gG1djgcbtuIMl5rQVlyF8dKpXvABQasCt2UUf2EQClVATYkM 4fcp3SgnGMi+xKnXMy1WLWLNdxyZQQPeYSJFgG5M3EWHdzCipm+RlbbqRJCRVGTmd7wo N8DtXwORT0b1xHIGOmAbC21+PUI61cb4lwzcyHweRb6oad++OWX9Uz/hzREE916i0nOj LiPHk3Cg5Cw/zLgAiaANDE/jFP9gxb5g7U/AhxNRHaiWiKyzUz3R6UJq7muYfaaWkpDL 9hqQ== X-Gm-Message-State: ABy/qLbU2eodJr4iJUsCdXAp4Rek2rlm5g7H5+4vy5I6MPnHJZ8MsBk4 WvsWhnEJquuLJQgE7MaqhFI4UCdO5CIG2HlNUYvwqg== X-Google-Smtp-Source: APBJJlGFzlzPmkeO1EUrS3ClZsjSaqt8mQBOXhkuLVgFqwkwORgmTl2yegz0GaslCEGy3ltUTiSf3w== X-Received: by 2002:a05:6512:2351:b0:4fb:89bb:bcc4 with SMTP id p17-20020a056512235100b004fb89bbbcc4mr5380137lfu.51.1688745628214; Fri, 07 Jul 2023 09:00:28 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id e11-20020a05600c108b00b003fba137857esm2829186wmd.14.2023.07.07.09.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 09:00:27 -0700 (PDT) From: Matthieu Baerts Date: Fri, 07 Jul 2023 18:00:15 +0200 Subject: [PATCH mptcp-next 5/6] mptcp: sockopt: set val in a generic way Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230707-mptcp-unify-sockopt-issue-353-v1-5-693e15c06646@tessares.net> References: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> In-Reply-To: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7097; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=MJ9rON4VDzG9iINn5KlIwhpylNaR1a59Mt/HOZd9ajU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkqDaY+3g9vQIDMNgMjXRiIWmdW1GvOWPFNC86g JSWUIq7c0KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZKg2mAAKCRD2t4JPQmmg c8TZEACnc1pfx29uIoXuLOM4Ri4r7ES7BpkZHGwkT1JRSlrPbhef3gIRuf/ZWKO5YV8EzUg0TpK zAmJRF0jVhsA74icYt4+Yctw6JvpqIm5JcVX57VDnhaIh64WHRAwL19ML5pKlFRXMjbLdf2Iryz YGnBGAfxrvzHytYOv0QkqYyf2zzxYM2KcIwzPmQTp6JQ/NOaYGoAH3n8i7R0AjF6qJf0cFCQfuv AoUbeaZ/hdr/yZdxuosI9uFnPnbdcyqLDU3VwV3ogspxtPoL8U73OjI/ap2tPWfZhnTaFBtLIaE uvGG0FT8Op4qRHX8ugxew37E4MjkgLTXRELp7D3T9kystzLNcIeH5YoMXBBjcK8+LAiNZAywvsu vWDyeBHkyk2XQByaZi1m9Q/1PqfhjIiFEIeJ2ebWFuRwggxTva99XhaBwFhPaKr/8RAbfJaFYQX Zi6hO5xY06pHesLKegHbtLOOtJQs4fW0bcLElMKmzXIDWIh4+YgJVBto7TRdAOwihMMUS+njSQ4 PedzXwVk45mFpHHwsXQJRZbh/gR1q8Av7NXlhH2WkhASuQIj1oi6Y1dp62ydSGnfFDo9cI428s5 ETSz0UjcWPAOP2QJKiCWfrPAoR2IHSjp2EyxKGRqiXWYZxpVy49ayuLT5T8KoQTD53e8bKUR3K2 q74OH5nxmQDmexA== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Currently, to set socket option, we mostly deal with them case by case by setting the right field in the socket structure and in fact, copying what is done elsewhere in SOL_IP(V6). Supporting a new option is then more complex and we can see some disparities on how things are done between the different options. Instead, we can rely on ip(v6)_setsockopt() to set the different values. By doing that, we uniform the way we deal with the different options and we can also go through the BPF et Netlink hooks if needed. We can also easily support new options later. Note that there are still two cases where we still need to deal with the end values directly, thus with something specific case by case: - For SOL_TCP socket options because we cannot store them in the MPTCP socket. Note we can also store info in the different subflows (and create a first one if there is no subflow) and retrieve info from there. - To sync the socket options when a new subflow has been created to minimise the work. But maybe it is fine to call some getsockopt() / setsockopt(). We could also save a list of setsockopt() that have been done in the past and only re-do these ones. That should help with the maintenance of these socket options and ease the support of new ones. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/353 Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 148 ++++++++++++++++++---------------------------------- 1 file changed, 50 insertions(+), 98 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index f0007fa7a0a8..a17739683fdb 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -385,51 +385,6 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return -EOPNOTSUPP; } -static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, - sockptr_t optval, unsigned int optlen) -{ - struct sock *sk = (struct sock *)msk; - int ret = -EOPNOTSUPP; - struct socket *ssock; - - switch (optname) { - case IPV6_V6ONLY: - case IPV6_TRANSPARENT: - case IPV6_FREEBIND: - lock_sock(sk); - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { - release_sock(sk); - return PTR_ERR(ssock); - } - - ret = tcp_setsockopt(ssock->sk, SOL_IPV6, optname, optval, optlen); - if (ret != 0) { - release_sock(sk); - return ret; - } - - sockopt_seq_inc(msk); - - switch (optname) { - case IPV6_V6ONLY: - sk->sk_ipv6only = ssock->sk->sk_ipv6only; - break; - case IPV6_TRANSPARENT: - inet_sk(sk)->transparent = inet_sk(ssock->sk)->transparent; - break; - case IPV6_FREEBIND: - inet_sk(sk)->freebind = inet_sk(ssock->sk)->freebind; - break; - } - - release_sock(sk); - break; - } - - return ret; -} - static bool mptcp_supported_sockopt(int level, int optname) { if (level == SOL_IP) { @@ -700,94 +655,65 @@ static int mptcp_setsockopt_sol_tcp_nodelay(struct mptcp_sock *msk, sockptr_t op return 0; } -static int mptcp_setsockopt_sol_ip_set_transparent(struct mptcp_sock *msk, int optname, - sockptr_t optval, unsigned int optlen) +static int mptcp_setsockopt_msk(struct mptcp_sock *msk, int level, int optname, + sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; - struct inet_sock *issk; - struct socket *ssock; - int err; - err = ip_setsockopt(sk, SOL_IP, optname, optval, optlen); - if (err != 0) - return err; + /* We cannot use tcp_setsockopt() with the msk */ + if (level == SOL_IP) + return ip_setsockopt(sk, level, optname, optval, optlen); - lock_sock(sk); + if (level == SOL_IPV6) + return ipv6_setsockopt(sk, level, optname, optval, optlen); - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { - release_sock(sk); - return PTR_ERR(ssock); - } + if (level == SOL_TCP) + return 0; - issk = inet_sk(ssock->sk); - - switch (optname) { - case IP_FREEBIND: - issk->freebind = inet_sk(sk)->freebind; - break; - case IP_TRANSPARENT: - issk->transparent = inet_sk(sk)->transparent; - break; - default: - release_sock(sk); - WARN_ON_ONCE(1); - return -EOPNOTSUPP; - } - - sockopt_seq_inc(msk); - release_sock(sk); - return 0; + return -EOPNOTSUPP; } -static int mptcp_setsockopt_v4_set_tos(struct mptcp_sock *msk, int optname, - sockptr_t optval, unsigned int optlen) +static int mptcp_setsockopt_all_sf(struct mptcp_sock *msk, int level, + int optname, sockptr_t optval, + unsigned int optlen) { struct mptcp_subflow_context *subflow; struct sock *sk = (struct sock *)msk; - int err, val; + int err; - err = ip_setsockopt(sk, SOL_IP, optname, optval, optlen); + err = mptcp_setsockopt_msk(msk, level, optname, optval, optlen); if (err != 0) return err; lock_sock(sk); sockopt_seq_inc(msk); - val = inet_sk(sk)->tos; mptcp_for_each_subflow(msk, subflow) { struct sock *ssk = mptcp_subflow_tcp_sock(subflow); - __ip_sock_set_tos(ssk, val); + tcp_setsockopt(ssk, level, optname, optval, optlen); } release_sock(sk); return 0; } -static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname, - sockptr_t optval, unsigned int optlen) -{ - switch (optname) { - case IP_FREEBIND: - case IP_TRANSPARENT: - return mptcp_setsockopt_sol_ip_set_transparent(msk, optname, optval, optlen); - case IP_TOS: - return mptcp_setsockopt_v4_set_tos(msk, optname, optval, optlen); - } - - return -EOPNOTSUPP; -} - static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int optname, sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; struct socket *sock; + struct sock *ssk; int ret; - /* Limit to first subflow, before the connection establishment */ + /* Limit to first subflow */ lock_sock(sk); + ssk = msk->first; + if (ssk) { + ret = tcp_setsockopt(ssk, level, optname, optval, optlen); + goto unlock; + } + sock = __mptcp_nmpc_socket(msk); if (IS_ERR(sock)) { ret = PTR_ERR(sock); @@ -801,6 +727,32 @@ static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int return ret; } +static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname, + sockptr_t optval, unsigned int optlen) +{ + switch (optname) { + case IP_FREEBIND: + case IP_TRANSPARENT: + case IP_TOS: + return mptcp_setsockopt_all_sf(msk, SOL_IP, optname, optval, optlen); + } + + return -EOPNOTSUPP; +} + +static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, + sockptr_t optval, unsigned int optlen) +{ + switch (optname) { + case IPV6_V6ONLY: + case IPV6_TRANSPARENT: + case IPV6_FREEBIND: + return mptcp_setsockopt_all_sf(msk, SOL_IPV6, optname, optval, optlen); + } + + return -EOPNOTSUPP; +} + static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname, sockptr_t optval, unsigned int optlen) { From patchwork Fri Jul 7 16:00:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13305092 X-Patchwork-Delegate: pabeni@redhat.com Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E02A3107B0 for ; Fri, 7 Jul 2023 16:00:30 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-3fb4146e8deso26258435e9.0 for ; Fri, 07 Jul 2023 09:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1688745629; x=1691337629; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8xeq8sRLnjGrw3maYyBofnm9B7mHn4a/exqLD4jwmTc=; b=32ixuT399BPr82QmpUoVMxfwVZ3/QctdDTmh+zCJh48wav2HwPEeOTJpz0xwPIynwu 3onzW0mWuJRastGrMObIHRNwR//eXCxBWeRR/MyFV/OSuuwtxmwhAQceFzsRngAQaBwB GEOEJO6nSfvitFCJREuLdaVeGAWUa2boOzVkGgouWrm561E8LHc0Y/yBZfUCZsVeacDH 9xq+pp7F29yzveYzmI3d5ZuXW8bIAbxiT2mZfZhrxXwsmHkFlyAioceL6SqiTZ5120AO BWXmKDd90U1KXLEZCMiqj6surBntyaw3U6RYkkRWNpB/2SvOjDq0AslyrttSHWoJWvB3 8Zww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688745629; x=1691337629; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8xeq8sRLnjGrw3maYyBofnm9B7mHn4a/exqLD4jwmTc=; b=RI/W56NuW2kFkdkmLDQTN+lH9q2G1fOiXbxdMdW8qr0EWN4d0Tt5QBGdhLU2AAp0Xi wyPPKl7AFMxpCSryGj2c9AR14mb4aGjskSXCeeJYwsqRrN3WbUeIHdVXbhffc25TGK4h GvyoUU/6BIM9wtU3CxH+B/uG1ZjunpZCxRwQx8Wyuoi/yD0qd3dnSacUtuJO/j24tDsy 7WmhRzTG0cz/XzPCsj/jSYnre3FwK2poeR0KBOak/iEm47qlmznJBwVqtCPNx6CVKYKR GsPgDcOvTpJEWKs/wpe6k54Cqtqkv7U5XUsyWNMAvEOEuy49R81M+BmqAA0pjJfQUdjy 2Zcw== X-Gm-Message-State: ABy/qLYO5zLRQHbn4vrIzpTFedR3kzCEy11jmOqyQxMTenu9ELIVg8Fo nldwqTWB7D9lJDfq9s4yxlGKv3hxXLQIGZEkXI/m0w== X-Google-Smtp-Source: APBJJlEtqA/AvWWFjpyxHNfrTPayNxny5i6iz45KgFPfFwMWVhroiDdOmn3eFlFPpWvu2S7MybKkJw== X-Received: by 2002:a7b:c415:0:b0:3fb:fa26:45a8 with SMTP id k21-20020a7bc415000000b003fbfa2645a8mr82831wmi.28.1688745628722; Fri, 07 Jul 2023 09:00:28 -0700 (PDT) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id e11-20020a05600c108b00b003fba137857esm2829186wmd.14.2023.07.07.09.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 09:00:28 -0700 (PDT) From: Matthieu Baerts Date: Fri, 07 Jul 2023 18:00:16 +0200 Subject: [PATCH mptcp-next 6/6] mptcp: sockopt: support IP_TTL & IPV6_UNICAST_HOPS Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230707-mptcp-unify-sockopt-issue-353-v1-6-693e15c06646@tessares.net> References: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> In-Reply-To: <20230707-mptcp-unify-sockopt-issue-353-v1-0-693e15c06646@tessares.net> To: mptcp@lists.linux.dev Cc: Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3003; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=XoXkCw/r20bM9+9XCYW29khspTN7it+40kFbty2kfIU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkqDaYf52ikSusJ333dxjpQ6EaYg7qDs0BkfJBi PuYBqCrHWiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZKg2mAAKCRD2t4JPQmmg cxc3D/wLOQLBhgJU7A84xjw3vLRXYf/T5G+pAc40c8lQy3Us4gZ64Jz0fF13abJR+bSm16dEsYS qimAlOtz1bgEQwmd8aH0pfpPM7xjox3urbuyRZt79zMcq+KULfV4CYa/nz9IltAaZW+HHy2nVCG wucfrWfwHGjm5NH8XJSOheMlD91gIj/o9iMFb14R/rclW34OkuHR9fPk1tCXs0GN+3sNLREu0D5 /FRhFULvyNXMyZ3iGRTWUhaJKEPb8YCOH14klx96NRmNsreAHF+VRbU4LLBkObtPVVSFEYlEeun 5q/KHs8XdeN0r2jLrXNT+QQ5Zi77kpDIbS8sEz7VNsyV227tzzCMlXWwsDD1o17WXPaM/ZALrI1 yWrzlzXzenYYXM5UeJDE1jUhi/CkiPx8nl668M+Cyv01kA/TDLatI9O2/ft/HUNiTsNXYmlqbNv SUY4LxWWn9HVuMwO7UtiKAy+9rLi6AaE3pX8QGnpjYAQkcUFTJ7toj+CKpoiM7mSVbbMgp9C6MV F3KPHreoizsCImvyfhy1ET6bOq0904zBQ3SC1TEiQkLSTM0Wh/PytZU+K8MfOb7W8aQ9jJ0F4tz N2C6FpLbps8/ObgD6CuoApIBfZq0Cs9t450UNB+CCjkhoS2Tj5ZUQOZhJZiMGzUXwcp8FbU8RcS 9X0XZeqsYp3fahQ== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This adds support for IP_TTL and IPv6_UNICAST_HOPS, the IPv6 equivalent. The socket option is propagated to all subflows by default. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/296 Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index a17739683fdb..cf35775179ab 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -393,6 +393,7 @@ static bool mptcp_supported_sockopt(int level, int optname) case IP_FREEBIND: case IP_TRANSPARENT: case IP_TOS: + case IP_TTL: /* the following are control cmsg related */ case IP_PKTINFO: @@ -406,7 +407,6 @@ static bool mptcp_supported_sockopt(int level, int optname) case IP_RECVFRAGSIZE: /* common stuff that need some love */ - case IP_TTL: case IP_BIND_ADDRESS_NO_PORT: case IP_MTU_DISCOVER: case IP_RECVERR: @@ -438,6 +438,7 @@ static bool mptcp_supported_sockopt(int level, int optname) case IPV6_V6ONLY: case IPV6_TRANSPARENT: case IPV6_FREEBIND: + case IPV6_UNICAST_HOPS: /* the following are control cmsg related */ case IPV6_RECVPKTINFO: @@ -460,7 +461,6 @@ static bool mptcp_supported_sockopt(int level, int optname) case IPV6_TCLASS: case IPV6_PKTINFO: case IPV6_2292PKTOPTIONS: - case IPV6_UNICAST_HOPS: case IPV6_MTU_DISCOVER: case IPV6_MTU: case IPV6_RECVERR: @@ -734,6 +734,7 @@ static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname, case IP_FREEBIND: case IP_TRANSPARENT: case IP_TOS: + case IP_TTL: return mptcp_setsockopt_all_sf(msk, SOL_IP, optname, optval, optlen); } @@ -747,6 +748,7 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, case IPV6_V6ONLY: case IPV6_TRANSPARENT: case IPV6_FREEBIND: + case IPV6_UNICAST_HOPS: return mptcp_setsockopt_all_sf(msk, SOL_IPV6, optname, optval, optlen); } @@ -1322,6 +1324,7 @@ static int mptcp_getsockopt_v4(struct mptcp_sock *msk, int optname, case IP_FREEBIND: case IP_TRANSPARENT: case IP_TOS: + case IP_TTL: return mptcp_getsockopt_msk(msk, SOL_IP, optname, optval, optlen); } @@ -1335,6 +1338,7 @@ static int mptcp_getsockopt_v6(struct mptcp_sock *msk, int optname, case IPV6_V6ONLY: case IPV6_TRANSPARENT: case IPV6_FREEBIND: + case IPV6_UNICAST_HOPS: return mptcp_getsockopt_msk(msk, SOL_IPV6, optname, optval, optlen); } @@ -1436,6 +1440,10 @@ static void sync_socket_options(struct mptcp_sock *msk, struct sock *ssk) inet_sk(ssk)->transparent = inet_sk(sk)->transparent; inet_sk(ssk)->freebind = inet_sk(sk)->freebind; + inet_sk(ssk)->uc_ttl = inet_sk(sk)->uc_ttl; + + if (ssk->sk_family == AF_INET6) + inet6_sk(ssk)->hop_limit = inet6_sk(sk)->hop_limit; } static void __mptcp_sockopt_sync(struct mptcp_sock *msk, struct sock *ssk)