Permalink
Browse files

Merge #1311 branch 'snabbco/max-next' into next

  • Loading branch information...
lukego committed Apr 13, 2018
2 parents 496ad72 + 4679c9c commit 62c4cce24f6ce43bd4d05976c4339a01ed4ffffd
View
@@ -0,0 +1,13 @@
FROM alpine:3.7 AS build
RUN apk add --no-cache libgcc alpine-sdk gcc libpcap-dev linux-headers findutils
COPY . /snabb
RUN cd /snabb && make clean && make -j && cd src && make -j
FROM alpine:3.7
RUN apk add --no-cache libgcc
COPY --from=build /snabb/src/snabb /usr/local/bin/
VOLUME /u
WORKDIR /u
ENTRYPOINT ["/usr/local/bin/snabb"]
View
@@ -47,4 +47,9 @@ dist: all
cd "$(DISTDIR)/.." && tar cJvf "`basename '$(DISTDIR)'`.tar.xz" "`basename '$(DISTDIR)'`"
rm -rf "$(DISTDIR)"
docker:
docker build -t snabb .
@ln -sf ../src/scripts/dock.sh src/snabb
@echo "Usage: docker run -ti --rm snabb <program> ..."
@echo "or simply call 'src/snabb <program> ...'"
.SERIAL: all
View
@@ -114,6 +114,27 @@ $ cp src/snabb /usr/local/bin/
$ sudo snabb packetblaster replay capture.pcap 01:00.0
```
### snabb container
Basic support for building and running snabb in a Docker container is available via
```
$ make docker
```
This will build a tiny snabb container (8MB), ready to be used:
```
$ docker run -ti --rm snabb --help
```
Or simply run snabb, as you would under linux. This is made possible by using a wrapper shell script that
gets linked to as part of 'make docker':
```
$ src/snabb --help
```
## How do I get involved?
Here are the ways you can get involved:
View
@@ -53,7 +53,7 @@ traffic will go to a single MAC address. If this address is provided
as part of the configuration, no ARP request will be made; otherwise
it will be determined from the *next_ip* via ARP.
— Key **self_ip**
— Key **next_ip**
*Optional*. The IPv4 address of the next-hop host. Required only if
*next_mac* is not specified as part of the configuration.
View
@@ -505,9 +505,9 @@ function pace_breathing ()
else
sleep = math.floor(sleep/2)
end
lastfrees = counter.read(frees)
lastfreebytes = counter.read(freebytes)
lastfreebits = counter.read(freebits)
lastfrees = tonumber(counter.read(frees))
lastfreebytes = tonumber(counter.read(freebytes))
lastfreebits = tonumber(counter.read(freebits))
end
end
View
@@ -225,23 +225,23 @@ end
-- Fork a child process that monitors us and performs cleanup actions
-- when we terminate.
local snabbpid = S.getpid()
local lockfile = os.tmpname()
local lock = S.open(lockfile, "wronly")
S.unlink(lockfile)
S.sigprocmask("block", "hup, int, quit, term")
lock:lockf("lock", 0)
if assert(S.fork()) ~= 0 then
-- parent process: run snabb
-- Parent process; run Snabb.
S.sigprocmask("unblock", "hup, int, quit, term")
xpcall(main, handler)
-- Lock will be released however the process exits.
else
-- child process: supervise parent & perform cleanup
-- Subscribe to SIGHUP on parent death
-- Child process: Supervise parent & perform cleanup. Lock not
-- inherited from parent.
S.prctl("set_name", "[snabb sup]")
S.prctl("set_pdeathsig", "hup")
-- Trap relevant signals to a file descriptor
local exit_signals = "hup, int, quit, term"
local signalfd = S.signalfd(exit_signals)
S.sigprocmask("block", exit_signals)
-- wait until we receive a signal
local signals
repeat signals = assert(S.util.signalfd_read(signalfd)) until #signals > 0
-- cleanup after parent process
-- Wait for parent to release lock.
lock:lockf("lock", 0)
-- Finally, clean up after parent process.
shutdown(snabbpid)
-- exit with signal-appropriate status
os.exit(128 + signals[1].signo)
os.exit(128)
end
View
@@ -11,15 +11,16 @@ Want to be a known developer? Sure! Just edit the [user account list](https://gi
## Servers
Name | Purpose | SSH | Xeon model | NICs
Name | Purpose | SSH | Intel CPU | NICs
------------|---------------------------------------------------|-------------------------| -------- | ------------------------------------------------
lugano-1 | General use | lugano-1.snabb.co | E3 1650v3 | 2 x 10G (82599), 4 x 10G (X710), 2 x 40G (XL710)
lugano-2 | General use | lugano-2.snabb.co | E3 1650v3 | 2 x 10G (82599), 4 x 10G (X710), 2 x 40G (XL710)
lugano-3 | General use | lugano-3.snabb.co | E3 1650v3 | 2 x 10G (82599), 2 x 100G (ConnectX-4)
lugano-4 | General use | lugano-4.snabb.co | E3 1650v3 | 2 x 10G (82599), 2 x 100G (ConnectX-4)
lugano-1 | General use | lugano-1.snabb.co | E5 1650v3 | 2 x 10G (82599), 4 x 10G (X710), 2 x 40G (XL710)
lugano-2 | General use | lugano-2.snabb.co | E5 1650v3 | 2 x 10G (82599), 4 x 10G (X710), 2 x 40G (XL710)
lugano-3 | General use | lugano-3.snabb.co | E5 1650v3 | 2 x 10G (82599), 2 x 100G (ConnectX-4)
lugano-4 | General use | lugano-4.snabb.co | E5 1650v3 | 2 x 10G (82599), 2 x 100G (ConnectX-4)
davos | Continuous Integration tests & driver development | lab1.snabb.co port 2000 | 2x E5 2603 | Diverse 10G/40G: Intel, SolarFlare, Mellanox, Chelsio, Broadcom. Installed upon request.
grindelwald | Snabb NFV testing | lab1.snabb.co port 2010 | 2x E5 2697v2 | 12 x 10G (Intel 82599)
interlaken | Haswell/AVX2 testing | lab1.snabb.co port 2030 | 2x E5 2620v3 | 12 x 10G (Intel 82599)
murren-* | Hydra fleet for tests without NICs | (none) | i7-6700 | (none)
## Get started
View
@@ -682,7 +682,8 @@ function selftest()
-- keep references to avoid GCing too early
local handle = {}
local function read(size)
local buf = ffi.new('uint8_t[?]', size, file:read(size))
local buf = ffi.new('uint8_t[?]', size)
ffi.copy(buf, file:read(size), size)
table.insert(handle, buf)
return buf
end
View
@@ -28,7 +28,7 @@ struct {
}
]]
function write_file_header(file)
function write_file_header (file)
local pcap_file = ffi.new(pcap_file_t)
pcap_file.magic_number = 0xa1b2c3d4
pcap_file.version_major = 2
@@ -52,16 +52,21 @@ function write_record_header (file, length)
file:write(ffi.string(pcap_record, ffi.sizeof(pcap_record)))
end
-- Return an iterator for pcap records in FILENAME.
function records (filename)
local file = io.open(filename, "r")
if file == nil then error("Unable to open file: " .. filename) end
function read_file_header (file)
local pcap_file = readc(file, pcap_file_t)
if pcap_file.magic_number == 0xD4C3B2A1 then
error("Endian mismatch in " .. filename)
elseif pcap_file.magic_number ~= 0xA1B2C3D4 then
error("Bad PCAP magic number in " .. filename)
end
return pcap_file
end
-- Return an iterator for pcap records in FILENAME.
function records (filename)
local file = io.open(filename, "r")
if file == nil then error("Unable to open file: " .. filename) end
read_file_header(file)
local function pcap_records_it (t, i)
local record = readc(file, pcap_record_t)
if record == nil then return nil end
Oops, something went wrong.

0 comments on commit 62c4cce

Please sign in to comment.