+static void
+upgradeNetworkConfiguration()
+{
+ static dispatch_once_t once;
+
+ /*
+ * Once, per start of InterfaceNamer, we check/ensure that the
+ * configuration has been upgraded.
+ *
+ * Note: this check should not be performed until we know that
+ * the __wait_for_IOKit_to_quiesce() conditions have been
+ * satisfied.
+ */
+
+ dispatch_once(&once, ^{
+ SCPreferencesRef ni_prefs;
+ Boolean updated;
+
+ // save the [current] DB with the interfaces that have been named
+ writeInterfaceList(S_dblist);
+
+ // upgrade the configuration
+ ni_prefs = SCPreferencesCreate(NULL, CFSTR(MY_PLUGIN_NAME ":upgradeNetworkConfiguration"), INTERFACES_DEFAULT_CONFIG);
+ if (ni_prefs == NULL) {
+ SC_log(LOG_NOTICE, "SCPreferencesCreate() failed: %s", SCErrorString(SCError()));
+ return;
+ }
+ updated = __SCNetworkConfigurationUpgrade(NULL, &ni_prefs, TRUE);
+ CFRelease(ni_prefs);
+
+ if (updated) {
+ // re-read list of previously named network interfaces
+ if (S_dblist != NULL) {
+ CFRelease(S_dblist);
+ }
+ S_dblist = readInterfaceList();
+
+ addTimestamp(S_state, CFSTR("*UPGRADED*"));
+ SC_log(LOG_INFO, "network configuration upgraded");
+ updateStore();
+ }
+ });
+
+ return;
+}
+