diff options
author | Justin Pettit <jpettit@nicira.com> | 2012-01-03 13:34:20 -0800 |
---|---|---|
committer | Justin Pettit <jpettit@nicira.com> | 2012-01-04 16:36:00 -0800 |
commit | 2716b6379dc86331330d78b496985e908320ddfa (patch) | |
tree | 603f3af45a9c25b150e3bb37c55a5252fceea7c7 /ofproto/ofproto-dpif.c | |
parent | a64d0f34a1adf9d586a64a5fecf829d3f473c4c7 (diff) |
ofproto-dpif: Fake-up OFPP_NONE input bundle for mirroring and normal.
Both mirroring and "normal" processing make use of the input bundle to
perform various sanity checks. Controller-generated traffic typically
uses an ingress port of OFPP_NONE, which doesn't have a corresponding
input bundle. This commit fakes one up well enough that mirroring and
"normal" processing succeed.
We looked at creating an actual bundle based on the "real" OFPP_NONE.
This was even uglier, since there were even more special-cases that
needed to be handled, including having to hide it from port queries.
Reported-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'ofproto/ofproto-dpif.c')
-rw-r--r-- | ofproto/ofproto-dpif.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 3fe9af02..cca23cac 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -179,6 +179,16 @@ static void bundle_wait(struct ofbundle *); static struct ofbundle *lookup_input_bundle(struct ofproto_dpif *, uint16_t in_port, bool warn); +/* A controller may use OFPP_NONE as the ingress port to indicate that + * it did not arrive on a "real" port. 'ofpp_none_bundle' exists for + * when an input bundle is needed for validation (e.g., mirroring or + * OFPP_NORMAL processing). It is not connected to an 'ofproto' or have + * any 'port' structs, so care must be taken when dealing with it. */ +static struct ofbundle ofpp_none_bundle = { + .name = "OFPP_NONE", + .vlan_mode = PORT_VLAN_TRUNK +}; + static void stp_run(struct ofproto_dpif *ofproto); static void stp_wait(struct ofproto_dpif *ofproto); @@ -4792,6 +4802,11 @@ input_vid_to_vlan(const struct ofbundle *in_bundle, uint16_t vid) static bool input_vid_is_valid(uint16_t vid, struct ofbundle *in_bundle, bool warn) { + /* Allow any VID on the OFPP_NONE port. */ + if (in_bundle == &ofpp_none_bundle) { + return true; + } + switch (in_bundle->vlan_mode) { case PORT_VLAN_ACCESS: if (vid) { @@ -5105,6 +5120,11 @@ update_learning_table(struct ofproto_dpif *ofproto, { struct mac_entry *mac; + /* Don't learn the OFPP_NONE port. */ + if (in_bundle == &ofpp_none_bundle) { + return; + } + if (!mac_learning_may_learn(ofproto->ml, flow->dl_src, vlan)) { return; } @@ -5140,6 +5160,12 @@ lookup_input_bundle(struct ofproto_dpif *ofproto, uint16_t in_port, bool warn) { struct ofport_dpif *ofport; + /* Special-case OFPP_NONE, which a controller may use as the ingress + * port for traffic that it is sourcing. */ + if (in_port == OFPP_NONE) { + return &ofpp_none_bundle; + } + /* Find the port and bundle for the received packet. */ ofport = get_ofp_port(ofproto, in_port); if (ofport && ofport->bundle) { @@ -5233,7 +5259,8 @@ xlate_normal(struct action_xlate_ctx *ctx) return; } - /* We know 'in_port' exists, since lookup_input_bundle() succeeded. */ + /* We know 'in_port' exists unless it is "ofpp_none_bundle", + * since lookup_input_bundle() succeeded. */ in_port = get_ofp_port(ctx->ofproto, ctx->flow.in_port); /* Drop malformed frames. */ @@ -5267,7 +5294,8 @@ xlate_normal(struct action_xlate_ctx *ctx) vlan = input_vid_to_vlan(in_bundle, vid); /* Check other admissibility requirements. */ - if (!is_admissible(ctx->ofproto, &ctx->flow, in_port, vlan, &ctx->tags)) { + if (in_port && + !is_admissible(ctx->ofproto, &ctx->flow, in_port, vlan, &ctx->tags)) { return; } |