2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

instruction/clear-actions: string parser/formater, of packet decoder/encoder

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Isaku Yamahata
2012-10-05 15:56:57 +09:00
committed by Ben Pfaff
parent 8dd546660e
commit b19e879339
6 changed files with 57 additions and 15 deletions

View File

@@ -958,7 +958,11 @@ ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
goto exit; goto exit;
} }
} }
/* TODO:XXX Clear-Actions */ if (insts[OVSINST_OFPIT11_CLEAR_ACTIONS]) {
instruction_get_OFPIT11_CLEAR_ACTIONS(
insts[OVSINST_OFPIT11_CLEAR_ACTIONS]);
ofpact_put_CLEAR_ACTIONS(ofpacts);
}
/* TODO:XXX Write-Actions */ /* TODO:XXX Write-Actions */
/* TODO:XXX Write-Metadata */ /* TODO:XXX Write-Metadata */
if (insts[OVSINST_OFPIT11_GOTO_TABLE]) { if (insts[OVSINST_OFPIT11_GOTO_TABLE]) {
@@ -972,8 +976,7 @@ ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
} }
if (insts[OVSINST_OFPIT11_WRITE_METADATA] || if (insts[OVSINST_OFPIT11_WRITE_METADATA] ||
insts[OVSINST_OFPIT11_WRITE_ACTIONS] || insts[OVSINST_OFPIT11_WRITE_ACTIONS]) {
insts[OVSINST_OFPIT11_CLEAR_ACTIONS]) {
error = OFPERR_OFPBIC_UNSUP_INST; error = OFPERR_OFPBIC_UNSUP_INST;
goto exit; goto exit;
} }
@@ -1051,6 +1054,7 @@ ofpact_check__(const struct ofpact *a, const struct flow *flow, int max_ports)
case OFPACT_EXIT: case OFPACT_EXIT:
return 0; return 0;
case OFPACT_CLEAR_ACTIONS:
case OFPACT_GOTO_TABLE: case OFPACT_GOTO_TABLE:
return 0; return 0;
@@ -1269,6 +1273,7 @@ ofpact_to_nxast(const struct ofpact *a, struct ofpbuf *out)
case OFPACT_SET_IPV4_DSCP: case OFPACT_SET_IPV4_DSCP:
case OFPACT_SET_L4_SRC_PORT: case OFPACT_SET_L4_SRC_PORT:
case OFPACT_SET_L4_DST_PORT: case OFPACT_SET_L4_DST_PORT:
case OFPACT_CLEAR_ACTIONS:
case OFPACT_GOTO_TABLE: case OFPACT_GOTO_TABLE:
NOT_REACHED(); NOT_REACHED();
} }
@@ -1359,6 +1364,7 @@ ofpact_to_openflow10(const struct ofpact *a, struct ofpbuf *out)
= htons(ofpact_get_SET_L4_DST_PORT(a)->port); = htons(ofpact_get_SET_L4_DST_PORT(a)->port);
break; break;
case OFPACT_CLEAR_ACTIONS:
case OFPACT_GOTO_TABLE: case OFPACT_GOTO_TABLE:
/* TODO:XXX */ /* TODO:XXX */
break; break;
@@ -1471,6 +1477,7 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out)
= htons(ofpact_get_SET_L4_DST_PORT(a)->port); = htons(ofpact_get_SET_L4_DST_PORT(a)->port);
break; break;
case OFPACT_CLEAR_ACTIONS:
case OFPACT_GOTO_TABLE: case OFPACT_GOTO_TABLE:
NOT_REACHED(); NOT_REACHED();
@@ -1534,10 +1541,12 @@ ofpacts_put_openflow11_instructions(const struct ofpact ofpacts[],
const struct ofpact *a; const struct ofpact *a;
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) { OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
/* TODO:XXX Clear-Actions */
/* TODO:XXX Write-Actions */ /* TODO:XXX Write-Actions */
/* TODO:XXX Write-Metadata */ /* TODO:XXX Write-Metadata */
if (a->type == OFPACT_GOTO_TABLE) { if (a->type == OFPACT_CLEAR_ACTIONS) {
struct ofp11_instruction *oi;
oi = instruction_put_OFPIT11_CLEAR_ACTIONS(openflow);
} else if (a->type == OFPACT_GOTO_TABLE) {
struct ofp11_instruction_goto_table *oigt; struct ofp11_instruction_goto_table *oigt;
oigt = instruction_put_OFPIT11_GOTO_TABLE(openflow); oigt = instruction_put_OFPIT11_GOTO_TABLE(openflow);
@@ -1602,6 +1611,7 @@ ofpact_outputs_to_port(const struct ofpact *ofpact, uint16_t port)
case OFPACT_AUTOPATH: case OFPACT_AUTOPATH:
case OFPACT_NOTE: case OFPACT_NOTE:
case OFPACT_EXIT: case OFPACT_EXIT:
case OFPACT_CLEAR_ACTIONS:
case OFPACT_GOTO_TABLE: case OFPACT_GOTO_TABLE:
default: default:
return false; return false;
@@ -1870,6 +1880,12 @@ ofpact_format(const struct ofpact *a, struct ds *s)
ds_put_cstr(s, "exit"); ds_put_cstr(s, "exit");
break; break;
case OFPACT_CLEAR_ACTIONS:
ds_put_format(s, "%s",
ofpact_instruction_name_from_type(
OVSINST_OFPIT11_CLEAR_ACTIONS));
break;
case OFPACT_GOTO_TABLE: case OFPACT_GOTO_TABLE:
ds_put_format(s, "%s:%"PRIu8, ds_put_format(s, "%s:%"PRIu8,
ofpact_instruction_name_from_type( ofpact_instruction_name_from_type(
@@ -1896,7 +1912,6 @@ ofpacts_format(const struct ofpact *ofpacts, size_t ofpacts_len,
ds_put_cstr(string, ","); ds_put_cstr(string, ",");
} }
/* TODO:XXX clear-actions */
/* TODO:XXX write-actions */ /* TODO:XXX write-actions */
/* TODO:XXX write-metadata */ /* TODO:XXX write-metadata */
ofpact_format(a, string); ofpact_format(a, string);

View File

@@ -90,7 +90,8 @@
DEFINE_OFPACT(EXIT, ofpact_null, ofpact) \ DEFINE_OFPACT(EXIT, ofpact_null, ofpact) \
\ \
/* Instructions */ \ /* Instructions */ \
/* TODO:XXX Clear-Actions, Write-Actions, Write-Metadata */ \ /* TODO:XXX Write-Actions, Write-Metadata */ \
DEFINE_OFPACT(CLEAR_ACTIONS, ofpact_null, ofpact) \
DEFINE_OFPACT(GOTO_TABLE, ofpact_goto_table, ofpact) DEFINE_OFPACT(GOTO_TABLE, ofpact_goto_table, ofpact)
/* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */ /* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */
@@ -173,9 +174,10 @@ ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
/* Action structure for each OFPACT_*. */ /* Action structure for each OFPACT_*. */
/* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT. /* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT, OFPACT_CLEAR_ACTIONS.
* *
* Used for OFPAT10_STRIP_VLAN, NXAST_DEC_TTL, NXAST_POP_QUEUE, NXAST_EXIT. * Used for OFPAT10_STRIP_VLAN, NXAST_DEC_TTL, NXAST_POP_QUEUE, NXAST_EXIT,
* OFPIT11_CLEAR_ACTIONS.
* *
* Action structure for actions that do not have any extra data beyond the * Action structure for actions that do not have any extra data beyond the
* action type. */ * action type. */
@@ -581,8 +583,9 @@ enum {
static inline bool static inline bool
ofpact_is_instruction(const struct ofpact *a) ofpact_is_instruction(const struct ofpact *a)
{ {
/* TODO:XXX Clear-Actions, Write-Actions, Write-Metadata */ /* TODO:XXX Write-Actions, Write-Metadata */
return a->type == OFPACT_GOTO_TABLE; return a->type == OFPACT_CLEAR_ACTIONS
|| a->type == OFPACT_GOTO_TABLE;
} }
const char *ofpact_instruction_name_from_type(enum ovs_instruction_type type); const char *ofpact_instruction_name_from_type(enum ovs_instruction_type type);

View File

@@ -580,8 +580,7 @@ parse_named_instruction(enum ovs_instruction_type type,
break; break;
case OVSINST_OFPIT11_CLEAR_ACTIONS: case OVSINST_OFPIT11_CLEAR_ACTIONS:
/* TODO:XXX */ ofpact_put_CLEAR_ACTIONS(ofpacts);
ovs_fatal(0, "instruction clear-actions is not supported yet");
break; break;
case OVSINST_OFPIT11_WRITE_METADATA: case OVSINST_OFPIT11_WRITE_METADATA:

View File

@@ -5600,6 +5600,14 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
xlate_fin_timeout(ctx, ofpact_get_FIN_TIMEOUT(a)); xlate_fin_timeout(ctx, ofpact_get_FIN_TIMEOUT(a));
break; break;
case OFPACT_CLEAR_ACTIONS:
/* TODO:XXX
* Nothing to do because writa-actions is not supported for now.
* When writa-actions is supported, clear-actions also must
* be supported at the same time.
*/
break;
case OFPACT_GOTO_TABLE: { case OFPACT_GOTO_TABLE: {
/* TODO:XXX remove recursion */ /* TODO:XXX remove recursion */
/* It is assumed that goto-table is last action */ /* It is assumed that goto-table is last action */

View File

@@ -311,10 +311,24 @@ dnl Write-Actions not supported yet.
# bad OF1.1 instructions: OFPBIC_UNSUP_INST # bad OF1.1 instructions: OFPBIC_UNSUP_INST
0003 0008 01 000000 0003 0008 01 000000
dnl Clear-Actions not supported yet. dnl Clear-Actions too-long
# bad OF1.1 instructions: OFPBIC_UNSUP_INST # bad OF1.1 instructions: OFPBIC_BAD_LEN
0005 0010 00000000 0000000000000000
dnl Clear-Actions non-zero padding
# actions=clear_actions
# 7: 01 -> 00
0005 0008 00000001
dnl Clear-Actions non-zero padding
# actions=clear_actions
# 4: 01 -> 00
0005 0008 01 000000 0005 0008 01 000000
dnl Clear-Actions
# actions=clear_actions
0005 0008 00000000
dnl Experimenter actions not supported yet. dnl Experimenter actions not supported yet.
# bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER # bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER
ffff 0008 01 000000 ffff 0008 01 000000

View File

@@ -1145,6 +1145,9 @@ keep the learned flows separate from the primary flow table 0.)
Applies the specific action(s) immediately. The syntax of actions are same Applies the specific action(s) immediately. The syntax of actions are same
to \fBactions=\fR field. to \fBactions=\fR field.
. .
.IP \fBclear_actions\fR
Clears all the actions in the action set immediately.
.
.IP \fBgoto_table\fR:\fItable\fR .IP \fBgoto_table\fR:\fItable\fR
Indicates the next table in the process pipeline. Indicates the next table in the process pipeline.
.RE .RE