Skip to content

Commit c380320

Browse files
ani-sinhaliuw
authored andcommitted
hv/hv_kvp_daemon: Some small fixes for handling NM keyfiles
Some small fixes: - lets make sure we are not adding ipv4 addresses in ipv6 section in keyfile and vice versa. - ADDR_FAMILY_IPV6 is a bit in addr_family. Test that bit instead of checking the whole value of addr_family. - Some trivial fixes in hv_set_ifconfig.sh. These fixes are proposed after doing some internal testing at Red Hat. CC: Shradha Gupta <[email protected]> CC: Saurabh Sengar <[email protected]> Fixes: 42999c9 ("hv/hv_kvp_daemon:Support for keyfile based connection profile") Signed-off-by: Ani Sinha <[email protected]> Reviewed-by: Shradha Gupta <[email protected]> Signed-off-by: Wei Liu <[email protected]> Message-ID: <[email protected]>
1 parent ffc2532 commit c380320

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tools/hv/hv_kvp_daemon.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
14211421
if (error)
14221422
goto setval_error;
14231423

1424-
if (new_val->addr_family == ADDR_FAMILY_IPV6) {
1424+
if (new_val->addr_family & ADDR_FAMILY_IPV6) {
14251425
error = fprintf(nmfile, "\n[ipv6]\n");
14261426
if (error < 0)
14271427
goto setval_error;
@@ -1455,14 +1455,18 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
14551455
if (error < 0)
14561456
goto setval_error;
14571457

1458-
error = fprintf(nmfile, "gateway=%s\n", (char *)new_val->gate_way);
1459-
if (error < 0)
1460-
goto setval_error;
1461-
1462-
error = fprintf(nmfile, "dns=%s\n", (char *)new_val->dns_addr);
1463-
if (error < 0)
1464-
goto setval_error;
1458+
/* we do not want ipv4 addresses in ipv6 section and vice versa */
1459+
if (is_ipv6 != is_ipv4((char *)new_val->gate_way)) {
1460+
error = fprintf(nmfile, "gateway=%s\n", (char *)new_val->gate_way);
1461+
if (error < 0)
1462+
goto setval_error;
1463+
}
14651464

1465+
if (is_ipv6 != is_ipv4((char *)new_val->dns_addr)) {
1466+
error = fprintf(nmfile, "dns=%s\n", (char *)new_val->dns_addr);
1467+
if (error < 0)
1468+
goto setval_error;
1469+
}
14661470
fclose(nmfile);
14671471
fclose(ifcfg_file);
14681472

tools/hv/hv_set_ifconfig.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@
5353
# or "manual" if no boot-time protocol should be used)
5454
#
5555
# address1=ipaddr1/plen
56-
# address=ipaddr2/plen
56+
# address2=ipaddr2/plen
5757
#
5858
# gateway=gateway1;gateway2
5959
#
6060
# dns=dns1;
6161
#
6262
# [ipv6]
6363
# address1=ipaddr1/plen
64-
# address2=ipaddr1/plen
64+
# address2=ipaddr2/plen
6565
#
6666
# gateway=gateway1;gateway2
6767
#

0 commit comments

Comments
 (0)