diff options
author | Jing Peng <pj.hades@gmail.com> | 2022-04-29 15:14:07 -0400 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2022-05-02 06:46:18 +0000 |
commit | 6a2868734c2f96186b6bfb705969a5daa702ebb6 (patch) | |
tree | 6c237bbd7bedb4969f6caa7bc46478bfe00db2af /src/plugins/dhcp | |
parent | 39d88cc0d4e9f419ff04ad5bc7ebb17ebe446bb2 (diff) |
dhcp: fix dhcp_compl_event
This patch fixes two problems:
1. The lease field in the dhcp_compl_event message can include a list of
vl_api_domain_server_t structs, but no memory is allocated for it.
2. The DNS server address is not copied properly, resulting in wrong IP4
addresses in the event message.
Type: fix
Signed-off-by: Jing Peng <pj.hades@gmail.com>
Change-Id: I42c533e7af697568c69714011d983f88368a7e15
Diffstat (limited to 'src/plugins/dhcp')
-rw-r--r-- | src/plugins/dhcp/dhcp_api.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/dhcp/dhcp_api.c b/src/plugins/dhcp/dhcp_api.c index 2b8d41a10c1..91ee0aacf7a 100644 --- a/src/plugins/dhcp/dhcp_api.c +++ b/src/plugins/dhcp/dhcp_api.c @@ -279,8 +279,8 @@ dhcp_client_lease_encode (vl_api_dhcp_lease_t * lease, lease->count = vec_len (client->domain_server_address); for (i = 0; i < lease->count; i++) - clib_memcpy (&lease->domain_server[i].address, - (u8 *) & client->domain_server_address[i], + clib_memcpy (&lease->domain_server[i].address.un.ip4, + (u8 *) &client->domain_server_address[i], sizeof (ip4_address_t)); clib_memcpy (&lease->host_mac[0], client->client_hardware_address, 6); @@ -321,7 +321,9 @@ dhcp_compl_event_callback (u32 client_index, const dhcp_client_t * client) if (!reg) return; - mp = vl_msg_api_alloc (sizeof (*mp)); + mp = vl_msg_api_alloc (sizeof (*mp) + + sizeof (vl_api_domain_server_t) * + vec_len (client->domain_server_address)); mp->client_index = client_index; mp->pid = client->pid; dhcp_client_lease_encode (&mp->lease, client); |