Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Gluon tunneldigger/L2TP related packages #978

Closed
wants to merge 1 commit into from
Closed

Added Gluon tunneldigger/L2TP related packages #978

wants to merge 1 commit into from

Conversation

lcb01a
Copy link
Contributor

@lcb01a lcb01a commented Dec 12, 2016

Hi,

Recreated the PR as there were issues with empty commits.

To answer a previous question:
Tunneldigger is an alternative for Fastd without any encryption which uses Kernelspace L2TP and thus is way faster than Fastd.

gluon-config-mode-tunneldigger
gluon-mesh-vpn-tunneldigger
gluon-migrate-vpn
gluon-tunneldigger-watchdog

Cheers
Cyrus

Copy link
Member

@neocturne neocturne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a few issues, but they should be easy to fix.

local fastd_enabled = uci:get('fastd', 'mesh_vpn', 'enabled')

local tunneldigger_installed = util.exec('sh' , '-c', 'opkg list-installed | grep -e \'^tunneldigger\'')
local fastd_installed = util.exec('sh' , '-c', 'opkg list-installed | grep -e \'^fastd\'')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break on systems without opkg (for example the ar71xx-tiny target of the Gluon lede branch). I think testing for the existence of /usr/bin/fastd and /usr/bin/tunneldigger would be more robust.

