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

tunneldigger config change, bind to interface #606

Closed
pmelange opened this issue Oct 22, 2018 · 10 comments
Closed

tunneldigger config change, bind to interface #606

pmelange opened this issue Oct 22, 2018 · 10 comments

Comments

@pmelange
Copy link
Contributor

pmelange commented Oct 22, 2018

This applies to both ffuplink and bbbdigger.

If the node is not connect to wan, but meshes, tunneldigger will attept to build the tunnel though another the smart gw. This creates an undesired loopback. The solition is to add option bind_interface 'wan'.

Changing the option solves this problem But leads to another. Even though the wan interface is not up, tunneldigger tries to connect. This produces a lot of log entries.

I see two pssible solutions. [Edit, see below]

@pmelange
Copy link
Contributor Author

An issue arrises when router is not connected to a wan and only meshes. The wan is not connected to anything, yet tunneldigger tries to make a connection anyhow. There were 80 log entries in 10 seconds, which repeat five seconds later.

Mon Oct 22 01:04:52 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:52 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:52 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:52 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:52 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:52 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:52 2018 daemon.info td-client: Performing broker selection...
Mon Oct 22 01:04:53 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:53 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:53 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:53 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:53 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:53 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:53 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:53 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:53 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:53 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:53 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:53 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:53 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:53 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:53 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:53 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:53 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:53 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:56 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:56 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:56 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:56 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:56 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:56 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:56 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:56 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:56 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:56 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:56 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:56 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:56 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:56 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:56 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:56 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:56 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:56 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:58 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:58 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:58 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:58 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:58 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:58 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:58 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:58 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:58 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:58 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:58 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:58 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:58 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:58 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:58 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:04:59 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:04:59 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:04:59 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:05:01 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:05:01 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:05:01 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:05:01 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:05:01 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:05:01 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:05:01 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:05:01 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:05:01 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:05:01 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:05:01 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:05:01 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:05:01 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:05:01 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:05:01 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:05:02 2018 daemon.info td-client: Reinitializing tunnel context.
Mon Oct 22 01:05:02 2018 daemon.err td-client: Failed to bind to device!
Mon Oct 22 01:05:02 2018 daemon.err td-client: Unable to reinitialize the context!
Mon Oct 22 01:05:02 2018 daemon.err td-client: No suitable brokers found. Retrying in 5 seconds

I see two possible solutions.

  1. Change l2tp_client.c at line 434 to wait for a timeout when the bind fails and try again. And without it being an error. (this means we fork tunneldigger)
  2. Change the init to only start those which do not bind. Create a hotplug script to handle those which do bind.

I am willing to make the changes, but I want to know what the development group thinks before I go making changes.

pmelange added a commit to freifunk-berlin/firmware-packages that referenced this issue Oct 22, 2018
If the node is not connect to wan, but meshes, tunneldigger will attept to
build the tunnel though the smart gw. This creates an undesired loopback.
The solition is to add option bind_interface 'wan'

This issue is described in freifunk-berlin/firmware#606
@pmelange
Copy link
Contributor Author

There is an issue at wlanslovenija/tunneldigger#84

@booo
Copy link
Member

booo commented Oct 22, 2018

Please add a hotplug script that starts/stops the tunneldigger service. We did the same for openvpn.

@pmelange
Copy link
Contributor Author

OK. So now the question is, should we keep using and patching the gluon tunneldigger (it is just a Makefile, initscript, and sample config file). Or should we just make our own tunneldigger package.

The gluon script grabs the source code from wlanslovenia. We could do that just as easily.

Where would our version of tunneldigger go? in firmware-packages/utils, firmware-packages/addons or firmware-packages/defaults? Will the build env always take our tunneldigger package over the one from gluon? Or should we name it freifunk-berlin-tunneldigger to aviod any conflicts?

@booo
Copy link
Member

booo commented Oct 22, 2018

We can add the hotplug script to the defaults package for tunneldigger. It only has to trigger a start and stop. Why should we create/fork a new tunneldigger package?

@pmelange
Copy link
Contributor Author

I have a rewritten init script and a functioning hotplug script.

I'm still not sure how to package this into the firmware. Here are my ideas:

  1. Update the patch https://github.com/freifunk-berlin/firmware/blob/master/patches/101-tunneldigger_init.patch
  2. Create a package similar to how freifunk-gluon does it (basically a makefile which pulls the tunneldigger code, builds the client, then adds the specialized init and hotplug script)? https://github.com/freifunk-gluon/packages/blob/master/net/tunneldigger/Makefile
  3. Create a freifunk-berlin-tunneldigger-default package which contains only the init and hotplug files. (Will this properly overwrite the init script from gluon)?

All of these options do not force us to fork tunneldigger.

@booo
Copy link
Member

booo commented Oct 23, 2018

Can you upload your work somewhere and reference it here?

Why do you have to rewrite the init script?

The hotplug script can be part of this package https://github.com/freifunk-berlin/firmware-packages/tree/master/uplinks/freifunk-berlin-uplink-tunnelberlin-tunneldigger-files and this package https://github.com/freifunk-berlin/firmware-packages/tree/master/addons/freifunk-berlin-bbbdigger as far as I can tell.

@pmelange
Copy link
Contributor Author

The new init script is https://github.com/pmelange/Temporary-Files/blob/master/tunneldigger.init
The new hotplug script is https://github.com/pmelange/Temporary-Files/blob/master/tunneldigger.hotplug

The init script and the hotplug script are written to be independent of the tunnel (uplink-tunnelberlin-tunneldigger or bbbdigger or whatever).

The changes to the init script are:

  • do not start a tunnel if an interface is defined by the bind_interface option.
  • move the tunnel_id increment to the top of the handle_td function.

The hotplug script:

  • brings up a tunnel if the interface goes up and is defined by the bind_interface option
  • brings down a tunnel if the interface goes down and is defined by the bind_interface option

I would not add this to either uplink-tunnelberlin-tunneldigger or bbbdigger. These belong with the tunneldigger package.

pmelange added a commit that referenced this issue Oct 24, 2018
An issue arrises when a router is not connected to a wan and only meshes.
The wan is not connected to anything, yet tunneldigger tries to make a
connection anyhow.  To aviod this, the init script has been modified
to _not_ make tunnels when they are configured with the bind_interface
option.  Additionally, a hotplug script has been created to create
and destroy tunnels on demand as the interfaces go up and down.  The
hoplug script only works with tunnel configured with the bind_interface
option.

More info at #606
@pmelange
Copy link
Contributor Author

pmelange commented Nov 3, 2018

There is a new PR to handle this. #614

@pmelange
Copy link
Contributor Author

This seems to new be intergrated properly. closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants