Re: [PATCHv2] vhost-net: add dhclient work-around from userspace

Michael S. Tsirkin
2010-09-20T21:05:33Z

On Mon, Sep 20, 2010 at 02:12:40PM +0200, xming wrote:
> Hi,
>
> I think I am hitting this, in a weird way :D. Running 0.12.90,
> vhost_net and kernel 2.6.35.4, I have troubles to get dhcp clients to
> work except an old dhcp client "pump" seems to work out of the box.
> Below are the output of dhcpcd, isc's dhcp client and busybox' udhcpc.
>
> My dhcp server is in a guest with vhost_net running dnsmasq. Clients
> which do not use vhost_net (plain virtio, e1000 and physical machines)
> do not have any problems. The dhcp server itself is a dhcp client and
> uses dhcpcd to get lease from ADSL modem w/o issues.
> When the dhcp server is not using vhost_net, then all clients can get a lease.
>
> So my conclusion so far is that when the server is using vhost_net and
> clients are using vhost_net (and above mentioned software), then it's
> getting invalid/checksum error UDP. the only working DHCP client is
> pump.

Newer versions of dhclient should also be OK: they detect
that checksum is missing in the packet. Try it e.g. with
a recent fedora guest as a client.

To solve the problem for old clients, recent kernels and iptables have
support for CHECKSUM target.

You can use this target to compute and fill in the checksum in
a packet that lacks a checksum.

Typical expected use:
iptables -A POSTROUTING -t mangle -p udp --dport bootpc \
-j CHECKSUM --checksum-fill

libvirt will program these for you if it sets up the server,
maybe there needs a flag to tell it that server is local.

> # dhcpcd
> dhcpcd[9089]: version 5.2.7 starting
> dhcpcd[9089]: eth0: broadcasting for a lease
> dhcpcd[9089]: eth0: invalid UDP packet from 192.168.1.1
> dhcpcd[9089]: eth0: invalid UDP packet from 192.168.1.1
> dhcpcd[9089]: eth0: invalid UDP packet from 192.168.1.1
> dhcpcd[9089]: eth0: invalid UDP packet from 192.168.1.1
> dhcpcd[9089]: timed out
> dhcpcd[9089]: allowing 8 seconds for IPv4LL timeout
> dhcpcd[9089]: eth0: probing for an IPv4LL address
> dhcpcd[9089]: eth0: checking for 169.254.195.227
> dhcpcd[9089]: eth0: using IPv4LL address 169.254.195.227
> dhcpcd[9089]: forked to background, child pid 9109
>
> # dhclient
> Internet Systems Consortium DHCP Client V3.1.2p1-Gentoo
> Copyright 2004-2009 Internet Systems Consortium.
> All rights reserved.
> For info, please visit http://www.isc.org/sw/dhcp/
>
> Listening on LPF/eth0/00:16:3e:00:07:01
> Sending on LPF/eth0/00:16:3e:00:07:01
> Sending on Socket/fallback
> DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
> DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
> DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
> DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13
> DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13
> 5 bad udp checksums in 5 packets
> DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 14
> No DHCPOFFERS received.
> No working leases in persistent database - sleeping.
>
>
> # busybox udhcpc
> ### adapter index 2
> ### adapter hardware address 00:16:3e:00:07:01
> udhcpc (v1.13.2) started
> ### vfork'ing and execle'ing /usr/share/udhcpc/default.script
> udhcpc: exec /usr/share/udhcpc/default.script: No such file or directory
> ### entering raw listen mode
> ### opening raw socket on ifindex 2
> ### got raw socket fd 5
> ### attached filter to raw socket fd 5
> ### bound to raw socket fd 5
> ### adding option 0x35
> ### adding option 0x3d
> ### adding option 0x3c
> ### adding option 0x39
> Sending discover...
> ### Waiting on select...
> udhcpc: packet with bad UDP checksum received, ignoring
> ### Waiting on select...
> ### adding option 0x35
> ### adding option 0x3d
> ### adding option 0x3c
> ### adding option 0x39
> Sending discover...
> ### Waiting on select...
> udhcpc: packet with bad UDP checksum received, ignoring
> ### Waiting on select...
> ### adding option 0x35
> ### adding option 0x3d
> ### adding option 0x3c
> ### adding option 0x39
> Sending discover...
> ### Waiting on select...
> udhcpc: packet with bad UDP checksum received, ignoring
> ### Waiting on select...
> ### vfork'ing and execle'ing /usr/share/udhcpc/default.script
> udhcpc: exec /usr/share/udhcpc/default.script: No such file or directory
> ### Waiting on select...
> ### adding option 0x35
> ### adding option 0x3d
> ### adding option 0x3c
> ### adding option 0x39
> Sending discover...
> ### Waiting on select...
> udhcpc: packet with bad UDP checksum received, ignoring
> ### Waiting on select...
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html