uci:section('network', 'interface', 'mesh_vpn',
{
ifname = 'mesh-vpn',
proto = 'batadv',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outdated, see https://github.com/freifunk-gluon/gluon/blob/master/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd#L124 for the new mesh protocol agnostic configuration using proto gluon_mesh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also support setting the MTU of the underlying Interface manually?
e.g.:

uci:section('network', 'interface', 'mesh_vpn',
{
ifname = 'mesh-vpn',
proto = 'gluon_mesh',
transitive = 1,
fixed_mtu = 1,
mtu = site.tunneldigger_mesh_vpn.mtu,
}
)

We set the MTU when creating the initial interface configuration and not by using the daemon.
Otherwise we would either need a patch for gluon to support this or patch tunneldigger to set the MTU based on opkg settings.

proto = 'batadv',
mesh = 'bat0',
mesh_no_rebroadcast = 1,
mtu = site.tunneldigger_mesh_vpn.mtu,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the MAC address assigned for the tunneldigger interface?

As it can't be enabled at the same time as the fastd mesh VPN (as both use the interface name mesh-vpn), it could use the same MAC address, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L2TP uses random MAC adresses with each connection. The MAC can be changed manually but only with kernel version 3.18 and up as the support is missing in earlier kernel versions.

There is however a kernel patch which I didn't bother adding at the time:
https://www.mail-archive.com/openl2tp-users@lists.sourceforge.net/msg00060.html

#!/bin/sh
PIDFILE=/var/run/tunneldigger.mesh-vpn.pid

if [ "$(uci get tunneldigger.@broker[0].enabled)" == "1" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== is invalid in [] expressions (but accepted by many implementations, sometimes with a warning), this should be =.

if [ "$(pgrep tunneldigger | head -n 1)" != "$(cat $PIDFILE)" ]; then
/etc/init.d/tunneldigger restart
logger -t tunneldiger-watchdog "Daemon not running, restarted tunneldigger."
elif [ "$(batctl o |grep mesh-vpn |wc -l)" == "0" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite ugly, I wonder if we can find a nicer solution...


section = uci:add('tunneldigger', 'broker')

uci:section('tunneldigger', 'broker', section,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to use a static section name like mesh_vpn for the broker instead of referring to it using @broker[0], so this can't collide with other tunneldigger configurations (that is, if the tunneldigger init script can handle multiple instances, which I didn't check)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init script only supports one instance at the time, I guess we could add the support later on but at the time I didn't want to derive too far from the original package.

PIDFILE=/var/run/tunneldigger.mesh-vpn.pid

if [ "$(uci get tunneldigger.@broker[0].enabled)" == "1" ]; then
if [ "$(pgrep tunneldigger | head -n 1)" != "$(cat $PIDFILE)" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this could be pidof tunneldigger? Again, this should probably learn to cope with multiple instances (but this can be done later).

@@ -0,0 +1,61 @@
#!/usr/bin/lua
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Lua scripts should be moved from files to luasrc, and GluonSrcDiet (and luadest CP) calls be added to the corresponding Makefiles, as seen in most Gluon packages.

@lcb01a
Copy link
Contributor Author

lcb01a commented Dec 13, 2016

I commented on a few items, I will fix the rest of the issues as soon as possible.

@lcb01a
Copy link
Contributor Author

lcb01a commented Dec 13, 2016

I've updated the commit to address some of the issues.
I guess the most important issue left is regarding the new way to configure the interface.

@lcb01a lcb01a mentioned this pull request Dec 13, 2016
@rotanid rotanid added the 0. type: enhancement The changeset is an enhancement label Dec 13, 2016
@jplitza
Copy link
Member

jplitza commented Dec 14, 2016

I probably missed something, but why do we need a watchdog? Is Tunneldigger that unstable?

@lcb01a
Copy link
Contributor Author

lcb01a commented Jan 12, 2017

@jplitza
The watchdog is there just in case the daemon dies, its an optional package.

Regarding the remaing issues:

  • Ugly watchdog: I could remove the package for now and people who need this can still grab it from the ffrl / düsseldorf repositories
  • Use the mesh protocol agnostic "gluon_mesh" in uci network config: This is not possible at this moment as the gluon_mesh protocol does not support to set the MTU of the unterlying interface.
    e.g. setting mtu = "1360" is completely ignored, this should be added to the gluon_mesh protocol as tunneldigger is not responsible for the initial MTU configuration and we don't use the path MTU feature of tunneldigger (It doesn't work well with batman).

@corny
Copy link
Contributor

corny commented Jan 12, 2017

@lcb01a Just use procd, which is able to restart a died process.

@lcb01a
Copy link
Contributor Author

lcb01a commented Jan 13, 2017

@corny
Thanks for the suggestion, this looks promising :)

@lcb01a
Copy link
Contributor Author

lcb01a commented Feb 21, 2017

Hi,

The PR has been updated:

  • Removed tunneldigger-watchdog, this can still be included via repo if needed
  • gluon-mesh-von-tunneldigger now uses the gluon_mesh proto correctly

I guess this should address all issues that have emerged.

@neocturne neocturne added this to the 2017.1 milestone Feb 25, 2017
@lcb01a
Copy link
Contributor Author

lcb01a commented Feb 27, 2017

Hi, any update on this? :)

Copy link
Member

@neocturne neocturne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few things that need to be updated, and I'd really like to see that unnamed broker section go away. The rest looks good!

end
end

return M
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will need to be updated for gluon-web. Doing so should be straightforward, as it is very similar to the fastd-mesh-vpn one.


function M.section(form)
local msg = i18n.translate('Your internet connection can be used to establish a ' ..
'L2TP VPN connection with other nodes. ' ..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we want to explicitly mention "L2TP" here, as we're trying to avoid technical terms in the wizard. Unfortunately, I have no idea how to distinguish this from the fastd mesh VPN otherwise...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess everyone in the freifunk community knows it by the term L2TP so sticking with it for now should be the best way. We could also use the daemon name instead but I don't know if that is any more meaningful

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure whether there will be two vpn options or if it's even possible to build with both (fastd/l2tp)
if not, we gain nothing from mentioning the technical term L2TP (or fastd)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats true, but I rather not use the term "unencrypted" VPN since people falsely assume this means they are not safe from the receiving a law suit.
I can leave out the term completely and just call it VPN :)

SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Support for connecting batman-adv meshes via tunneltigger/l2tpv3 pseudowire
DEPENDS:=+gluon-core gluon-mesh-batman-adv +gluon-wan-dnsmasq +tunneldigger +iptables-mod-extra +simple-tc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove gluon-mesh-batman-adv from the depends, so the package is usable with Babel as well (as soon as we merge that).

if need_table('tunneldigger_mesh_vpn.bandwidth_limit', nil, false) then
need_boolean('tunneldigger_mesh_vpn.bandwidth_limit.enabled', false)
need_number('tunneldigger_mesh_vpn.bandwidth_limit.ingress', false)
need_number('tunneldigger_mesh_vpn.bandwidth_limit.egress', false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use tabs for indentation (in the other files as well).


section = uci:add('tunneldigger', 'broker')

uci:section('tunneldigger', 'broker', section,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to just explicitly name the section instead of using an anonymous section. You could just

uci:delete('tunneldigger', 'mesh_vpn')
uci:section('tunneldigger', 'broker', 'mesh_vpn', ...)

instead of deleting all broker sections. Instead of uci:get_first you could use uci:get_bool, like we to in other scripts.

For migration from an older configuration using an anonymous section, you could use:

if not uci:get('tunneldigger', 'mesh_vpn') then
	uci:delete_all('tunneldigger', 'broker')
end

)

uci:save('firewall')
uci:commit('firewall')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never commit UCI config in upgrade scripts, the last upgrade script will commit everything.

if not uci:get('simple-tc', 'mesh_vpn') then
local config = {
ifname = 'mesh-vpn',
enabled = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 0 and 1 can be changed to false and true as well with simple-uci.

local uci = require("simple-uci").cursor()


function file_exists(name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use nixio.fs.access as in the other files instead of defining your own function.

uci:set("fastd", "mesh_vpn", "enabled", enabled)
uci:save("fastd")
uci:commit("fastd")
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, you can change enabled to use booleans, and don't commit UCI here.

uci:save("fastd")
uci:commit("fastd")
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One empty line too much here.

@lcb01a
Copy link
Contributor Author

lcb01a commented Mar 1, 2017

Hi

The issues you mentioned have been adressed and verified by me. Only the terminology for the config mode isn't clear (Whether to use L2TP in the text or not).

Cheers

@neocturne
Copy link
Member

As we don't plan to support fastd and L2TP VPN in the same image (yet?), I think it's preferable to keep the texts the same and not to mention L2TP explcitly.

@lcb01a
Copy link
Contributor Author

lcb01a commented Mar 4, 2017

I removed the mentioning of L2TP from the config mode package and updated the commit :)

*gluon-config-mode-tunneldigger
*gluon-mesh-vpn-tunneldigger
*gluon-migrate-vpn
joerg-d pushed a commit to ffggrz/tunneldigger-packages that referenced this pull request Mar 7, 2017
@neocturne
Copy link
Member

Thanks, I've just merged your changes.

I ended up doing some refactoring to decrease duplication in the fastd and tunneldigger mesh VPN packages, and added the new site.conf options to the docs. I integerated the migrate-vpn script into a new gluon-mesh-vpn-core package and added support for tunneldigger to the existing gluon-config-mode-mesh-vpn package after adding your translation updates.

It would be great if you could check that I didn't break anything when refactoring.

@neocturne neocturne closed this Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. type: enhancement The changeset is an enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants