]> git.ozlabs.org Git - petitboot/commitdiff
discover: Avoid writing network overrides to NVRAM
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 6 Sep 2016 03:30:30 +0000 (13:30 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 8 Sep 2016 04:26:27 +0000 (14:26 +1000)
Explicitly keep track of whether the current interface config was set by
an IPMI network override, and avoid overwriting any saved config unless
the override was marked persistent.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/ipmi.c
discover/platform-powerpc.c
lib/pb-config/pb-config.c
lib/pb-protocol/pb-protocol.c
lib/types/types.h

index 38423b2647319fe7a3b040adc61a293857f9c9fd..2aaf114c20c5bb248141d01b0c786ff26dcd402e 100644 (file)
@@ -309,6 +309,7 @@ int parse_ipmi_interface_override(struct config *config, uint8_t *buf,
                i += ipsize;
        }
 
                i += ipsize;
        }
 
+       ifconf->override = true;
        pb_log("Applying IPMI network interface override\n");
 
        /* Replace any existing interface config */
        pb_log("Applying IPMI network interface override\n");
 
        /* Replace any existing interface config */
index 8fca5bd4bdb60da2dce3990696b283ab9d5648f8..2b89121264e4c11e02856c8d7861c1e20dbf53bf 100644 (file)
@@ -635,6 +635,15 @@ static void update_network_config(struct platform_powerpc *platform,
        unsigned int i;
        char *val;
 
        unsigned int i;
        char *val;
 
+       /*
+        * Don't store IPMI overrides to NVRAM. If this was a persistent
+        * override it was already stored in NVRAM by
+        * get_ipmi_network_override()
+        */
+       if (config->network.n_interfaces &&
+               config->network.interfaces[0]->override)
+               return;
+
        val = talloc_strdup(platform, "");
 
        for (i = 0; i < config->network.n_interfaces; i++) {
        val = talloc_strdup(platform, "");
 
        for (i = 0; i < config->network.n_interfaces; i++) {
index 52a43b1607dc8bbf1410569474b1bd9c786bf8d6..581d70f08cb8f65a4c680e77e7512366fc640e7a 100644 (file)
@@ -33,6 +33,7 @@ static struct interface_config *config_copy_interface(struct config *ctx,
                        talloc_strdup(dest, src->static_config.url);
                break;
        }
                        talloc_strdup(dest, src->static_config.url);
                break;
        }
+       dest->override = src->override;
 
        return dest;
 }
 
        return dest;
 }
index 1560ef797fe1ed31f0e0c98bf9ad215092f44eba..706aec9786169af697c0488f535a2730c95269db 100644 (file)
@@ -283,6 +283,8 @@ static int pb_protocol_interface_config_len(struct interface_config *conf)
                len += 4 + optional_strlen(conf->static_config.url);
        }
 
                len += 4 + optional_strlen(conf->static_config.url);
        }
 
+       len += 4 /* conf->override */;
+
        return len;
 }
 
        return len;
 }
 
@@ -511,6 +513,9 @@ static int pb_protocol_serialise_config_interface(char *buf,
                                conf->static_config.url);
        }
 
                                conf->static_config.url);
        }
 
+       *(uint32_t *)pos = conf->override;
+       pos += 4;
+
        return pos - buf;
 }
 
        return pos - buf;
 }
 
@@ -1019,6 +1024,10 @@ static int pb_protocol_deserialise_config_interface(const char **buf,
                        return -1;
        }
 
                        return -1;
        }
 
+       if (read_u32(buf, len, &tmp))
+               return -1;
+       iface->override = !!tmp;
+
        return 0;
 }
 
        return 0;
 }
 
index 6b607cdeecccfd622a5ee3cf0c33a41b52cbe2b4..7b9269b1899905cb250feaaf2fb1a365b21a0f6d 100644 (file)
@@ -129,6 +129,7 @@ struct interface_config {
                        char *url;
                } static_config;
        };
                        char *url;
                } static_config;
        };
+       bool    override;
 };
 
 struct network_config {
 };
 
 struct network_config {