From patchwork Thu Apr 16 17:59:28 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: 1271843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (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 4936XR2vzVz9sWb for ; Fri, 17 Apr 2020 04:03:19 +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 4936XR1Bg9zDrNg for ; Fri, 17 Apr 2020 04:03:19 +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 4936S62vmczDrq9 for ; Fri, 17 Apr 2020 03:59:33 +1000 (AEST) Received: from smtp-auth2.server.rpi.edu (route.canit.rpi.edu [128.113.2.232]) by smtp10.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHxUt5096909 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:59:30 -0400 Received: from smtp-auth2.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth2.server.rpi.edu (Postfix) with ESMTP id 32A6E1A0EA for ; Thu, 16 Apr 2020 13:59:30 -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-auth2.server.rpi.edu (Postfix) with ESMTPSA id 10C211A0DF for ; Thu, 16 Apr 2020 13:59:30 -0400 (EDT) Date: Thu, 16 Apr 2020 13:59:28 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 06/11] Write GUIDs to NVRAM Message-ID: <7fe88bbd5fc32ddad101832bac84eb01d0658df2.1587059235.git.weeksd2@rpi.edu> 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: 032rtXuJx 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" Store any hardware address up to the maximum size in NVRAM. Due to the way each octet is appended, a hardware address less than 2 can not be stored. Signed-off-by: Daniel M. Weeks --- discover/platform-powerpc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index a6e24fc..08c2b78 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -565,13 +565,19 @@ static void populate_config(struct platform_powerpc *platform, static char *iface_config_str(void *ctx, struct interface_config *config) { char *str; + unsigned int i; + + /* never this short but necessary */ + if (config->hwaddr_len < 2) + return NULL; - /* todo: HWADDR size is hardcoded as 6, but we may need to handle - * different hardware address formats */ - str = talloc_asprintf(ctx, "%02x:%02x:%02x:%02x:%02x:%02x,", - config->hwaddr[0], config->hwaddr[1], - config->hwaddr[2], config->hwaddr[3], - config->hwaddr[4], config->hwaddr[5]); + pb_debug("%s: hwaddr len %d", __func__, config->hwaddr_len); + str = talloc_asprintf(ctx, "%02x:", config->hwaddr[0]); + for (i = 1; i < config->hwaddr_len-1; i++) { + str = talloc_asprintf_append(str, "%02x:", config->hwaddr[i]); + } + str = talloc_asprintf_append(str, "%02x,", config->hwaddr[config->hwaddr_len-1]); + pb_debug("%s: hwaddr: %s\n", __func__, str); if (config->ignore) { str = talloc_asprintf_append(str, "ignore"); @@ -639,6 +645,8 @@ static void update_network_config(struct platform_powerpc *platform, for (i = 0; i < config->network.n_interfaces; i++) { char *iface_str = iface_config_str(platform, config->network.interfaces[i]); + if (iface_str == NULL) + continue; val = talloc_asprintf_append(val, "%s%s", *val == '\0' ? "" : " ", iface_str); talloc_free(iface_str);