mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 14:55:18 +00:00
ofpacts_check: Remove unnecessary flow copying.
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
committed by
Ben Pfaff
parent
d614823e2b
commit
eca39bced3
@@ -1142,9 +1142,9 @@ exit:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* May modify flow->dl_type, caller must restore it. */
|
||||||
static enum ofperr
|
static enum ofperr
|
||||||
ofpact_check__(const struct ofpact *a, const struct flow *flow,
|
ofpact_check__(const struct ofpact *a, struct flow *flow, ofp_port_t max_ports)
|
||||||
ofp_port_t max_ports, ovs_be16 *dl_type)
|
|
||||||
{
|
{
|
||||||
const struct ofpact_enqueue *enqueue;
|
const struct ofpact_enqueue *enqueue;
|
||||||
|
|
||||||
@@ -1217,11 +1217,11 @@ ofpact_check__(const struct ofpact *a, const struct flow *flow,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case OFPACT_PUSH_MPLS:
|
case OFPACT_PUSH_MPLS:
|
||||||
*dl_type = ofpact_get_PUSH_MPLS(a)->ethertype;
|
flow->dl_type = ofpact_get_PUSH_MPLS(a)->ethertype;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case OFPACT_POP_MPLS:
|
case OFPACT_POP_MPLS:
|
||||||
*dl_type = ofpact_get_POP_MPLS(a)->ethertype;
|
flow->dl_type = ofpact_get_POP_MPLS(a)->ethertype;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case OFPACT_SAMPLE:
|
case OFPACT_SAMPLE:
|
||||||
@@ -1239,36 +1239,25 @@ ofpact_check__(const struct ofpact *a, const struct flow *flow,
|
|||||||
|
|
||||||
/* Checks that the 'ofpacts_len' bytes of actions in 'ofpacts' are
|
/* Checks that the 'ofpacts_len' bytes of actions in 'ofpacts' are
|
||||||
* appropriate for a packet with the prerequisites satisfied by 'flow' in a
|
* appropriate for a packet with the prerequisites satisfied by 'flow' in a
|
||||||
* switch with no more than 'max_ports' ports. */
|
* switch with no more than 'max_ports' ports.
|
||||||
|
*
|
||||||
|
* May temporarily modify 'flow', but restores the changes before returning. */
|
||||||
enum ofperr
|
enum ofperr
|
||||||
ofpacts_check(const struct ofpact ofpacts[], size_t ofpacts_len,
|
ofpacts_check(const struct ofpact ofpacts[], size_t ofpacts_len,
|
||||||
const struct flow *flow, ofp_port_t max_ports)
|
struct flow *flow, ofp_port_t max_ports)
|
||||||
{
|
{
|
||||||
const struct ofpact *a;
|
const struct ofpact *a;
|
||||||
ovs_be16 dl_type = flow->dl_type;
|
ovs_be16 dl_type = flow->dl_type;
|
||||||
struct flow updated_flow;
|
enum ofperr error = 0;
|
||||||
|
|
||||||
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
|
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
|
||||||
enum ofperr error;
|
error = ofpact_check__(a, flow, max_ports);
|
||||||
|
|
||||||
/* If the dl_type was changed by an action then its new value
|
|
||||||
* should be present in the flow passed to ofpact_check__(). */
|
|
||||||
if (flow->dl_type != dl_type) {
|
|
||||||
/* Only copy flow at most once */
|
|
||||||
if (flow != &updated_flow) {
|
|
||||||
updated_flow = *flow;
|
|
||||||
flow = &updated_flow;
|
|
||||||
}
|
|
||||||
updated_flow.dl_type = dl_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = ofpact_check__(a, flow, max_ports, &dl_type);
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
flow->dl_type = dl_type; /* Restore. */
|
||||||
return 0;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verifies that the 'ofpacts_len' bytes of actions in 'ofpacts' are
|
/* Verifies that the 'ofpacts_len' bytes of actions in 'ofpacts' are
|
||||||
|
@@ -493,7 +493,7 @@ enum ofperr ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
|
|||||||
uint8_t table_id,
|
uint8_t table_id,
|
||||||
struct ofpbuf *ofpacts);
|
struct ofpbuf *ofpacts);
|
||||||
enum ofperr ofpacts_check(const struct ofpact[], size_t ofpacts_len,
|
enum ofperr ofpacts_check(const struct ofpact[], size_t ofpacts_len,
|
||||||
const struct flow *, ofp_port_t max_ports);
|
struct flow *, ofp_port_t max_ports);
|
||||||
enum ofperr ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len);
|
enum ofperr ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len);
|
||||||
|
|
||||||
/* Converting ofpacts to OpenFlow. */
|
/* Converting ofpacts to OpenFlow. */
|
||||||
|
Reference in New Issue
Block a user