Commit 0783d72f authored by Tomas Hozza's avatar Tomas Hozza Committed by Greg Kroah-Hartman

tools: hv: Fix how ifcfg-* file is created

Fix for the daemon code and for hv_set_ifconfig.sh script, so
that the created ifcfg-* file is consistent with initscripts
documentation.
Signed-off-by: default avatarTomas Hozza <thozza@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 00246d08
...@@ -1162,16 +1162,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type) ...@@ -1162,16 +1162,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type)
snprintf(str, sizeof(str), "%s", "DNS"); snprintf(str, sizeof(str), "%s", "DNS");
break; break;
} }
if (i != 0) {
if (type != DNS) { if (type == DNS) {
snprintf(sub_str, sizeof(sub_str),
"_%d", i++);
} else {
snprintf(sub_str, sizeof(sub_str),
"%d", ++i);
}
} else if (type == DNS) {
snprintf(sub_str, sizeof(sub_str), "%d", ++i); snprintf(sub_str, sizeof(sub_str), "%d", ++i);
} else if (type == GATEWAY && i == 0) {
++i;
} else {
snprintf(sub_str, sizeof(sub_str), "%d", i++);
} }
...@@ -1191,17 +1188,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type) ...@@ -1191,17 +1188,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type)
snprintf(str, sizeof(str), "%s", "DNS"); snprintf(str, sizeof(str), "%s", "DNS");
break; break;
} }
if ((j != 0) || (type == DNS)) {
if (type != DNS) { if (type == DNS) {
snprintf(sub_str, sizeof(sub_str), snprintf(sub_str, sizeof(sub_str), "%d", ++i);
"_%d", j++); } else if (j == 0) {
} else { ++j;
snprintf(sub_str, sizeof(sub_str), } else {
"%d", ++i); snprintf(sub_str, sizeof(sub_str), "_%d", j++);
}
} else if (type == DNS) {
snprintf(sub_str, sizeof(sub_str),
"%d", ++i);
} }
} else { } else {
return HV_INVALIDARG; return HV_INVALIDARG;
...@@ -1244,18 +1237,19 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) ...@@ -1244,18 +1237,19 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
* Here is the format of the ip configuration file: * Here is the format of the ip configuration file:
* *
* HWADDR=macaddr * HWADDR=macaddr
* IF_NAME=interface name * DEVICE=interface name
* DHCP=yes (This is optional; if yes, DHCP is configured) * BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
* or "none" if no boot-time protocol should be used)
* *
* IPADDR=ipaddr1 * IPADDR0=ipaddr1
* IPADDR_1=ipaddr2 * IPADDR1=ipaddr2
* IPADDR_x=ipaddry (where y = x + 1) * IPADDRx=ipaddry (where y = x + 1)
* *
* NETMASK=netmask1 * NETMASK0=netmask1
* NETMASK_x=netmasky (where y = x + 1) * NETMASKx=netmasky (where y = x + 1)
* *
* GATEWAY=ipaddr1 * GATEWAY=ipaddr1
* GATEWAY_x=ipaddry (where y = x + 1) * GATEWAYx=ipaddry (where y = x + 1)
* *
* DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
* *
...@@ -1294,12 +1288,12 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) ...@@ -1294,12 +1288,12 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
if (error) if (error)
goto setval_error; goto setval_error;
error = kvp_write_file(file, "IF_NAME", "", if_name); error = kvp_write_file(file, "DEVICE", "", if_name);
if (error) if (error)
goto setval_error; goto setval_error;
if (new_val->dhcp_enabled) { if (new_val->dhcp_enabled) {
error = kvp_write_file(file, "DHCP", "", "yes"); error = kvp_write_file(file, "BOOTPROTO", "", "dhcp");
if (error) if (error)
goto setval_error; goto setval_error;
...@@ -1307,6 +1301,11 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) ...@@ -1307,6 +1301,11 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
* We are done!. * We are done!.
*/ */
goto setval_done; goto setval_done;
} else {
error = kvp_write_file(file, "BOOTPROTO", "", "none");
if (error)
goto setval_error;
} }
/* /*
......
...@@ -20,18 +20,19 @@ ...@@ -20,18 +20,19 @@
# Here is the format of the ip configuration file: # Here is the format of the ip configuration file:
# #
# HWADDR=macaddr # HWADDR=macaddr
# IF_NAME=interface name # DEVICE=interface name
# DHCP=yes (This is optional; if yes, DHCP is configured) # BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
# or "none" if no boot-time protocol should be used)
# #
# IPADDR=ipaddr1 # IPADDR0=ipaddr1
# IPADDR_1=ipaddr2 # IPADDR1=ipaddr2
# IPADDR_x=ipaddry (where y = x + 1) # IPADDRx=ipaddry (where y = x + 1)
# #
# NETMASK=netmask1 # NETMASK0=netmask1
# NETMASK_x=netmasky (where y = x + 1) # NETMASKx=netmasky (where y = x + 1)
# #
# GATEWAY=ipaddr1 # GATEWAY=ipaddr1
# GATEWAY_x=ipaddry (where y = x + 1) # GATEWAYx=ipaddry (where y = x + 1)
# #
# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
# #
...@@ -53,11 +54,6 @@ echo "NM_CONTROLLED=no" >> $1 ...@@ -53,11 +54,6 @@ echo "NM_CONTROLLED=no" >> $1
echo "PEERDNS=yes" >> $1 echo "PEERDNS=yes" >> $1
echo "ONBOOT=yes" >> $1 echo "ONBOOT=yes" >> $1
dhcp=$(grep "DHCP" $1 2>/dev/null)
if [ "$dhcp" != "" ];
then
echo "BOOTPROTO=dhcp" >> $1;
fi
cp $1 /etc/sysconfig/network-scripts/ cp $1 /etc/sysconfig/network-scripts/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment