X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fofproto-dpif.c;h=a42d09eb9575f2dc8f6f09667335e5bbc667a567;hb=2b540ecba2c583ec6050b5cc0017660eb101e4ed;hp=7ad65691b754b05139b74e030ce549c408a403d2;hpb=6a6455e5cea4b87df8073026ec961f11efe2a541;p=openvswitch diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 7ad65691..a42d09eb 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -109,7 +109,7 @@ static void flow_push_stats(struct rule_dpif *, const struct flow *, uint64_t packets, uint64_t bytes, long long int used); -static uint32_t rule_calculate_tag(const struct flow *, +static tag_type rule_calculate_tag(const struct flow *, const struct flow_wildcards *, uint32_t basis); static void rule_invalidate(const struct rule_dpif *); @@ -145,8 +145,8 @@ static void update_mirror_stats(struct ofproto_dpif *ofproto, uint64_t packets, uint64_t bytes); struct ofbundle { - struct ofproto_dpif *ofproto; /* Owning ofproto. */ struct hmap_node hmap_node; /* In struct ofproto's "bundles" hmap. */ + struct ofproto_dpif *ofproto; /* Owning ofproto. */ void *aux; /* Key supplied by ofproto's client. */ char *name; /* Identifier for log messages. */ @@ -209,11 +209,17 @@ struct action_xlate_ctx { * revalidating without a packet to refer to. */ const struct ofpbuf *packet; - /* Should OFPP_NORMAL MAC learning and NXAST_LEARN actions execute? We - * want to execute them if we are actually processing a packet, or if we - * are accounting for packets that the datapath has processed, but not if - * we are just revalidating. */ - bool may_learn; + /* Should OFPP_NORMAL update the MAC learning table? We want to update it + * if we are actually processing a packet, or if we are accounting for + * packets that the datapath has processed, but not if we are just + * revalidating. */ + bool may_learn_macs; + + /* Should "learn" actions update the flow table? We want to update it if + * we are actually processing a packet, or in most cases if we are + * accounting for packets that the datapath has processed, but not if we + * are just revalidating. */ + bool may_flow_mod; /* The rule that we are currently translating, or NULL. */ struct rule_dpif *rule; @@ -346,7 +352,7 @@ static void facet_flush_stats(struct facet *); static void facet_update_time(struct facet *, long long int used); static void facet_reset_counters(struct facet *); static void facet_push_stats(struct facet *); -static void facet_account(struct facet *); +static void facet_account(struct facet *, bool may_flow_mod); static bool facet_is_controller_flow(struct facet *); @@ -1113,6 +1119,14 @@ get_cfm_remote_mpids(const struct ofport *ofport_, const uint64_t **rmps, return -1; } } + +static int +get_cfm_health(const struct ofport *ofport_) +{ + struct ofport_dpif *ofport = ofport_dpif_cast(ofport_); + + return ofport->cfm ? cfm_get_health(ofport->cfm) : -1; +} /* Spanning Tree. */ @@ -2471,14 +2485,12 @@ send_packet_in_miss(struct ofproto_dpif *ofproto, const struct ofpbuf *packet, pin.packet = packet->data; pin.packet_len = packet->size; - pin.total_len = packet->size; pin.reason = OFPR_NO_MATCH; pin.controller_id = 0; pin.table_id = 0; pin.cookie = 0; - pin.buffer_id = 0; /* not yet known */ pin.send_len = 0; /* not used for flow table misses */ flow_get_metadata(flow, &pin.fmd); @@ -2486,7 +2498,7 @@ send_packet_in_miss(struct ofproto_dpif *ofproto, const struct ofpbuf *packet, /* Registers aren't meaningful on a miss. */ memset(pin.fmd.reg_masks, 0, sizeof pin.fmd.reg_masks); - connmgr_send_packet_in(ofproto->up.connmgr, &pin, flow); + connmgr_send_packet_in(ofproto->up.connmgr, &pin); } static bool @@ -2991,7 +3003,7 @@ update_stats(struct ofproto_dpif *p) facet->tcp_flags |= stats->tcp_flags; subfacet_update_time(subfacet, stats->used); - facet_account(facet); + facet_account(facet, true); facet_push_stats(facet); } else { if (!VLOG_DROP_WARN(&rl)) { @@ -3243,7 +3255,7 @@ facet_remove(struct facet *facet) } static void -facet_account(struct facet *facet) +facet_account(struct facet *facet, bool may_flow_mod) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto); uint64_t n_bytes; @@ -3269,7 +3281,8 @@ facet_account(struct facet *facet) action_xlate_ctx_init(&ctx, ofproto, &facet->flow, facet->flow.vlan_tci, facet->rule, facet->tcp_flags, NULL); - ctx.may_learn = true; + ctx.may_learn_macs = true; + ctx.may_flow_mod = may_flow_mod; ofpbuf_delete(xlate_actions(&ctx, facet->rule->up.actions, facet->rule->up.n_actions)); } @@ -3343,7 +3356,7 @@ facet_flush_stats(struct facet *facet) } facet_push_stats(facet); - facet_account(facet); + facet_account(facet, false); if (ofproto->netflow && !facet_is_controller_flow(facet)) { struct ofexpired expired; @@ -4409,7 +4422,7 @@ xlate_table_action(struct action_xlate_ctx *ctx, if (table_id > 0 && table_id < N_TABLES) { struct table_dpif *table = &ofproto->tables[table_id]; if (table->other_table) { - ctx->tags |= (rule + ctx->tags |= (rule && rule->tag ? rule->tag : rule_calculate_tag(&ctx->flow, &table->other_table->wc, @@ -4502,7 +4515,13 @@ execute_controller_action(struct action_xlate_ctx *ctx, int len, eth_pop_vlan(packet); eh = packet->l2; - assert(eh->eth_type == ctx->flow.dl_type); + + /* If the Ethernet type is less than ETH_TYPE_MIN, it's likely an 802.2 + * LLC frame. Calculating the Ethernet type of these frames is more + * trouble than seems appropriate for a simple assertion. */ + assert(ntohs(eh->eth_type) < ETH_TYPE_MIN + || eh->eth_type == ctx->flow.dl_type); + memcpy(eh->eth_src, ctx->flow.dl_src, sizeof eh->eth_src); memcpy(eh->eth_dst, ctx->flow.dl_dst, sizeof eh->eth_dst); @@ -4535,12 +4554,10 @@ execute_controller_action(struct action_xlate_ctx *ctx, int len, pin.table_id = ctx->table_id; pin.cookie = ctx->rule ? ctx->rule->up.flow_cookie : 0; - pin.buffer_id = 0; pin.send_len = len; - pin.total_len = packet->size; flow_get_metadata(&ctx->flow, &pin.fmd); - connmgr_send_packet_in(ctx->ofproto->up.connmgr, &pin, &ctx->flow); + connmgr_send_packet_in(ctx->ofproto->up.connmgr, &pin); ofpbuf_delete(packet); } @@ -4968,7 +4985,7 @@ do_xlate_actions(const union ofp_action *in, size_t n_in, case OFPUTIL_NXAST_LEARN: ctx->has_learn = true; - if (ctx->may_learn) { + if (ctx->may_flow_mod) { xlate_learn_action(ctx, (const struct nx_action_learn *) ia); } break; @@ -5021,7 +5038,8 @@ action_xlate_ctx_init(struct action_xlate_ctx *ctx, ctx->base_flow.vlan_tci = initial_tci; ctx->rule = rule; ctx->packet = packet; - ctx->may_learn = packet != NULL; + ctx->may_learn_macs = packet != NULL; + ctx->may_flow_mod = packet != NULL; ctx->tcp_flags = tcp_flags; ctx->resubmit_hook = NULL; } @@ -5649,7 +5667,7 @@ xlate_normal(struct action_xlate_ctx *ctx) } /* Learn source MAC. */ - if (ctx->may_learn) { + if (ctx->may_learn_macs) { update_learning_table(ctx->ofproto, &ctx->flow, vlan, in_bundle); } @@ -5698,7 +5716,7 @@ xlate_normal(struct action_xlate_ctx *ctx) /* Calculates the tag to use for 'flow' and wildcards 'wc' when it is inserted * into an OpenFlow table with the given 'basis'. */ -static uint32_t +static tag_type rule_calculate_tag(const struct flow *flow, const struct flow_wildcards *wc, uint32_t secret) { @@ -6322,6 +6340,13 @@ hash_realdev_vid(uint16_t realdev_ofp_port, int vid) return hash_2words(realdev_ofp_port, vid); } +/* Returns the ODP port number of the Linux VLAN device that corresponds to + * 'vlan_tci' on the network device with port number 'realdev_odp_port' in + * 'ofproto'. For example, given 'realdev_odp_port' of eth0 and 'vlan_tci' 9, + * it would return the port number of eth0.9. + * + * Unless VLAN splinters are enabled for port 'realdev_odp_port', this + * function just returns its 'realdev_odp_port' argument. */ static uint32_t vsp_realdev_to_vlandev(const struct ofproto_dpif *ofproto, uint32_t realdev_odp_port, ovs_be16 vlan_tci) @@ -6358,9 +6383,18 @@ vlandev_find(const struct ofproto_dpif *ofproto, uint16_t vlandev_ofp_port) return NULL; } +/* Returns the OpenFlow port number of the "real" device underlying the Linux + * VLAN device with OpenFlow port number 'vlandev_ofp_port' and stores the + * VLAN VID of the Linux VLAN device in '*vid'. For example, given + * 'vlandev_ofp_port' of eth0.9, it would return the OpenFlow port number of + * eth0 and store 9 in '*vid'. + * + * Returns 0 and does not modify '*vid' if 'vlandev_ofp_port' is not a Linux + * VLAN device. Unless VLAN splinters are enabled, this is what this function + * always does.*/ static uint16_t vsp_vlandev_to_realdev(const struct ofproto_dpif *ofproto, - uint16_t vlandev_ofp_port, int *vid) + uint16_t vlandev_ofp_port, int *vid) { if (!hmap_is_empty(&ofproto->vlandev_map)) { const struct vlan_splinter *vsp; @@ -6465,6 +6499,7 @@ const struct ofproto_class ofproto_dpif_class = { set_cfm, get_cfm_fault, get_cfm_remote_mpids, + get_cfm_health, set_stp, get_stp_status, set_stp_port,