An assumption for this change is assuming that miss-rules are added by add_internal_flow().
If so it seems to me that the current rule_is_table_miss() does not match such rules. This is because add_internal_flows() adds rules with the mask of register 0 set to all 1s due to the following line in add_internal_flow(). match_set_reg(&fm.match, 0, id); This patch proposes an alternate approach which is to provide a function to determine if a rule is a miss rule. And infer that any rule that results in execute_controller_action() being called has a controller action present and if that rule is internal then it is the miss rule. This allows generated_by_table_miss for miss rules. Signed-off-by: Simon Horman <ho...@verge.net.au> --- ofproto/ofproto-dpif-xlate.c | 5 ++++- ofproto/ofproto-dpif.c | 12 ++++++++++-- ofproto/ofproto-dpif.h | 2 +- ofproto/ofproto-provider.h | 12 +----------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 7f78460..52f55ad 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -2140,8 +2140,11 @@ execute_controller_action(struct xlate_ctx *ctx, int len, pin->controller_id = controller_id; pin->send_len = len; + /* If a rule is internal and has a controller action, + * which is implied by the rule being processed here, + * then it is the rule to handle a table miss. */ pin->generated_by_table_miss = (ctx->rule - && rule_dpif_is_table_miss(ctx->rule)); + && rule_dpif_is_internal(ctx->rule)); ofproto_dpif_send_packet_in(ctx->xbridge->ofproto, pin); ofpbuf_delete(packet); } diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 61521ed..433c0c0 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3023,9 +3023,9 @@ rule_dpif_is_fail_open(const struct rule_dpif *rule) } bool -rule_dpif_is_table_miss(const struct rule_dpif *rule) +rule_dpif_is_internal(const struct rule_dpif *rule) { - return rule_is_table_miss(&rule->up); + return rule_is_internal(&rule->up); } ovs_be64 @@ -4408,6 +4408,14 @@ ofproto_dpif_unixctl_init(void) unixctl_command_register("dpif/dump-flows", "[-m] bridge", 1, 2, ofproto_unixctl_dpif_dump_flows, NULL); } + + +/* Returns true if 'rule' is an internal rule, false otherwise. */ +bool +rule_is_internal(const struct rule *rule) +{ + return rule->table_id == TBL_INTERNAL; +} /* Linux VLAN device support (e.g. "eth0.10" for VLAN 10.) * diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index f526104..df8d79e 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -89,7 +89,7 @@ void rule_dpif_credit_stats(struct rule_dpif *rule , const struct dpif_flow_stats *); bool rule_dpif_is_fail_open(const struct rule_dpif *); -bool rule_dpif_is_table_miss(const struct rule_dpif *); +bool rule_dpif_is_internal(const struct rule_dpif *); struct rule_actions *rule_dpif_get_actions(const struct rule_dpif *); diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index d116451..e8ed2e9 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -408,17 +408,7 @@ struct rule_actions *rule_get_actions(const struct rule *rule) struct rule_actions *rule_get_actions__(const struct rule *rule) OVS_REQUIRES(rule->mutex); -/* Returns true if 'rule' is an OpenFlow 1.3 "table-miss" rule, false - * otherwise. - * - * ("Table-miss" rules are special because a packet_in generated through one - * uses OFPR_NO_MATCH as its reason, whereas packet_ins generated by any other - * rule use OFPR_ACTION.) */ -static inline bool -rule_is_table_miss(const struct rule *rule) -{ - return rule->cr.priority == 0 && cls_rule_is_catchall(&rule->cr); -} +bool rule_is_internal(const struct rule *); /* A set of actions within a "struct rule". * -- 1.8.5.2 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev