From patchwork Thu Apr 16 17:53:40 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: 1271822 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 4936PJ1SzLz9sWM for ; Fri, 17 Apr 2020 03:57:08 +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 4936PH0ZydzDsGv for ; Fri, 17 Apr 2020 03:57:07 +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.229; helo=smtp9.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 smtp9.server.rpi.edu (smtp9.server.rpi.edu [128.113.2.229]) (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 4936KZ6hPgzDqFD for ; Fri, 17 Apr 2020 03:53:53 +1000 (AEST) Received: from smtp-auth3.server.rpi.edu (smtp-auth3.server.rpi.edu [128.113.2.233]) by smtp9.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHrnOL115648 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:53:50 -0400 Received: from smtp-auth3.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth3.server.rpi.edu (Postfix) with ESMTP id D51EE580B7 for ; Thu, 16 Apr 2020 13:53:44 -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 B43775804D for ; Thu, 16 Apr 2020 13:53:44 -0400 (EDT) Date: Thu, 16 Apr 2020 13:53:40 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 01/11] Debug parsing hwaddr in NVRAM config read 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: 022rtRO8f 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.229 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" This should never happen. If it does, it indicates either failing NVRAM or a bug between storing and loading a hardware address. Signed-off-by: Daniel M. Weeks --- discover/platform-powerpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index dc4abb8..4c3c63a 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -300,8 +300,10 @@ static int parse_one_interface_config(struct config *config, if (!tok) goto out_err; - if (parse_hwaddr(ifconf, tok)) + if (parse_hwaddr(ifconf, tok)) { + pb_debug("Failed to parse hwaddr from config\n"); goto out_err; + } /* second token is the method */ tok = strtok_r(NULL, ",", &saveptr); From patchwork Thu Apr 16 17:54:01 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: 1271823 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 4936Pg5bYJz9sWQ for ; Fri, 17 Apr 2020 03:57:27 +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 4936Pd3vKtzDsJQ for ; Fri, 17 Apr 2020 03:57:25 +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 4936Kx01fczDqFD for ; Fri, 17 Apr 2020 03:54:12 +1000 (AEST) Received: from smtp-auth2.server.rpi.edu (smtp-auth2.server.rpi.edu [128.113.2.232]) by smtp10.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHs6Td095935 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:54:07 -0400 Received: from smtp-auth2.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth2.server.rpi.edu (Postfix) with ESMTP id DB9771A05B for ; Thu, 16 Apr 2020 13:54:06 -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 BA1F11A037 for ; Thu, 16 Apr 2020 13:54:06 -0400 (EDT) Date: Thu, 16 Apr 2020 13:54:01 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 02/11] Debug failure to find device during requery Message-ID: <0aceb8d1aede12b3d946ae67a9ae5850faba9667.1587059210.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: 032rtS7Cn 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" This should never happen. If it does, it likely indicates a bug where network device UUIDs and hardware addresses are not treated/parsed the same way. Signed-off-by: Daniel M. Weeks --- discover/network.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/discover/network.c b/discover/network.c index 6457f9e..041367f 100644 --- a/discover/network.c +++ b/discover/network.c @@ -508,8 +508,10 @@ void network_requery_device(struct network *network, struct interface *interface; interface = find_interface_by_uuid(network, dev->uuid); - if (!interface) + if (!interface) { + pb_debug("Unable to find %s to requery\n", dev->uuid); return; + } if (interface->udhcpc_process) { interface->udhcpc_process->exit_cb = NULL; From patchwork Thu Apr 16 17:54:18 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: 1271824 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 4936Q52YwCz9sWM for ; Fri, 17 Apr 2020 03:57:49 +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 4936Q45qHXzDsG2 for ; Fri, 17 Apr 2020 03:57:48 +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.229; helo=smtp9.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 smtp9.server.rpi.edu (smtp9.server.rpi.edu [128.113.2.229]) (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 4936LF1kHrzDrR2 for ; Fri, 17 Apr 2020 03:54:28 +1000 (AEST) Received: from smtp-auth3.server.rpi.edu (route.canit.rpi.edu [128.113.2.233]) by smtp9.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHsM44115806 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:54:23 -0400 Received: from smtp-auth3.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth3.server.rpi.edu (Postfix) with ESMTP id B000458099 for ; Thu, 16 Apr 2020 13:54:22 -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 909DE5804D for ; Thu, 16 Apr 2020 13:54:22 -0400 (EDT) Date: Thu, 16 Apr 2020 13:54:18 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 03/11] Use hwsize rather than HWADDR_SIZE Message-ID: <55f2711b818b0d5aa535b74ec514058c0738dba0.1587059210.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: 022rtSm9S 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.229 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" This is mainly housekeeping in the interest of future flexibility. For now, hwsize is still required to be HWADDR_SIZE. Signed-off-by: Daniel M. Weeks --- discover/network.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discover/network.c b/discover/network.c index 041367f..62df720 100644 --- a/discover/network.c +++ b/discover/network.c @@ -684,7 +684,7 @@ void network_mark_interface_ready(struct device_handler *handler, interface = talloc_zero(network, struct interface); interface->ifindex = ifindex; interface->state = IFSTATE_NEW; - memcpy(interface->hwaddr, mac, HWADDR_SIZE); + memcpy(interface->hwaddr, mac, hwsize); strncpy(interface->name, ifname, sizeof(interface->name) - 1); list_for_each_entry(&network->interfaces, tmp, list) @@ -713,7 +713,7 @@ void network_mark_interface_ready(struct device_handler *handler, talloc_strdup(interface->dev->device, ifname); } - if (memcmp(interface->hwaddr, mac, HWADDR_SIZE) != 0) { + if (memcmp(interface->hwaddr, mac, hwsize) != 0) { macstr = mac_bytes_to_string(interface, mac, hwsize); pb_log("Warning - new MAC for interface %d does not match: %s\n", ifindex, macstr); From patchwork Thu Apr 16 17:54:34 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: 1271825 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4936QN58Hnz9sWQ for ; Fri, 17 Apr 2020 03:58:04 +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 4936QL4FQczDrg6 for ; Fri, 17 Apr 2020 03:58:02 +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 4936LV1zk8zDsGm for ; Fri, 17 Apr 2020 03:54:41 +1000 (AEST) Received: from smtp-auth1.server.rpi.edu (smtp-auth1.server.rpi.edu [128.113.2.231]) by smtp10.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHscTO096076 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:54:38 -0400 Received: from smtp-auth1.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth1.server.rpi.edu (Postfix) with ESMTP id A9EE2580B6 for ; Thu, 16 Apr 2020 13:54:38 -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-auth1.server.rpi.edu (Postfix) with ESMTPSA id 8902A5805A for ; Thu, 16 Apr 2020 13:54:38 -0400 (EDT) Date: Thu, 16 Apr 2020 13:54:34 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 04/11] Make MAC address length requirement explicit Message-ID: <73eae9f3e19004708ded8e3381f32dfe08ee958e.1587059210.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: 032rtSCDt 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" In the future, the size of the hwaddr buffer may not be 6 bytes. Signed-off-by: Daniel M. Weeks --- discover/ipmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discover/ipmi.c b/discover/ipmi.c index d652e9f..32319fc 100644 --- a/discover/ipmi.c +++ b/discover/ipmi.c @@ -244,7 +244,7 @@ int parse_ipmi_interface_override(struct config *config, uint8_t *buf, } /* At the moment only support 6-byte MAC addresses */ - if (hwsize != sizeof(ifconf->hwaddr)) { + if (hwsize != HWADDR_SIZE) { pb_log("Unsupported HW address size in network override: %u\n", hwsize); return -1; From patchwork Thu Apr 16 17:54:48 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: 1271826 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 4936Qd6GzQz9sWM for ; Fri, 17 Apr 2020 03:58:17 +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 4936Qc09H2zDsMK for ; Fri, 17 Apr 2020 03:58:16 +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.229; helo=smtp9.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 smtp9.server.rpi.edu (smtp9.server.rpi.edu [128.113.2.229]) (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 4936M03YJvzDrR2 for ; Fri, 17 Apr 2020 03:55:08 +1000 (AEST) Received: from smtp-auth3.server.rpi.edu (smtp-auth3.server.rpi.edu [128.113.2.233]) by smtp9.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHsrc3115906 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:54:56 -0400 Received: from smtp-auth3.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth3.server.rpi.edu (Postfix) with ESMTP id B1EB5580E0 for ; Thu, 16 Apr 2020 13:54:52 -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 71874580DF for ; Thu, 16 Apr 2020 13:54:52 -0400 (EDT) Date: Thu, 16 Apr 2020 13:54:48 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 05/11] Add hwaddr length field to interface config Message-ID: <851952481e8176e31ded29bb696a050f2797b1a1.1587059210.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: 022rtSRat 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.229 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" This field allows hardware addresses of different lengths to be stored in in the fixed-size field hwaddr. The pb interface_config (de)serialize functions are updated to include this new field. Signed-off-by: Daniel M. Weeks --- lib/pb-protocol/pb-protocol.c | 8 +++++++- lib/types/types.h | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index dbbda40..b5186ad 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -273,7 +273,7 @@ static int pb_protocol_interface_config_len(struct interface_config *conf) { unsigned int len; - len = sizeof(conf->hwaddr) + + len = 4 + sizeof(conf->hwaddr) + 4 /* conf->ignore */; if (conf->ignore) @@ -524,6 +524,9 @@ static int pb_protocol_serialise_config_interface(char *buf, { char *pos = buf; + *(uint32_t *)pos = __cpu_to_be32(conf->hwaddr_len); + pos += 4; + memcpy(pos, conf->hwaddr, sizeof(conf->hwaddr)); pos += sizeof(conf->hwaddr); @@ -1058,6 +1061,9 @@ static int pb_protocol_deserialise_config_interface(const char **buf, { unsigned int tmp; + if (read_u32(buf, len, &iface->hwaddr_len)) + return -1; + if (*len < sizeof(iface->hwaddr)) return -1; diff --git a/lib/types/types.h b/lib/types/types.h index 9ab2a43..719332a 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -139,8 +139,9 @@ struct system_info { #define HWADDR_SIZE 6 struct interface_config { - uint8_t hwaddr[HWADDR_SIZE]; - bool ignore; + unsigned int hwaddr_len; + uint8_t hwaddr[HWADDR_SIZE]; + bool ignore; enum { CONFIG_METHOD_DHCP, CONFIG_METHOD_STATIC, From patchwork Thu Apr 16 17:55:04 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: 1271829 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 4936R25GHTz9sWS for ; Fri, 17 Apr 2020 03:58:38 +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 4936R13MrrzDqkS for ; Fri, 17 Apr 2020 03:58:37 +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 4936MD5VbYzDqYn for ; Fri, 17 Apr 2020 03:55:19 +1000 (AEST) Received: from smtp-auth1.server.rpi.edu (route.canit.rpi.edu [128.113.2.231]) by smtp10.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHt93n096203 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:55:10 -0400 Received: from smtp-auth1.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth1.server.rpi.edu (Postfix) with ESMTP id A1C0F58096 for ; Thu, 16 Apr 2020 13:55:09 -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-auth1.server.rpi.edu (Postfix) with ESMTPSA id 7A80558089 for ; Thu, 16 Apr 2020 13:55:09 -0400 (EDT) Date: Thu, 16 Apr 2020 13:55:04 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 06/11] Add hwaddr length field to interface 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: 032rtT9E7 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" This adds a field to the interface data structure within the network unit, to match the field added to the interface config. Signed-off-by: Daniel M. Weeks --- discover/network.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/discover/network.c b/discover/network.c index 62df720..99f97b7 100644 --- a/discover/network.c +++ b/discover/network.c @@ -40,9 +40,10 @@ struct interface { - int ifindex; - char name[IFNAMSIZ]; - uint8_t hwaddr[HWADDR_SIZE]; + int ifindex; + char name[IFNAMSIZ]; + uint8_t hwaddr[HWADDR_SIZE]; + unsigned int hwaddr_len; enum { IFSTATE_NEW, 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) { From patchwork Thu Apr 16 17:55:41 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: 1271832 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 4936Rn4JnQz9sWS for ; Fri, 17 Apr 2020 03:59:17 +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 4936Rm6QbpzDqkS for ; Fri, 17 Apr 2020 03:59:16 +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 4936Mr3fyWzDsM2 for ; Fri, 17 Apr 2020 03:55:52 +1000 (AEST) Received: from smtp-auth1.server.rpi.edu (route.canit.rpi.edu [128.113.2.231]) by smtp10.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHtl1p096325 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:55:47 -0400 Received: from smtp-auth1.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth1.server.rpi.edu (Postfix) with ESMTP id 113A758108 for ; Thu, 16 Apr 2020 13:55:47 -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-auth1.server.rpi.edu (Postfix) with ESMTPSA id E492F58104 for ; Thu, 16 Apr 2020 13:55:46 -0400 (EDT) Date: Thu, 16 Apr 2020 13:55:41 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 08/11] New function to compare hardware addresses 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: 032rtTLFA 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" This simplifies comparing hardware address buffers when they may be of different lengths. Signed-off-by: Daniel M. Weeks --- lib/util/util.c | 13 +++++++++++++ lib/util/util.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/lib/util/util.c b/lib/util/util.c index a18926c..e672d19 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -47,3 +47,16 @@ void mac_str(uint8_t *mac, unsigned int maclen, char *buf, unsigned int buflen) return; } + +int hwaddr_cmp(uint8_t *hwaddr1, size_t hwaddr1_len, uint8_t *hwaddr2, size_t hwaddr2_len) +{ + /* emulate memcmp even though it's unnecessary */ + + if (hwaddr1_len > hwaddr2_len) + return 1; + + if (hwaddr1_len < hwaddr2_len) + return -1; + + return memcmp(hwaddr1, hwaddr2, hwaddr1_len); +} diff --git a/lib/util/util.h b/lib/util/util.h index 39966d0..416e1af 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -18,6 +18,7 @@ #ifndef UTIL_H #define UTIL_H +#include #include #ifndef container_of @@ -51,5 +52,7 @@ void mac_str(uint8_t *mac, unsigned int maclen, char *buf, unsigned int buflen); +int hwaddr_cmp(uint8_t *hwaddr1, size_t hwaddr1_len, uint8_t *hwaddr2, size_t hwaddr2_len); + #endif /* UTIL_H */ From patchwork Thu Apr 16 17:56:00 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: 1271833 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 4936S32cRJz9sWS for ; Fri, 17 Apr 2020 03:59:31 +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 4936S24rmzzDsGm for ; Fri, 17 Apr 2020 03:59:30 +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 4936NC1yX2zDsGh for ; Fri, 17 Apr 2020 03:56:10 +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 03GHu5Zc096377 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:56:06 -0400 Received: from smtp-auth3.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth3.server.rpi.edu (Postfix) with ESMTP id 2359A58024 for ; Thu, 16 Apr 2020 13:56:05 -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 F03CF58008 for ; Thu, 16 Apr 2020 13:56:04 -0400 (EDT) Date: Thu, 16 Apr 2020 13:56:00 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 09/11] Use hwaddr_len over sizeof hwaddr Message-ID: <492d4efdba3eaf9edbac5218f83367658238ba81.1587059210.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: 032rtU5G2 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 length of the hardware address stored in hwaddr may be shorter than the size of the field. Only the actual length should be used in comparisons and transformations of hwaddr. Signed-off-by: Daniel M. Weeks --- discover/network.c | 25 +++++++++++++------------ discover/platform-powerpc.c | 4 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/discover/network.c b/discover/network.c index 0433c70..8637fc8 100644 --- a/discover/network.c +++ b/discover/network.c @@ -89,7 +89,7 @@ static char *mac_bytes_to_string(void *ctx, uint8_t *addr, int len) } static const struct interface_config *find_config_by_hwaddr( - uint8_t *hwaddr) + uint8_t *hwaddr, int hwaddr_len) { const struct config *config; unsigned int i; @@ -140,7 +140,7 @@ static struct interface *find_interface_by_uuid(struct network *network, list_for_each_entry(&network->interfaces, interface, list) { mac = mac_bytes_to_string(interface, interface->hwaddr, - sizeof(interface->hwaddr)); + interface->hwaddr_len); if (!strcmp(mac, uuid)) { talloc_free(mac); return interface; @@ -161,7 +161,7 @@ uint8_t *find_mac_by_name(void *ctx, struct network *network, return NULL; return talloc_memdup(ctx, &interface->hwaddr, - sizeof(uint8_t) * HWADDR_SIZE); + interface->hwaddr_len); } static int network_init_netlink(struct network *network) @@ -221,7 +221,7 @@ static void create_interface_dev(struct network *network, struct interface *interface) { char *uuid = mac_bytes_to_string(interface, interface->hwaddr, - sizeof(interface->hwaddr)); + interface->hwaddr_len); interface->dev = discover_device_create(network->handler, uuid, interface->name); @@ -253,7 +253,7 @@ void network_register_device(struct network *network, iface->dev = dev; dev->uuid = mac_bytes_to_string(iface->dev, iface->hwaddr, - sizeof(iface->hwaddr)); + iface->hwaddr_len); } void network_unregister_device(struct network *network, @@ -390,7 +390,7 @@ static void configure_interface_static(struct network *network, return; } - system_info_set_interface_address(sizeof(interface->hwaddr), + system_info_set_interface_address(interface->hwaddr_len, interface->hwaddr, config->static_config.address); @@ -417,7 +417,7 @@ static void configure_interface_static(struct network *network, config->static_config.url, mac_bytes_to_string(interface->dev, interface->hwaddr, - sizeof(interface->hwaddr)), + interface->hwaddr_len), config->static_config.address); device_handler_start_requery_timeout(network->handler, interface->dev, -1); @@ -455,7 +455,8 @@ static void configure_interface(struct network *network, return; } - config = find_config_by_hwaddr(interface->hwaddr); + config = find_config_by_hwaddr(interface->hwaddr, interface->hwaddr_len); + if (config && config->ignore) { pb_log("network: ignoring interface %s\n", interface->name); interface->state = IFSTATE_IGNORED; @@ -521,7 +522,7 @@ void network_requery_device(struct network *network, process_release(interface->udhcpc_process); } - config = find_config_by_hwaddr(interface->hwaddr); + config = find_config_by_hwaddr(interface->hwaddr, interface->hwaddr_len); if (config && config->ignore) return; @@ -540,7 +541,7 @@ void network_requery_device(struct network *network, config->static_config.url, mac_bytes_to_string(interface->dev, interface->hwaddr, - sizeof(interface->hwaddr)), + interface->hwaddr_len), config->static_config.address); device_handler_start_requery_timeout(network->handler, dev, -1); @@ -613,7 +614,7 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg) interface = talloc_zero(network, struct interface); interface->ifindex = info->ifi_index; interface->state = IFSTATE_NEW; - memcpy(interface->hwaddr, ifaddr, sizeof(interface->hwaddr)); + memcpy(interface->hwaddr, ifaddr, interface->hwaddr_len); strncpy(interface->name, ifname, sizeof(interface->name) - 1); list_for_each_entry(&network->interfaces, tmp, list) @@ -641,7 +642,7 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg) /* notify the sysinfo code about changes to this interface */ if (strcmp(interface->name, "lo")) system_info_register_interface( - sizeof(interface->hwaddr), + interface->hwaddr_len, interface->hwaddr, interface->name, info->ifi_flags & IFF_LOWER_UP); diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index be2fbab..9bdba30 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -261,14 +261,14 @@ static void set_param(struct platform_powerpc *platform, const char *name, static int parse_hwaddr(struct interface_config *ifconf, char *str) { - int i; + unsigned int i; 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++) { + for (i = 0; i < ifconf->hwaddr_len; i++) { char byte[3], *endp; unsigned long x; From patchwork Thu Apr 16 17:56:15 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: 1271834 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 4936SM5B2Lz9sWS for ; Fri, 17 Apr 2020 03:59:47 +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 4936SL1PDhzDsM4 for ; Fri, 17 Apr 2020 03:59:46 +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 4936NV1sWxzDsM2 for ; Fri, 17 Apr 2020 03:56:25 +1000 (AEST) Received: from smtp-auth3.server.rpi.edu (smtp-auth3.server.rpi.edu [128.113.2.233]) by smtp10.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHuKMg096436 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:56:20 -0400 Received: from smtp-auth3.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth3.server.rpi.edu (Postfix) with ESMTP id 1F5F5580C5 for ; Thu, 16 Apr 2020 13:56:20 -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 F2B04580AA for ; Thu, 16 Apr 2020 13:56:19 -0400 (EDT) Date: Thu, 16 Apr 2020 13:56:15 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 10/11] Use helper when comparing hardware addresses Message-ID: <5cf6f70927fc8ecb887c5e11a58d9eb5bba32a17.1587059210.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: 032rtUkGj 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" Since hwaddr fields may store hardware addresses of different lengths, it's necessary to use hwaddr_cmp which will compare lengths before comparing contents. In some cases this was already done but the helper has been substituted for consistency. Signed-off-by: Daniel M. Weeks --- discover/network.c | 12 ++++++------ discover/sysinfo.c | 11 +++-------- ui/ncurses/nc-config.c | 5 +++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/discover/network.c b/discover/network.c index 8637fc8..a2a17e0 100644 --- a/discover/network.c +++ b/discover/network.c @@ -101,7 +101,7 @@ static const struct interface_config *find_config_by_hwaddr( for (i = 0; i < config->network.n_interfaces; i++) { struct interface_config *ifconf = config->network.interfaces[i]; - if (!memcmp(ifconf->hwaddr, hwaddr, HWADDR_SIZE)) + if (!hwaddr_cmp(ifconf->hwaddr, ifconf->hwaddr_len, hwaddr, hwaddr_len)) return ifconf; } @@ -618,8 +618,8 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg) strncpy(interface->name, ifname, sizeof(interface->name) - 1); list_for_each_entry(&network->interfaces, tmp, list) - if (memcmp(interface->hwaddr, tmp->hwaddr, - sizeof(interface->hwaddr)) == 0) { + if (hwaddr_cmp(interface->hwaddr, interface->hwaddr_len, + tmp->hwaddr, tmp->hwaddr_len) == 0) { pb_log("%s: %s has duplicate MAC address, ignoring\n", __func__, interface->name); talloc_free(interface); @@ -691,8 +691,8 @@ void network_mark_interface_ready(struct device_handler *handler, strncpy(interface->name, ifname, sizeof(interface->name) - 1); list_for_each_entry(&network->interfaces, tmp, list) - if (memcmp(interface->hwaddr, tmp->hwaddr, - sizeof(interface->hwaddr)) == 0) { + if (hwaddr_cmp(interface->hwaddr, interface->hwaddr_len, + tmp->hwaddr, tmp->hwaddr_len) == 0) { pb_log("%s: %s has duplicate MAC address, ignoring\n", __func__, interface->name); talloc_free(interface); @@ -716,7 +716,7 @@ void network_mark_interface_ready(struct device_handler *handler, talloc_strdup(interface->dev->device, ifname); } - if (memcmp(interface->hwaddr, mac, hwsize) != 0) { + if (hwaddr_cmp(interface->hwaddr, interface->hwaddr_len, mac, hwsize) != 0) { macstr = mac_bytes_to_string(interface, mac, hwsize); pb_log("Warning - new MAC for interface %d does not match: %s\n", ifindex, macstr); diff --git a/discover/sysinfo.c b/discover/sysinfo.c index 74d1eae..73012e8 100644 --- a/discover/sysinfo.c +++ b/discover/sysinfo.c @@ -5,6 +5,7 @@ #include #include +#include #include "discover-server.h" #include "platform.h" #include "sysinfo.h" @@ -37,10 +38,7 @@ void system_info_set_interface_address(unsigned int hwaddr_size, for (i = 0; i < sysinfo->n_interfaces; i++) { if_info = sysinfo->interfaces[i]; - if (if_info->hwaddr_size != hwaddr_size) - continue; - - if (memcmp(if_info->hwaddr, hwaddr, hwaddr_size)) + if (hwaddr_cmp(if_info->hwaddr, if_info->hwaddr_size, hwaddr, hwaddr_size)) continue; /* Found an existing interface. Notify clients if a new address @@ -68,10 +66,7 @@ void system_info_register_interface(unsigned int hwaddr_size, uint8_t *hwaddr, if_info = sysinfo->interfaces[i]; - if (if_info->hwaddr_size != hwaddr_size) - continue; - - if (memcmp(if_info->hwaddr, hwaddr, hwaddr_size)) + if (hwaddr_cmp(if_info->hwaddr, if_info->hwaddr_size, hwaddr, hwaddr_size)) continue; /* Found an existing interface. Notify clients on any name or diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index d72955e..4eb2499 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -29,6 +29,7 @@ #include #include +#include #include "nc-cui.h" #include "nc-config.h" #include "nc-widgets.h" @@ -988,8 +989,8 @@ static void config_screen_setup_widgets(struct config_screen *screen, char str[50], mac[20]; bool is_default; - is_default = ifcfg && !memcmp(ifcfg->hwaddr, info->hwaddr, - sizeof(ifcfg->hwaddr)); + is_default = ifcfg && !hwaddr_cmp(ifcfg->hwaddr, ifcfg->hwaddr_len, info->hwaddr, + info->hwaddr_size); mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac)); snprintf(str, sizeof(str), "%s [%s, %s]", info->name, mac, From patchwork Thu Apr 16 17:56:31 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: 1271835 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 4936Sk4gsNz9sWT for ; Fri, 17 Apr 2020 04:00:06 +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 4936Sk0vlNzDsJQ for ; Fri, 17 Apr 2020 04:00:06 +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.229; helo=smtp9.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 smtp9.server.rpi.edu (smtp9.server.rpi.edu [128.113.2.229]) (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 4936Nl36nZzDqFD for ; Fri, 17 Apr 2020 03:56:38 +1000 (AEST) Received: from smtp-auth2.server.rpi.edu (route.canit.rpi.edu [128.113.2.232]) by smtp9.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHuZ3b116208 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:56:35 -0400 Received: from smtp-auth2.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth2.server.rpi.edu (Postfix) with ESMTP id 222B91A0E9 for ; Thu, 16 Apr 2020 13:56:35 -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 018651A0E8 for ; Thu, 16 Apr 2020 13:56:34 -0400 (EDT) Date: Thu, 16 Apr 2020 13:56:31 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 11/11] Rename HWADDR_SIZE for clarity Message-ID: <1392b2684ad07f20633299a66f252b5267517164.1587059210.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: 022rtUzcX 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.229 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" Any remaining references to HWADDR_SIZE are for MAC address comparisons or transformations. This renames them to provide clarity when other sizes may be possible/significant. Signed-off-by: Daniel M. Weeks --- discover/ipmi.c | 2 +- discover/network.c | 6 +++--- discover/platform-powerpc.c | 2 +- discover/udev.c | 6 +++--- lib/pb-protocol/pb-protocol.c | 16 ++++++++-------- lib/types/types.h | 4 ++-- test/parser/network.c | 4 ++-- ui/ncurses/nc-sysinfo.c | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/discover/ipmi.c b/discover/ipmi.c index 14a9e07..01955ea 100644 --- a/discover/ipmi.c +++ b/discover/ipmi.c @@ -244,7 +244,7 @@ int parse_ipmi_interface_override(struct config *config, uint8_t *buf, } /* At the moment only support 6-byte MAC addresses */ - if (hwsize != HWADDR_SIZE) { + if (hwsize != MAC_HWADDR_SIZE) { pb_log("Unsupported HW address size in network override: %u\n", hwsize); return -1; diff --git a/discover/network.c b/discover/network.c index a2a17e0..338762b 100644 --- a/discover/network.c +++ b/discover/network.c @@ -25,7 +25,7 @@ #include "device-handler.h" #include "paths.h" -#define HWADDR_SIZE 6 +#define MAC_HWADDR_SIZE 6 #define PIDFILE_BASE (LOCAL_STATE_DIR "/petitboot/") #define INITIAL_BUFSIZE 4096 @@ -42,7 +42,7 @@ struct interface { int ifindex; char name[IFNAMSIZ]; - uint8_t hwaddr[HWADDR_SIZE]; + uint8_t hwaddr[MAC_HWADDR_SIZE]; unsigned int hwaddr_len; enum { @@ -673,7 +673,7 @@ void network_mark_interface_ready(struct device_handler *handler, return; } - if (hwsize != HWADDR_SIZE) + if (hwsize != MAC_HWADDR_SIZE) return; if (strncmp(ifname, "lo", strlen("lo")) == 0) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 9bdba30..29f8003 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -1329,7 +1329,7 @@ static int get_sysinfo(struct platform *p, struct system_info *sysinfo) sysinfo->identifier = talloc_steal(sysinfo, buf); talloc_free(filename); - sysinfo->bmc_mac = talloc_zero_size(sysinfo, HWADDR_SIZE); + sysinfo->bmc_mac = talloc_zero_size(sysinfo, MAC_HWADDR_SIZE); if (platform->ipmi) get_ipmi_bmc_mac(p, sysinfo->bmc_mac); diff --git a/discover/udev.c b/discover/udev.c index 45a8b56..470bbc3 100644 --- a/discover/udev.c +++ b/discover/udev.c @@ -272,7 +272,7 @@ static int udev_check_interface_ready(struct device_handler *handler, return -1; } - mac = talloc_array(handler, uint8_t, HWADDR_SIZE); + mac = talloc_array(handler, uint8_t, MAC_HWADDR_SIZE); if (!mac) return -1; @@ -282,13 +282,13 @@ static int udev_check_interface_ready(struct device_handler *handler, */ byte[2] = '\0'; for (i = strlen("enx"), j = 0; - i < strlen(mac_name) && j < HWADDR_SIZE; i += 2) { + i < strlen(mac_name) && j < MAC_HWADDR_SIZE; i += 2) { memcpy(byte, &mac_name[i], 2); mac[j++] = strtoul(byte, NULL, 16); } network_mark_interface_ready(handler, - atoi(ifindex), interface, mac, HWADDR_SIZE); + atoi(ifindex), interface, mac, MAC_HWADDR_SIZE); talloc_free(mac); return 0; diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index b5186ad..569c83d 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -264,7 +264,7 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo) } /* BMC MAC */ - len += HWADDR_SIZE; + len += MAC_HWADDR_SIZE; return len; } @@ -508,10 +508,10 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo, } if (sysinfo->bmc_mac) - memcpy(pos, sysinfo->bmc_mac, HWADDR_SIZE); + memcpy(pos, sysinfo->bmc_mac, MAC_HWADDR_SIZE); else - memset(pos, 0, HWADDR_SIZE); - pos += HWADDR_SIZE; + memset(pos, 0, MAC_HWADDR_SIZE); + pos += MAC_HWADDR_SIZE; assert(pos <= buf + buf_len); (void)buf_len; @@ -1041,15 +1041,15 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo, sysinfo->blockdevs[i] = bd_info; } - for (i = 0; i < HWADDR_SIZE; i++) { + for (i = 0; i < MAC_HWADDR_SIZE; i++) { if (pos[i] != 0) { - sysinfo->bmc_mac = talloc_memdup(sysinfo, pos, HWADDR_SIZE); + sysinfo->bmc_mac = talloc_memdup(sysinfo, pos, MAC_HWADDR_SIZE); break; } } - pos += HWADDR_SIZE; - len -= HWADDR_SIZE; + pos += MAC_HWADDR_SIZE; + len -= MAC_HWADDR_SIZE; rc = 0; out: diff --git a/lib/types/types.h b/lib/types/types.h index 719332a..674a748 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -136,11 +136,11 @@ struct system_info { unsigned int n_blockdevs; }; -#define HWADDR_SIZE 6 +#define MAC_HWADDR_SIZE 6 struct interface_config { unsigned int hwaddr_len; - uint8_t hwaddr[HWADDR_SIZE]; + uint8_t hwaddr[MAC_HWADDR_SIZE]; bool ignore; enum { CONFIG_METHOD_DHCP, diff --git a/test/parser/network.c b/test/parser/network.c index 6870dd2..fab1d9b 100644 --- a/test/parser/network.c +++ b/test/parser/network.c @@ -8,7 +8,7 @@ struct interface { int ifindex; char name[IFNAMSIZ]; - uint8_t hwaddr[HWADDR_SIZE]; + uint8_t hwaddr[MAC_HWADDR_SIZE]; enum { IFSTATE_NEW, @@ -49,7 +49,7 @@ uint8_t *find_mac_by_name(void *ctx, struct network *network, return NULL; return talloc_memdup(ctx, &interface->hwaddr, - sizeof(uint8_t) * HWADDR_SIZE); + sizeof(uint8_t) * MAC_HWADDR_SIZE); } void network_requery_device(struct network *network, diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c index 8252b45..f0f9cb1 100644 --- a/ui/ncurses/nc-sysinfo.c +++ b/ui/ncurses/nc-sysinfo.c @@ -113,7 +113,7 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen, if (sysinfo->bmc_mac) { line(NULL); - mac_str(sysinfo->bmc_mac, HWADDR_SIZE, macbuf, sizeof(macbuf)); + mac_str(sysinfo->bmc_mac, MAC_HWADDR_SIZE, macbuf, sizeof(macbuf)); line(_("Management (BMC) interface")); line(_(" MAC: %s"), macbuf); }