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

Improve handling of hosts coming back online #32

Closed
micolous opened this Issue May 12, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@micolous
Owner

micolous commented May 12, 2012

This was something I talked about with @kleinig on IRC, but it should really be a formal feature request.

The issue is that when a device comes back online, internet connectivity isn't immediate.

There are certain operating systems where this doesn't work, because they have a broken DHCP behaviour -- they will immediately try to use an old address on the network without renewing their lease, or will try to use an old address on the network that they have ended the lease and returned to the DHCP server. This tends to effect operating systems that have "instant" network access after resuming from sleep:

  • Apple iOS 4.1 and later
  • Google Android
  • Mac OS X 10.5.8 and earlier

Princeton University's Office of IT have quite detailed information about this misbehaviour:

I suspect that Windows 8 will introduce similar broken functionality.

Anyway, the basic implementation of this feature will be to have a script that ISC's DHCPd and dnsmasq can call to notify tollgate there is a new lease on the network. This will help speed up reconnection.

Likewise, the DHCP servers could also notify tollgate about DHCP lease expiries or releases by a similar mechanism.

This would probably be a management command in frontend.

@micolous

This comment has been minimized.

Owner

micolous commented May 28, 2012

dnsmasq supports calling a script whenever a host is added or removed from the DHCP lease table. This is done with the --dhcp-script option (or configuration setting). It supplies the script with three or four arguments:

  • "add" if a host is added, "del" if it is removed
  • The MAC address of the host (seperated by colons, eg: 11:22:33:44:55:66)
  • The IP address of the host
  • The hostname of the host, if known.

It also supplies a number of environment variables with extra information about the dnsmasq instance. Because this only supports calling a script, a wrapper will be needed to transfer this information to a management command, eg:

#!/bin/sh
/var/tollgate_site/manage.py dhcp_script $*

ISC dhcpd has "on commit" events which allow similar programs to be executed, however does not define a strict format.

This page describes how to run a script whenever there is a new lease: http://jpmens.net/2011/07/06/execute-a-script-when-isc-dhcp-hands-out-a-new-lease/

on commit {
    set clip = binary-to-ascii(10, 8, ".", leased-address);
    set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    execute("/var/tollgate_site/manage.py", "dhcp_script", "add", clhw, clip, host-decl-name);
}
on release {
    set clip = binary-to-ascii(10, 8, ".", leased-address);
    set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    execute("/var/tollgate_site/manage.py", "dhcp_script", "del", clhw, clip, host-decl-name);
}
on expiry {
    set clip = binary-to-ascii(10, 8, ".", leased-address);
    set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    execute("/var/tollgate_site/manage.py", "dhcp_script", "del", clhw, clip, host-decl-name);
}

(Note, those commands aren't actually implemented yet, they're just plans.)

Though given the concerns above I'm worried that triggering on expiry will break some devices.

But I'm of the opinion that it's a bug on their end, not mine. But that won't stop us copping the blame for it either.

@kleinig

This comment has been minimized.

Contributor

kleinig commented Jun 5, 2012

perhaps a quick fix would be, instead of "online computers and devices" it should be "all devices listed"

On the my devices and quota page

Switch on internet connectivity. If you have quota available, internet access will be granted to all of your online computers and devices.

@micolous

This comment has been minimized.

Owner

micolous commented Jun 7, 2012

No, this is something different.

Basically at the moment in order for a host to come back online, it needs to either go through one of the following two conditions:

  1. refresh_hosts has run. In a recommended configuration, this is every 10 minutes.
  2. refresh_networkhost_quick followed by sync_user_connections has run. The first part is run whenever anyone uses 'enable internet connectivity for this PC', logs another system in, or uses the 'login other computers' page. The second part is run whenever the user enables internet access, resets their quota, logs in or owns or disowns a host.

At the moment number 2 isn't happening often enough. refresh_networkhost_quick can be run very frequently, it's execution is very fast (much faster than refresh_hosts which does a manual ARP scan). I'm thinking it needs to run in more places. However, sync_user_connections is slow.

But the better way to handle this is to have the DHCP server notify when it's lease table has changed. This way it isn't run an excessive amount of times.

micolous added a commit that referenced this issue Jun 7, 2012

added example configuration for dnsmasq. implemented support for toll…
…gate to get notifications from dnsmasq about lease status changes (issue #32)
@micolous

This comment has been minimized.

Owner

micolous commented Jun 7, 2012

This is now in the system, and the Fedora configuration is updated. Also added example dnsmasq configuration. Some additional documentation is required about this functionality as part of the deployment instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment