Setting up a miniflow for lookup is faster than a full struct flow.
Signed-off-by: Jarno Rajahalme <[email protected]>
---
lib/ovs-router.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index 6b5ba00..5da99ba 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -62,16 +62,24 @@ ovs_router_entry_cast(const struct cls_rule *cr)
}
}
+static const struct ovs_router_entry *
+ovs_router_lookup__(ovs_be32 ip_dst)
+{
+ struct miniflow mf;
+ struct mf_ctx ctx = MF_CTX_INITIALIZER(mf.inline_values, MINI_N_INLINE);
+
+ miniflow_push_be32(ctx, nw_dst, ip_dst);
+ MF_CTX_FINISH(ctx, &mf);
+
+ return ovs_router_entry_cast(classifier_lookup_miniflow(&cls, &mf));
+}
+
bool
ovs_router_lookup(ovs_be32 ip_dst, char output_bridge[], ovs_be32 *gw)
{
- const struct cls_rule *cr;
- struct flow flow = {.nw_dst = ip_dst};
-
- cr = classifier_lookup(&cls, &flow, NULL);
- if (cr) {
- struct ovs_router_entry *p = ovs_router_entry_cast(cr);
+ const struct ovs_router_entry *p = ovs_router_lookup__(ip_dst);
+ if (p) {
strncpy(output_bridge, p->output_bridge, IFNAMSIZ);
*gw = p->gw;
return true;
--
1.7.10.4
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev