Skip to content

Commit

Permalink
lime-proto-bmx6: introduce bmx6_pref_gw option
Browse files Browse the repository at this point in the history
Can be used to add priority (x10) to a specific bmx6 Internet gateway

Signed-off-by: Pau Escrich <p4u@dabax.net>
  • Loading branch information
p4u committed Mar 28, 2017
1 parent c3fa1e1 commit 21080a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
28 changes: 25 additions & 3 deletions packages/lime-proto-bmx6/src/bmx6.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ function bmx6.configure(args)
uci:set(bmx6.f, "json", "plugin")
uci:set(bmx6.f, "json", "plugin", "bmx6_json.so")

-- Enable sms plugin
-- Enable sms plugin
uci:set(bmx6.f, "sms", "plugin")
uci:set(bmx6.f, "sms", "plugin", "bmx6_sms.so")


-- Enable tun plugin, DISCLAIMER: this must be positioned before table plugin if used.
-- uci:set(bmx6.f, "ptun", "plugin")
-- uci:set(bmx6.f, "ptun", "plugin", "bmx6_tun.so")
--uci:set(bmx6.f, "ptun", "plugin")
--uci:set(bmx6.f, "ptun", "plugin", "bmx6_tun.so")

-- Disable ThrowRules because they are broken in IPv6 with current Linux Kernel
uci:set(bmx6.f, "ipVersion", "ipVersion")
uci:set(bmx6.f, "ipVersion", "ipVersion", "6")


-- Search for networks in 172.16.0.0/12
uci:set(bmx6.f, "nodes", "tunOut")
uci:set(bmx6.f, "nodes", "tunOut", "nodes")
Expand Down Expand Up @@ -81,6 +82,27 @@ function bmx6.configure(args)
uci:set(bmx6.f, "publicv6", "network", "2000::/3")
uci:set(bmx6.f, "publicv6", "maxPrefixLen", "64")

-- Set prefered GW if defined
local pref_gw = config.get("network", "bmx6_pref_gw") or nil
if pref_gw then
uci:set(bmx6.f, "inet4p", "tunOut")
uci:set(bmx6.f, "inet4p", "tunOut", "inet4p")
uci:set(bmx6.f, "inet4p", "network", "0.0.0.0/0")
uci:set(bmx6.f, "inet4p", "maxPrefixLen", "0")
uci:set(bmx6.f, "inet4p", "gwName", pref_gw)
uci:set(bmx6.f, "inet4p", "rating", "1000")

uci:set(bmx6.f, "inet6p", "tunOut")
uci:set(bmx6.f, "inet6p", "tunOut", "inet6p")
uci:set(bmx6.f, "inet6p", "network", "::/0")
uci:set(bmx6.f, "inet6p", "maxPrefixLen", "0")
uci:set(bmx6.f, "inet6p", "gwName", pref_gw)
uci:set(bmx6.f, "inet6p", "rating", "1000")
else
uci:delete(bmx6.f, "inet4p", "tunOut")
uci:delete(bmx6.f, "inet6p", "tunOut")
end

if config.get_bool("network", "bmx6_over_batman") then
for _,protoArgs in pairs(config.get("network", "protocols")) do
if(utils.split(protoArgs, network.protoParamsSeparator)[1] == "batadv") then bmx6.setup_interface("bat0", args) end
Expand Down
1 change: 1 addition & 0 deletions packages/lime-system/files/etc/config/lime-example
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ config lime network
option main_ipv6_address '2a00:1508:0a%N1:%N200::/64' # Parametrizable in the same way as main_ipv4_address. If used, the IP autocompletion will fill maximum the last 24 bits, so specifying an IP autocompletion range bigger than /104 is not useful.
option anygw_mac 'aa:aa:aa:%N1:%N2:aa' # Parametrizable with %Nn. Keep in mind that the ebtables rule will use a mask of ff:ff:ff:00:00:00 so br-lan will not forward anything coming in that matches the first 3 bytes of it's own anygw_mac (aa:aa:aa: by default)
option bmx6_mtu '1398' # Set MTU for bmx6 tunnel interfaces
# option bmx6_pref_gw 'gw_hostname' # Force bmx6 to use a specific gateway to Internet (hostname must be used as identifier)
list protocols adhoc # List of protocols configured by LiMe, some of these require the relative package "lime-proto-...". Note that if you set here some protocols, you overwrite the *whole* list of protocols set in /etc/config/lime-defaults
list protocols lan
list protocols anygw
Expand Down

0 comments on commit 21080a5

Please sign in to comment.