Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tomas Hozza and committed by
Greg Kroah-Hartman
0783d72f 00246d08

+38 -43
+29 -30
tools/hv/hv_kvp_daemon.c
··· 1162 1162 snprintf(str, sizeof(str), "%s", "DNS"); 1163 1163 break; 1164 1164 } 1165 - if (i != 0) { 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) { 1165 + 1166 + if (type == DNS) { 1174 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 ··· 1188 1191 snprintf(str, sizeof(str), "%s", "DNS"); 1189 1192 break; 1190 1193 } 1191 - if ((j != 0) || (type == DNS)) { 1192 - if (type != DNS) { 1193 - snprintf(sub_str, sizeof(sub_str), 1194 - "_%d", j++); 1195 - } else { 1196 - snprintf(sub_str, sizeof(sub_str), 1197 - "%d", ++i); 1198 - } 1199 - } else if (type == DNS) { 1200 - snprintf(sub_str, sizeof(sub_str), 1201 - "%d", ++i); 1194 + 1195 + if (type == DNS) { 1196 + snprintf(sub_str, sizeof(sub_str), "%d", ++i); 1197 + } else if (j == 0) { 1198 + ++j; 1199 + } else { 1200 + snprintf(sub_str, sizeof(sub_str), "_%d", j++); 1202 1201 } 1203 1202 } else { 1204 1203 return HV_INVALIDARG; ··· 1237 1244 * Here is the format of the ip configuration file: 1238 1245 * 1239 1246 * HWADDR=macaddr 1240 - * IF_NAME=interface name 1241 - * DHCP=yes (This is optional; if yes, DHCP is configured) 1247 + * DEVICE=interface name 1248 + * BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured 1249 + * or "none" if no boot-time protocol should be used) 1242 1250 * 1243 - * IPADDR=ipaddr1 1244 - * IPADDR_1=ipaddr2 1245 - * IPADDR_x=ipaddry (where y = x + 1) 1251 + * IPADDR0=ipaddr1 1252 + * IPADDR1=ipaddr2 1253 + * IPADDRx=ipaddry (where y = x + 1) 1246 1254 * 1247 - * NETMASK=netmask1 1248 - * NETMASK_x=netmasky (where y = x + 1) 1255 + * NETMASK0=netmask1 1256 + * NETMASKx=netmasky (where y = x + 1) 1249 1257 * 1250 1258 * GATEWAY=ipaddr1 1251 - * GATEWAY_x=ipaddry (where y = x + 1) 1259 + * GATEWAYx=ipaddry (where y = x + 1) 1252 1260 * 1253 1261 * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 1254 1262 * ··· 1288 1294 if (error) 1289 1295 goto setval_error; 1290 1296 1291 - error = kvp_write_file(file, "IF_NAME", "", if_name); 1297 + error = kvp_write_file(file, "DEVICE", "", if_name); 1292 1298 if (error) 1293 1299 goto setval_error; 1294 1300 1295 1301 if (new_val->dhcp_enabled) { 1296 - error = kvp_write_file(file, "DHCP", "", "yes"); 1302 + error = kvp_write_file(file, "BOOTPROTO", "", "dhcp"); 1297 1303 if (error) 1298 1304 goto setval_error; 1299 1305 ··· 1301 1307 * We are done!. 1302 1308 */ 1303 1309 goto setval_done; 1310 + 1311 + } else { 1312 + error = kvp_write_file(file, "BOOTPROTO", "", "none"); 1313 + if (error) 1314 + goto setval_error; 1304 1315 } 1305 1316 1306 1317 /*
+9 -13
tools/hv/hv_set_ifconfig.sh
··· 20 20 # Here is the format of the ip configuration file: 21 21 # 22 22 # HWADDR=macaddr 23 - # IF_NAME=interface name 24 - # DHCP=yes (This is optional; if yes, DHCP is configured) 23 + # DEVICE=interface name 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 - # IPADDR_1=ipaddr2 28 - # IPADDR_x=ipaddry (where y = x + 1) 27 + # IPADDR0=ipaddr1 28 + # IPADDR1=ipaddr2 29 + # IPADDRx=ipaddry (where y = x + 1) 29 30 # 30 - # NETMASK=netmask1 31 - # NETMASK_x=netmasky (where y = x + 1) 31 + # NETMASK0=netmask1 32 + # NETMASKx=netmasky (where y = x + 1) 32 33 # 33 34 # GATEWAY=ipaddr1 34 - # GATEWAY_x=ipaddry (where y = x + 1) 35 + # GATEWAYx=ipaddry (where y = x + 1) 35 36 # 36 37 # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) 37 38 # ··· 54 53 echo "PEERDNS=yes" >> $1 55 54 echo "ONBOOT=yes" >> $1 56 55 57 - dhcp=$(grep "DHCP" $1 2>/dev/null) 58 - if [ "$dhcp" != "" ]; 59 - then 60 - echo "BOOTPROTO=dhcp" >> $1; 61 - fi 62 56 63 57 cp $1 /etc/sysconfig/network-scripts/ 64 58