Skip to content

Commit

Permalink
apps.tap: add forwarding option
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed May 19, 2022
1 parent ea636f4 commit 8a5d3e2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/apps/tap/tap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Tap._config = {
mtu_fixup = { default = true },
mtu_offset = { default = 14 },
mtu_set = { default = nil },
overwrite_src_mac = { default = false }
overwrite_src_mac = { default = false },
forwarding = { default = false }
}

-- Get or set the MTU of a tap device. Return the current value.
Expand Down Expand Up @@ -142,6 +143,13 @@ function Tap:new (conf)

local mac = _macaddr(sock, ifr)

if conf.forwarding then
local tap_sysctl_base = "net/ipv4/conf/"..conf.name
assert(S.sysctl(tap_sysctl_base.."/rp_filter", '0'))
assert(S.sysctl(tap_sysctl_base.."/accept_local", '1'))
assert(S.sysctl(tap_sysctl_base.."/forwarding", '1'))
end

return setmetatable({fd = fd,
sock = sock,
ifr = ifr,
Expand Down

0 comments on commit 8a5d3e2

Please sign in to comment.