Skip to content

Commit

Permalink
Fix source IPv6 from B4, and better interleaving of streams
Browse files Browse the repository at this point in the history
  • Loading branch information
wingo committed Mar 8, 2019
1 parent b63f196 commit 1b74cf9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/program/packetblaster/lwaftr/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function B4Gen:new(conf)
lib.bitfield(32, ipv6_hdr, 'v_tc_fl', 4, 8, 1) -- Traffic class
ipv6_hdr.next_header = PROTO_IPV4_ENCAPSULATION
ipv6_hdr.hop_limit = DEFAULT_TTL
ipv6_hdr.src_ip = b4_ipv6
ipv6_hdr.dst_ip = aftr_ipv6

ipv4_hdr.src_ip = b4_ipv4
Expand Down Expand Up @@ -474,3 +475,22 @@ function InetGen:pull ()
end
end
end

Interleave = {}

function Interleave:new()
return setmetatable({}, {__index=Interleave})
end

function Interleave:push ()
local continue = true
while continue do
continue = false
for _, inport in ipairs(self.input) do
if not link.empty(inport) then
transmit(self.output.output, receive(inport))
continue = true
end
end
end
end
8 changes: 5 additions & 3 deletions src/program/packetblaster/lwaftr/lwaftr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local main = require("core.main")
local S = require("syscall")
local B4Gen = require("program.packetblaster.lwaftr.lib").B4Gen
local InetGen = require("program.packetblaster.lwaftr.lib").InetGen
local Interleave = require("program.packetblaster.lwaftr.lib").Interleave
local Tap = require("apps.tap.tap").Tap
local vlan = require("apps.vlan.vlan")
local arp = require("apps.ipv4.arp")
Expand Down Expand Up @@ -256,10 +257,11 @@ function run (args)

-- Split based on ethertype.
config.app(c, "mux", V4V6.V4V6, {})
v4_input, v4_output = finish_v4('mux.v4', 'mux.v4')
v6_input, v6_output = finish_v6('mux.v6', 'mux.v6')
config.app(c, "join", Interleave, {})
v4_input, v4_output = finish_v4('join.v4', 'mux.v4')
v6_input, v6_output = finish_v6('join.v6', 'mux.v6')
config.link(c, output .. " -> mux.input")
config.link(c, "mux.output -> " .. input)
config.link(c, "join.output -> " .. input)
end
end

Expand Down

0 comments on commit 1b74cf9

Please sign in to comment.