Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AAF1EC64EC4 for ; Fri, 10 Mar 2023 09:53:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F352185F00; Fri, 10 Mar 2023 10:52:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CHGtTmAZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9695085984; Fri, 10 Mar 2023 10:52:23 +0100 (CET) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C2F4B85ACE for ; Fri, 10 Mar 2023 10:52:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=christian.gmeiner@gmail.com Received: by mail-ed1-x536.google.com with SMTP id s11so18145204edy.8 for ; Fri, 10 Mar 2023 01:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678441938; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5l2/vnOssndUtZ5+Q7DKVkWCRCdoA+b90rivly4LB4U=; b=CHGtTmAZTiKEP0MFCvF25l+lFMW/UEjV2PIE6Ks/X7Dn0DQ97wfU5iEvIDNyszbPg/ ieGuU4V87QT3MPysMFf770e4jLe8UYeqsKqcv9rjtkywDup9uQa2V4GlEz/vMlz7aY31 8dr47aNwDesKpdAHJOS+YBjOw+diqyuUCga5OPUtKtc3V8J4D6hP2grLgxU1VtyK3Mpy YLsEi+DFMaFkDDKs61fRpV/2lgQYpeb/dzAZkGOMM3V7obeW96ZeLWGzzGnXL+a2GDSN 7M4FD2E/wJyyWKjwKdgwp9Y2CVprWFR9RZJTpK/TYg9F7Urviz+HQXAh8M5A41dTXcyh Vb6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678441938; 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=5l2/vnOssndUtZ5+Q7DKVkWCRCdoA+b90rivly4LB4U=; b=nninZGVZLcBb2DLIoAHayLnganzGMTHIIBWq5VjKIhJuqdskMDjyhhd+7jrU7LAJn5 HhDJI3ADZj8PnHr+n74cnNdHFqrDfhAbrYBYwFo5vXv0tHc/s9cZgVZ9fXLUUCyG3bpA XuwvJNlo2ZaZxXK/rtFveKFcbLZK9OPfuTpZLVVzZoqmxKyAjBQjoUGm4RAP51bknF2L grnFdpTScQwKK3egQ0UP6bQpJFDFVkhKGkdCeyI9SxnGxN7h8AYibhv2B4jgvfpGX+QI FVN4kRCJQui8EydR+IuL2cKaMqDFrWliEtbdjTk4xMTGuf7DFXxtjaZ3mgt8/4LJuEiR 9+zQ== X-Gm-Message-State: AO0yUKWastF83BHhgMxew4zOOEba1VXziEMQwLPGv74llKxAAN56TEBa pbCnbGpx1zKTUjgxDgJAIvNzHLV8384= X-Google-Smtp-Source: AK7set/nTGdGzt2skKoILFE+TUSm38XOId23KazZSMrfn3+/IjckOJOO3JQcmpRZhNK3lEroJqt65Q== X-Received: by 2002:a17:907:8a06:b0:889:ed81:dff7 with SMTP id sc6-20020a1709078a0600b00889ed81dff7mr31100569ejc.9.1678441938368; Fri, 10 Mar 2023 01:52:18 -0800 (PST) Received: from localhost.localdomain (80-108-76-242.cable.dynamic.surfer.at. [80.108.76.242]) by smtp.gmail.com with ESMTPSA id i27-20020a50871b000000b004eb16b75b93sm613689edb.49.2023.03.10.01.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 01:52:17 -0800 (PST) From: Christian Gmeiner To: Joe Hershberger , Ramon Fried , u-boot@lists.denx.de (open list) Cc: Thomas RIENOESSL , u-boot@lists.denx.de (open list) Subject: [PATCH v2 4/4] net: add NFSv1 support Date: Fri, 10 Mar 2023 10:51:55 +0100 Message-Id: <20230310095155.29832-5-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310095155.29832-1-christian.gmeiner@gmail.com> References: <20230310095155.29832-1-christian.gmeiner@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Thomas RIENOESSL NFSv1 support added by Christian Gmeiner, Thomas Rienoessl, September 27, 2018. As of now, NFSv3 is the default choice. if the server does not support NFSv3, we fall back to versions 2 or 1. Signed-off-by: Thomas RIENOESSL --- net/nfs.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/net/nfs.c b/net/nfs.c index 21cae52f35..7a8887ef23 100644 --- a/net/nfs.c +++ b/net/nfs.c @@ -26,6 +26,10 @@ * NFSv2 is still used by default. But if server does not support NFSv2, then * NFSv3 is used, if available on NFS server. */ +/* NOTE 5: NFSv1 support added by Christian Gmeiner, Thomas Rienoessl, + * September 27, 2018. As of now, NFSv3 is the default choice. If the server + * does not support NFSv3, we fall back to versions 2 or 1. */ + #include #include #include @@ -78,6 +82,7 @@ static char nfs_path_buff[2048]; enum nfs_version { NFS_UNKOWN = 0, + NFS_V1 = 1, NFS_V2 = 2, NFS_V3 = 3, }; @@ -192,6 +197,7 @@ static void rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) switch (rpc_prog) { case PROG_NFS: switch (choosen_nfs_version) { + case NFS_V1: case NFS_V2: rpc_pkt.u.call.vers = htonl(2); break; @@ -205,8 +211,26 @@ static void rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) break; } break; - case PROG_PORTMAP: case PROG_MOUNT: + switch (choosen_nfs_version) { + case NFS_V1: + rpc_pkt.u.call.vers = htonl(1); + break; + + case NFS_V2: + rpc_pkt.u.call.vers = htonl(2); + break; + + case NFS_V3: + rpc_pkt.u.call.vers = htonl(3); + break; + + case NFS_UNKOWN: + /* nothing to do */ + break; + } + break; + case PROG_PORTMAP: default: rpc_pkt.u.call.vers = htonl(2); /* portmapper is version 2 */ } @@ -311,7 +335,7 @@ static void nfs_readlink_req(void) p = &(data[0]); p = rpc_add_credentials(p); - if (choosen_nfs_version == NFS_V2) { + if (choosen_nfs_version != NFS_V3) { memcpy(p, filefh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); } else { /* NFS_V3 */ @@ -340,7 +364,7 @@ static void nfs_lookup_req(char *fname) p = &(data[0]); p = rpc_add_credentials(p); - if (choosen_nfs_version == NFS_V2) { + if (choosen_nfs_version != NFS_V3) { memcpy(p, dirfh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(fnamelen); @@ -380,7 +404,7 @@ static void nfs_read_req(int offset, int readlen) p = &(data[0]); p = rpc_add_credentials(p); - if (choosen_nfs_version == NFS_V2) { + if (choosen_nfs_version != NFS_V3) { memcpy(p, filefh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(offset); @@ -410,13 +434,13 @@ static void nfs_send(void) switch (nfs_state) { case STATE_PRCLOOKUP_PROG_MOUNT_REQ: - if (choosen_nfs_version == NFS_V2) + if (choosen_nfs_version != NFS_V3) rpc_lookup_req(PROG_MOUNT, 1); else /* NFS_V3 */ rpc_lookup_req(PROG_MOUNT, 3); break; case STATE_PRCLOOKUP_PROG_NFS_REQ: - if (choosen_nfs_version == NFS_V2) + if (choosen_nfs_version != NFS_V3) rpc_lookup_req(PROG_NFS, 2); else /* NFS_V3 */ rpc_lookup_req(PROG_NFS, 3); @@ -457,7 +481,7 @@ static int rpc_handle_error(struct rpc_t *rpc_pkt) const int min = ntohl(rpc_pkt->u.reply.data[0]); const int max = ntohl(rpc_pkt->u.reply.data[1]); - if (max < NFS_V2 || max > NFS_V3 || min > NFS_V3) { + if (max < NFS_V1 || max > NFS_V3 || min > NFS_V3) { puts("*** ERROR: NFS version not supported"); debug(": Requested: V%d, accepted: min V%d - max V%d\n", choosen_nfs_version, @@ -588,7 +612,7 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len) if (ret) return ret; - if (choosen_nfs_version == NFS_V2) { + if (choosen_nfs_version != NFS_V3) { if (((uchar *)&(rpc_pkt.u.reply.data[0]) - (uchar *)(&rpc_pkt) + NFS_FHSIZE) > len) return -NFS_RPC_DROP; memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE); @@ -712,7 +736,7 @@ static int nfs_read_reply(uchar *pkt, unsigned len) if (!(nfs_offset % ((NFS_READ_SIZE / 2) * 10))) putc('#'); - if (choosen_nfs_version == NFS_V2) { + if (choosen_nfs_version != NFS_V3) { rlen = ntohl(rpc_pkt.u.reply.data[18]); data_ptr = (uchar *)&(rpc_pkt.u.reply.data[19]); } else { /* NFS_V3 */ -- 2.39.2