Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1076653lqt; Fri, 7 Jun 2024 07:27:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3jbYT/SXfAch17guvf2zZiimXaE89GWT1KcVrQ/ROcDmeQ1sFPh6xTqS8gsNK35gmriJNjwstApMUpsF1qfdG9ZQPVLM0cRoB30UQwg== X-Google-Smtp-Source: AGHT+IFsfuv5DqrDyju28kPGi7XDStpr3GqZT0UvX3ORkUWxznVn5AJBzWQRJbyoHDil2C1s/onF X-Received: by 2002:a05:622a:4b16:b0:440:5030:3946 with SMTP id d75a77b69052e-44050303d37mr14054501cf.19.1717770430420; Fri, 07 Jun 2024 07:27:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717770430; cv=pass; d=google.com; s=arc-20160816; b=tQ7K4TYAAwpHPl1oahX5qeEM7iI68RFPFc5TKMa9twnqZfQ/eogZZD98/a0spoqzd7 LmxQA/yL1XSWzil34aX55c5sGlZFZ3KainFejgsdjE+7xLg3H7ZTvVQiPc0js5GJpLp+ rOhc6LVVMFctAKfuqT3ioSNtVTXI597sy0aMANYwylP2AdFqH7/fIHFHUdA3YeLmGCK1 BfhVgyhDeERB/sma2lK/kW6qNehsMLNAuW3Uz5kOKBEvLvp5Q82iBD17cNOz6t1VwWU5 yUhrgFVoMg8aboFOzbSp1mHj69l9gpG/jjkEj1/4bOZ9gz6G6BRzGHE/Zrzb9/OhJ1ZG NgTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=M9dlgZkIscT7i9SR2+2bwIs/yvQBVrOiww8RhLy2Pik=; fh=OUKZWod6C22emJS3X689dwhO5bDgGbDS06P/Z6+EGqk=; b=HKdM/943LfBsIHOUcep2/0cl3PdfyXcBbUOyQpOwkFtetWFLu95d45Is973bNhjEoW 9VaPdRdBx/4viDBQCzp7/pL/bFC0k8k3g5S5ebtLFq3dazHBLdDq0qxxzt7pgcEvVaaJ IZk8xx6BBJQ6kxaKdFZ/9bKjtSjG3nE8uDUgkvTf2C3Scg+6ABwOQUpKSYEg17PN9bdb Yj9q7S7yLztKj0su7oQn+Ykeb/d3uG8Y+WPVn1gOmqKg7AkeXVJPxR3um8zswKANtQ3D z3+TLNgeLDc8oQ6BsSr08Lmr8CUQAJDcLW5FccH+42RePXtVgK3r1MkGT6v8UJwi2E5M jfTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3592-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3592-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 d75a77b69052e-44038b3846bsi40946111cf.406.2024.06.07.07.27.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3592-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; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3592-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3592-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 0607B1C22CF0 for ; Fri, 7 Jun 2024 14:27:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F576195990; Fri, 7 Jun 2024 14:27:02 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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 D00BF1974F7 for ; Fri, 7 Jun 2024 14:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770422; cv=none; b=kMM6ZPiY4x/xjU/ZSBQ78N1F0lyjYlgIFGvQvxXWHkNaOcy/4djCVwJ0obMrni8OFfa3/cOPyzTeEnRXBf5C3oURIuaZJy/BjvnF6Ie3fXXADDSFG0lp1j2Cgr3hq1Eac5zbpQTnNBnwH4f3zLvhd6L4no2KZtVVUSsV1jtQ6bk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770422; c=relaxed/simple; bh=cIb3MJM4RkF/Px7ti/U0lk0FUmVhCpxVRzmtxzt/KG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hS6r4m+x9BKAWbpt/npFeu2DXQMfX8QZHZQDyEYg2ZlPun2YB85uEQddWFKwm1SaOISJ3vixNUeS0hqdiwp2GEfSCLrHcxaThoAf3S+giRz6TJuo0/MfA62/rwaCND0vF5+X+wcgb6ot8fn4Jty1FG8qHY0FkaDY3kefWfUN8kY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=snitzer.net; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=snitzer.net Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-79523244ccfso170304285a.0 for ; Fri, 07 Jun 2024 07:27:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717770419; x=1718375219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M9dlgZkIscT7i9SR2+2bwIs/yvQBVrOiww8RhLy2Pik=; b=mrEL74Pv5uuqpcNi9FnCO74oHAQXDGDXjtqUSDbplJOOHeaY7ZdA8etPBNHmAeH2nc T4LV/hUD6R1rDbCNVZS5zi627UyhLE3ZUniQ10pqvKGHhSvGh6n9BsJzbP7y6gM5KHFp gegpqPWQo3RYsdFXeowzyIW967IMd/nW67CWYV5kNiUseCcw/pVZqz5sitzlENJmmfOw aNTX5NStjdyaMusd65cizIIFgCpfDDO8TSXwO+TqaEXl0QUpGYqOXZybRpNGVtuGdE0l eurJ/koJ9q5Wz2WQR6TfIB3jCOKhPmDplmhRohO/ImfnU0Gedoz3rrwn9HVHGy8Pem2w CAPw== X-Gm-Message-State: AOJu0YxDXXGCxMkIMgr/UyNHqrvjS/0tlNRK7ul6REv/ocNao59gNHhk AZq4d1lp7qRpz5zEAPScybekPsSDfyVvaNlLgHO1L1++DP3M9sHsBpFdnW2UO0iJmcb19nqTwZ0 NLlrSuQ== X-Received: by 2002:a05:620a:1a22:b0:795:4d37:82a8 with SMTP id af79cd13be357-7954d378dbcmr153909885a.22.1717770419305; Fri, 07 Jun 2024 07:26:59 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79532887f13sm170522585a.71.2024.06.07.07.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:26:58 -0700 (PDT) From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , snitzer@hammerspace.com Subject: [for-6.11 PATCH 07/29] sunrpc: add and export rpc_ntop6_addr_noscopeid Date: Fri, 7 Jun 2024 10:26:24 -0400 Message-ID: <20240607142646.20924-8-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org> References: <20240607142646.20924-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Peng Tao Signed-off-by: Peng Tao Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust Signed-off-by: Mike Snitzer --- include/linux/sunrpc/addr.h | 9 +++++++++ net/sunrpc/addr.c | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h index 07d454873b6d..e1007bddc3c4 100644 --- a/include/linux/sunrpc/addr.h +++ b/include/linux/sunrpc/addr.h @@ -68,6 +68,9 @@ static inline bool __rpc_copy_addr4(struct sockaddr *dst, } #if IS_ENABLED(CONFIG_IPV6) +extern size_t rpc_ntop6_addr_noscopeid(const struct in6_addr *addr, + char *buf, const int buflen); + static inline bool rpc_cmp_addr6(const struct sockaddr *sap1, const struct sockaddr *sap2) { @@ -94,6 +97,12 @@ static inline bool __rpc_copy_addr6(struct sockaddr *dst, return true; } #else /* !(IS_ENABLED(CONFIG_IPV6) */ +static size_t rpc_ntop6_addr_noscopeid(const struct in6_addr *addr, + char *buf, const int buflen) +{ + return 0; +} + static inline bool rpc_cmp_addr6(const struct sockaddr *sap1, const struct sockaddr *sap2) { diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index 97ff11973c49..78a123a7c39b 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c @@ -25,12 +25,9 @@ #if IS_ENABLED(CONFIG_IPV6) -static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, - char *buf, const int buflen) +size_t rpc_ntop6_addr_noscopeid(const struct in6_addr *addr, + char *buf, const int buflen) { - const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; - const struct in6_addr *addr = &sin6->sin6_addr; - /* * RFC 4291, Section 2.2.2 * @@ -55,13 +52,23 @@ static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, */ if (ipv6_addr_v4mapped(addr)) return snprintf(buf, buflen, "::ffff:%pI4", - &addr->s6_addr32[3]); + &addr->s6_addr32[3]); /* * RFC 4291, Section 2.2.1 */ return snprintf(buf, buflen, "%pI6c", addr); } +EXPORT_SYMBOL_GPL(rpc_ntop6_addr_noscopeid); + +static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, + char *buf, const int buflen) +{ + const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; + const struct in6_addr *addr = &sin6->sin6_addr; + + return rpc_ntop6_addr_noscopeid(addr, buf, buflen); +} static size_t rpc_ntop6(const struct sockaddr *sap, char *buf, const size_t buflen) -- 2.44.0