Table Features are supported

This commit is contained in:
Eishun Kondoh 2017-11-22 15:55:04 +09:00
parent 5762231816
commit ab21f6e240
3 changed files with 94 additions and 13 deletions

View file

@ -32,28 +32,28 @@ defmodule Openflow.Match do
<<type_int::16, length::16, fields_bin::bytes, 0::size(padding)-unit(8)>>
end
def codec_header(oxm_field) when is_atom(oxm_field) do
oxm_field = case has_mask(oxm_field) do
def codec_header(oxm_field0) when is_atom(oxm_field0) do
oxm_field = case has_mask(oxm_field0) do
1 ->
string = to_string(oxm_field)
string = to_string(oxm_field0)
"masked_" <> field = string
String.to_atom(field)
0 ->
oxm_field
oxm_field0
end
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_int = Openflow.Enums.to_int(oxm_class, :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)
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 when experimenter in [:nicira_ext_match, :onf_ext_match, :hp_ext_match] ->
oxm_class_int = 0xffff
experimenter_int = Openflow.Enums.to_int(experimenter, :experimenter_oxm_vendors)
oxm_field_int = Openflow.Enums.to_int(oxm_field, experimenter)
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>>
end
end
@ -179,7 +179,7 @@ defmodule Openflow.Match do
%{class: match_class, field: field_name, has_mask: false, value: value_bin}
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? =
oxm_field
|> to_string

View file

@ -132,9 +132,90 @@ defmodule Flay do
tables = [
TableFeatures.Body.new(
table_id: 0,
name: "Custom L2 Src",
max_entries: 8192,
config: [:table_miss_mask]
name: "classifier",
max_entries: 50,
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)

View file

@ -2,9 +2,9 @@ defmodule FlogTest do
use ExUnit.Case, async: false
use Bitwise
@vlan_trunk_port "veth0" # FIXME:
@access_port "veth3" # FIXME:
@vxlan_port "veth4" # FIXME:
@vlan_trunk_port "1" # FIXME:
@access_port "2" # FIXME:
@vxlan_port "5" # FIXME:
@bootnet_vid 0x1000 ||| 5
@user_vid 0x1000 ||| 123
@vlan_present {0x1000, 0x1000}