ofproto: Break out resubmit resource checking
authorSimon Horman <horms@verge.net.au>
Wed, 30 Oct 2013 09:17:13 +0000 (18:17 +0900)
committerBen Pfaff <blp@nicira.com>
Sat, 2 Nov 2013 18:58:06 +0000 (11:58 -0700)
Break out resubmit resource checking into a helper function
xlate_resubmit_resource_check() and use this new function.
This is to allow the check to be re-used by a subsequent patch.

Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif-xlate.c

index ae6f638..d300ec5 100644 (file)
@@ -1715,9 +1715,8 @@ xlate_recursively(struct xlate_ctx *ctx, struct rule_dpif *rule)
     ctx->recurse--;
 }
 
-static void
-xlate_table_action(struct xlate_ctx *ctx,
-                   ofp_port_t in_port, uint8_t table_id, bool may_packet_in)
+static bool
+xlate_resubmit_resource_check(struct xlate_ctx *ctx)
 {
     static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
 
@@ -1731,6 +1730,17 @@ xlate_table_action(struct xlate_ctx *ctx,
     } else if (ctx->stack.size >= 65536) {
         VLOG_ERR_RL(&rl, "resubmits yielded over 64 kB of stack");
     } else {
+        return true;
+    }
+
+    return false;
+}
+
+static void
+xlate_table_action(struct xlate_ctx *ctx,
+                   ofp_port_t in_port, uint8_t table_id, bool may_packet_in)
+{
+    if (xlate_resubmit_resource_check(ctx)) {
         struct rule_dpif *rule;
         ofp_port_t old_in_port = ctx->xin->flow.in_port.ofp_port;
         uint8_t old_table_id = ctx->table_id;