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 *);
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. */
* 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;
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 *);
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);
/* 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
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)) {
}
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;
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));
}
}
facet_push_stats(facet);
- facet_account(facet);
+ facet_account(facet, false);
if (ofproto->netflow && !facet_is_controller_flow(facet)) {
struct ofexpired expired;
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,
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);
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);
}
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;
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;
}
}
/* Learn source MAC. */
- if (ctx->may_learn) {
+ if (ctx->may_learn_macs) {
update_learning_table(ctx->ofproto, &ctx->flow, vlan, in_bundle);
}
/* 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)
{
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)
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;