From: Ben Pfaff Date: Thu, 19 Mar 2009 17:41:37 +0000 (-0700) Subject: dpif: Accept 64 kB packets from the kernel. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f579be6c63c1747f744953f9157a2313fa80a99e;p=openvswitch dpif: Accept 64 kB packets from the kernel. 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. --- diff --git a/lib/dpif.c b/lib/dpif.c index ce36fb97..7e19c1af 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -599,7 +599,7 @@ dpif_recv(struct dpif *dpif, struct ofpbuf **bufp) 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; diff --git a/secchan/pinsched.c b/secchan/pinsched.c index ca4d5ed9..6ab09dae 100644 --- a/secchan/pinsched.c +++ b/secchan/pinsched.c @@ -176,6 +176,12 @@ pinsched_send(struct pinsched *ps, uint16_t port_no, /* 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); }