This set looks good to me.<br><br><div class="gmail_quote">On Mon, Apr 19, 2010 at 5:08 PM, Ben Pfaff <span dir="ltr">&lt;<a href="mailto:blp@nicira.com">blp@nicira.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Open vSwitch has always advertised maximum flow table sizes, but it has<br>
never enforced them.  This commit implements enforcement.<br>
<br>
Bug #1899.<br>
---<br>
 ofproto/ofproto.c |   14 ++++++++++++--<br>
 1 files changed, 12 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c<br>
index 6498f7c..f77fc97 100644<br>
--- a/ofproto/ofproto.c<br>
+++ b/ofproto/ofproto.c<br>
@@ -67,6 +67,10 @@ enum {<br>
     TABLEID_WILD = 1            /* Wildcard table. */<br>
 };<br>
<br>
+/* Maximum number of rules of each kind permitted. */<br>
+#define MAX_EXACT_FLOWS 65536<br>
+#define MAX_WILD_FLOWS 65536<br>
+<br>
 struct ofport {<br>
     struct netdev *netdev;<br>
     struct ofp_phy_port opp;    /* In host byte order. */<br>
@@ -2538,7 +2542,7 @@ handle_table_stats_request(struct ofproto *p, struct ofconn *ofconn,<br>
     strcpy(ots-&gt;name, &quot;exact&quot;);<br>
     ots-&gt;wildcards = htonl(0);<br>
     ots-&gt;active_count = htonl(ofproto_count_visible_exact(p));<br>
-    ots-&gt;max_entries = htonl(dpstats.max_capacity);<br>
+    ots-&gt;max_entries = htonl(MIN(MAX_EXACT_FLOWS, dpstats.max_capacity));<br>
     ots-&gt;lookup_count = htonll(dpstats.n_frags + dpstats.n_hit +<br>
                                dpstats.n_missed);<br>
     ots-&gt;matched_count = htonll(dpstats.n_hit); /* XXX */<br>
@@ -2551,7 +2555,7 @@ handle_table_stats_request(struct ofproto *p, struct ofconn *ofconn,<br>
     ots-&gt;wildcards = p-&gt;tun_id_from_cookie ? htonl(OVSFW_ALL)<br>
                                            : htonl(OFPFW_ALL);<br>
     ots-&gt;active_count = htonl(ofproto_count_visible_wild(p));<br>
-    ots-&gt;max_entries = htonl(65536);<br>
+    ots-&gt;max_entries = htonl(MAX_WILD_FLOWS);<br>
     ots-&gt;lookup_count = htonll(0);              /* XXX */<br>
     ots-&gt;matched_count = htonll(0);             /* XXX */<br>
<br>
@@ -2975,6 +2979,12 @@ add_flow(struct ofproto *p, struct ofconn *ofconn,<br>
         }<br>
     }<br>
<br>
+    if (ofm-&gt;match.wildcards<br>
+        ? ofproto_count_visible_wild(p) &gt;= MAX_WILD_FLOWS<br>
+        : ofproto_count_visible_exact(p) &gt;= MAX_EXACT_FLOWS) {<br>
+        return ofp_mkerr(OFPET_FLOW_MOD_FAILED, OFPFMFC_ALL_TABLES_FULL);<br>
+    }<br>
+<br>
     rule = rule_create(p, NULL, (const union ofp_action *) ofm-&gt;actions,<br>
                        n_actions, ntohs(ofm-&gt;idle_timeout),<br>
                        ntohs(ofm-&gt;hard_timeout),  ofm-&gt;cookie,<br>
<font color="#888888">--<br>
1.6.6.1<br>
<br>
<br>
_______________________________________________<br>
dev mailing list<br>
<a href="mailto:dev@openvswitch.org">dev@openvswitch.org</a><br>
<a href="http://openvswitch.org/mailman/listinfo/dev_openvswitch.org" target="_blank">http://openvswitch.org/mailman/listinfo/dev_openvswitch.org</a><br>
</font></blockquote></div><br>