Table Features are supported
This commit is contained in:
parent
5762231816
commit
ab21f6e240
3 changed files with 94 additions and 13 deletions
|
|
@ -32,28 +32,28 @@ defmodule Openflow.Match do
|
||||||
<<type_int::16, length::16, fields_bin::bytes, 0::size(padding)-unit(8)>>
|
<<type_int::16, length::16, fields_bin::bytes, 0::size(padding)-unit(8)>>
|
||||||
end
|
end
|
||||||
|
|
||||||
def codec_header(oxm_field) when is_atom(oxm_field) do
|
def codec_header(oxm_field0) when is_atom(oxm_field0) do
|
||||||
oxm_field = case has_mask(oxm_field) do
|
oxm_field = case has_mask(oxm_field0) do
|
||||||
1 ->
|
1 ->
|
||||||
string = to_string(oxm_field)
|
string = to_string(oxm_field0)
|
||||||
"masked_" <> field = string
|
"masked_" <> field = string
|
||||||
String.to_atom(field)
|
String.to_atom(field)
|
||||||
0 ->
|
0 ->
|
||||||
oxm_field
|
oxm_field0
|
||||||
end
|
end
|
||||||
case Openflow.Match.Field.vendor_of(oxm_field) do
|
case Openflow.Match.Field.vendor_of(oxm_field) do
|
||||||
oxm_class when oxm_class in [:nxm_0, :nxm_1, :openflow_basic, :packet_register] ->
|
oxm_class when oxm_class in [:nxm_0, :nxm_1, :openflow_basic, :packet_register] ->
|
||||||
oxm_class_int = Openflow.Enums.to_int(oxm_class, :oxm_class)
|
oxm_class_int = Openflow.Enums.to_int(oxm_class, :oxm_class)
|
||||||
oxm_field_int = Openflow.Enums.to_int(oxm_field, oxm_class)
|
oxm_field_int = Openflow.Enums.to_int(oxm_field, oxm_class)
|
||||||
oxm_length = div(Openflow.Match.Field.n_bits_of(oxm_field), 8)
|
oxm_length = div(Openflow.Match.Field.n_bits_of(oxm_field), 8)
|
||||||
has_mask = has_mask(oxm_field)
|
has_mask = has_mask(oxm_field0)
|
||||||
<<oxm_class_int::16, oxm_field_int::7, has_mask::1, oxm_length::8>>
|
<<oxm_class_int::16, oxm_field_int::7, has_mask::1, oxm_length::8>>
|
||||||
experimenter when experimenter in [:nicira_ext_match, :onf_ext_match, :hp_ext_match] ->
|
experimenter when experimenter in [:nicira_ext_match, :onf_ext_match, :hp_ext_match] ->
|
||||||
oxm_class_int = 0xffff
|
oxm_class_int = 0xffff
|
||||||
experimenter_int = Openflow.Enums.to_int(experimenter, :experimenter_oxm_vendors)
|
experimenter_int = Openflow.Enums.to_int(experimenter, :experimenter_oxm_vendors)
|
||||||
oxm_field_int = Openflow.Enums.to_int(oxm_field, experimenter)
|
oxm_field_int = Openflow.Enums.to_int(oxm_field, experimenter)
|
||||||
oxm_length = div(Openflow.Match.Field.n_bits_of(oxm_field) + 4, 8)
|
oxm_length = div(Openflow.Match.Field.n_bits_of(oxm_field) + 4, 8)
|
||||||
has_mask = has_mask(oxm_field)
|
has_mask = has_mask(oxm_field0)
|
||||||
<<oxm_class_int::16, oxm_field_int::7, has_mask::1, oxm_length::8, experimenter_int::32>>
|
<<oxm_class_int::16, oxm_field_int::7, has_mask::1, oxm_length::8, experimenter_int::32>>
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -179,7 +179,7 @@ defmodule Openflow.Match do
|
||||||
%{class: match_class, field: field_name, has_mask: false, value: value_bin}
|
%{class: match_class, field: field_name, has_mask: false, value: value_bin}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp has_mask(oxm_field) when is_atom(oxm_field) do
|
def has_mask(oxm_field) when is_atom(oxm_field) do
|
||||||
has_mask? =
|
has_mask? =
|
||||||
oxm_field
|
oxm_field
|
||||||
|> to_string
|
|> to_string
|
||||||
|
|
|
||||||
87
test/flay.ex
87
test/flay.ex
|
|
@ -132,9 +132,90 @@ defmodule Flay do
|
||||||
tables = [
|
tables = [
|
||||||
TableFeatures.Body.new(
|
TableFeatures.Body.new(
|
||||||
table_id: 0,
|
table_id: 0,
|
||||||
name: "Custom L2 Src",
|
name: "classifier",
|
||||||
max_entries: 8192,
|
max_entries: 50,
|
||||||
config: [:table_miss_mask]
|
config: [:table_miss_mask],
|
||||||
|
match: [
|
||||||
|
:in_port,
|
||||||
|
:eth_type,
|
||||||
|
:eth_src,
|
||||||
|
:masked_eth_dst,
|
||||||
|
:ip_proto,
|
||||||
|
:vlan_vid,
|
||||||
|
:ipv4_src,
|
||||||
|
:udp_dst,
|
||||||
|
:tcp_dst
|
||||||
|
],
|
||||||
|
wildcards: [
|
||||||
|
:in_port,
|
||||||
|
:eth_src
|
||||||
|
:eth_type,
|
||||||
|
:masked_eth_dst,
|
||||||
|
:vlan_vid,
|
||||||
|
:ip_proto,
|
||||||
|
:ipv4_src,
|
||||||
|
:udp_dst,
|
||||||
|
:tcp_dst,
|
||||||
|
],
|
||||||
|
instructions: [
|
||||||
|
Openflow.Instruction.GotoTable,
|
||||||
|
Openflow.Instruction.ApplyActions
|
||||||
|
],
|
||||||
|
apply_actions: [
|
||||||
|
Openflow.Action.Output,
|
||||||
|
Openflow.Action.PushVlan,
|
||||||
|
Openflow.Action.PopVlan,
|
||||||
|
Openflow.Action.SetField
|
||||||
|
],
|
||||||
|
apply_setfield: [
|
||||||
|
:eth_dst,
|
||||||
|
:vlan_vid
|
||||||
|
],
|
||||||
|
next_tables: [
|
||||||
|
1,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableFeatures.Body.new(
|
||||||
|
table_id: 1,
|
||||||
|
name: "admission_control",
|
||||||
|
max_entries: 50,
|
||||||
|
config: [:table_miss_mask],
|
||||||
|
match: [
|
||||||
|
:in_port,
|
||||||
|
:eth_type,
|
||||||
|
:eth_src,
|
||||||
|
:vlan_vid,
|
||||||
|
:masked_eth_dst,
|
||||||
|
:ip_proto,
|
||||||
|
:udp_dst,
|
||||||
|
:tcp_dst,
|
||||||
|
],
|
||||||
|
wildcards: [
|
||||||
|
:in_port,
|
||||||
|
:eth_type,
|
||||||
|
:eth_src,
|
||||||
|
:masked_eth_dst,
|
||||||
|
:vlan_vid,
|
||||||
|
:ip_proto,
|
||||||
|
:udp_dst,
|
||||||
|
:tcp_dst,
|
||||||
|
],
|
||||||
|
instructions: [
|
||||||
|
Openflow.Instruction.GotoTable,
|
||||||
|
Openflow.Instruction.ApplyActions
|
||||||
|
],
|
||||||
|
apply_actions: [
|
||||||
|
Openflow.Action.Output,
|
||||||
|
Openflow.Action.PushVlan,
|
||||||
|
Openflow.Action.PopVlan,
|
||||||
|
Openflow.Action.SetField
|
||||||
|
],
|
||||||
|
apply_setfield: [
|
||||||
|
:eth_dst,
|
||||||
|
:vlan_vid,
|
||||||
|
:ipv4_src,
|
||||||
|
:ipv4_dst
|
||||||
|
],
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
TableFeatures.Request.new(tables)
|
TableFeatures.Request.new(tables)
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ defmodule FlogTest do
|
||||||
use ExUnit.Case, async: false
|
use ExUnit.Case, async: false
|
||||||
use Bitwise
|
use Bitwise
|
||||||
|
|
||||||
@vlan_trunk_port "veth0" # FIXME:
|
@vlan_trunk_port "1" # FIXME:
|
||||||
@access_port "veth3" # FIXME:
|
@access_port "2" # FIXME:
|
||||||
@vxlan_port "veth4" # FIXME:
|
@vxlan_port "5" # FIXME:
|
||||||
@bootnet_vid 0x1000 ||| 5
|
@bootnet_vid 0x1000 ||| 5
|
||||||
@user_vid 0x1000 ||| 123
|
@user_vid 0x1000 ||| 123
|
||||||
@vlan_present {0x1000, 0x1000}
|
@vlan_present {0x1000, 0x1000}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue