This diff fixes a memory leak in ofp_read() that happens in every message and a infinite loop that happens when the remote switch closes the connection.
ok? Index: ofp.c =================================================================== RCS file: /home/obsdcvs/src/usr.sbin/switchd/ofp.c,v retrieving revision 1.7 diff -u -p -r1.7 ofp.c --- ofp.c 14 Sep 2016 13:46:51 -0000 1.7 +++ ofp.c 21 Sep 2016 11:59:46 -0000 @@ -146,6 +146,7 @@ void ofp_close(struct switch_connection *con) { log_info("%s: connection %u closed", __func__, con->con_id); + event_del(&con->con_ev); switch_remove(con->con_sc, con->con_switch); close(con->con_fd); TAILQ_REMOVE(&conn_head, con, con_next); @@ -203,7 +204,7 @@ ofp_read(int fd, short event, void *arg) if ((len = read(fd, buf, sizeof(buf))) == -1) goto fail; if (len == 0) - return; + goto fail; if ((ibuf = ibuf_new(buf, len)) == NULL) goto fail; @@ -236,6 +237,7 @@ ofp_read(int fd, short event, void *arg) goto fail; } + ibuf_release(ibuf); return; fail: