From patchwork Fri Nov 30 20:03:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10707109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EACE13B0 for ; Fri, 30 Nov 2018 20:04:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8399028899 for ; Fri, 30 Nov 2018 20:04:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77AA928922; Fri, 30 Nov 2018 20:04:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C56AA28899 for ; Fri, 30 Nov 2018 20:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726629AbeLAHOW (ORCPT ); Sat, 1 Dec 2018 02:14:22 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:42859 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbeLAHOW (ORCPT ); Sat, 1 Dec 2018 02:14:22 -0500 Received: by mail-oi1-f193.google.com with SMTP id w13so5763835oiw.9; Fri, 30 Nov 2018 12:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1adVQGu3EzleOzF5553sjm9Y+OTh0F8rRsMvzXeiYLM=; b=Zw/9LYLtl29uqW/YnJZj+22JU0fgMEofliECH1R+e7N5JMHy6ZqMR5UgCbrrz5s8Lv 4t0QjFAhnorPuas5LvzoIAd3qP8QXfhhNTkchLs2TCwMkXujvFPa7/QNIn4la3qil9kk IbiBVNkIzRbi5yRx1typ7oPdUTkmdJZL3qr5chgJlk49J/CX6Eh0o+hg1ibaJzS6Pr9J q9Ccw1r8qfetzgkbGA4Etazh3Bmw7Gu5wm7jHfzLybOP52Sm63OBYHSRgmrtEIKCZQK1 g6rn3Rz9YhD5hnA/gaNkjdz4tRIPeciZYJSn/w2kly+C8qVIffjHikHd60K4fK+anCdJ Xz0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1adVQGu3EzleOzF5553sjm9Y+OTh0F8rRsMvzXeiYLM=; b=bFFmn/hHS6KrWYjDldwDByuDuoWI+Z4A9jOPJ0kIuFHqclRd2Lxrxaf5ks1ihuKy8M +196/gCW0/02G9kNdulAlhY/DLt0Rj1REVb7wRllEYmYHBr8vrhDEWCg2uGk6jYD3bnr miSKxjn8rKlPn+6Y43zJNGV/zCUyxI8JMp1nZCQ8/YHDrrz3VyKVjJm86XH8tRTT4yk/ OCjxcl8HKrlc9XTf43nWSMdCwYzRd75HTyL77j5cprYEHO440Fto0ABZHMhNnewjybW3 nG9a4bA6tD//95hTGnCbrgEIFpBXDeCTStHn/BHQM2ncGELN5y1SGEUvsgE1BFLQBYfR ov6w== X-Gm-Message-State: AA+aEWY7Bu33R68J+Mly20IhLIiE8P3G24fwHXiWw/i81TlyKKrOxZEG Lbvbs2Skc/rvf9nfLFN1LdUM49Rj X-Google-Smtp-Source: AFSGD/WPHu3XxwqKCQCVYrc4KK2qhasqXmsoOZ75yWO8yH32Oe77m9eFcYIwKyFeh4yW7qvu+37UwA== X-Received: by 2002:aca:a90f:: with SMTP id s15mr4289512oie.137.1543608237537; Fri, 30 Nov 2018 12:03:57 -0800 (PST) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id q10sm2065289otl.15.2018.11.30.12.03.55 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 30 Nov 2018 12:03:56 -0800 (PST) From: Olga Kornievskaia To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 03/10] NFSD fill-in netloc4 structure Date: Fri, 30 Nov 2018 15:03:41 -0500 Message-Id: <20181130200348.59524-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181130200348.59524-1-olga.kornievskaia@gmail.com> References: <20181130200348.59524-1-olga.kornievskaia@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP nfs.4 defines nfs42_netaddr structure that represents netloc4. Populate needed fields from the sockaddr structure. This will be used by flexfiles and 4.2 inter copy Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfsd.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 0668999..a8fec63 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -366,6 +367,37 @@ static inline bool nfsd4_spo_must_allow(struct svc_rqst *rqstp) extern const u32 nfsd_suppattrs[3][3]; +static inline u32 nfsd4_set_netaddr(struct sockaddr *addr, + struct nfs42_netaddr *netaddr) +{ + struct sockaddr_in *sin = (struct sockaddr_in *)addr; + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr; + unsigned int port; + size_t ret_addr, ret_port; + + switch (addr->sa_family) { + case AF_INET: + port = ntohs(sin->sin_port); + sprintf(netaddr->netid, "tcp"); + netaddr->netid_len = 3; + break; + case AF_INET6: + port = ntohs(sin6->sin6_port); + sprintf(netaddr->netid, "tcp6"); + netaddr->netid_len = 4; + break; + default: + return nfserr_inval; + } + ret_addr = rpc_ntop(addr, netaddr->addr, sizeof(netaddr->addr)); + ret_port = snprintf(netaddr->addr + ret_addr, + RPCBIND_MAXUADDRLEN + 1 - ret_addr, + ".%u.%u", port >> 8, port & 0xff); + WARN_ON(ret_port >= RPCBIND_MAXUADDRLEN + 1 - ret_addr); + netaddr->addr_len = ret_addr + ret_port; + return 0; +} + static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2) { return !((bm1[0] & ~bm2[0]) ||