From mboxrd@z Thu Jan 1 00:00:00 1970 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 CC754C54EBD for ; Sat, 7 Jan 2023 01:28:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1740885423; Sat, 7 Jan 2023 02:28:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="ZBb7uEXG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4235885368; Fri, 6 Jan 2023 23:23:05 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by phobos.denx.de (Postfix) with ESMTP id E66B7852C4 for ; Fri, 6 Jan 2023 23:23:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanedmond@linux.microsoft.com Received: from ovlvm106.redmond.corp.microsoft.com (unknown [131.107.174.57]) by linux.microsoft.com (Postfix) with ESMTPSA id A6C7420B8762; Fri, 6 Jan 2023 14:23:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A6C7420B8762 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1673043781; bh=fGrZ2YQrRvt/Mg8OI4U2EOUVPXUo6/hdhqkLX8pCPXE=; h=From:To:Cc:Subject:Date:From; b=ZBb7uEXGXkR0IYJ4SKPvr3/fxei+jsq4R3eHKiHrNkX5I9BH0fDBDvtaStOTeeeAk D4QgMVIA0JnGWdo+K7E2f80XI6+NlHZkla7+mUSNZISZcGUkgpSlx5+BUX1CjZjcx6 8bec+rpcwNnf/soiTtKWF7XGH3gcGYXy8e3MXeW8= From: seanedmond@linux.microsoft.com To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, v.v.mitrofanov@yadro.com, seanedmond@microsoft.com Subject: [PATCH] net: ipv6: Fix IPv6 netmask parsing Date: Fri, 6 Jan 2023 14:22:55 -0800 Message-Id: <20230106222255.15242-1-seanedmond@linux.microsoft.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Sat, 07 Jan 2023 02:28:28 +0100 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.6 at phobos.denx.de X-Virus-Status: Clean From: Sean Edmond It should be possible to specify a netmask when setting a static IPv6 address. For example: setenv ip6addr 2001:cafe:cafe:cafe::100/64 The net_prefix_length and net_ip6 should be updated properly. Signed-off-by: Sean Edmond --- net/net6.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/net6.c b/net/net6.c index fdea078788..75577bcea1 100644 --- a/net/net6.c +++ b/net/net6.c @@ -47,10 +47,13 @@ static int on_ip6addr(const char *name, const char *value, enum env_op op, } mask = strchr(value, '/'); - len = strlen(value); - if (mask) - net_prefix_length = simple_strtoul(value + len, NULL, 10); + if (mask) { + net_prefix_length = simple_strtoul(mask + 1, NULL, 10); + len = mask - value; + } else { + len = strlen(value); + } return string_to_ip6(value, len, &net_ip6); } -- 2.39.0