diff options
author | Tomas Hozza <thozza@redhat.com> | 2013-01-13 16:27:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-17 14:47:21 -0500 |
commit | 0783d72fa4cd8aae7c3f30746c70f6f3a2507594 (patch) | |
tree | e1f4e24338720cc93deaddc3dfc84fadcc384177 /tools | |
parent | 00246d08be901b9ac27c3082bd066119b71b4679 (diff) |
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: Tomas Hozza <thozza@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/hv/hv_kvp_daemon.c | 59 | ||||
-rwxr-xr-x | tools/hv/hv_set_ifconfig.sh | 22 |
2 files changed, 38 insertions, 43 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 0358ad26d2fd..384051745c5e 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
@@ -1162,16 +1162,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type) | |||
1162 | snprintf(str, sizeof(str), "%s", "DNS"); | 1162 | snprintf(str, sizeof(str), "%s", "DNS"); |
1163 | break; | 1163 | break; |
1164 | } | 1164 | } |
1165 | if (i != 0) { | 1165 | |
1166 | if (type != DNS) { | 1166 | if (type == DNS) { |
1167 | snprintf(sub_str, sizeof(sub_str), | ||
1168 | "_%d", i++); | ||
1169 | } else { | ||
1170 | snprintf(sub_str, sizeof(sub_str), | ||
1171 | "%d", ++i); | ||
1172 | } | ||
1173 | } else if (type == DNS) { | ||
1174 | snprintf(sub_str, sizeof(sub_str), "%d", ++i); | 1167 | snprintf(sub_str, sizeof(sub_str), "%d", ++i); |
1168 | } else if (type == GATEWAY && i == 0) { | ||
1169 | ++i; | ||
1170 | } else { | ||
1171 | snprintf(sub_str, sizeof(sub_str), "%d", i++); | ||
1175 | } | 1172 | } |
1176 | 1173 | ||
1177 | 1174 | ||
@@ -1191,17 +1188,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type) | |||
1191 | snprintf(str, sizeof(str), "%s", "DNS"); | 1188 | snprintf(str, sizeof(str), "%s", "DNS"); |
1192 | break; | 1189 | break; |
1193 | } | 1190 | } |
1194 | if ((j != 0) || (type == DNS)) { | 1191 | |
1195 | if (type != DNS) { | 1192 | if (type == DNS) { |
1196 | snprintf(sub_str, sizeof(sub_str), | 1193 | snprintf(sub_str, sizeof(sub_str), "%d", ++i); |
1197 | "_%d", j++); | 1194 | } else if (j == 0) { |
1198 | } else { | 1195 | ++j; |
1199 | snprintf(sub_str, sizeof(sub_str), | 1196 | } else { |
1200 | "%d", ++i); | 1197 | snprintf(sub_str, sizeof(sub_str), "_%d", j++); |
1201 | } | ||
1202 | } else if (type == DNS) { | ||
1203 | snprintf(sub_str, sizeof(sub_str), | ||
1204 | "%d", ++i); | ||
1205 | } | 1198 | } |
1206 | } else { | 1199 | } else { |
1207 | return HV_INVALIDARG; | 1200 | return HV_INVALIDARG; |
@@ -1244,18 +1237,19 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) | |||
1244 | * Here is the format of the ip configuration file: | 1237 | * Here is the format of the ip configuration file: |
1245 | * | 1238 | * |
1246 | * HWADDR=macaddr | 1239 | * HWADDR=macaddr |
1247 | * IF_NAME=interface name | 1240 | * DEVICE=interface name |
1248 | * DHCP=yes (This is optional; if yes, DHCP is configured) | 1241 | * BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured |
1242 | * or "none" if no boot-time protocol should be used) | ||
1249 | * | 1243 | * |
1250 | * IPADDR=ipaddr1 | 1244 | * IPADDR0=ipaddr1 |
1251 | * IPADDR_1=ipaddr2 | 1245 | * IPADDR1=ipaddr2 |
1252 | * IPADDR_x=ipaddry (where y = x + 1) | 1246 | * IPADDRx=ipaddry (where y = x + 1) |
1253 | * | 1247 | * |
1254 | * NETMASK=netmask1 | 1248 | * NETMASK0=netmask1 |
1255 | * NETMASK_x=netmasky (where y = x + 1) | 1249 | * NETMASKx=netmasky (where y = x + 1) |
1256 | * | 1250 | * |
1257 | * GATEWAY=ipaddr1 | 1251 | * GATEWAY=ipaddr1 |
1258 | * GATEWAY_x=ipaddry (where y = x + 1) | 1252 | * GATEWAYx=ipaddry (where y = x + 1) |
1259 | * | 1253 | * |
1260 | * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) | 1254 | * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) |
1261 | * | 1255 | * |
@@ -1294,12 +1288,12 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) | |||
1294 | if (error) | 1288 | if (error) |
1295 | goto setval_error; | 1289 | goto setval_error; |
1296 | 1290 | ||
1297 | error = kvp_write_file(file, "IF_NAME", "", if_name); | 1291 | error = kvp_write_file(file, "DEVICE", "", if_name); |
1298 | if (error) | 1292 | if (error) |
1299 | goto setval_error; | 1293 | goto setval_error; |
1300 | 1294 | ||
1301 | if (new_val->dhcp_enabled) { | 1295 | if (new_val->dhcp_enabled) { |
1302 | error = kvp_write_file(file, "DHCP", "", "yes"); | 1296 | error = kvp_write_file(file, "BOOTPROTO", "", "dhcp"); |
1303 | if (error) | 1297 | if (error) |
1304 | goto setval_error; | 1298 | goto setval_error; |
1305 | 1299 | ||
@@ -1307,6 +1301,11 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) | |||
1307 | * We are done!. | 1301 | * We are done!. |
1308 | */ | 1302 | */ |
1309 | goto setval_done; | 1303 | goto setval_done; |
1304 | |||
1305 | } else { | ||
1306 | error = kvp_write_file(file, "BOOTPROTO", "", "none"); | ||
1307 | if (error) | ||
1308 | goto setval_error; | ||
1310 | } | 1309 | } |
1311 | 1310 | ||
1312 | /* | 1311 | /* |
diff --git a/tools/hv/hv_set_ifconfig.sh b/tools/hv/hv_set_ifconfig.sh index daf7ec0cd04e..735aafd64a3f 100755 --- a/tools/hv/hv_set_ifconfig.sh +++ b/tools/hv/hv_set_ifconfig.sh | |||
@@ -20,18 +20,19 @@ | |||
20 | # Here is the format of the ip configuration file: | 20 | # Here is the format of the ip configuration file: |
21 | # | 21 | # |
22 | # HWADDR=macaddr | 22 | # HWADDR=macaddr |
23 | # IF_NAME=interface name | 23 | # DEVICE=interface name |
24 | # DHCP=yes (This is optional; if yes, DHCP is configured) | 24 | # BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured |
25 | # or "none" if no boot-time protocol should be used) | ||
25 | # | 26 | # |
26 | # IPADDR=ipaddr1 | 27 | # IPADDR0=ipaddr1 |
27 | # IPADDR_1=ipaddr2 | 28 | # IPADDR1=ipaddr2 |
28 | # IPADDR_x=ipaddry (where y = x + 1) | 29 | # IPADDRx=ipaddry (where y = x + 1) |
29 | # | 30 | # |
30 | # NETMASK=netmask1 | 31 | # NETMASK0=netmask1 |
31 | # NETMASK_x=netmasky (where y = x + 1) | 32 | # NETMASKx=netmasky (where y = x + 1) |
32 | # | 33 | # |
33 | # GATEWAY=ipaddr1 | 34 | # GATEWAY=ipaddr1 |
34 | # GATEWAY_x=ipaddry (where y = x + 1) | 35 | # GATEWAYx=ipaddry (where y = x + 1) |
35 | # | 36 | # |
36 | # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) | 37 | # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) |
37 | # | 38 | # |
@@ -53,11 +54,6 @@ echo "NM_CONTROLLED=no" >> $1 | |||
53 | echo "PEERDNS=yes" >> $1 | 54 | echo "PEERDNS=yes" >> $1 |
54 | echo "ONBOOT=yes" >> $1 | 55 | echo "ONBOOT=yes" >> $1 |
55 | 56 | ||
56 | dhcp=$(grep "DHCP" $1 2>/dev/null) | ||
57 | if [ "$dhcp" != "" ]; | ||
58 | then | ||
59 | echo "BOOTPROTO=dhcp" >> $1; | ||
60 | fi | ||
61 | 57 | ||
62 | cp $1 /etc/sysconfig/network-scripts/ | 58 | cp $1 /etc/sysconfig/network-scripts/ |
63 | 59 | ||