-static bool
-may_port_action(long long int *port_action_timer)
-{
- if (need_reconfigure) {
- return false;
- }
-
- time_refresh();
- if (*port_action_timer == LLONG_MAX) {
- *port_action_timer = time_msec() + OFP_PORT_ACTION_WINDOW;
- } else if (time_msec() > *port_action_timer) {
- need_reconfigure = true;
- return false;
- }
- return true;
-}
-
-/* Delete each ofproto port on 'br' that doesn't have a corresponding "struct
- * iface".
- *
- * The kernel will reject any attempt to add a given port to a datapath if that
- * port already belongs to a different datapath, so we must do all port
- * deletions before any port additions. */
-static void
-bridge_del_ofproto_ports(struct bridge *br,
- long long int *port_action_timer)
-{
- struct ofproto_port_dump dump;
- struct ofproto_port ofproto_port;
-
- OFPROTO_PORT_FOR_EACH (&ofproto_port, &dump, br->ofproto) {
- const char *name = ofproto_port.name;
- struct iface *iface;
- const char *type;
- int error;
-
- /* Ignore the local port. We can't change it anyhow. */
- if (!strcmp(name, br->name)) {
- continue;
- }
-
- /* Get the type that 'ofproto_port' should have (ordinarily the
- * type of its corresponding iface) or NULL if it should be
- * deleted. */
- iface = iface_lookup(br, name);
- type = (iface ? iface->type
- : bridge_has_bond_fake_iface(br, name) ? "internal"
- : NULL);
-
- /* If it's the wrong type then delete the ofproto port. */
- if (type
- && !strcmp(ofproto_port.type, type)
- && (!iface || !iface->netdev
- || !strcmp(netdev_get_type(iface->netdev), type))) {
- continue;
- }
-
- if (may_port_action(port_action_timer)) {
- error = ofproto_port_del(br->ofproto, ofproto_port.ofp_port);
- if (error) {
- VLOG_WARN("bridge %s: failed to remove %s interface (%s)",
- br->name, name, strerror(error));
- } else {
- VLOG_INFO("bridge %s: removed interface %s (%d)", br->name,
- name, ofproto_port.ofp_port);
- }
- }
- if (iface) {
- netdev_close(iface->netdev);
- iface->netdev = NULL;
- }
- }
-}
-