example/router: Use bundle_control to install default flows
This commit is contained in:
parent
15e362437a
commit
c843121e14
2 changed files with 20 additions and 0 deletions
|
|
@ -45,6 +45,7 @@ defmodule SimpleRouter.Openflow.Controller do
|
||||||
:ok = debug("port_reply from dpid: #{dpid}")
|
:ok = debug("port_reply from dpid: #{dpid}")
|
||||||
ports = handle_ports(ports)
|
ports = handle_ports(ports)
|
||||||
routes = Config.routes()
|
routes = Config.routes()
|
||||||
|
:ok = onf_bundle_open(dpid, bundle_id: 1, flags: [:atomic, :ordered])
|
||||||
:ok = FlowTables.classifier(dpid)
|
:ok = FlowTables.classifier(dpid)
|
||||||
:ok = init_egress_groups(ports, dpid)
|
:ok = init_egress_groups(ports, dpid)
|
||||||
:ok = init_interface_lookup_flows(ports, dpid)
|
:ok = init_interface_lookup_flows(ports, dpid)
|
||||||
|
|
@ -52,6 +53,7 @@ defmodule SimpleRouter.Openflow.Controller do
|
||||||
:ok = init_egress_flows(ports, dpid)
|
:ok = init_egress_flows(ports, dpid)
|
||||||
:ok = init_connected_routes(ports, dpid)
|
:ok = init_connected_routes(ports, dpid)
|
||||||
:ok = init_static_routes(routes, dpid)
|
:ok = init_static_routes(routes, dpid)
|
||||||
|
:ok = onf_bundle_commit(dpid, bundle_id: 1, flags: [:atomic, :ordered])
|
||||||
{:noreply, %{state | ports: ports}}
|
{:noreply, %{state | ports: ports}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
# ARP
|
# ARP
|
||||||
send_flow_mod_add(
|
send_flow_mod_add(
|
||||||
datapath_id,
|
datapath_id,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
table_id: @classifier_table_id,
|
table_id: @classifier_table_id,
|
||||||
priority: 1,
|
priority: 1,
|
||||||
match: Match.new(eth_type: 0x0806),
|
match: Match.new(eth_type: 0x0806),
|
||||||
|
|
@ -28,6 +30,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
# IPv4
|
# IPv4
|
||||||
send_flow_mod_add(
|
send_flow_mod_add(
|
||||||
datapath_id,
|
datapath_id,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
table_id: @classifier_table_id,
|
table_id: @classifier_table_id,
|
||||||
priority: 1,
|
priority: 1,
|
||||||
match: Match.new(eth_type: 0x0800),
|
match: Match.new(eth_type: 0x0800),
|
||||||
|
|
@ -39,6 +43,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
send_flow_mod_add(
|
send_flow_mod_add(
|
||||||
datapath_id,
|
datapath_id,
|
||||||
table_id: @routing_table_id,
|
table_id: @routing_table_id,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
priority: 100 + iface.prefix_length,
|
priority: 100 + iface.prefix_length,
|
||||||
match: Match.new(
|
match: Match.new(
|
||||||
eth_type: 0x0800,
|
eth_type: 0x0800,
|
||||||
|
|
@ -55,6 +61,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
send_flow_mod_add(
|
send_flow_mod_add(
|
||||||
datapath_id,
|
datapath_id,
|
||||||
table_id: @routing_table_id,
|
table_id: @routing_table_id,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
priority: route.prefix_length,
|
priority: route.prefix_length,
|
||||||
match: Match.new(
|
match: Match.new(
|
||||||
eth_type: 0x0800,
|
eth_type: 0x0800,
|
||||||
|
|
@ -77,6 +85,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
send_flow_mod_add(
|
send_flow_mod_add(
|
||||||
datapath_id,
|
datapath_id,
|
||||||
priority: 0,
|
priority: 0,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
table_id: @arp_lookup_table_id,
|
table_id: @arp_lookup_table_id,
|
||||||
match: Match.new(reg1: iface.number),
|
match: Match.new(reg1: iface.number),
|
||||||
instructions: [
|
instructions: [
|
||||||
|
|
@ -99,6 +109,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
send_flow_mod_add(
|
send_flow_mod_add(
|
||||||
datapath_id,
|
datapath_id,
|
||||||
table_id: @interface_lookup_table_id,
|
table_id: @interface_lookup_table_id,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
priority: iface.prefix_length,
|
priority: iface.prefix_length,
|
||||||
match: match,
|
match: match,
|
||||||
instructions: [
|
instructions: [
|
||||||
|
|
@ -115,6 +127,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
send_flow_mod_add(
|
send_flow_mod_add(
|
||||||
datapath_id,
|
datapath_id,
|
||||||
table_id: @egress_table_id,
|
table_id: @egress_table_id,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
priority: 1,
|
priority: 1,
|
||||||
match: Match.new(reg1: iface.number),
|
match: Match.new(reg1: iface.number),
|
||||||
instructions: ApplyActions.new(Group.new(iface.number))
|
instructions: ApplyActions.new(Group.new(iface.number))
|
||||||
|
|
@ -128,6 +142,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
datapath_id,
|
datapath_id,
|
||||||
table_id: @arp_handler_table_id,
|
table_id: @arp_handler_table_id,
|
||||||
priority: 0,
|
priority: 0,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
match: Match.new(
|
match: Match.new(
|
||||||
in_port: iface.number,
|
in_port: iface.number,
|
||||||
eth_type: 0x0806,
|
eth_type: 0x0806,
|
||||||
|
|
@ -144,6 +160,8 @@ defmodule SimpleRouter.Openflow.FlowTables do
|
||||||
datapath_id,
|
datapath_id,
|
||||||
table_id: @arp_handler_table_id,
|
table_id: @arp_handler_table_id,
|
||||||
priority: 0,
|
priority: 0,
|
||||||
|
bundle_id: 1,
|
||||||
|
bundle_flags: [:atomic, :ordered],
|
||||||
match: Match.new(
|
match: Match.new(
|
||||||
in_port: iface.number,
|
in_port: iface.number,
|
||||||
eth_type: 0x0806,
|
eth_type: 0x0806,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue