diff options
| author | K. Y. Srinivasan <kys@microsoft.com> | 2012-08-16 21:32:16 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-17 11:23:58 -0400 |
| commit | 04405784591117539eac4f5348c86d66dc0dd4f1 (patch) | |
| tree | 2e7db1336724a5fe0cd79ed233dc192077b551b7 /tools | |
| parent | 0d5b6b197f9b9a58ead8ac5e68e38c068c31ba4c (diff) | |
Tools: hv: Gather subnet information
Now, gather sub-net information for the specified interface.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/hv/hv_kvp_daemon.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 13ae098a0114..de1724cbaf59 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
| @@ -534,6 +534,7 @@ kvp_get_ip_address(int family, char *if_name, int op, | |||
| 534 | struct ifaddrs *ifap; | 534 | struct ifaddrs *ifap; |
| 535 | struct ifaddrs *curp; | 535 | struct ifaddrs *curp; |
| 536 | int offset = 0; | 536 | int offset = 0; |
| 537 | int sn_offset = 0; | ||
| 537 | const char *str; | 538 | const char *str; |
| 538 | int error = 0; | 539 | int error = 0; |
| 539 | char *buffer; | 540 | char *buffer; |
| @@ -594,12 +595,38 @@ kvp_get_ip_address(int family, char *if_name, int op, | |||
| 594 | * Gather info other than the IP address. | 595 | * Gather info other than the IP address. |
| 595 | * IP address info will be gathered later. | 596 | * IP address info will be gathered later. |
| 596 | */ | 597 | */ |
| 597 | if (curp->ifa_addr->sa_family == AF_INET) | 598 | if (curp->ifa_addr->sa_family == AF_INET) { |
| 598 | ip_buffer->addr_family |= ADDR_FAMILY_IPV4; | 599 | ip_buffer->addr_family |= ADDR_FAMILY_IPV4; |
| 599 | else | 600 | /* |
| 601 | * Get subnet info. | ||
| 602 | */ | ||
| 603 | error = kvp_process_ip_address( | ||
| 604 | curp->ifa_netmask, | ||
| 605 | AF_INET, | ||
| 606 | (char *) | ||
| 607 | ip_buffer->sub_net, | ||
| 608 | length, | ||
| 609 | &sn_offset); | ||
| 610 | if (error) | ||
| 611 | goto gather_ipaddr; | ||
| 612 | } else { | ||
| 600 | ip_buffer->addr_family |= ADDR_FAMILY_IPV6; | 613 | ip_buffer->addr_family |= ADDR_FAMILY_IPV6; |
| 614 | /* | ||
| 615 | * Get subnet info. | ||
| 616 | */ | ||
| 617 | error = kvp_process_ip_address( | ||
| 618 | curp->ifa_netmask, | ||
| 619 | AF_INET6, | ||
| 620 | (char *) | ||
| 621 | ip_buffer->sub_net, | ||
| 622 | length, | ||
| 623 | &sn_offset); | ||
| 624 | if (error) | ||
| 625 | goto gather_ipaddr; | ||
| 626 | } | ||
| 601 | } | 627 | } |
| 602 | 628 | ||
| 629 | gather_ipaddr: | ||
| 603 | error = kvp_process_ip_address(curp->ifa_addr, | 630 | error = kvp_process_ip_address(curp->ifa_addr, |
| 604 | curp->ifa_addr->sa_family, | 631 | curp->ifa_addr->sa_family, |
| 605 | buffer, | 632 | buffer, |
