Commit 4e006ac5 authored by Alessandro Rubini's avatar Alessandro Rubini

rvlan: add two diagnostic helps

The user can now send SIGUSR1 to get a snapshot of the current status,
and SIGUSR2 to force reauthentication of all ports (without getting
through stop/start).

Please note that during reauth we do not configure ports to the
auth_vlan network: they would just continue to live on their current
VLAN while the radius server is queried. For those ports where nothing
changed, no service interruption happens.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent ac632613
......@@ -17,6 +17,8 @@
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#define RVLAN_STATUS_FILE "/tmp/rvlan-status"
#ifdef __arm__ /* real wr switch */
# define IS_WRS 1
# include <libwr/config.h>
......@@ -37,6 +39,7 @@ int rvlan_change_pending; /* wrsw_vlans must be called globally */
char *rvlan_radius_servers; /* strdup from config */
char *rvlan_radius_secret;
int rvlan_auth_vlan, rvlan_noauth_vlan, rvlan_obey_dotconfig;
int rvlan_gotsignal;
struct rvlan_dev {
char *name; /* Allocated */
......@@ -628,6 +631,43 @@ void rvlan_reconfigure_vlans(void)
/* FIXME */
}
/* Save status for diagnostics, on SIGUSR1 */
void rvlan_dump_status(void)
{
struct rvlan_dev *dev;
if (verbose)
printf("Dumping status on request\n");
FILE *f = fopen(RVLAN_STATUS_FILE,"w");
if (!f)
return;
for (dev = devs; dev; dev = dev->next) {
char macstr[32];
sprintf(macstr, "%02x%02x%02x%02x%02x%02x",
dev->mac[0], dev->mac[1], dev->mac[2],
dev->mac[3], dev->mac[4], dev->mac[5]);
fprintf(f, "%s (%s <-> %s): state %s, vlan %i, pid %i, fd %i\n",
dev->name, macstr, dev->peer_mac,
fsm_names[dev->fsm_state],
dev->chosen_vlan, dev->pid, dev->poll_fd);
}
fclose(f);
}
/* Do it again, on SIGUSR2 */
void rvlan_reauth(void)
{
struct rvlan_dev *dev;
for (dev = devs; dev; dev = dev->next)
dev->fsm_state = RVLAN_JUSTUP;
}
void rvlan_sighandler(int signum)
{
rvlan_gotsignal = signum;
signal(signum, rvlan_sighandler);
}
/* And a main to keep it all together */
int main(int argc, char **argv)
{
......@@ -640,6 +680,9 @@ int main(int argc, char **argv)
setlinebuf(stdout);
signal(SIGUSR1, rvlan_sighandler);
signal(SIGUSR2, rvlan_sighandler);
if (getenv("RVLAN_DEV_PREFIX"))
rvlan_dev_prefix = getenv("RVLAN_DEV_PREFIX");
......@@ -734,5 +777,14 @@ int main(int argc, char **argv)
rvlan_poll_devices(sock);
if (rvlan_change_pending)
rvlan_reconfigure_vlans();
if (rvlan_gotsignal == SIGUSR1) {
rvlan_dump_status();
rvlan_gotsignal = 0;
}
if (rvlan_gotsignal == SIGUSR2) {
rvlan_reauth();
rvlan_gotsignal = 0;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment