From 8e61c1104eddbe737a67cbf559fcb48971f59569 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Thu, 18 Oct 2012 03:51:58 +0900 Subject: [PATCH] ofpaction: support OF11 pop_vlan This patch adds support of OF11+ pop_vlan. Signed-off-by: Isaku Yamahata [blp@nicira.com added a test] Signed-off-by: Ben Pfaff --- lib/ofp-actions.c | 6 +++++- lib/ofp-actions.h | 2 +- lib/ofp-parse.c | 1 + lib/ofp-util.def | 2 +- tests/ofp-actions.at | 3 +++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 0d1a2acdd..b774a61e0 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -685,6 +685,10 @@ ofpact_from_openflow11(const union ofp_action *a, struct ofpbuf *out) ofpact_put_SET_VLAN_PCP(out)->vlan_pcp = a->vlan_pcp.vlan_pcp; break; + case OFPUTIL_OFPAT11_POP_VLAN: + ofpact_put_STRIP_VLAN(out); + break; + case OFPUTIL_OFPAT11_SET_DL_SRC: memcpy(ofpact_put_SET_ETH_SRC(out)->mac, ((const struct ofp_action_dl_addr *) a)->dl_addr, ETH_ADDR_LEN); @@ -1443,7 +1447,7 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) break; case OFPACT_STRIP_VLAN: - /* XXX */ + ofputil_put_OFPAT11_POP_VLAN(out); break; case OFPACT_SET_ETH_SRC: diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h index 3049aaafd..37a60825f 100644 --- a/lib/ofp-actions.h +++ b/lib/ofp-actions.h @@ -177,7 +177,7 @@ ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len) /* OFPACT_STRIP_VLAN, OFPACT_POP_QUEUE, OFPACT_EXIT, OFPACT_CLEAR_ACTIONS. * * Used for OFPAT10_STRIP_VLAN, NXAST_POP_QUEUE, NXAST_EXIT, - * OFPIT11_CLEAR_ACTIONS. + * OFPAT11_POP_VLAN, OFPIT11_CLEAR_ACTIONS. * * Action structure for actions that do not have any extra data beyond the * action type. */ diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index 04f5ab174..122f4b36d 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -403,6 +403,7 @@ parse_named_action(enum ofputil_action_code code, const struct flow *flow, break; case OFPUTIL_OFPAT10_STRIP_VLAN: + case OFPUTIL_OFPAT11_POP_VLAN: ofpact_put_STRIP_VLAN(ofpacts); break; diff --git a/lib/ofp-util.def b/lib/ofp-util.def index e61049bbd..3954dc0cb 100644 --- a/lib/ofp-util.def +++ b/lib/ofp-util.def @@ -31,7 +31,7 @@ OFPAT11_ACTION(OFPAT11_SET_NW_TOS, ofp_action_nw_tos, 0, "mod_nw_tos") OFPAT11_ACTION(OFPAT11_SET_TP_SRC, ofp_action_tp_port, 0, "mod_tp_src") OFPAT11_ACTION(OFPAT11_SET_TP_DST, ofp_action_tp_port, 0, "mod_tp_dst") //OFPAT11_ACTION(OFPAT11_PUSH_VLAN, ofp11_action_push, 0, "push_vlan") -//OFPAT11_ACTION(OFPAT11_POP_VLAN, ofp_action_header, 0, "pop_vlan") +OFPAT11_ACTION(OFPAT11_POP_VLAN, ofp_action_header, 0, "pop_vlan") //OFPAT11_ACTION(OFPAT11_SET_QUEUE, ofp11_action_set_queue, 0, "set_queue") //OFPAT11_ACTION(OFPAT11_SET_NW_TTL, ofp11_action_nw_ttl, 0, "set_nw_ttl") OFPAT11_ACTION(OFPAT11_DEC_NW_TTL, ofp_action_header, 0, NULL) diff --git a/tests/ofp-actions.at b/tests/ofp-actions.at index c5d666cec..8d95ae904 100644 --- a/tests/ofp-actions.at +++ b/tests/ofp-actions.at @@ -160,6 +160,9 @@ AT_DATA([test-data], [dnl # actions=mod_tp_dst:443 000a 0008 01bb 0000 +# actions=strip_vlan +0012 0008 00000000 + # actions=resubmit:5 ffff 0010 00002320 0001 0005 00000000 -- 2.43.0