diff options
author | 2010-04-30 07:51:47 -0400 | |
---|---|---|
committer | 2010-04-30 07:51:47 -0400 | |
commit | 7c66c033a91f084aac60abcfb76afa5b7b55dc76 (patch) | |
tree | 14b4cbf2d2d58c05a63f3f11d15b4bc8476ef2cc | |
parent | Fix virt-pki-validate's determination of CN (diff) | |
download | libvirt-7c66c033a91f084aac60abcfb76afa5b7b55dc76.tar.gz libvirt-7c66c033a91f084aac60abcfb76afa5b7b55dc76.tar.bz2 libvirt-7c66c033a91f084aac60abcfb76afa5b7b55dc76.zip |
nwfilter: Also pick IP address from a DHCP ACK message
The local DHCP server on virtbr0 sends DHCP ACK messages when a VM is
started and requests an IP address while the initial DHCP lease on the
VM's MAC address hasn't expired. So, also pick the IP address of the VM
if that type of message is seen.
Thanks to Gerhard Stenzel for providing a test case for this.
Changes from V1 to V2:
- cleanup: replacing DHCP option numbers through constants
-rw-r--r-- | src/nwfilter/nwfilter_learnipaddr.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index 9af9bab0b..b63398e07 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -98,6 +98,11 @@ struct dhcp { } ATTRIBUTE_PACKED; #define DHCP_MSGT_DHCPOFFER 2 +#define DHCP_MSGT_DHCPACK 5 + + +#define DHCP_OPT_BCASTADDRESS 28 +#define DHCP_OPT_MESSAGETYPE 53 struct ether_vlan_header { @@ -336,17 +341,18 @@ procDHCPOpts(struct dhcp *dhcp, int dhcp_opts_len, switch (dhcpopt->code) { - case 28: /* Broadcast address */ + case DHCP_OPT_BCASTADDRESS: /* Broadcast address */ if (dhcp_opts_len >= 6) { uint32_t *tmp = (uint32_t *)&dhcpopt->value; (*bcastaddr) = ntohl(*tmp); } break; - case 53: /* Message type */ + case DHCP_OPT_MESSAGETYPE: /* Message type */ if (dhcp_opts_len >= 3) { uint8_t *val = (uint8_t *)&dhcpopt->value; switch (*val) { + case DHCP_MSGT_DHCPACK: case DHCP_MSGT_DHCPOFFER: *vmaddr = dhcp->yiaddr; *howDetected = DETECT_DHCP; |