Under virtualization (e.g. Xen) we sometimes receive packets as large as
64 kB, so the dpif code has to be prepared to accept it.
The only place where we keep these packets around for any amount of time
is when we need to schedule them for sending later, so trim them down
from 64 kB to their actual size in that case.
int retval;
int error;
- buf = ofpbuf_new(2048); /* XXX scale based on netdev MTUs */
+ buf = ofpbuf_new(65536);
retval = read(dpif->fd, ofpbuf_tail(buf), ofpbuf_tailroom(buf));
if (retval < 0) {
error = errno;
/* Otherwise queue it up for the periodic callback to drain out. */
struct ofp_queue *q;
+ /* We are called with a buffer obtained from dpif_recv() that has much
+ * more allocated space than actual content most of the time. Since
+ * we're going to store the packet for some time, free up that
+ * otherwise wasted space. */
+ ofpbuf_trim(packet);
+
if (ps->n_queued >= ps->burst_limit) {
drop_packet(ps);
}