From: Ben Pfaff Date: Tue, 10 Mar 2009 17:41:30 +0000 (-0700) Subject: secchan: Purge buffered packets on startup. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b06f246ac3f5f089c5adcebaaca8f3f444d8d18;p=openvswitch secchan: Purge buffered packets on startup. This keeps packets that can be minutes old from getting forwarded. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 10a76786..e222162f 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -1131,6 +1131,8 @@ get_dp_stats(struct datapath *dp, struct odp_stats __user *statsp) stats.n_missed += s->n_missed; stats.n_lost += s->n_lost; } + stats.max_miss_queue = DP_MAX_QUEUE_LEN; + stats.max_action_queue = DP_MAX_QUEUE_LEN; return copy_to_user(statsp, &stats, sizeof stats); } diff --git a/include/openflow/datapath-protocol.h b/include/openflow/datapath-protocol.h index ec3d7252..c65293cd 100644 --- a/include/openflow/datapath-protocol.h +++ b/include/openflow/datapath-protocol.h @@ -92,7 +92,11 @@ struct odp_stats { __u64 n_frags; /* Number of dropped IP fragments. */ __u64 n_hit; /* Number of flow table matches. */ __u64 n_missed; /* Number of flow table misses. */ - __u64 n_lost; /* Number of misses not sent to userspace. */ + __u64 n_lost; /* Number of misses not sent to userspace. */ + + /* Queues. */ + __u16 max_miss_queue; /* Max length of ODPL_MISS queue. */ + __u16 max_action_queue; /* Max length of ODPL_ACTION queue. */ }; /* Logical ports. */ diff --git a/lib/dpif.c b/lib/dpif.c index 9b89a9e2..c179fbda 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -246,6 +246,29 @@ dpif_set_listen_mask(struct dpif *dpif, int listen_mask) return IOCTL(dpif, ODP_SET_LISTEN_MASK, &listen_mask); } +int +dpif_purge(struct dpif *dpif) +{ + struct odp_stats stats; + unsigned int i; + int error; + + error = dpif_get_dp_stats(dpif, &stats); + if (error) { + return error; + } + + for (i = 0; i < stats.max_miss_queue + stats.max_action_queue; i++) { + struct ofpbuf *buf; + error = dpif_recv(dpif, &buf); + if (error) { + return error == EAGAIN ? 0 : error; + } + ofpbuf_delete(buf); + } + return 0; +} + int dpif_port_add(struct dpif *dpif, const char *devname, uint16_t port_no) { diff --git a/lib/dpif.h b/lib/dpif.h index f52b9acf..070d28aa 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -67,6 +67,7 @@ int dpif_set_drop_frags(struct dpif *, bool drop_frags); int dpif_get_listen_mask(const struct dpif *, int *listen_mask); int dpif_set_listen_mask(struct dpif *, int listen_mask); +int dpif_purge(struct dpif *); int dpif_port_add(struct dpif *, const char *devname, uint16_t port_no); int dpif_port_del(struct dpif *, uint16_t port_no); diff --git a/secchan/ofproto.c b/secchan/ofproto.c index bc99ea20..36794ae6 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -223,6 +223,7 @@ ofproto_create(const char *datapath, const struct ofhooks *ofhooks, void *aux, return error; } dpif_flow_flush(&dpif); + dpif_purge(&dpif); /* Start monitoring datapath ports for status changes. */ error = dpifmon_create(datapath, &dpifmon);