It's simple to hide it than to make it thread safe and ensure it stays that way in the long term.
Signed-off-by: Ethan Jackson <et...@nicira.com> --- ofproto/ofproto-dpif-xlate.c | 26 +++++++++++++++++++++----- ofproto/ofproto-dpif-xlate.h | 12 +++++++----- ofproto/ofproto-dpif.c | 7 +++++-- ofproto/ofproto-dpif.h | 4 +--- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 808dfb2..aa90edf 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -68,6 +68,10 @@ struct xbridge { struct dpif_ipfix *ipfix; /* Ipfix handle, or null. */ struct stp *stp; /* STP or null if disabled. */ + /* Special rules installed by ofproto-dpif. */ + struct rule_dpif *miss_rule; + struct rule_dpif *no_packet_in_rule; + enum ofp_config_flags frag; /* Fragmentation handling. */ bool has_netflow; /* Bridge runs netflow? */ bool has_in_band; /* Bridge has in band control? */ @@ -207,8 +211,10 @@ static bool dscp_from_skb_priority(const struct xport *, uint32_t skb_priority, void xlate_ofproto_set(struct ofproto_dpif *ofproto, const char *name, - struct dpif *dpif, const struct mac_learning *ml, - struct stp *stp, const struct mbridge *mbridge, + struct dpif *dpif, struct rule_dpif *miss_rule, + struct rule_dpif *no_packet_in_rule, + const struct mac_learning *ml, struct stp *stp, + const struct mbridge *mbridge, const struct dpif_sflow *sflow, const struct dpif_ipfix *ipfix, enum ofp_config_flags frag, bool forward_bpdu, bool has_in_band, bool has_netflow) @@ -257,6 +263,8 @@ xlate_ofproto_set(struct ofproto_dpif *ofproto, const char *name, xbridge->has_in_band = has_in_band; xbridge->has_netflow = has_netflow; xbridge->frag = frag; + xbridge->miss_rule = miss_rule; + xbridge->no_packet_in_rule = no_packet_in_rule; } void @@ -1485,14 +1493,22 @@ ctx_rule_hooks(struct xlate_ctx *ctx, struct rule_dpif *rule, ctx->xin->resubmit_hook(ctx->xin, rule, ctx->recurse); } if (rule == NULL && may_packet_in) { + struct xport *xport; + /* XXX * check if table configuration flags * OFPTC_TABLE_MISS_CONTROLLER, default. * OFPTC_TABLE_MISS_CONTINUE, * OFPTC_TABLE_MISS_DROP - * When OF1.0, OFPTC_TABLE_MISS_CONTINUE is used. What to do? - */ - rule = rule_dpif_miss_rule(ctx->xbridge->ofproto, &ctx->xin->flow); + * When OF1.0, OFPTC_TABLE_MISS_CONTINUE is used. What to do? */ + xport = get_ofp_port(ctx->xbridge, ctx->xin->flow.in_port.ofp_port); + if (!xport) { + rule = ctx->xbridge->miss_rule; + } else if (xport->config & OFPUTIL_PC_NO_PACKET_IN) { + rule = ctx->xbridge->no_packet_in_rule; + } else { + rule = ctx->xbridge->miss_rule; + } } if (rule && ctx->xin->resubmit_stats) { rule_credit_stats(rule, ctx->xin->resubmit_stats); diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h index befb235..52a19be 100644 --- a/ofproto/ofproto-dpif-xlate.h +++ b/ofproto/ofproto-dpif-xlate.h @@ -111,11 +111,13 @@ struct xlate_in { }; void xlate_ofproto_set(struct ofproto_dpif *, const char *name, - struct dpif *, const struct mac_learning *, - struct stp *, const struct mbridge *, - const struct dpif_sflow *, const struct dpif_ipfix *, - enum ofp_config_flags, bool forward_bpdu, - bool has_in_band, bool has_netflow); + struct dpif *, struct rule_dpif *miss_rule, + struct rule_dpif *no_packet_in_rule, + const struct mac_learning *, struct stp *, + const struct mbridge *, const struct dpif_sflow *, + const struct dpif_ipfix *, enum ofp_config_flags, + bool forward_bpdu, bool has_in_band, bool has_netflow); + void xlate_remove_ofproto(struct ofproto_dpif *); void xlate_bundle_set(struct ofproto_dpif *, struct ofbundle *, diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 439adf7..17bc12f 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -86,6 +86,8 @@ static struct rule_dpif *rule_dpif_lookup(struct ofproto_dpif *, struct flow_wildcards *wc); static void rule_get_stats(struct rule *, uint64_t *packets, uint64_t *bytes); +static struct rule_dpif *rule_dpif_miss_rule(struct ofproto_dpif *, + const struct flow *); struct ofbundle { struct hmap_node hmap_node; /* In struct ofproto's "bundles" hmap. */ @@ -783,7 +785,8 @@ type_run(const char *type) } xlate_ofproto_set(ofproto, ofproto->up.name, - ofproto->backer->dpif, ofproto->ml, + ofproto->backer->dpif, ofproto->miss_rule, + ofproto->no_packet_in_rule, ofproto->ml, ofproto->stp, ofproto->mbridge, ofproto->sflow, ofproto->ipfix, ofproto->up.frag_handling, @@ -5175,7 +5178,7 @@ rule_dpif_lookup_in_table(struct ofproto_dpif *ofproto, return rule_dpif_cast(rule_from_cls_rule(cls_rule)); } -struct rule_dpif * +static struct rule_dpif * rule_dpif_miss_rule(struct ofproto_dpif *ofproto, const struct flow *flow) { struct ofport_dpif *port; diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index 18b1829..1c07a65 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -22,6 +22,7 @@ #include "ovs-thread.h" #include "timer.h" #include "util.h" +#include "ovs-thread.h" union user_action_cookie; struct ofproto_dpif; @@ -58,9 +59,6 @@ struct rule_dpif *rule_dpif_lookup_in_table(struct ofproto_dpif *, struct flow_wildcards *, uint8_t table_id); -struct rule_dpif *rule_dpif_miss_rule(struct ofproto_dpif *ofproto, - const struct flow *); - void rule_credit_stats(struct rule_dpif *, const struct dpif_flow_stats *); bool ofproto_has_vlan_splinters(const struct ofproto_dpif *); -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev