Upstream dhcp fixes

Cherry-picked upstream commits cd6f5ead3f19fa516bc35a677f2f47add017e284, 77332e9b290f6fa7bc7f4d31c7397b8917064bce and 1cab97f50abd040cbb69c4b44c542a2dbb578ec3. 

We already had the fix made in upstream commit ffcbe0a1fc07a93d552cc2da06018d129bfda75c.