X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fodp-execute.c;h=12ad67981d3ae325a46a1681d2082e6b42bef178;hb=28c5588e8e1a8d091c5d2275232c35f2968a97fa;hp=7a96ca0ad770d7a1977fcade029d531e05b5b948;hpb=09f9da0bcaf0f6fd4221b28ecedc3d4db6235fe5;p=sliver-openvswitch.git diff --git a/lib/odp-execute.c b/lib/odp-execute.c index 7a96ca0ad..12ad67981 100644 --- a/lib/odp-execute.c +++ b/lib/odp-execute.c @@ -1,5 +1,5 @@ /* - * 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"); @@ -21,6 +21,7 @@ #include #include +#include "dpif.h" #include "netlink.h" #include "ofpbuf.h" #include "odp-util.h" @@ -32,10 +33,12 @@ static void 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 @@ -50,7 +53,7 @@ odp_set_tunnel_action(const struct nlattr *a, struct flow_tnl *tun_key) 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); @@ -61,7 +64,7 @@ set_arp(struct ofpbuf *packet, const struct ovs_key_arp *arp_key) static void odp_execute_set_action(struct ofpbuf *packet, const struct nlattr *a, - struct flow *md) + struct pkt_metadata *md) { enum ovs_key_attr type = nl_attr_type(a); const struct ovs_key_ipv4 *ipv4_key; @@ -124,6 +127,14 @@ odp_execute_set_action(struct ofpbuf *packet, const struct nlattr *a, 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: @@ -140,13 +151,14 @@ odp_execute_set_action(struct ofpbuf *packet, const struct nlattr *a, } static void -odp_execute_actions__(void *dp, struct ofpbuf *packet, struct flow *key, +odp_execute_actions__(void *dp, struct ofpbuf *packet, bool steal, + struct pkt_metadata *, const struct nlattr *actions, size_t actions_len, odp_execute_cb dp_execute_action, bool more_actions); static void -odp_execute_sample(void *dp, struct ofpbuf *packet, struct flow *md, - const struct nlattr *action, +odp_execute_sample(void *dp, struct ofpbuf *packet, bool steal, + struct pkt_metadata *md, const struct nlattr *action, odp_execute_cb dp_execute_action, bool more_actions) { const struct nlattr *subactions = NULL; @@ -174,13 +186,14 @@ odp_execute_sample(void *dp, struct ofpbuf *packet, struct flow *md, } } - odp_execute_actions__(dp, packet, md, nl_attr_get(subactions), + odp_execute_actions__(dp, packet, steal, md, nl_attr_get(subactions), nl_attr_get_size(subactions), dp_execute_action, more_actions); } static void -odp_execute_actions__(void *dp, struct ofpbuf *packet, struct flow *md, +odp_execute_actions__(void *dp, struct ofpbuf *packet, bool steal, + struct pkt_metadata *md, const struct nlattr *actions, size_t actions_len, odp_execute_cb dp_execute_action, bool more_actions) { @@ -194,17 +207,21 @@ odp_execute_actions__(void *dp, struct ofpbuf *packet, struct flow *md, /* 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: + case OVS_ACTION_ATTR_HASH: if (dp_execute_action) { /* Allow 'dp_execute_action' to steal the packet data if we do * not need it any more. */ - bool steal = !more_actions && left <= NLA_ALIGN(a->nla_len); - dp_execute_action(dp, packet, md, a, steal); + 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_PUSH_VLAN: { const struct ovs_action_push_vlan *vlan = nl_attr_get(a); - eth_push_vlan(packet, vlan->vlan_tci); + eth_push_vlan(packet, htons(ETH_TYPE_VLAN), vlan->vlan_tci); break; } @@ -227,7 +244,7 @@ odp_execute_actions__(void *dp, struct ofpbuf *packet, struct flow *md, break; case OVS_ACTION_ATTR_SAMPLE: - odp_execute_sample(dp, packet, md, a, dp_execute_action, + odp_execute_sample(dp, packet, steal, md, a, dp_execute_action, more_actions || left > NLA_ALIGN(a->nla_len)); break; @@ -239,10 +256,16 @@ odp_execute_actions__(void *dp, struct ofpbuf *packet, struct flow *md, } void -odp_execute_actions(void *dp, struct ofpbuf *packet, struct flow *md, +odp_execute_actions(void *dp, struct ofpbuf *packet, bool steal, + struct pkt_metadata *md, const struct nlattr *actions, size_t actions_len, odp_execute_cb dp_execute_action) { - odp_execute_actions__(dp, packet, md, actions, actions_len, + odp_execute_actions__(dp, packet, steal, md, actions, actions_len, dp_execute_action, false); + + if (!actions_len && steal) { + /* Drop action. */ + ofpbuf_delete(packet); + } }