提交 71e4622e 编写于 作者: C coolsnowwolf

Revert "add luci-app-vpn-policy-routing for VPN client to splitte route"

This reverts commit b6f46d76.
上级 b6f46d76
# Copyright 2017-2018 Stan Grishin (stangri@melmac.net)
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.net>
LUCI_TITLE:=VPN Policy-Based Routing Service Web UI
LUCI_DESCRIPTION:=Provides Web UI for vpn-policy-routing service.
LUCI_DEPENDS:=+luci-mod-admin-full +vpn-policy-routing
LUCI_PKGARCH:=all
PKG_RELEASE:=32
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
module("luci.controller.vpn-policy-routing", package.seeall)
function index()
if nixio.fs.access("/etc/config/vpn-policy-routing") then
entry({"admin", "services", "vpn-policy-routing"}, cbi("vpn-policy-routing"), _("VPN Policy Routing"))
end
end
-- local readmeURL = "https://github.com/openwrt/packages/tree/master/net/vpn-policy-routing/files/README.md"
local readmeURL = "https://github.com/stangri/openwrt_packages/tree/master/vpn-policy-routing/files/README.md"
-- function log(obj)
-- if obj ~= nil then if type(obj) == "table" then luci.util.dumptable(obj) else luci.util.perror(obj) end else luci.util.perror("Empty object") end
-- end
local uci = require "luci.model.uci".cursor()
local sys = require "luci.sys"
local util = require "luci.util"
local ip = require "luci.ip"
local fs = require "nixio.fs"
local t = uci:get("vpn-policy-routing", "config", "supported_interface")
if not t then
supportedIfaces = ""
elseif type(t) == "table" then
for key,value in pairs(t) do supportedIfaces = supportedIfaces and supportedIfaces .. ' ' .. value or value end
elseif type(t) == "string" then
supportedIfaces = t
end
t = uci:get("vpn-policy-routing", "config", "ignored_interface")
if not t then
ignoredIfaces = ""
elseif type(t) == "table" then
for key,value in pairs(t) do ignoredIfaces = ignoredIfaces and ignoredIfaces .. ' ' .. value or value end
elseif type(t) == "string" then
ignoredIfaces = t
end
local lanIPAddr = uci:get("network", "lan", "ipaddr")
local lanNetmask = uci:get("network", "lan", "netmask")
if lanIPAddr and lanNetmask then
laPlaceholder = ip.new(lanIPAddr .. "/" .. lanNetmask )
end
function is_supported_interface(arg)
local name=arg['.name']
local proto=arg['proto']
local ifname=arg['ifname']
if name and supportedIfaces:find(name) then return true end
if name and not ignoredIfaces:find(name) then
if type(ifname) == "table" then
for key,value in pairs(ifname) do
if value and value:sub(1,3) == "tun" then return true end
if value and value:sub(1,3) == "tap" then return true end
if value and value:sub(1,3) == "tor" then return true end
if value and fs.access("/sys/devices/virtual/net/" .. value .. "/tun_flags") then return true end
end
elseif type(ifname) == "string" then
if ifname and ifname:sub(1,3) == "tun" then return true end
if ifname and ifname:sub(1,3) == "tap" then return true end
if ifname and ifname:sub(1,3) == "tor" then return true end
if ifname and fs.access("/sys/devices/virtual/net/" .. ifname .. "/tun_flags") then return true end
end
if proto and proto:sub(1,11) == "openconnect" then return true end
if proto and proto:sub(1,4) == "pptp" then return true end
if proto and proto:sub(1,4) == "l2tp" then return true end
if proto and proto:sub(1,9) == "wireguard" then return true end
end
end
c = Map("vpn-policy-routing", translate("Openconnect, OpenVPN, PPTP, Wireguard and WAN Policy-Based Routing"))
h = c:section(NamedSection, "config", "vpn-policy-routing", translate("Service Status"))
local packageName = "vpn-policy-routing"
local enabledFlag = uci:get(packageName, "config", "enabled")
local status = util.ubus('service', 'list', { name = packageName })
if status and status[packageName] and status[packageName]['instances'] and status[packageName]['instances']['status'] and status[packageName]['instances']['status']['data'] and status[packageName]['instances']['status']['data']['status'] then
status = status[packageName]['instances']['status']['data']['status']
else
local ipt_status = util.trim(sys.exec("iptables-save | grep -m1 'VPR_PREROUTING'"))
status = util.trim(sys.exec("/bin/ubus call service list \"{'name': 'vpn-policy-routing'}\" | /usr/bin/jsonfilter -l1 -e \"@['vpn-policy-routing']['instances']['status']['data']['status']\""))
if not status or status == "" then
if ipt_status and ipt_status ~= "" then
status = "Started without PROCD support"
else
status = "Stopped"
end
end
end
en = h:option(Button, "__toggle")
if enabledFlag ~= "1" or status:match("Stopped") then
en.title = translate("Service is disabled/stopped")
en.inputtitle = translate("Enable/Start")
en.inputstyle = "apply important"
else
en.title = translate("Service is enabled/started")
en.inputtitle = translate("Stop/Disable")
en.inputstyle = "reset important"
ds = h:option(DummyValue, "_dummy", translate("Service Status"))
ds.template = "vpn-policy-routing/status"
ds.value = status
if not status:match("Success") and not status:match("Started without PROCD support") then
reload = h:option(Button, "__reload")
reload.title = translate("Service started with error(s)")
reload.inputtitle = translate("Reload")
reload.inputstyle = "apply important"
function reload.write()
luci.sys.exec("/etc/init.d/vpn-policy-routing reload")
luci.http.redirect(luci.dispatcher.build_url("admin/services/" .. packageName))
end
end
end
function en.write()
enabledFlag = enabledFlag == "1" and "0" or "1"
uci:set(packageName, "config", "enabled", enabledFlag)
uci:save(packageName)
uci:commit(packageName)
if enabledFlag == "0" then
luci.sys.init.stop(packageName)
else
luci.sys.init.enable(packageName)
luci.sys.init.start(packageName)
end
luci.http.redirect(luci.dispatcher.build_url("admin/services/" .. packageName))
end
-- General options
s1 = c:section(NamedSection, "config", "vpn-policy-routing", translate("Configuration"))
s1.override_values = true
s1.override_depends = true
s1:tab("basic", translate("Basic Configuration"))
v = s1:taboption("basic", ListValue, "verbosity", translate("Output verbosity"),translate("Controls both system log and console output verbosity"))
v:value("0", translate("Suppress/No output"))
v:value("1", translate("Condensed output"))
v:value("2", translate("Verbose output"))
v.default = 2
se = s1:taboption("basic", ListValue, "strict_enforcement", translate("Strict enforcement"),translate("See the") .. " "
.. [[<a href="]] .. readmeURL .. [[#strict-enforcement" target="_blank">]]
.. translate("README") .. [[</a>]] .. " " .. translate("for details"))
se:value("0", translate("Do not enforce policies when their gateway is down"))
se:value("1", translate("Strictly enforce policies when their gateway is down"))
se.default = 1
dnsmasq = s1:taboption("basic", ListValue, "dnsmasq_enabled", translate("Use DNSMASQ for domain policies"),
translate("Please check the" .. " "
.. [[<a href="]] .. readmeURL .. [[#use-dnsmasq" target="_blank">]]
.. translate("README") .. [[</a>]] .. " " .. translate("before enabling this option.")))
dnsmasq:value("0", translate("Disabled"))
dnsmasq:value("1", translate("Enabled"))
ipset = s1:taboption("basic", ListValue, "ipset_enabled", translate("Use ipsets"),
translate("Please check the") .. " "
.. [[<a href="]] .. readmeURL .. [[#additional-settings" target="_blank">]]
.. translate("README") .. [[</a>]] .. " " .. translate("before changing this option."))
ipset:depends({dnsmasq_enabled="0"})
ipset:value("", translate("Disabled"))
ipset:value("1", translate("Enabled"))
ipv6 = s1:taboption("basic", ListValue, "ipv6_enabled", translate("IPv6 Support"))
ipv6:value("0", translate("Disabled"))
ipv6:value("1", translate("Enabled"))
s1:tab("advanced", translate("Advanced Configuration"),
"<br/>&nbsp;&nbsp;&nbsp;&nbsp;<b>" .. translate("WARNING:") .. "</b>" .. " " .. translate("Please make sure to check the") .. " "
.. [[<a href="]] .. readmeURL .. [[#additional-settings" target="_blank">]] .. translate("README") .. [[</a>]] .. " "
.. translate("before changing anything in this section! Change any of the settings below with extreme caution!") .. "<br/><br/>")
supported = s1:taboption("advanced", DynamicList, "supported_interface", translate("Supported Interfaces"), translate("Allows to specify the list of interface names (in lower case) to be explicitly supported by the service. Can be useful if your OpenVPN tunnels have dev option other than tun* or tap*."))
supported.optional = false
supported.rmempty = true
ignored = s1:taboption("advanced", DynamicList, "ignored_interface", translate("Ignored Interfaces"), translate("Allows to specify the list of interface names (in lower case) to be ignored by the service. Can be useful if running both VPN server and VPN client on the router."))
ignored.optional = false
ignored.rmempty = true
iprule = s1:taboption("advanced", ListValue, "iprule_enabled", translate("IP Rules Support"), translate("Add an ip rule, not an iptables entry for policies with just the local address. Use with caution to manipulte policies priorities."))
iprule:value("", translate("Disabled"))
iprule:value("1", translate("Enabled"))
iprule.rmempty = true
udp = s1:taboption("advanced", ListValue, "udp_proto_enabled", translate("UDP Protocol Support"), translate("Add UDP protocol iptables rules for protocol policies with unset local addresses and either local or remote port set. By default (unless this is enabled) only TCP protocol iptables rules are added."))
udp:value("", translate("Disabled"))
udp:value("1", translate("Enabled"))
udp.rmempty = true
forward = s1:taboption("advanced", ListValue, "forward_chain_enabled", translate("Create FORWARD Chain"), translate("Create and use a FORWARD chain in the mangle table."))
forward:value("", translate("Disabled"))
forward:value("1", translate("Enabled"))
forward.rmempty = true
input = s1:taboption("advanced", ListValue, "input_chain_enabled", translate("Create INPUT Chain"), translate("Create and use an INPUT chain in the mangle table."))
input:value("", translate("Disabled"))
input:value("1", translate("Enabled"))
input.rmempty = true
output = s1:taboption("advanced", ListValue, "output_chain_enabled", translate("Create OUTPUT Chain"), translate("Create and use an OUTPUT chain in the mangle table. Policies in the OUTPUT chain will affect traffic from the router itself. All policies with unset local address will be duplicated in the OUTPUT chain."))
output:value("", translate("Disabled"))
output:value("1", translate("Enabled"))
output.rmempty = true
icmp = s1:taboption("advanced", ListValue, "icmp_interface", translate("Default ICMP Interface"), translate("Force the ICMP protocol interface."))
icmp:depends({output_chain_enabled="1"})
icmp:value("", translate("No Change"))
icmp:value("wan", translate("WAN"))
uci:foreach("network", "interface", function(s)
local name=s['.name']
if is_supported_interface(s) then icmp:value(name, string.upper(name)) end
end)
icmp.rmempty = true
wantid = s1:taboption("advanced", Value, "wan_tid", translate("WAN Table ID"), translate("Starting (WAN) Table ID number for tables created by the service."))
wantid.rmempty = true
wantid.placeholder = "201"
wantid = s1:taboption("advanced", Value, "wan_mark", translate("WAN Table FW Mark"), translate("Starting (WAN) FW Mark for marks used by the service. High starting mark is used to avoid conflict with SQM/QoS. Change with caution together with") .. " " .. translate("Service FW Mask") .. ".")
wantid.rmempty = true
wantid.placeholder = "0x010000"
wantid = s1:taboption("advanced", Value, "fw_mask", translate("Service FW Mask"), translate("FW Mask used by the service. High mask is used to avoid conflict with SQM/QoS. Change with caution together with") .. " " .. translate("WAN Table FW Mark") .. ".")
wantid.rmempty = true
wantid.placeholder = "0xff0000"
-- Policies
p = Map("vpn-policy-routing")
p.template="cbi/map"
s3 = p:section(TypedSection, "policy", translate("Policies"), translate("Comment, interface and at least one other field are required. Multiple local and remote addresses/devices/domains and ports can be space separated. Placeholders below represent just the format/syntax and will not be used if fields are left blank."))
s3.template = "cbi/tblsection"
s3.sortable = true
s3.anonymous = true
s3.addremove = true
s3:option(Value, "comment", translate("Comment"))
la = s3:option(Value, "local_addresses", translate("Local addresses/devices"))
if laPlaceholder then
la.placeholder = laPlaceholder
end
la.rmempty = true
lp = s3:option(Value, "local_ports", translate("Local ports"))
lp.datatype = "list(neg(portrange))"
lp.placeholder = "0-65535"
lp.rmempty = true
ra = s3:option(Value, "remote_addresses", translate("Remote addresses/domains"))
ra.placeholder = "0.0.0.0/0"
ra.rmempty = true
rp = s3:option(Value, "remote_ports", translate("Remote ports"))
rp.datatype = "list(neg(portrange))"
rp.placeholder = "0-65535"
rp.rmempty = true
gw = s3:option(ListValue, "interface", translate("Interface"))
-- gw.datatype = "network"
gw.rmempty = false
gw.default = "wan"
gw:value("wan","WAN")
uci:foreach("network", "interface", function(s)
local name=s['.name']
if is_supported_interface(s) then gw:value(name, string.upper(name)) end
end)
dscp = Map("vpn-policy-routing")
s6 = dscp:section(NamedSection, "config", "vpn-policy-routing", translate("DSCP Tagging"), translate("Set DSCP tags (in range between 1 and 63) for specific interfaces."))
wan = s6:option(Value, "wan_dscp", translate("WAN DSCP Tag"))
wan.datatype = "range(1,63)"
wan.rmempty = true
uci:foreach("network", "interface", function(s)
local name=s['.name']
if is_supported_interface(s) then s6:option(Value, name .. "_dscp", string.upper(name) .. " " .. translate("DSCP Tag")).rmempty = true end
end)
return c, p, dscp
<%- if firstmap and messages then local msg; for _, msg in ipairs(messages) do -%>
<div class="errorbox"><%=pcdata(msg)%></div>
<%- end end -%>
<%-+cbi/apply_xhr-%>
<div class="cbi-map" id="cbi-<%=self.config%>">
<% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %>
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
<%- if firstmap and applymap then cbi_apply_xhr(self.config, parsechain, redirect) end -%>
<% if self.tabbed then %>
<ul class="cbi-tabmenu map" style="margin-bottom:-32px;">
<%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %>
<% for i, section in ipairs(self.children) do %>
<%- if not self.selected_tab then self.selected_tab = section.sectiontype end %>
<li id="tab.m-<%=self.config%>.<%=section.section or section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>">
<a onclick="this.blur(); return cbi_t_switch('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')" href="<%=REQUEST_URI%>?tab.m-<%=self.config%>=<%=section.section or section.sectiontype%>"><%=section.title or section.section or section.sectiontype %></a>
<% if section.sectiontype == self.selected_tab then %><input type="hidden" id="tab.m-<%=self.config%>" name="tab.m-<%=self.config%>" value="<%=section.section or section.sectiontype%>" /><% end %>
</li>
<% end %>
</ul>
<% for i, section in ipairs(self.children) do %>
<div class="cbi-tabcontainer" id="container.m-<%=self.config%>.<%=section.section or section.sectiontype%>"<% if section.sectiontype ~= self.selected_tab then %> style="display:none"<% end %>>
<% section:render() %>
</div>
<script type="text/javascript">cbi_t_add('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')</script>
<% end %>
<% if not self.save then -%>
<div class="cbi-section-error">
<% for _, section in ipairs(self.children) do %>
<% if section.error and section.error[section.section] then -%>
<ul><li>
<%:One or more invalid/required values on tab%>:&nbsp;<%=section.title or section.section or section.sectiontype%>
</li></ul>
<%- end %>
<% end %>
</div>
<%- end %>
<% else %>
<%- self:render_children() %>
<% end %>
<br />
</div>
<%#
Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
-%>
<%+cbi/valueheader%>
<input name="status" id="status" type="text" class="cbi-input-text" style="outline:none;border:none;box-shadow:none;background:transparent;font-weight:bold;line-height:30px;height:30px;width:50em;" value="<%=self:cfgvalue(section)%>" disabled="disabled" />
<%+cbi/valuefooter%>
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid ""
"Add UDP protocol iptables rules for protocol policies with unset local "
"addresses and either local or remote port set. By default (unless this is "
"enabled) only TCP protocol iptables rules are added."
msgstr ""
msgid ""
"Add an ip rule, not an iptables entry for policies with just the local "
"address. Use with caution to manipulte policies priorities."
msgstr ""
msgid "Advanced Configuration"
msgstr ""
msgid ""
"Allows to specify the list of interface names (in lower case) to be "
"explicitly supported by the service. Can be useful if your OpenVPN tunnels "
"have dev option other than tun* or tap*."
msgstr ""
msgid ""
"Allows to specify the list of interface names (in lower case) to be ignored "
"by the service. Can be useful if running both VPN server and VPN client on "
"the router."
msgstr ""
msgid "Basic Configuration"
msgstr ""
msgid "Comment"
msgstr ""
msgid ""
"Comment, interface and at least one other field are required. Multiple local "
"and remote addresses/devices/domains and ports can be space separated. "
"Placeholders below represent just the format/syntax and will not be used if "
"fields are left blank."
msgstr ""
msgid "Condensed output"
msgstr ""
msgid "Configuration"
msgstr ""
msgid "Controls both system log and console output verbosity"
msgstr ""
msgid "Create FORWARD Chain"
msgstr ""
msgid "Create INPUT Chain"
msgstr ""
msgid "Create OUTPUT Chain"
msgstr ""
msgid "Create and use a FORWARD chain in the mangle table."
msgstr ""
msgid "Create and use an INPUT chain in the mangle table."
msgstr ""
msgid ""
"Create and use an OUTPUT chain in the mangle table. Policies in the OUTPUT "
"chain will affect traffic from the router itself. All policies with unset "
"local address will be duplicated in the OUTPUT chain."
msgstr ""
msgid "DSCP Tag"
msgstr ""
msgid "DSCP Tagging"
msgstr ""
msgid "Default ICMP Interface"
msgstr ""
msgid "Disabled"
msgstr ""
msgid "Do not enforce policies when their gateway is down"
msgstr ""
msgid "Enable/Start"
msgstr ""
msgid "Enabled"
msgstr ""
msgid ""
"FW Mask used by the service. High mask is used to avoid conflict with SQM/"
"QoS. Change with caution together with"
msgstr ""
msgid "Force the ICMP protocol interface."
msgstr ""
msgid "IP Rules Support"
msgstr ""
msgid "IPv6 Support"
msgstr ""
msgid "Ignored Interfaces"
msgstr ""
msgid "Interface"
msgstr ""
msgid "Local addresses/devices"
msgstr ""
msgid "Local ports"
msgstr ""
msgid "No Change"
msgstr ""
msgid "One or more invalid/required values on tab"
msgstr ""
msgid "Openconnect, OpenVPN, PPTP, Wireguard and WAN Policy-Based Routing"
msgstr ""
msgid "Output verbosity"
msgstr ""
msgid "Please check the"
msgstr ""
msgid "Please make sure to check the"
msgstr ""
msgid "Policies"
msgstr ""
msgid "README"
msgstr ""
msgid "Remote addresses/domains"
msgstr ""
msgid "Remote ports"
msgstr ""
msgid "See the"
msgstr ""
msgid "Service FW Mask"
msgstr ""
msgid "Service is disabled/stopped"
msgstr ""
msgid "Service is enabled/started"
msgstr ""
msgid "Set DSCP tags (in range between 1 and 63) for specific interfaces."
msgstr ""
msgid ""
"Starting (WAN) FW Mark for marks used by the service. High starting mark is "
"used to avoid conflict with SQM/QoS. Change with caution together with"
msgstr ""
msgid "Starting (WAN) Table ID number for tables created by the service."
msgstr ""
msgid "Stop/Disable"
msgstr ""
msgid "Strict enforcement"
msgstr ""
msgid "Strictly enforce policies when their gateway is down"
msgstr ""
msgid "Supported Interfaces"
msgstr ""
msgid "Suppress/No output"
msgstr ""
msgid "UDP Protocol Support"
msgstr ""
msgid "Use DNSMASQ for domain policies"
msgstr ""
msgid "Use ipsets"
msgstr ""
msgid "VPN Policy Routing"
msgstr ""
msgid "Verbose output"
msgstr ""
msgid "WAN"
msgstr ""
msgid "WAN DSCP Tag"
msgstr ""
msgid "WAN Table FW Mark"
msgstr ""
msgid "WAN Table ID"
msgstr ""
msgid "WARNING:"
msgstr ""
msgid ""
"before changing anything in this section! Change any of the settings below "
"with extreme caution!"
msgstr ""
msgid "before changing this option."
msgstr ""
msgid "for details"
msgstr ""
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@vpn-policy-routing[-1]
add ucitrack vpn-policy-routing
set ucitrack.@vpn-policy-routing[-1].init=vpn-policy-routing
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
# Copyright 2017-2018 Stan Grishin (stangri@melmac.net)
# This is free software, licensed under the GNU General Public License v3.
include $(TOPDIR)/rules.mk
PKG_NAME:=vpn-policy-routing
PKG_VERSION:=0.0.2
PKG_RELEASE:=26
PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.net>
include $(INCLUDE_DIR)/package.mk
define Package/vpn-policy-routing
SECTION:=net
CATEGORY:=Network
DEPENDS:=+ipset +iptables +resolveip +kmod-ipt-ipset +!BUSYBOX_CONFIG_IP:ip-full
CONFLICTS:=vpnbypass
TITLE:=VPN Policy-Based Routing Service
PKGARCH:=all
endef
define Package/vpn-policy-routing/description
This service allows policy-based routing for L2TP, Openconnect, OpenVPN, PPTP and Wireguard tunnels and WAN interface.
Policies can specify domains, local IPs/subnets and ports, as well as remote IPs/subnets and ports.
endef
define Package/vpn-policy-routing/conffiles
/etc/config/vpn-policy-routing
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)/files/
$(CP) ./files/vpn-policy-routing.init $(PKG_BUILD_DIR)/files/vpn-policy-routing.init
sed -i "s|^\(PKG_VERSION\).*|\1='$(PKG_VERSION)-$(PKG_RELEASE)'|" $(PKG_BUILD_DIR)/files/vpn-policy-routing.init
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/vpn-policy-routing/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/vpn-policy-routing.init $(1)/etc/init.d/vpn-policy-routing
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/vpn-policy-routing.conf $(1)/etc/config/vpn-policy-routing
$(INSTALL_DIR) $(1)/etc/hotplug.d/firewall
$(INSTALL_DATA) ./files/vpn-policy-routing.firewall.hotplug $(1)/etc/hotplug.d/firewall/99-vpn-policy-routing
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DATA) ./files/vpn-policy-routing.iface.hotplug $(1)/etc/hotplug.d/iface/70-vpn-policy-routing
endef
define Package/vpn-policy-routing/postinst
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
/etc/init.d/vpn-policy-routing enable
if ! /bin/ubus -S call system board | /bin/grep 'Turris' | /bin/grep -q '15.05' ; then
rm -rf /etc/hotplug.d/iface/70-vpn-policy-routing
fi
while uci -q del ucitrack.@vpn-policy-routing[-1]; do :; done
uci -q del_list ucitrack.@firewall[0].affects='vpn-policy-routing' || true
uci -q batch <<-EOF >/dev/null
add ucitrack vpn-policy-routing
set ucitrack.@vpn-policy-routing[0].init='vpn-policy-routing'
add_list ucitrack.@firewall[0].affects='vpn-policy-routing'
commit ucitrack
EOF
fi
exit 0
endef
define Package/vpn-policy-routing/prerm
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
while uci -q delete ucitrack.@vpn-policy-routing[-1]; do :; done
uci -q del_list ucitrack.@firewall[0].affects='vpn-policy-routing' || true
echo "Stopping service and removing rc.d symlink for vpn-policy-routing"
/etc/init.d/vpn-policy-routing stop || true
/etc/init.d/vpn-policy-routing disable || true
fi
exit 0
endef
$(eval $(call BuildPackage,vpn-policy-routing))
# VPN Policy-Based Routing
## Description
This service allows you to define rules (policies) for routing traffic via WAN or your L2TP, Openconnect, OpenVPN, PPTP or Wireguard tunnels. Policies can be set based on any combination of local/remote ports, local/remote IPv4 or IPv6 addresses/subnets or domains. This service supersedes the [VPN Bypass](https://github.com/openwrt/packages/blob/master/net/vpnbypass/files/README.md) service, by supporting IPv6 and by allowing you to set explicit rules not just for WAN interface (bypassing OpenVPN tunnel), but for L2TP, Openconnect, OpenVPN, PPTP and Wireguard tunnels as well.
## Features
### Gateways/Tunnels
- Any policy can target either WAN or a VPN tunnel interface.
- L2TP tunnels supported (with protocol names l2tp\*).
- Openconnect tunnels supported (with protocol names openconnect\*).
- OpenVPN tunnels supported (with device names tun\* or tap\*).
- PPTP tunnels supported (with protocol names pptp\*).
- Wireguard tunnels supported (with protocol names wireguard\*).
### IPv4/IPv6/Port-Based Policies
- Policies based on local names, IPs or subnets. You can specify a single IP (as in ```192.168.1.70```) or a local subnet (as in ```192.168.1.81/29```) or a local device name (as in ```nexusplayer```). IPv6 addresses are also supported.
- Policies based on local ports numbers. Can be set as an individual port number (```32400```), a range (```5060-5061```), a space-separated list (```80 8080```) or a combination of the above (```80 8080 5060-5061```). Limited to 15 space-separated entries per policy.
- Policies based on remote IPs/subnets or domain names. Same format/syntax as local IPs/subnets.
- Policies based on remote ports numbers. Same format/syntax and restrictions as local ports.
- You can mix the IP addresses/subnets and device (or domain) names in one field separating them by space (like this: ```66.220.2.74 he.net tunnelbroker.net```).
### DSCP-tag Based Policies
You can also set policies for traffic with specific DSCP tag. On Windows 10, for example, you can mark traffic from specific apps with DSCP tags (instructions for tagging specific app traffic in Windows 10 can be found [here](http://serverfault.com/questions/769843/cannot-set-dscp-on-windows-10-pro-via-group-policy)).
### Strict enforcement
- Supports strict policy enforcement, even if the policy interface is down -- resulting in network being unreachable for specific policy (enabled by default).
### Use DNSMASQ
- Service can be set to utilize ```dnsmasq```'s ```ipset``` support. This requires the ```dnsmasq-full``` to be installed (see [How to install dnsmasq-full](#how-to-install-dnsmasq-full)) and it significantly improves the start up time because ```dnsmasq``` resolves the domain names and adds them to appropriate ```ipset``` in background. Another benefit of using ```dnsmasq```'s ```ipset``` is that it also automatically adds third-level domains to the ```ipset```: if ```domain.com``` is added to the policy, this policy will affect all ```*.domain.com``` subdomains. This also works for top-level domains as well, a policy targeting the ```at``` for example, will affect all the ```*.at``` domains.
### Customization
- Can be fully configured with ```uci``` commands or by editing ```/etc/config/vpn-policy-routing``` file.
- Has a companion package (```luci-app-vpn-policy-routing```) so policies can be configured with Web UI.
### Other Features
- Doesn't stay in memory, creates the routing tables and ```iptables``` rules/```ipset``` entries which are automatically updated when supported/monitored interface changes.
- Proudly made in Canada, using locally-sourced electrons.
## Screenshot (luci-app-vpn-policy-routing)
Basic Settings
![screenshot](https://raw.githubusercontent.com/stangri/openwrt_packages/master/screenshots/vpn-policy-routing/screenshot03-basic.png "screenshot")
Advanced Settings
![screenshot](https://raw.githubusercontent.com/stangri/openwrt_packages/master/screenshots/vpn-policy-routing/screenshot03-advanced.png "screenshot")
## How it works
On start, this service creates routing tables for each supported interface (WAN/WAN6 and VPN tunnels) which are used to route specially marked packets. Service adds new ```VPR_PREROUTING``` chain in the ```mangle``` table's ```PREROUTING``` chain (can be optionally set to create chains in the ```FORWARD```, ```INPUT``` and ```OUTPUT``` chains of ```mangle``` table, see [Additional settings](#additional-settings) for details). Evaluation and marking of packets happens in the ```VPR_PREROUTING``` (and if enabled, also in ```VPR_FORWARD```, ```VPR_INPUT``` and ```VPR_OUTPUT```) chains. If enabled, the service also creates the ```ipset``` per each supported interface and the corresponding ```iptables``` rule for marking packets matching the ```ipset```. The service then processes the user-created policies.
### Processing Policies
Each policy can result in either a new ```iptables``` rule or, if ```ipset``` or use of ```dnsmasq``` are enabled, an ```ipset``` or a ```dnsmasq```'s ```ipset``` entry.
- Policies with local IP addresses or local device names are always created as ```iptables``` rules.
- Policies with local or remote ports are always created as ```iptables``` rules.
- Policies with local or remote netmasks are always created as ```iptables``` rules.
- Policies with **only** remote IP address or a domain name are created as ```dnsmasq```'s ```ipset``` or an ```ipset``` (if enabled).
### Policies Priorities
- If support for ```dnsmasq```'s ```ipset``` and ```ipset``` is disabled, then only ```iptables``` rules are created. The policy priority is the same as its order as listed in Web UI and ```/etc/config/vpn-policy-routing```. The higher the policy is in the Web UI and configuration file, the higher its priority is.
- If support for ```dnsmasq```'s ```ipset``` and ```ipset``` is enabled, then the ```ipset``` entries have the highest priority (irrelevant of their position in the policies list) and the other policies are processed in the same order as they are listed in Web UI and ```/etc/config/vpn-policy-routing```.
- If there are conflicting ```ipset``` entries for different interfaces, the priority is given to the interface which is listed first in the ```/etc/config/network``` file.
- If set, the ```DSCP``` policies trump all other policies, including ```ipset``` ones.
## Requirements
This service requires the following packages to be installed on your router: ```ipset```, ```resolveip```, ```ip-full``` (or a ```busybox``` built with ```ip``` support), ```kmod-ipt-ipset``` and ```iptables```.
To satisfy the requirements, connect to your router via ssh and run the following commands:
```sh
opkg update; opkg install ipset resolveip ip-full kmod-ipt-ipset iptables
```
### How to install dnsmasq-full
If you want to use ```dnsmasq```'s ```ipset``` support, you will need to install ```dnsmasq-full``` instead of the ```dnsmasq```. To do that, connect to your router via ssh and run the following command:
```sh
opkg update; opkg remove dnsmasq; opkg install dnsmasq-full
```
### Unmet dependencies
If you are running a development (trunk/snapshot) build of OpenWrt/LEDE Project on your router and your build is outdated (meaning that packages of the same revision/commit hash are no longer available and when you try to satisfy the [requirements](#requirements) you get errors), please flash either current LEDE release image or current development/snapshot image.
## How to install
Please make sure that the [requirements](#requirements) are satisfied and install ```vpn-policy-routing``` and ```luci-app-vpn-policy-routing``` from Web UI or connect to your router via ssh and run the following commands:
```sh
opkg update
opkg install vpn-policy-routing luci-app-vpn-policy-routing
```
If these packages are not found in the official feed/repo for your version of OpenWrt/LEDE Project, you will need to [add a custom repo to your router](#add-custom-repo-to-your-router) first.
### Add custom repo to your router
If your router is not set up with the access to repository containing these packages you will need to add custom repository to your router by connecting to your router via ssh and running the following commands:
#### OpenWrt 15.05.1 Instructions
```sh
opkg update; opkg install ca-certificates wget libopenssl
echo -e -n 'untrusted comment: LEDE usign key of Stan Grishin\nRWR//HUXxMwMVnx7fESOKO7x8XoW4/dRidJPjt91hAAU2L59mYvHy0Fa\n' > /tmp/stangri-repo.pub && opkg-key add /tmp/stangri-repo.pub
! grep -q 'stangri_repo' /etc/opkg/customfeeds.conf && echo 'src/gz stangri_repo https://raw.githubusercontent.com/stangri/openwrt-repo/master' >> /etc/opkg/customfeeds.conf
opkg update
opkg install vpn-policy-routing luci-app-vpn-policy-routing
```
#### LEDE Project 17.01.x and OpenWrt 18.06.x Instructions
```sh
opkg update
opkg list-installed | grep -q uclient-fetch || opkg install uclient-fetch
opkg list-installed | grep -q libustream || opkg install libustream-mbedtls
echo -e -n 'untrusted comment: LEDE usign key of Stan Grishin\nRWR//HUXxMwMVnx7fESOKO7x8XoW4/dRidJPjt91hAAU2L59mYvHy0Fa\n' > /tmp/stangri-repo.pub && opkg-key add /tmp/stangri-repo.pub
! grep -q 'stangri_repo' /etc/opkg/customfeeds.conf && echo 'src/gz stangri_repo https://raw.githubusercontent.com/stangri/openwrt-repo/master' >> /etc/opkg/customfeeds.conf
opkg update
opkg install vpn-policy-routing luci-app-vpn-policy-routing
```
## Default Settings
Default configuration has service disabled (use Web UI to enable/start service or run ```uci set vpn-policy-routing.config.enabled=1; uci commit vpn-policy-routing;```).
## Additional settings
The ```vpn-policy-routing``` settings are split into ```basic``` and ```advanced``` settings. The full list of configuration parameters of ```vpn-policy-routing.config``` section is:
|Web UI Section|Parameter|Type|Default|Comment|
| --- | --- | --- | --- | --- |
|Basic|enabled|boolean|0|Enable/disable the ```vpn-policy-routing``` service.|
|Basic|verbosity|integer|2|Can be set to 0, 1 or 2 to control the console and system log output verbosity of the ```vpn-policy-routing``` service.|
|Basic|strict_enforcement|boolean|1|Enforce policies when their interface is down. See [Strict enforcement](#strict-enforcement) for more details.|
|Basic|dnsmasq_enabled|boolean|1|Enable/disable use of ```dnsmasq``` for ```ipset``` entries. See [Use DNSMASQ](#use-dnsmasq) for more details. Assumes ```ipset_enabled=1```. Make sure the [requirements](#requirements) are met.|
|Basic|ipset_enabled|boolean|1|Enable/disable use of ```ipset``` entries for compatible policies. This speeds up service start-up and operation. Make sure the [requirements](#requirements) are met. This setting is hidden in Web UI unless ```Use DNSMASQ for domain policies``` is disabled.|
|Basic|ipv6_enabled|boolean|1|Enable/disable IPv6 support.|
|Advanced|supported_interface|list/string||Allows to specify the list of interface names (in lower case) to be explicitly supported by the ```vpn-policy-routing``` service. Can be useful if your OpenVPN tunnels have dev option other than tun\* or tap\*.|
|Advanced|ignored_interface|list/string||Allows to specify the list of interface names (in lower case) to be ignored by the ```vpn-policy-routing``` service. Can be useful if running both VPN server and VPN client on the router.|
|Advanced|iprule_enabled|boolean|0|Add an ```ip rule```, not an ```iptables``` entry for policies with just the local address. Use with caution to manipulate policies priorities.|
|Advanced|udp_proto_enabled|boolean|0|Add ```UDP``` protocol ```iptables``` rules for protocol policies with unset local addresses and either local or remote port set. By default (unless this variable is set to 1) only ```TCP``` protocol iptables rules are added.|
|Advanced|forward_chain_enabled|boolean|0|Create and use a ```FORWARD``` chain in the mangle table. By default the ```vpn-policy-routing``` only creates and uses the ```PREROUTING``` chain. Use with caution.|
|Advanced|input_chain_enabled|boolean|0|Create and use an ```INPUT``` chain in the mangle table. By default the ```vpn-policy-routing``` only creates and uses the ```PREROUTING``` chain. Use with caution.|
|Advanced|output_chain_enabled|boolean|0|Create and use an ```OUTPUT``` chain in the mangle table. By default the ```vpn-policy-routing``` only creates and uses the ```PREROUTING``` chain. Policies in the ```OUTPUT``` chain will affect traffic from the router itself. All policies with unset local address will be duplicated in the ```OUTPUT``` chain. Use with caution.|
|Advanced|icmp_interface|string||Set the default ICMP protocol interface (interface name in lower case). Requires ```output_chain_enabled=1```. This setting is hidden in Web UI unless ```Create OUTPUT Chain``` is enabled. Use with caution.|
|Advanced|wan_tid|integer|201|Starting (WAN) Table ID number for tables created by the ```vpn-policy-routing``` service.|
|Advanced|wan_mark|hexadecimal|0x010000|Starting (WAN) fw mark for marks used by the ```vpn-policy-routing``` service. High starting mark is used to avoid conflict with SQM/QoS, this can be changed by user. Change with caution together with ```fw_mask```.|
|Advanced|fw_mask|hexadecimal|0xff0000|FW Mask used by the ```vpn-policy-routing``` service. High mask is used to avoid conflict with SQM/QoS, this can be changed by user. Change with caution together with ```wan_mark```.|
||wan_dscp|integer||Allows use of [DSCP-tag based policies](#dscp-tag-based-policies) for WAN interface.|
||{interface_name}_dscp|integer||Allows use of [DSCP-tag based policies](#dscp-tag-based-policies) for a VPN interface.|
### Example Policies
```text
config policy
option name 'Plex Local Server'
option interface 'wan'
option local_ports '32400'
config policy
option name 'Plex Remote Servers'
option interface 'wan'
option remote_addresses 'plex.tv my.plexapp.com'
config policy
option name 'LogmeIn Hamachi'
option interface 'wan'
option remote_addresses '25.0.0.0/8 hamachi.cc hamachi.com logmein.com'
config policy
option name 'Local Subnet'
option interface 'wan'
option local_addresses '192.168.1.81/29'
config policy
option name 'Local IP'
option interface 'wan'
option local_addresses '192.168.1.70'
```
### Multiple OpenVPN Clients
If you use multiple OpenVPN clients on your router, the order in which their devices are named (tun0, tun1, etc) is not guaranteed by OpenWrt/LEDE Project. The following settings are recommended in this case.
For ```/etc/config/network```:
```text
config interface 'vpnclient0'
option proto 'none'
option ifname 'ovpnc0'
config interface 'vpnclient1'
option proto 'none'
option ifname 'ovpnc1'
```
For ```/etc/config/openvpn```:
```text
config openvpn 'vpnclient0'
option client '1'
option dev_type 'tun'
option dev 'ovpnc0'
...
config openvpn 'vpnclient1'
option client '1'
option dev_type 'tun'
option dev 'ovpnc1'
...
```
For ```/etc/config/vpn-policy-routing```:
```text
config vpn-policy-routing 'config'
list supported_interface 'vpnclient0 vpnclient1'
...
```
## Discussion
Please head to [LEDE Project Forum](https://forum.lede-project.org/t/vpn-policy-based-routing-web-ui-discussion/10389) for discussions of this service.
## Getting help
If things are not working as intended, please include the following in your post:
- content of ```/etc/config/vpn-policy-routing```
- the output of ```/etc/init.d/vpn-policy-routing status```
- the output of ```/etc/init.d/vpn-policy-routing reload``` with verbosity setting set to 2
If you don't want to post the ```/etc/init.d/vpn-policy-routing status``` output in a public forum, there's a way to have the support details automatically uploaded to my account at paste.ee by running: ```/etc/init.d/vpn-policy-routing status -p```. You need to have the following packages installed to enable paste.ee upload functionality: ```curl libopenssl ca-bundle```. WARNING: while paste.ee uploads are unlisted, they are still publicly available.
## Notes/Known Issues
- While you can select some down/inactive VPN tunnel in Web UI, the appropriate tunnel must be up/active for the policies to properly work without errors on service start.
- If your ```OpenVPN``` interface has the device name different from tun\* or tap\*, please make sure that the tunnel is up before trying to assign it policies in Web UI.
- Service does not alter the default routing. Depending on your VPN tunnel settings (and settings of the VPN server you are connecting to), the default routing might be set to go via WAN or via VPN tunnel. This service affects only routing of the traffic matching the policies. If you want to override default routing, consider adding the following to your OpenVPN tunnel config:
```text
option route_nopull '1'
```
<!-- option route '0.0.0.0 0.0.0.0' -->
or set the following option for your Wireguard tunnel config:
```text
option route_allowed_ips '0'
```
## Thanks
I'd like to thank everyone who helped create, test and troubleshoot this service. Without contributions from [@hnyman](https://github.com/hnyman), [@dibdot](https://github.com/dibdot), [@danrl](https://github.com/danrl), [@tohojo](https://github.com/tohojo), [@cybrnook](https://github.com/cybrnook), [@nidstigator](https://github.com/nidstigator), [@AndreBL](https://github.com/AndreBL) and [@dz0ny](https://github.com/dz0ny) and rigorous testing by [@dziny](https://github.com/dziny), [@bluenote73](https://github.com/bluenote73), [@buckaroo](https://github.com/pgera) and [@Alexander-r](https://github.com/Alexander-r) it wouldn't have been possible. Wireguard support is courtesy of [Mullvad](https://www.mullvad.net).
config vpn-policy-routing 'config'
option enabled '0'
option verbosity '2'
option ipv6_enabled '0'
option ipset_enabled '1'
option dnsmasq_enabled '0'
option strict_enforcement '1'
#!/bin/sh
[ "$ACTION" = "reload" ] || exit 0
logger -t "vpn-policy-routing" "Reloading vpn-policy-routing due to $ACTION of firewall"
/etc/init.d/vpn-policy-routing reload
#!/bin/sh
if [ "$ACTION" != "ifup" ] && [ "$ACTION" != "ifupdate" ]; then exit 0; fi
logger -t vpn-policy-routing "Reloading vpn-policy-routing due to $ACTION of $INTERFACE ($DEVICE)"
/etc/init.d/vpn-policy-routing reload
#include "qcom-ipq8064-v2.0.dtsi"
#include <dt-bindings/input/input.h>
/ {
model = "NEC Aterm WG2600HP";
compatible = "nec,wg2600hp", "qcom,ipq8064";
memory@0 {
reg = <0x42000000 0x1e000000>;
device_type = "memory";
};
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;
rsvd@41200000 {
reg = <0x41200000 0x300000>;
no-map;
};
};
aliases {
serial0 = &gsbi4_serial;
mdio-gpio0 = &mdio0;
led-boot = &power_green;
led-failsafe = &power_green;
led-running = &power_green;
led-upgrade = &power_green;
};
chosen {
linux,stdout-path = "serial0:115200n8";
};
soc {
pinmux@800000 {
button_pins: button_pins {
mux {
pins = "gpio16", "gpio54", "gpio24", "gpio25";
function = "gpio";
drive-strength = <2>;
bias-pull-up;
};
};
i2c4_pins: i2c4_pinmux {
mux {
pins = "gpio12", "gpio13";
function = "gsbi4";
drive-strength = <12>;
bias-disable;
};
};
led_pins: led_pins {
mux {
pins = "gpio6", "gpio7", "gpio8", "gpio9", "gpio14",
"gpio15", "gpio55", "gpio56", "gpio57", "gpio58",
"gpio64", "gpio65";
function = "gpio";
drive-strength = <2>;
bias-pull-down;
};
};
spi_pins: spi_pins {
mux {
pins = "gpio18", "gpio19", "gpio21";
function = "gsbi5";
bias-pull-down;
};
data {
pins = "gpio18", "gpio19";
drive-strength = <10>;
};
cs {
pins = "gpio20";
drive-strength = <10>;
bias-pull-up;
};
clk {
pins = "gpio21";
drive-strength = <12>;
};
};
mdio0_pins: mdio0_pins {
mux {
pins = "gpio0", "gpio1";
function = "gpio";
drive-strength = <8>;
bias-disable;
};
};
rgmii2_pins: rgmii2_pins {
mux {
pins = "gpio27", "gpio28", "gpio29", "gpio30", "gpio31", "gpio32",
"gpio51", "gpio52", "gpio59", "gpio60", "gpio61", "gpio62" ;
function = "rgmii2";
drive-strength = <8>;
bias-disable;
};
};
usb_pwr_en_pins: usb_pwr_en_pins {
mux {
pins = "gpio22";
function = "gpio";
drive-strength = <2>;
bias-pull-down;
output-high;
};
};
};
gsbi@16300000 {
qcom,mode = <GSBI_PROT_I2C_UART>;
status = "ok";
serial@16340000 {
status = "ok";
};
/*
* The i2c device on gsbi4 should not be enabled.
* On ipq806x designs gsbi4 i2c is meant for exclusive
* RPM usage. Turning this on in kernel manifests as
* i2c failure for the RPM.
*/
};
gsbi5: gsbi@1a200000 {
qcom,mode = <GSBI_PROT_SPI>;
status = "ok";
spi4: spi@1a280000 {
status = "ok";
pinctrl-0 = <&spi_pins>;
pinctrl-names = "default";
cs-gpios = <&qcom_pinmux 20 GPIO_ACTIVE_HIGH>;
flash: m25p80@0 {
compatible = "jedec,spi-nor";
#address-cells = <1>;
#size-cells = <1>;
spi-max-frequency = <50000000>;
reg = <0>;
SBL1@0 {
label = "SBL1";
reg = <0x0 0x20000>;
read-only;
};
MIBIB@20000 {
label = "MIBIB";
reg = <0x20000 0x20000>;
read-only;
};
SBL2@40000 {
label = "SBL2";
reg = <0x40000 0x40000>;
read-only;
};
SBL3@80000 {
label = "SBL3";
reg = <0x80000 0x80000>;
read-only;
};
DDRCONFIG@100000 {
label = "DDRCONFIG";
reg = <0x100000 0x10000>;
read-only;
};
SSD@110000 {
label = "SSD";
reg = <0x110000 0x10000>;
read-only;
};
TZ@120000 {
label = "TZ";
reg = <0x120000 0x80000>;
read-only;
};
RPM@1a0000 {
label = "RPM";
reg = <0x1a0000 0x80000>;
read-only;
};
APPSBL@220000 {
label = "APPSBL";
reg = <0x220000 0x80000>;
read-only;
};
APPSBLENV@2a0000 {
label = "APPSBLENV";
reg = <0x2a0000 0x10000>;
};
PRODUCTDATA: PRODUCTDATA@2b0000 {
label = "PRODUCTDATA";
reg = <0x2b0000 0x30000>;
read-only;
};
ART@2e0000 {
label = "ART";
reg = <0x2e0000 0x40000>;
read-only;
};
TP@320000 {
label = "TP";
reg = <0x320000 0x40000>;
read-only;
};
TINY@360000 {
label = "TINY";
reg = <0x360000 0x500000>;
read-only;
};
firmware@860000 {
label = "firmware";
reg = <0x860000 0x17a0000>;
};
};
};
};
phy@100f8800 { /* USB3 port 1 HS phy */
status = "ok";
};
phy@100f8830 { /* USB3 port 1 SS phy */
status = "ok";
};
phy@110f8800 { /* USB3 port 0 HS phy */
status = "ok";
};
phy@110f8830 { /* USB3 port 0 SS phy */
status = "ok";
};
usb30@0 {
status = "ok";
pinctrl-0 = <&usb_pwr_en_pins>;
pinctrl-names = "default";
};
usb30@1 {
status = "ok";
};
pcie0: pci@1b500000 {
status = "ok";
reset-gpio = <&qcom_pinmux 3 GPIO_ACTIVE_HIGH>;
pinctrl-0 = <&pcie0_pins>;
pinctrl-names = "default";
};
pcie1: pci@1b700000 {
status = "ok";
reset-gpio = <&qcom_pinmux 48 GPIO_ACTIVE_HIGH>;
pinctrl-0 = <&pcie1_pins>;
pinctrl-names = "default";
force_gen1 = <1>;
};
mdio0: mdio {
compatible = "virtual,mdio-gpio";
#address-cells = <1>;
#size-cells = <0>;
gpios = <&qcom_pinmux 1 GPIO_ACTIVE_HIGH &qcom_pinmux 0 GPIO_ACTIVE_HIGH>;
pinctrl-0 = <&mdio0_pins>;
pinctrl-names = "default";
phy0: ethernet-phy@0 {
reg = <0>;
qca,ar8327-initvals = <
0x00004 0x7600000 /* PAD0_MODE */
0x00008 0x1000000 /* PAD5_MODE */
0x0000c 0x80 /* PAD6_MODE */
0x000e4 0x6a545 /* MAC_POWER_SEL */
0x000e0 0xc74164de /* SGMII_CTRL */
0x0007c 0x4e /* PORT0_STATUS */
0x00094 0x4e /* PORT6_STATUS */
>;
};
phy4: ethernet-phy@4 {
reg = <4>;
};
};
gmac1: ethernet@37200000 {
status = "ok";
phy-mode = "rgmii";
qcom,id = <1>;
pinctrl-0 = <&rgmii2_pins>;
pinctrl-names = "default";
mtd-mac-address = <&PRODUCTDATA 6>;
fixed-link {
speed = <1000>;
full-duplex;
};
};
gmac2: ethernet@37400000 {
status = "ok";
phy-mode = "sgmii";
qcom,id = <2>;
mtd-mac-address = <&PRODUCTDATA 0>;
fixed-link {
speed = <1000>;
full-duplex;
};
};
};
gpio-keys {
compatible = "gpio-keys";
pinctrl-0 = <&button_pins>;
pinctrl-names = "default";
wps {
label = "wps";
gpios = <&qcom_pinmux 16 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
reset {
label = "reset";
gpios = <&qcom_pinmux 54 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
bridge {
label = "bridge";
gpios = <&qcom_pinmux 24 GPIO_ACTIVE_LOW>;
linux,code = <BTN_0>;
linux,input-type = <EV_SW>;
};
converter {
label = "converter";
gpios = <&qcom_pinmux 25 GPIO_ACTIVE_LOW>;
linux,code = <BTN_0>;
linux,input-type = <EV_SW>;
};
};
gpio-leds {
compatible = "gpio-leds";
pinctrl-0 = <&led_pins>;
pinctrl-names = "default";
converter_green {
label = "wg2600hp:green:converter";
gpios = <&qcom_pinmux 6 GPIO_ACTIVE_HIGH>;
};
power_red {
label = "wg2600hp:red:power";
gpios = <&qcom_pinmux 7 GPIO_ACTIVE_HIGH>;
};
active_green {
label = "wg2600hp:green:active";
gpios = <&qcom_pinmux 8 GPIO_ACTIVE_HIGH>;
};
active_red {
label = "wg2600hp:red:active";
gpios = <&qcom_pinmux 9 GPIO_ACTIVE_HIGH>;
};
power_green: power_green {
label = "wg2600hp:green:power";
gpios = <&qcom_pinmux 14 GPIO_ACTIVE_HIGH>;
};
converter_red {
label = "wg2600hp:red:converter";
gpios = <&qcom_pinmux 15 GPIO_ACTIVE_HIGH>;
};
wlan2g_green {
label = "wg2600hp:green:wlan2g";
gpios = <&qcom_pinmux 55 GPIO_ACTIVE_HIGH>;
};
wlan2g_red {
label = "wg2600hp:red:wlan2g";
gpios = <&qcom_pinmux 56 GPIO_ACTIVE_HIGH>;
};
wlan5g_green {
label = "wg2600hp:green:wlan5g";
gpios = <&qcom_pinmux 57 GPIO_ACTIVE_HIGH>;
};
wlan5g_red {
label = "wg2600hp:red:wlan5g";
gpios = <&qcom_pinmux 58 GPIO_ACTIVE_HIGH>;
};
tv_green {
label = "wg2600hp:green:tv";
gpios = <&qcom_pinmux 64 GPIO_ACTIVE_HIGH>;
};
tv_red {
label = "wg2600hp:red:tv";
gpios = <&qcom_pinmux 65 GPIO_ACTIVE_HIGH>;
};
};
};
&adm_dma {
status = "ok";
};
......@@ -10,7 +10,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -618,6 +618,16 @@ dtb-$(CONFIG_ARCH_QCOM) += \
@@ -618,6 +618,15 @@ dtb-$(CONFIG_ARCH_QCOM) += \
qcom-apq8084-mtp.dtb \
qcom-ipq4019-ap.dk01.1-c1.dtb \
qcom-ipq8064-ap148.dtb \
......@@ -23,7 +23,6 @@ Signed-off-by: John Crispin <john@phrozen.org>
+ qcom-ipq8064-wpq864.dtb \
+ qcom-ipq8065-nbg6817.dtb \
+ qcom-ipq8065-r7800.dtb \
+ qcom-ipq8064-wg2600hp.dtb \
qcom-msm8660-surf.dtb \
qcom-msm8960-cdp.dtb \
qcom-msm8974-lge-nexus5-hammerhead.dtb \
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册