/* Type functions. */
+static struct ofproto_dpif *
+lookup_ofproto_dpif_by_port_name(const char *name)
+{
+ struct ofproto_dpif *ofproto;
+
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ if (sset_contains(&ofproto->ports, name)) {
+ return ofproto;
+ }
+ }
+
+ return NULL;
+}
+
static int
type_run(const char *type)
{
/* Check for port changes in the dpif. */
while ((error = dpif_port_poll(backer->dpif, &devname)) == 0) {
- struct ofproto_dpif *ofproto = NULL;
+ struct ofproto_dpif *ofproto;
struct dpif_port port;
/* Don't report on the datapath's device. */
continue;
}
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node,
- &all_ofproto_dpifs) {
- if (sset_contains(&ofproto->ports, devname)) {
- break;
- }
- }
-
+ ofproto = lookup_ofproto_dpif_by_port_name(devname);
if (dpif_port_query_by_name(backer->dpif, devname, &port)) {
/* The port was removed. If we know the datapath,
* report it through poll_set(). If we don't, it may be