+ /* If the requested OpenFlow port for 'iface' changed, and it's not
+ * already the correct port, then we might want to temporarily delete
+ * this interface, so we can add it back again with the new OpenFlow
+ * port number. */
+ requested_ofp_port = iface_get_requested_ofp_port(iface->cfg);
+ if (iface->ofp_port != OFPP_LOCAL &&
+ requested_ofp_port != OFPP_NONE &&
+ requested_ofp_port != iface->ofp_port) {
+ ofp_port_t victim_request;
+ struct iface *victim;
+
+ /* Check for an existing OpenFlow port currently occupying
+ * 'iface''s requested port number. If there isn't one, then
+ * delete this port. Otherwise we need to consider further. */
+ victim = iface_from_ofp_port(br, requested_ofp_port);
+ if (!victim) {
+ goto delete;
+ }
+
+ /* 'victim' is a port currently using 'iface''s requested port
+ * number. Unless 'victim' specifically requested that port
+ * number, too, then we can delete both 'iface' and 'victim'
+ * temporarily. (We'll add both of them back again later with new
+ * OpenFlow port numbers.)
+ *
+ * If 'victim' did request port number 'requested_ofp_port', just
+ * like 'iface', then that's a configuration inconsistency that we
+ * can't resolve. We might as well let it keep its current port
+ * number. */
+ victim_request = iface_get_requested_ofp_port(victim->cfg);
+ if (victim_request != requested_ofp_port) {
+ del = add_ofp_port(victim->ofp_port, del, &n, &allocated);
+ iface_destroy(victim);
+ goto delete;
+ }
+ }
+