Skip to content

Commit

Permalink
Merge pull request snabbco#402 from mwiget/raw
Browse files Browse the repository at this point in the history
Linux network interface support via RawSocket for snabbvmx
  • Loading branch information
dpino authored Sep 2, 2016
2 parents 9bedbc4 + 3c3c41b commit 94c9ec7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/program/snabbvmx/lwaftr/README
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Arguments:

--conf <config-file> configuration file for lwaftr service
--id <port-id> port_id for virtio socket
--pci <pci-addr> PCI device number for NIC
--pci <pci-addr> PCI device number for NIC (or Linux interface name)
--mac <mac address> Ethernet address of virtio interface
--sock <socket-path> Socket path for virtio-user interfaces

Expand All @@ -18,9 +18,9 @@ Optional:

Example config file:

# cat snabbvmx-lwaftr-em3-em4.cfg
# cat snabbvmx-lwaftr-xe0.cfg
return {
lwaftr = "snabbvmx-lwaftr-em3-em4.conf",
lwaftr = "snabbvmx-lwaftr-xe0.conf",
ipv6_interface = {
ipv6_address = "fc00::100",
mtu = 9500,
Expand Down
13 changes: 13 additions & 0 deletions src/program/snabbvmx/lwaftr/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local lwcounter = require("apps.lwaftr.lwcounter")
local nh_fwd = require("apps.nh_fwd.nh_fwd")
local pci = require("lib.hardware.pci")
local tap = require("apps.tap.tap")
local raw = require("apps.socket.raw")

local yesno = lib.yesno

Expand All @@ -31,6 +32,11 @@ local function nic_exists (pci_addr)
dir_exists(("%s/0000:%s"):format(devices, pci_addr))
end

local function net_exists (pci_addr)
local devices="/sys/class/net"
return dir_exists(("%s/%s"):format(devices, pci_addr))
end

local function fatal (msg)
print(msg)
main.exit(1)
Expand Down Expand Up @@ -58,6 +64,13 @@ local function load_phy (c, nic_id, interface)
},
macaddr = interface.mac_address, mtu = interface.mtu })
chain_input, chain_output = nic_id .. ".rx", nic_id .. ".tx"
elseif net_exists(interface.pci) then
print(("%s network interface %s"):format(nic_id, interface.pci))
if vlan then
print(("WARNING: VLAN not supported over %s. %s vlan %d"):format(interface.pci, nic_id, vlan))
end
config.app(c, nic_id, raw.RawSocket, interface.pci)
chain_input, chain_output = nic_id .. ".rx", nic_id .. ".tx"
else
print(("Couldn't find device info for PCI address '%s'"):format(interface.pci))
if not interface.mirror_id then
Expand Down

0 comments on commit 94c9ec7

Please sign in to comment.