Skip to content

Commit

Permalink
ignore invalid rlocs
Browse files Browse the repository at this point in the history
  • Loading branch information
capr committed Feb 1, 2016
1 parent 86300cf commit 10bc534
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/program/lisper/dev-env-docker/lisper04.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"control_sock" : "/root/lispers.net/lisp-ipc-map-cache",
"punt_sock" : "/root/lispers.net/lispers.net-itr",
//"punt_sock" : "lispers.net-itr",
"arp_timeout" : 60, // seconds

"interfaces": [
Expand Down
37 changes: 37 additions & 0 deletions src/program/lisper/dev-env-docker/watch_punt.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!snabb/src/snabb snsh
io.stdout:setvbuf'no'
io.stderr:setvbuf'no'

local function assert(v, ...)
if v then return v, ... end
error(tostring((...)), 2)
end

local ffi = require("ffi")
local S = require("syscall")
local _ = string.format

local file = "lispers.net-itr"

S.signal('pipe', 'ign') --I 💔 Linux

local sock = assert(S.socket("unix", "dgram, nonblock"))
S.unlink(file)
local sa = S.t.sockaddr_un(file)
assert(sock:bind(sa))

local bufsz = 10240
local buf = ffi.new('uint8_t[?]', bufsz)
while true do
if assert(S.select({readfds = {sock}}, 0)).count == 1 then
local len, err = S.read(sock, buf, bufsz)
if len then
if len > 0 then
print(ffi.string(buf, len))
end
else
print(err)
end
end
S.sleep(1/1000)
end
29 changes: 15 additions & 14 deletions src/program/lisper/lisper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,21 @@ local function update_fib(s)
local rloc = assert(t.rloc or t.rle)
local ip = parseip6(rloc)
local exit = lispers[ip]
assert(exit, "invalid rloc "..rloc)
local key = t.key and t.key ~= "" and parsehex(t.key)
local p = tonumber(t.priority)
local w = tonumber(t.weight)
local loc = {
type = "lisper",
ip = ip,
p = p,
w = w,
key = key,
exit = exit,
}
table.insert(rt, loc)
log_learn(iid, mac, loc)
if exit then
local key = t.key and t.key ~= "" and parsehex(t.key)
local p = tonumber(t.priority)
local w = tonumber(t.weight)
local loc = {
type = "lisper",
ip = ip,
p = p,
w = w,
key = key,
exit = exit,
}
table.insert(rt, loc)
log_learn(iid, mac, loc)
end
end
end
end
Expand Down

0 comments on commit 10bc534

Please sign in to comment.