From patchwork Fri Apr 5 15:58:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 1078515 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 44bPcK74NVz9sPn for ; Sat, 6 Apr 2019 02:58:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44bPcK0Y4ZzDqSf for ; Sat, 6 Apr 2019 02:58:25 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=thuth@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 44bPcD5RnbzDqSM for ; Sat, 6 Apr 2019 02:58:17 +1100 (AEDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13B3E30832C3 for ; Fri, 5 Apr 2019 15:58:15 +0000 (UTC) Received: from thuth.com (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15F3317265 for ; Fri, 5 Apr 2019 15:58:13 +0000 (UTC) From: Thomas Huth To: slof@lists.ozlabs.org Date: Fri, 5 Apr 2019 17:58:09 +0200 Message-Id: <20190405155809.1935-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 05 Apr 2019 15:58:15 +0000 (UTC) Subject: [SLOF] [PATCH] libnet: Correctly re-initialize the "ip_version" variable each time X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" I recently noticed that if you start QEMU with two NICs, and only want to boot from the second NIC, SLOF only tries to get an IP address via DHCPv6 instead of trying both, DHCPv4 and DHCPv6. For example: $ qemu-system-ppc64 -nic hubport,hubid=1 \ -nic user,model=virtio,tftp=/.../tftp,bootfile=zImage.pseries [...] Trying to load: from: /vdevice/l-lan@71000002 ... Initializing NIC Reading MAC address from device: 52:54:00:12:34:56 Requesting information via DHCP: 007 Aborted E3001 (net) Could not get IP address Trying to load: from: /pci@800000020000000/ethernet@0 ... Initializing NIC Reading MAC address from device: 52:54:00:12:34:57 Requesting information via DHCPv6: done Using IPv6 address: fec0::5254:ff:fe12:3457 The problem is that we never re-initialize the "ip_version" variable anymore, so once it has been set to 6, it stays at 6 for the second network boot attempt, too. Thus reset the variable to 4 at the beginning of the netload() function. Signed-off-by: Thomas Huth Reviewed-by: Greg Kurz --- lib/libnet/netload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libnet/netload.c b/lib/libnet/netload.c index f7ec341..2dc00f0 100644 --- a/lib/libnet/netload.c +++ b/lib/libnet/netload.c @@ -38,7 +38,7 @@ #define MAX_PKT_SIZE 1720 #define DEFAULT_BOOT_RETRIES 10 #define DEFAULT_TFTP_RETRIES 20 -static int ip_version = 4; +static int ip_version; typedef struct { char filename[100]; @@ -542,6 +542,8 @@ int netload(char *buffer, int len, char *args_fs, int alen) uint8_t own_mac[6]; char *pkt_buffer; + ip_version = 4; + pkt_buffer = SLOF_alloc_mem(MAX_PKT_SIZE); if (!pkt_buffer) { puts("ERROR: Unable to allocate memory");