Resolves: rhbz#1011595
Essential part of the patchset to have early integration testing with
NetworkManager, ie we are generating correct ifcfgs and NM handles them
as expected.
Next item: genrating correct command in anaconda-ks.cfg
---
loader/net.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
loader/net.h | 1 +
2 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/loader/net.c b/loader/net.c
index b678a80..43c107c 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -1573,6 +1573,9 @@ int writeEnabledNetInfo(iface_t *iface) {
}
g_strfreev(slaves);
}
+ if (iface->vlanid) {
+ writeBondVlanParentIfcfgFile(iface);
+ }
}
if (rename(ofile, nfile) == -1) {
@@ -1656,6 +1659,64 @@ int enable_NM_BOND_VLAN() {
}
+int writeBondVlanParentIfcfgFile(iface_t *iface) {
+ char *ofile = NULL;
+ char *nfile = NULL;
+ FILE *fp = NULL;
+ char *uuid = NULL;
+
+ checked_asprintf(&ofile, "%s/.ifcfg-%s",
+ NETWORK_SCRIPTS_PATH,
+ iface->device);
+ checked_asprintf(&nfile, "%s/ifcfg-%s",
+ NETWORK_SCRIPTS_PATH,
+ iface->device);
+
+ if ((fp = fopen(ofile, "w")) == NULL) {
+ free(ofile);
+ free(nfile);
+ return 2;
+ }
+
+ fprintf(fp, "DEVICE=%s\n", iface->device);
+ uuid = nm_utils_uuid_generate();
+ fprintf(fp, "UUID=%s\n", uuid);
+ fprintf(fp, "TYPE=Bond\n");
+ if (iface->bonding_opts) {
+ if (strchr(iface->bonding_opts, ';')) {
+ replaceChars(iface->bonding_opts, ';', ' ');
+ } else {
+ replaceChars(iface->bonding_opts, ',', ' ');
+ }
+ fprintf(fp, "BONDING_OPTS=\"%s\"\n", iface->bonding_opts);
+ }
+ fprintf(fp, "ONBOOT=yes\n");
+ fprintf(fp, "NM_CONTROLLED=yes\n");
+ g_free(uuid);
+
+ if (fclose(fp) == EOF) {
+ return 3;
+ }
+
+ if (rename(ofile, nfile) == -1) {
+ free(ofile);
+ free(nfile);
+ return 4;
+ }
+
+ if (ofile) {
+ free(ofile);
+ ofile = NULL;
+ }
+
+ if (nfile) {
+ free(nfile);
+ nfile = NULL;
+ }
+
+ return 0;
+}
+
int writeBondSlaveIfcfgFile(char *slave, char *master) {
char *ofile = NULL;
char *nfile = NULL;
@@ -2391,7 +2452,6 @@ int activateDevice(struct loaderData_s * loaderData, iface_t * iface) {
logMessage(ERROR, "writeDisabledIfcfgFile failure (%s): %d",
__func__, rc);
}
-
loaderData->netDev_set = 0;
loaderData->ipinfo_set = 0;
free(loaderData->ipv4);
diff --git a/loader/net.h b/loader/net.h
index 7f9e57c..abf9238 100644
--- a/loader/net.h
+++ b/loader/net.h
@@ -91,4 +91,5 @@ int split_bond_option(char *str, char **bondname, char **bondslaves, char **opti
int networkDeviceExists(char *name);
int writeBondSlaveIfcfgFile(char *slave, char *master);
void parseDnsServers(const char *dnss, iface_t *iface);
+int writeBondVlanParentIfcfgFile(iface_t *iface);
#endif
--
2.4.3