Skip to content
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

Merge max-next for v2018.02 #1311

Merged
merged 34 commits into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7d44865
[wip] use socker server mode
Nov 20, 2017
7fce594
undo previous wip
Nov 20, 2017
0a5a7e2
Merge branch 'master' of https://github.com/snabbco/snabb
mwiget Feb 2, 2018
73caaaf
Add DNS-SD program
dpino Dec 24, 2017
468e72c
Fix small mistake in arp documentation.
Feb 7, 2018
8ce8872
Add "snabb unhexdump" tool
wingo Feb 8, 2018
279aa38
core.app: remove garbage when using pace_breathing
alexandergall Feb 14, 2018
d10bda2
Merge tag 'v2018.01.1' into max-next
eugeneia Feb 16, 2018
e3a67d4
Merge PR #1287 (core.app: garbage in pace_breathing) into max-next
eugeneia Feb 16, 2018
b2232cf
Merge tag 'v2018.01.1' into documentation
eugeneia Feb 16, 2018
bb7e56c
Merge PR #1272 (Fix small mistake in arp docs) into documentation
eugeneia Feb 16, 2018
049b063
Merge branch 'documentation' into max-next
eugeneia Feb 16, 2018
35539ec
Correct/extend doc/snabblab.md
eugeneia Feb 6, 2018
3c9edf0
Show error if running on loop-back interface
dpino Feb 16, 2018
98c06a0
Merge PR #1271 (DNS-SD program) into max-next
eugeneia Feb 16, 2018
ff7ac84
Merge branch 'master' of https://github.com/snabbco/snabb into docker
mwiget Feb 18, 2018
c81176e
build snabb docker container
mwiget Feb 18, 2018
3337ae8
make clean before build to avoid using binaries built outside of docker
mwiget Feb 18, 2018
dff8877
adding container build and run instructions
mwiget Feb 18, 2018
ba390ec
src/snabb wrapper when building container snabb
mwiget Feb 22, 2018
3a4015c
document snabb wrapper script
mwiget Feb 22, 2018
b9ae0d7
adjust if statement to work in dash too
mwiget Mar 2, 2018
f8f1430
Merge branch 'master' into documentation
eugeneia Mar 9, 2018
da3a2f8
Make supervisor setup more reliable
wingo Mar 19, 2018
0736ffd
Fix out-of-bounds write in ctable test suite
wingo Mar 21, 2018
20573cc
Merge tag 'v2018.01.2' into max-next
eugeneia Mar 23, 2018
8ca6904
Merge branch 'documentation' into max-next
eugeneia Mar 23, 2018
4045897
Merge PR #1308 (Fix oob write in ctable test suite) into max-next
eugeneia Mar 23, 2018
729d161
Merge PR #1300 (Make supervisor setup more reliable) into max-next
eugeneia Mar 23, 2018
49e1aba
Merge PR #1274 (Add "snabb unhexdump" tool) into max-next
eugeneia Mar 23, 2018
a095968
merging launch-docker-container.sh with dock.sh
mwiget Mar 23, 2018
d806fe0
use separate docker run commands
mwiget Mar 24, 2018
b7f6ab2
run container privileged and build src
mwiget Mar 24, 2018
4679c9c
Merge PR #1289 (minimal alpine snabb docker image) into max-next
eugeneia Apr 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/apps/ipv4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 14 additions & 14 deletions src/core/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions src/doc/snabblab.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/lib/ctable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions src/lib/pcap/pcap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading