mirror of
https://github.com/openvswitch/ovs
synced 2025-09-03 15:55:19 +00:00
dpif: Simplify dpif_execute_helper_cb()
The may_steal flag is now used, Remove OVS_UNUSED. Since dp_packet_delete() handles the NULL pointer properly, we can drop a few tracking variables, and make the code easier to follow. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
This commit is contained in:
31
lib/dpif.c
31
lib/dpif.c
@@ -1107,12 +1107,11 @@ struct dpif_execute_helper_aux {
|
|||||||
* meaningful. */
|
* meaningful. */
|
||||||
static void
|
static void
|
||||||
dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
|
dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
|
||||||
const struct nlattr *action, bool may_steal OVS_UNUSED)
|
const struct nlattr *action, bool may_steal)
|
||||||
{
|
{
|
||||||
struct dpif_execute_helper_aux *aux = aux_;
|
struct dpif_execute_helper_aux *aux = aux_;
|
||||||
int type = nl_attr_type(action);
|
int type = nl_attr_type(action);
|
||||||
struct dp_packet *packet = packets_->packets[0];
|
struct dp_packet *packet = packets_->packets[0];
|
||||||
struct dp_packet *trunc_packet = NULL, *orig_packet;
|
|
||||||
|
|
||||||
ovs_assert(packets_->count == 1);
|
ovs_assert(packets_->count == 1);
|
||||||
|
|
||||||
@@ -1127,8 +1126,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
|
|||||||
struct ofpbuf execute_actions;
|
struct ofpbuf execute_actions;
|
||||||
uint64_t stub[256 / 8];
|
uint64_t stub[256 / 8];
|
||||||
struct pkt_metadata *md = &packet->md;
|
struct pkt_metadata *md = &packet->md;
|
||||||
bool dst_set, clone = false;
|
bool dst_set;
|
||||||
uint32_t cutlen = dp_packet_get_cutlen(packet);
|
|
||||||
|
|
||||||
dst_set = flow_tnl_dst_is_set(&md->tunnel);
|
dst_set = flow_tnl_dst_is_set(&md->tunnel);
|
||||||
if (dst_set) {
|
if (dst_set) {
|
||||||
@@ -1146,20 +1144,17 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
|
|||||||
execute.actions_len = NLA_ALIGN(action->nla_len);
|
execute.actions_len = NLA_ALIGN(action->nla_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_packet = packet;
|
struct dp_packet *clone = NULL;
|
||||||
|
uint32_t cutlen = dp_packet_get_cutlen(packet);
|
||||||
if (cutlen > 0 && (type == OVS_ACTION_ATTR_OUTPUT ||
|
if (cutlen && (type == OVS_ACTION_ATTR_OUTPUT
|
||||||
type == OVS_ACTION_ATTR_TUNNEL_PUSH ||
|
|| type == OVS_ACTION_ATTR_TUNNEL_PUSH
|
||||||
type == OVS_ACTION_ATTR_TUNNEL_POP ||
|
|| type == OVS_ACTION_ATTR_TUNNEL_POP
|
||||||
type == OVS_ACTION_ATTR_USERSPACE)) {
|
|| type == OVS_ACTION_ATTR_USERSPACE)) {
|
||||||
|
dp_packet_reset_cutlen(packet);
|
||||||
if (!may_steal) {
|
if (!may_steal) {
|
||||||
trunc_packet = dp_packet_clone(packet);
|
packet = clone = dp_packet_clone(packet);
|
||||||
packet = trunc_packet;
|
|
||||||
clone = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dp_packet_set_size(packet, dp_packet_size(packet) - cutlen);
|
dp_packet_set_size(packet, dp_packet_size(packet) - cutlen);
|
||||||
dp_packet_reset_cutlen(orig_packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
execute.packet = packet;
|
execute.packet = packet;
|
||||||
@@ -1170,13 +1165,11 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
|
|||||||
aux->error = dpif_execute(aux->dpif, &execute);
|
aux->error = dpif_execute(aux->dpif, &execute);
|
||||||
log_execute_message(aux->dpif, &execute, true, aux->error);
|
log_execute_message(aux->dpif, &execute, true, aux->error);
|
||||||
|
|
||||||
|
dp_packet_delete(clone);
|
||||||
|
|
||||||
if (dst_set) {
|
if (dst_set) {
|
||||||
ofpbuf_uninit(&execute_actions);
|
ofpbuf_uninit(&execute_actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clone) {
|
|
||||||
dp_packet_delete(trunc_packet);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user