#define NETDEV_RULE_PRIORITY 0x8000
#define NR_THREADS 1
+/* Use per thread recirc_depth to prevent recirculation loop. */
+#define MAX_RECIRC_DEPTH 5
+DEFINE_STATIC_PER_THREAD_DATA(uint32_t, recirc_depth, 0)
/* Configuration parameters. */
enum { MAX_FLOWS = 65536 }; /* Maximum number of flows in flow table. */
return EINVAL;
}
- /* Force unwildcard the in_port. */
- mask->in_port.odp_port = u32_to_odp(UINT32_MAX);
} else {
enum mf_field_id id;
/* No mask key, unwildcard everything except fields whose
}
}
+ /* Force unwildcard the in_port.
+ *
+ * We need to do this even in the case where we unwildcard "everything"
+ * above because "everything" only includes the 16-bit OpenFlow port number
+ * mask->in_port.ofp_port, which only covers half of the 32-bit datapath
+ * port number mask->in_port.odp_port. */
+ mask->in_port.odp_port = u32_to_odp(UINT32_MAX);
+
return 0;
}
}
static void
-dp_netdev_port_input(struct dp_netdev *dp, struct ofpbuf *packet,
- struct pkt_metadata *md)
+dp_netdev_input(struct dp_netdev *dp, struct ofpbuf *packet,
+ struct pkt_metadata *md)
+ OVS_REQ_RDLOCK(dp->port_rwlock)
{
struct dp_netdev_flow *netdev_flow;
struct flow key;
}
}
+static void
+dp_netdev_port_input(struct dp_netdev *dp, struct ofpbuf *packet,
+ struct pkt_metadata *md)
+ OVS_REQ_RDLOCK(dp->port_rwlock)
+{
+ uint32_t *recirc_depth = recirc_depth_get();
+
+ *recirc_depth = 0;
+ dp_netdev_input(dp, packet, md);
+}
+
static int
dp_netdev_output_userspace(struct dp_netdev *dp, struct ofpbuf *packet,
int queue_no, int type, const struct flow *flow,
struct dp_netdev_execute_aux *aux = aux_;
int type = nl_attr_type(a);
struct dp_netdev_port *p;
+ uint32_t *depth = recirc_depth_get();
switch ((enum ovs_action_attr)type) {
case OVS_ACTION_ATTR_OUTPUT:
break;
}
- case OVS_ACTION_ATTR_RECIRC: {
- const struct ovs_action_recirc *act;
+ case OVS_ACTION_ATTR_HASH: {
+ const struct ovs_action_hash *hash_act;
+ uint32_t hash;
- act = nl_attr_get(a);
- md->recirc_id = act->recirc_id;
- md->dp_hash = 0;
+ hash_act = nl_attr_get(a);
+ if (hash_act->hash_alg == OVS_HASH_ALG_L4) {
- if (act->hash_alg == OVS_RECIRC_HASH_ALG_L4) {
- struct flow flow;
+ hash = flow_hash_symmetric_l4(aux->key, hash_act->hash_bias);
+ if (!hash) {
+ hash = 1; /* 0 is not valid */
+ }
- flow_extract(packet, md, &flow);
- md->dp_hash = flow_hash_symmetric_l4(&flow, act->hash_bias);
+ } else {
+ VLOG_WARN("Unknown hash algorithm specified for the hash action.");
+ hash = 2;
}
- dp_netdev_port_input(aux->dp, packet, md);
+ md->dp_hash = hash;
break;
}
+ case OVS_ACTION_ATTR_RECIRC:
+ if (*depth < MAX_RECIRC_DEPTH) {
+ struct pkt_metadata recirc_md = *md;
+ struct ofpbuf *recirc_packet;
+
+ recirc_packet = may_steal ? packet : ofpbuf_clone(packet);
+ recirc_md.recirc_id = nl_attr_get_u32(a);
+
+ (*depth)++;
+ dp_netdev_input(aux->dp, recirc_packet, &recirc_md);
+ (*depth)--;
+
+ break;
+ } else {
+ VLOG_WARN("Packet dropped. Max recirculation depth exceeded.");
+ }
+ break;
+
case OVS_ACTION_ATTR_PUSH_VLAN:
case OVS_ACTION_ATTR_POP_VLAN:
case OVS_ACTION_ATTR_PUSH_MPLS:
case __OVS_ACTION_ATTR_MAX:
OVS_NOT_REACHED();
}
-
}
static void