From 4c71600d2256641b927e04b75e95751355e799f8 Mon Sep 17 00:00:00 2001 From: Daniele Di Proietto Date: Fri, 10 Mar 2017 15:44:40 -0800 Subject: ofp-actions: Add limit to learn action. This commit adds a new feature to the learn actions: the possibility to limit the number of learned flows. To be compatible with users of the old learn action, a new structure is introduced as well as a new OpenFlow raw action number. There's a small corner case when we have to delete the ukey. This happens when: * The learned rule has expired (or has been deleted). * The ukey that learned the rule is still in the datapath. * No packets hit the datapath flow recently. In this case we cannot relearn the rule (because there are no new packets), and the actions might depend on the learn execution, so the only option is to delete the ukey. I don't think this has big performance implications since it's done only for ukey with no traffic. We could also slowpath it, but that will cause an action upcall and the correct datapath actions will be installed later by a revalidator. If we delete the ukey, the next upcall will be a miss upcall and that will immediatedly install the correct datapath flow. Signed-off-by: Daniele Di Proietto Signed-off-by: Ben Pfaff --- include/openvswitch/ofp-actions.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h index d829509f8..fc2f1def6 100644 --- a/include/openvswitch/ofp-actions.h +++ b/include/openvswitch/ofp-actions.h @@ -660,6 +660,10 @@ struct ofpact_resubmit { * If NX_LEARN_F_SEND_FLOW_REM is set, then the learned flows will have their * OFPFF_SEND_FLOW_REM flag set. * + * If NX_LEARN_F_WRITE_RESULT is set, then the actions will write whether the + * learn operation succeded on a bit. If the learn is successful the bit will + * be set, otherwise (e.g. if the limit is hit) the bit will be unset. + * * If NX_LEARN_F_DELETE_LEARNED is set, then removing this action will delete * all the flows from the learn action's 'table_id' that have the learn * action's 'cookie'. Important points: @@ -685,6 +689,7 @@ struct ofpact_resubmit { enum nx_learn_flags { NX_LEARN_F_SEND_FLOW_REM = 1 << 0, NX_LEARN_F_DELETE_LEARNED = 1 << 1, + NX_LEARN_F_WRITE_RESULT = 1 << 2, }; #define NX_LEARN_N_BITS_MASK 0x3ff @@ -748,6 +753,13 @@ struct ofpact_learn { ovs_be64 cookie; /* Cookie for new flow. */ uint16_t fin_idle_timeout; /* Idle timeout after FIN, if nonzero. */ uint16_t fin_hard_timeout; /* Hard timeout after FIN, if nonzero. */ + /* If the number of flows on 'table_id' with 'cookie' exceeds this, + * the action will not add a new flow. */ + uint32_t limit; + /* Used only if 'flags' has NX_LEARN_F_WRITE_RESULT. If the execution + * failed to install a new flow because 'limit' is exceeded, + * result_dst will be set to 0, otherwise to 1. */ + struct mf_subfield result_dst; ); struct ofpact_learn_spec specs[]; -- cgit v1.2.1