/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
* Copyright (c) 2013 Simon Horman
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include "ofpbuf.h"
#include "odp-util.h"
#include "packets.h"
+#include "flow.h"
#include "unaligned.h"
#include "util.h"
odp_eth_set_addrs(struct ofpbuf *packet,
const struct ovs_key_ethernet *eth_key)
{
- struct eth_header *eh = packet->l2;
+ struct eth_header *eh = ofpbuf_l2(packet);
- memcpy(eh->eth_src, eth_key->eth_src, sizeof eh->eth_src);
- memcpy(eh->eth_dst, eth_key->eth_dst, sizeof eh->eth_dst);
+ if (eh) {
+ memcpy(eh->eth_src, eth_key->eth_src, sizeof eh->eth_src);
+ memcpy(eh->eth_dst, eth_key->eth_dst, sizeof eh->eth_dst);
+ }
}
static void
static void
set_arp(struct ofpbuf *packet, const struct ovs_key_arp *arp_key)
{
- struct arp_eth_header *arp = packet->l3;
+ struct arp_eth_header *arp = ofpbuf_l3(packet);
arp->ar_op = arp_key->arp_op;
memcpy(arp->ar_sha, arp_key->arp_sha, ETH_ADDR_LEN);
set_arp(packet, nl_attr_get_unspec(a, sizeof(struct ovs_key_arp)));
break;
+ case OVS_KEY_ATTR_DP_HASH:
+ md->dp_hash = nl_attr_get_u32(a);
+ break;
+
+ case OVS_KEY_ATTR_RECIRC_ID:
+ md->recirc_id = nl_attr_get_u32(a);
+ break;
+
case OVS_KEY_ATTR_UNSPEC:
case OVS_KEY_ATTR_ENCAP:
case OVS_KEY_ATTR_ETHERTYPE:
/* These only make sense in the context of a datapath. */
case OVS_ACTION_ATTR_OUTPUT:
case OVS_ACTION_ATTR_USERSPACE:
+ case OVS_ACTION_ATTR_RECIRC:
if (dp_execute_action) {
- bool may_steal;
/* Allow 'dp_execute_action' to steal the packet data if we do
* not need it any more. */
- may_steal = steal && (!more_actions && left <= NLA_ALIGN(a->nla_len));
+ bool may_steal = steal && (!more_actions
+ && left <= NLA_ALIGN(a->nla_len)
+ && type != OVS_ACTION_ATTR_RECIRC);
dp_execute_action(dp, packet, md, a, may_steal);
}
break;
+ case OVS_ACTION_ATTR_HASH: {
+ const struct ovs_action_hash *hash_act = nl_attr_get(a);
+
+ /* Calculate a hash value directly. This might not match the
+ * value computed by the datapath, but it is much less expensive,
+ * and the current use case (bonding) does not require a strict
+ * match to work properly. */
+ if (hash_act->hash_alg == OVS_HASH_ALG_L4) {
+ struct flow flow;
+ uint32_t hash;
+
+ flow_extract(packet, md, &flow);
+ hash = flow_hash_5tuple(&flow, hash_act->hash_basis);
+ md->dp_hash = hash ? hash : 1;
+ } else {
+ /* Assert on unknown hash algorithm. */
+ OVS_NOT_REACHED();
+ }
+ break;
+ }
+
case OVS_ACTION_ATTR_PUSH_VLAN: {
const struct ovs_action_push_vlan *vlan = nl_attr_get(a);
eth_push_vlan(packet, htons(ETH_TYPE_VLAN), vlan->vlan_tci);