mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 23:05:29 +00:00
ofproto-dpif: Use execute_actions to execute controller actions
Now that execute_actions() is available it can be used as a generic replacement for special-case action execution in execute_controller_action(). As suggested by Jesse Gross. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -170,7 +170,9 @@ odp_execute_actions(void *dp, struct ofpbuf *packet, struct flow *key,
|
|||||||
|
|
||||||
switch ((enum ovs_action_attr) type) {
|
switch ((enum ovs_action_attr) type) {
|
||||||
case OVS_ACTION_ATTR_OUTPUT:
|
case OVS_ACTION_ATTR_OUTPUT:
|
||||||
output(dp, packet, nl_attr_get_u32(a));
|
if (output) {
|
||||||
|
output(dp, packet, nl_attr_get_u32(a));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OVS_ACTION_ATTR_USERSPACE: {
|
case OVS_ACTION_ATTR_USERSPACE: {
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include "netlink.h"
|
#include "netlink.h"
|
||||||
#include "nx-match.h"
|
#include "nx-match.h"
|
||||||
#include "odp-util.h"
|
#include "odp-util.h"
|
||||||
|
#include "odp-execute.h"
|
||||||
#include "ofp-util.h"
|
#include "ofp-util.h"
|
||||||
#include "ofpbuf.h"
|
#include "ofpbuf.h"
|
||||||
#include "ofp-actions.h"
|
#include "ofp-actions.h"
|
||||||
@@ -6180,6 +6181,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
|
|||||||
{
|
{
|
||||||
struct ofputil_packet_in pin;
|
struct ofputil_packet_in pin;
|
||||||
struct ofpbuf *packet;
|
struct ofpbuf *packet;
|
||||||
|
struct flow key;
|
||||||
|
|
||||||
ovs_assert(!ctx->xout->slow || ctx->xout->slow == SLOW_CONTROLLER);
|
ovs_assert(!ctx->xout->slow || ctx->xout->slow == SLOW_CONTROLLER);
|
||||||
ctx->xout->slow = SLOW_CONTROLLER;
|
ctx->xout->slow = SLOW_CONTROLLER;
|
||||||
@@ -6189,48 +6191,15 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
|
|||||||
|
|
||||||
packet = ofpbuf_clone(ctx->xin->packet);
|
packet = ofpbuf_clone(ctx->xin->packet);
|
||||||
|
|
||||||
if (packet->l2 && packet->l3) {
|
key.skb_priority = 0;
|
||||||
struct eth_header *eh;
|
key.skb_mark = 0;
|
||||||
uint16_t mpls_depth;
|
memset(&key.tunnel, 0, sizeof key.tunnel);
|
||||||
|
|
||||||
eth_pop_vlan(packet);
|
commit_odp_actions(&ctx->xin->flow, &ctx->base_flow,
|
||||||
eh = packet->l2;
|
&ctx->xout->odp_actions);
|
||||||
|
|
||||||
memcpy(eh->eth_src, ctx->xin->flow.dl_src, sizeof eh->eth_src);
|
odp_execute_actions(NULL, packet, &key, ctx->xout->odp_actions.data,
|
||||||
memcpy(eh->eth_dst, ctx->xin->flow.dl_dst, sizeof eh->eth_dst);
|
ctx->xout->odp_actions.size, NULL, NULL);
|
||||||
|
|
||||||
if (ctx->xin->flow.vlan_tci & htons(VLAN_CFI)) {
|
|
||||||
eth_push_vlan(packet, ctx->xin->flow.vlan_tci);
|
|
||||||
}
|
|
||||||
|
|
||||||
mpls_depth = eth_mpls_depth(packet);
|
|
||||||
|
|
||||||
if (mpls_depth < ctx->xin->flow.mpls_depth) {
|
|
||||||
push_mpls(packet, ctx->xin->flow.dl_type, ctx->xin->flow.mpls_lse);
|
|
||||||
} else if (mpls_depth > ctx->xin->flow.mpls_depth) {
|
|
||||||
pop_mpls(packet, ctx->xin->flow.dl_type);
|
|
||||||
} else if (mpls_depth) {
|
|
||||||
set_mpls_lse(packet, ctx->xin->flow.mpls_lse);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet->l4) {
|
|
||||||
if (ctx->xin->flow.dl_type == htons(ETH_TYPE_IP)) {
|
|
||||||
packet_set_ipv4(packet, ctx->xin->flow.nw_src,
|
|
||||||
ctx->xin->flow.nw_dst, ctx->xin->flow.nw_tos,
|
|
||||||
ctx->xin->flow.nw_ttl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet->l7) {
|
|
||||||
if (ctx->xin->flow.nw_proto == IPPROTO_TCP) {
|
|
||||||
packet_set_tcp_port(packet, ctx->xin->flow.tp_src,
|
|
||||||
ctx->xin->flow.tp_dst);
|
|
||||||
} else if (ctx->xin->flow.nw_proto == IPPROTO_UDP) {
|
|
||||||
packet_set_udp_port(packet, ctx->xin->flow.tp_src,
|
|
||||||
ctx->xin->flow.tp_dst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pin.packet = packet->data;
|
pin.packet = packet->data;
|
||||||
pin.packet_len = packet->size;
|
pin.packet_len = packet->size;
|
||||||
|
Reference in New Issue
Block a user