From b24afa81b5f6b4bd0167084cb4e60d2cfeef3732 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 8 Apr 2009 09:45:43 -0700 Subject: [PATCH] dpif: Optimize no-actions case in dpif_execute(). If there are no actions, then the packet will get dropped in the kernel, so there's no point in making the system call at all. --- lib/dpif.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/dpif.c b/lib/dpif.c index 4da55332..119b40c3 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -558,16 +558,20 @@ dpif_execute(struct dpif *dpif, uint16_t in_port, const union odp_action actions[], size_t n_actions, const struct ofpbuf *buf) { - struct odp_execute execute; int error; - memset(&execute, 0, sizeof execute); - execute.in_port = in_port; - execute.actions = (union odp_action *) actions; - execute.n_actions = n_actions; - execute.data = buf->data; - execute.length = buf->size; - error = do_ioctl(dpif, ODP_EXECUTE, NULL, &execute); + if (n_actions > 0) { + struct odp_execute execute; + memset(&execute, 0, sizeof execute); + execute.in_port = in_port; + execute.actions = (union odp_action *) actions; + execute.n_actions = n_actions; + execute.data = buf->data; + execute.length = buf->size; + error = do_ioctl(dpif, ODP_EXECUTE, NULL, &execute); + } else { + error = 0; + } if (!(error ? VLOG_DROP_WARN(&error_rl) : VLOG_DROP_DBG(&dpmsg_rl))) { struct ds ds = DS_EMPTY_INITIALIZER; -- 2.30.2