From patchwork Thu Apr 16 17:55:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel M. Weeks" X-Patchwork-Id: 1271831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4936RN4Zntz9sWT for ; Fri, 17 Apr 2020 03:58:56 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=rpi.edu Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4936RN0TN8zDrgD for ; Fri, 17 Apr 2020 03:58:56 +1000 (AEST) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=rpi.edu (client-ip=128.113.2.230; helo=smtp10.server.rpi.edu; envelope-from=weeksd2@rpi.edu; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=rpi.edu Received: from smtp10.server.rpi.edu (smtp10.server.rpi.edu [128.113.2.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4936MR5PJ1zDsM9 for ; Fri, 17 Apr 2020 03:55:30 +1000 (AEST) Received: from smtp-auth3.server.rpi.edu (route.canit.rpi.edu [128.113.2.233]) by smtp10.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHtQvj096264 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:55:27 -0400 Received: from smtp-auth3.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth3.server.rpi.edu (Postfix) with ESMTP id A80D0580DC for ; Thu, 16 Apr 2020 13:55:26 -0400 (EDT) Received: from dev.danweeks.net (cpe-74-70-107-6.nycap.res.rr.com [74.70.107.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: weeksd2) by smtp-auth3.server.rpi.edu (Postfix) with ESMTPSA id 8462C580D1 for ; Thu, 16 Apr 2020 13:55:26 -0400 (EDT) Date: Thu, 16 Apr 2020 13:55:21 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 07/11] Set hwaddr_len field when hwaddr is set Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Virus-Scanned: ClamAV using ClamSMTP X-Bayes-Prob: 0.0001 (Score 0, tokens from: outgoing, @@RPTN) X-Spam-Score: 0.00 () [Hold at 10.10] X-CanIt-Incident-Id: 032rtTqFd X-CanIt-Geo: ip=74.70.107.6; country=US; region=New York; city=Troy; latitude=42.7273; longitude=-73.6696; http://maps.google.com/maps?q=42.7273,-73.6696&z=6 X-CanItPRO-Stream: outgoing X-Canit-Stats-ID: Bayes signature not available X-Scanned-By: CanIt (www . roaringpenguin . com) on 128.113.2.230 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" The new hwaddr_len field should be set any time the hwaddr field is set to indicate the true length of hwaddr. In the future, the buffer size may not be indicative of the actual address length. Signed-off-by: Daniel M. Weeks --- discover/ipmi.c | 1 + discover/network.c | 1 + discover/platform-powerpc.c | 2 ++ lib/pb-config/pb-config.c | 1 + ui/ncurses/nc-config.c | 1 + 5 files changed, 6 insertions(+) diff --git a/discover/ipmi.c b/discover/ipmi.c index 32319fc..14a9e07 100644 --- a/discover/ipmi.c +++ b/discover/ipmi.c @@ -271,6 +271,7 @@ int parse_ipmi_interface_override(struct config *config, uint8_t *buf, /* Hardware Address */ memcpy(ifconf->hwaddr, &buf[i], hwsize); + ifconf->hwaddr_len = hwsize; i += hwsize; /* Check 1-byte ignore and method flags */ diff --git a/discover/network.c b/discover/network.c index 99f97b7..0433c70 100644 --- a/discover/network.c +++ b/discover/network.c @@ -686,6 +686,7 @@ void network_mark_interface_ready(struct device_handler *handler, interface->ifindex = ifindex; interface->state = IFSTATE_NEW; memcpy(interface->hwaddr, mac, hwsize); + interface->hwaddr_len = hwsize; strncpy(interface->name, ifname, sizeof(interface->name) - 1); list_for_each_entry(&network->interfaces, tmp, list) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 4c3c63a..be2fbab 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -266,6 +266,8 @@ static int parse_hwaddr(struct interface_config *ifconf, char *str) if (strlen(str) != strlen("00:00:00:00:00:00")) return -1; + ifconf->hwaddr_len = strlen(str) / 3 + 1; + for (i = 0; i < HWADDR_SIZE; i++) { char byte[3], *endp; unsigned long x; diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c index 7fa925c..b21626f 100644 --- a/lib/pb-config/pb-config.c +++ b/lib/pb-config/pb-config.c @@ -14,6 +14,7 @@ static struct interface_config *config_copy_interface(struct config *ctx, struct interface_config); memcpy(dest->hwaddr, src->hwaddr, sizeof(src->hwaddr)); + dest->hwaddr_len = src->hwaddr_len; dest->ignore = src->ignore; if (dest->ignore) diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 5c0f23b..d72955e 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -278,6 +278,7 @@ static int screen_process_form(struct config_screen *screen) idx = widget_select_get_value(screen->widgets.iface_f); memcpy(iface->hwaddr, sysinfo->interfaces[idx]->hwaddr, sizeof(iface->hwaddr)); + iface->hwaddr_len = sysinfo->interfaces[idx]->hwaddr_size; } if (net_conf_type == NET_CONF_TYPE_DHCP_ONE) {