Message ID | 20190405155809.1935-1-thuth@redhat.com |
---|---|
State | Accepted |
Headers | show |
Series | libnet: Correctly re-initialize the "ip_version" variable each time | expand |
On Fri, 5 Apr 2019 17:58:09 +0200 Thomas Huth <thuth@redhat.com> wrote: > 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 <thuth@redhat.com> > --- Reviewed-by: Greg Kurz <groug@kaod.org> > 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");
On 06/04/2019 02:58, Thomas Huth wrote: > 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 <thuth@redhat.com> Thanks, applied. > --- > 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"); >
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");
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 <thuth@redhat.com> --- lib/libnet/netload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)