Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Push and Pop PBB actions #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/linc_us4/src/linc_us4_flow.erl
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,15 @@ validate_action(_SwitchId, #ofp_action_push_mpls{}, _Match) ->
{error,{bad_action,bad_argument}};
validate_action(_SwitchId, #ofp_action_pop_mpls{}, _Match) ->
ok;
validate_action(_SwitchId, #ofp_action_push_pbb{ethertype = Ether}, _Match) ->
case Ether of
16#88e7 ->
ok;
_ ->
{error, {bad_action, bad_argument}}
end;
validate_action(_SwitchId, #ofp_action_pop_pbb{}, _Match) ->
ok;
validate_action(_SwitchId, #ofp_action_set_field{field=Field}, Match) ->
case are_prerequisites_met(Field,Match) of
true ->
Expand Down
18 changes: 18 additions & 0 deletions apps/linc_us4/test/linc_us4_flow_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ flow_mod_test_() ->
,{"Delete where meter", fun delete_where_meter/0}
,{"Add flow with an incompatible value/mask pair in the match",
fun incompatible_value_mask_pair_in_match/0}
,{"Validate push_pbb action", fun push_pbb_action/0}
,{"Validate pop_pbb action", fun pop_pbb_action/0}
]}}.

bad_table_id() ->
Expand Down Expand Up @@ -1042,6 +1044,22 @@ incompatible_value_mask_pair_in_match() ->
?assertEqual({error, {bad_match, bad_wildcards}},
linc_us4_flow:modify(?SWITCH_ID, FlowModAdd)).

push_pbb_action() ->
FlowModAdd = #ofp_flow_mod{
table_id = 0,command = add,
instructions =
[#ofp_instruction_apply_actions{
actions = [#ofp_action_push_pbb{ethertype = 16#88e7}]}]},
?assertEqual(ok, linc_us4_flow:modify(?SWITCH_ID, FlowModAdd)).

pop_pbb_action() ->
FlowModAdd = #ofp_flow_mod{
table_id = 0,command = add,
instructions =
[#ofp_instruction_apply_actions{
actions = [#ofp_action_pop_pbb{}]}]},
?assertEqual(ok, linc_us4_flow:modify(?SWITCH_ID, FlowModAdd)).

statistics_test_() ->
{setup, fun setup/0, fun teardown/1,
{foreach, fun foreach_setup/0, fun foreach_teardown/1,
Expand Down