Skip to content

Commit

Permalink
Merge pull request snabbco#917 from Igalia/setup-conf
Browse files Browse the repository at this point in the history
Load config from setup.lua
  • Loading branch information
wingo authored Aug 23, 2017
2 parents dbe850a + b68815f commit 1294297
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 55 deletions.
20 changes: 0 additions & 20 deletions src/apps/lwaftr/conf.lua

This file was deleted.

17 changes: 0 additions & 17 deletions src/apps/lwaftr/dump.lua

This file was deleted.

2 changes: 1 addition & 1 deletion src/program/lwaftr/bench/bench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end

function run(args)
local opts, scheduling, conf_file, inv4_pcap, inv6_pcap = parse_args(args)
local conf = require('apps.lwaftr.conf').load_lwaftr_config(conf_file)
local conf = setup.read_config(conf_file)

-- If there is a name defined on the command line, it should override
-- anything defined in the config.
Expand Down
3 changes: 1 addition & 2 deletions src/program/lwaftr/check/check.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module(..., package.seeall)

local lib = require("core.lib")
local lwconf = require("apps.lwaftr.conf")
local setup = require("program.lwaftr.setup")
local util = require("program.lwaftr.check.util")
local engine = require("core.app")
Expand Down Expand Up @@ -43,7 +42,7 @@ function run(args)
or setup.load_check
local conf_file, inv4_pcap, inv6_pcap, outv4_pcap, outv6_pcap, counters_path =
unpack(args)
local conf = lwconf.load_lwaftr_config(conf_file)
local conf = setup.read_config(conf_file)
local c = config.new()
load_check(c, conf, inv4_pcap, inv6_pcap, outv4_pcap, outv6_pcap)
engine.configure(c)
Expand Down
2 changes: 1 addition & 1 deletion src/program/lwaftr/run/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ end

function run(args)
local opts, scheduling, conf_file, v4, v6 = parse_args(args)
local conf = require('apps.lwaftr.conf').load_lwaftr_config(conf_file)
local conf = setup.read_config(conf_file)

-- If there are v4 or v6 options we need to migrate the configuration in
-- memory from the PCI device specified, later we'll want to support
Expand Down
1 change: 1 addition & 0 deletions src/program/lwaftr/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local ipv4_ntop = require("lib.yang.util").ipv4_ntop
local S = require("syscall")
local engine = require("core.app")
local lib = require("core.lib")
local yang = require("lib.yang.yang")


local capabilities = {['ietf-softwire']={feature={'binding', 'br'}}}
Expand Down
3 changes: 1 addition & 2 deletions src/program/lwaftr/soaktest/soaktest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module(..., package.seeall)

local config = require("core.config")
local lib = require("core.lib")
local lwconf = require('apps.lwaftr.conf')
local setup = require("program.lwaftr.setup")
local engine = require("core.app")

Expand Down Expand Up @@ -40,7 +39,7 @@ function run (args)
local load_soak_test = opts["on-a-stick"] and setup.load_soak_test_on_a_stick
or setup.load_soak_test
local c = config.new()
local conf = lwconf.load_lwaftr_config(conf_file)
local conf = setup.read_config(conf_file)
load_soak_test(c, conf, inv4_pcap, inv6_pcap)

engine.configure(c)
Expand Down
12 changes: 2 additions & 10 deletions src/program/snabbvmx/lwaftr/lwaftr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,10 @@ function run(args)
local ingress_drop_wait = 20

if file_exists(conf_file) then
conf = lib.load_conf(conf_file)
if not file_exists(conf.lwaftr) then
-- Search in main config file.
conf.lwaftr = lib.dirname(conf_file).."/"..conf.lwaftr
end
if not file_exists(conf.lwaftr) then
fatal(("lwAFTR conf file '%s' not found"):format(conf.lwaftr))
end
lwconf = require('apps.lwaftr.conf').load_lwaftr_config(conf.lwaftr)
conf, lwconf = setup.load_conf(conf_file)
external_interface = lwconf.softwire_config.external_interface
internal_interface = lwconf.softwire_config.internal_interface
-- If one interface has vlan tags, the other one should as well.
-- If one interface has vlan tags, then the other one should as well.
assert((not external_interface.vlan_tag) == (not internal_interface.vlan_tag))
else
print(("Interface '%s' set to passthrough mode."):format(id))
Expand Down
6 changes: 4 additions & 2 deletions src/program/snabbvmx/lwaftr/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local pci = require("lib.hardware.pci")
local raw = require("apps.socket.raw")
local tap = require("apps.tap.tap")
local pcap = require("apps.pcap.pcap")
local yang = require("lib.yang.yang")

local fatal, file_exists = lwutil.fatal, lwutil.file_exists
local dir_exists, nic_exists = lwutil.dir_exists, lwutil.nic_exists
Expand Down Expand Up @@ -329,13 +330,14 @@ function passthrough(c, conf, sock_path)
end
end

local function load_conf (conf_filename)
function load_conf (conf_filename)
local function load_lwaftr_config (conf, conf_filename)
local filename = conf.lwaftr
if not file_exists(filename) then
filename = lib.dirname(conf_filename).."/"..filename
end
return require("apps.lwaftr.conf").load_lwaftr_config(filename)
return yang.load_configuration(filename,
{schema_name=lwaftr.LwAftr.yang_schema})
end
local conf = dofile(conf_filename)
return conf, load_lwaftr_config(conf, conf_filename)
Expand Down

0 comments on commit 1294297

Please sign in to comment.