-
Notifications
You must be signed in to change notification settings - Fork 298
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
Implement l2fwd-like app #736
base: master
Are you sure you want to change the base?
Changes from all commits
60967c6
8682fdf
42819b9
c563794
3f271e6
79fb2e0
245b207
63e2f46
fb2ccbb
41ebfb0
c366435
2012bd6
982b5a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Usage: l2fwd <PCI1> <PCI2> | ||
|
||
PCI1: [pciaddr|virtio:pciaddr] | ||
PCI2: [pciaddr|virtio:pciaddr] | ||
|
||
Creates a full-duplex softwire between PCI1 and PCI2. | ||
|
||
Examples: | ||
|
||
l2fwd 0000:01:00.0 0000:02:00.0 | ||
l2fwd virtio:0000:01:00.0 virtio:0000:02:00.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
README |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
module(...,package.seeall) | ||
|
||
local lib = require("core.lib") | ||
local main = require("core.main") | ||
|
||
local function show_usage(code) | ||
print(require("program.l2fwd.README_inc")) | ||
main.exit(code) | ||
end | ||
|
||
local function parse_args(args) | ||
local handlers = {} | ||
local opts = {} | ||
function handlers.h() show_usage(0) end | ||
function handlers.v() | ||
opts.verbose = true | ||
end | ||
function handlers.D(arg) | ||
opts.duration = assert(tonumber(arg), "duration must be a number") | ||
end | ||
args = lib.dogetopt(args, handlers, "hvD:", { help="h", verbose="v", duration="D"}) | ||
if #args ~= 2 then show_usage(1) end | ||
return opts, unpack(args) | ||
end | ||
|
||
local function parse_nic_driver(arg) | ||
local driver_class, pciaddr = arg:match("(%a+):([%w:.]+)") | ||
if not driver_class then return "pci", arg end | ||
return driver_class, pciaddr | ||
end | ||
|
||
local function config_nic(c, app_name, pciaddr) | ||
local driver | ||
local driver_class, pciaddr = parse_nic_driver(pciaddr) | ||
if driver_class == "virtio" then | ||
driver = require("apps.virtio_net.virtio_net").VirtioNet | ||
config.app(c, app_name, driver, {pciaddr = pciaddr}) | ||
else | ||
assert(driver_class == "pci", | ||
("Not supported driver class '%s'"):format(driver_class)) | ||
driver = require("apps.intel.intel_app").Intel82599 | ||
config.app(c, app_name, driver, {pciaddr = pciaddr}) | ||
end | ||
end | ||
|
||
function run(args) | ||
local opts, arg1, arg2 = parse_args(args) | ||
local c = config.new() | ||
|
||
config_nic(c, "nic1", arg1) | ||
config_nic(c, "nic2", arg2) | ||
|
||
config.link(c, "nic1.tx -> nic2.rx") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we get also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nnikolaev-virtualopensystems Am I right in assuming that would make l2fwd a two-way street? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly, this makes it full featured 2-way "forwarder". |
||
config.link(c, "nic2.tx -> nic1.rx") | ||
|
||
if opts.verbose then | ||
local fn = function() | ||
print("Report (last 1 sec):") | ||
engine.report_links() | ||
engine.report_load() | ||
end | ||
local t = timer.new("report", fn, 1e9, 'repeating') | ||
timer.activate(t) | ||
end | ||
|
||
engine.configure(c) | ||
if opts.duration then | ||
engine.main({duration=opts.duration}) | ||
else | ||
engine.main() | ||
end | ||
end | ||
|
||
function selftest() | ||
print("selftest: l2fwd") | ||
local driver_class, pciaddr | ||
driver_class, pciaddr = parse_nic_driver("virtio:0000:00:01.0") | ||
assert(driver_class == "virtio" and pciaddr == "0000:00:01.0") | ||
driver_class, pciaddr = parse_nic_driver("pci:0000:00:01.0") | ||
assert(driver_class == "pci" and pciaddr == "0000:00:01.0") | ||
driver_class, pciaddr = parse_nic_driver("0000:00:01.0") | ||
assert(driver_class == "pci" and pciaddr == "0000:00:01.0") | ||
print("OK") | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Usage: | ||
packetblaster bounce | ||
packetblaster replay | ||
packetblaster synth | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Usage: packetblaster bounce [OPTIONS] <PCAPFILE> <PCI1> <PCI2> | ||
|
||
-D DURATION, --duration DURATION | ||
Run for DURATION seconds. | ||
Default: unlimited | ||
-h, --help | ||
Print usage information. | ||
|
||
packetblaster transmits packets continuously to <PCI1> network adapter. | ||
Packets will eventually reach <PCI2>, if both network adapters are wired together. | ||
Packets bounce on <PCI2> and get back to <PCI1>. | ||
|
||
Examples: | ||
packetblaster bounce myfile.cap 0000:01:00.0 0000:01:00.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
README |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly do the changes to
LoadGen
do? Does theLoadGen
documentation need an update to reflectconf.report_rx
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified LoadGen so it reports on received packets as well as transmitted packets. As traffic gets bounced to its originator and the NIC is locked by the program running the packetblaster, this was the only possible way I thought of of checking traffic gets actually bounced back.
I missed updating LoadGen docs, if the change finally makes it I will update the docs.