Commit 41d06b13 authored by David S. Miller's avatar David S. Miller

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Included changes:
- sysfs removal postponement during interface un-registration
- random32() function renaming
- struct refactoring
- kernel doc improvement
- deleyed_work initialisation clean up work
- copyright year and internal version number update
- kernel doc improvement
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1ad759d8 5ac2a177
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2011-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
...@@ -123,7 +123,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv) ...@@ -123,7 +123,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
unsigned int msecs; unsigned int msecs;
msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER; msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
msecs += random32() % (2 * BATADV_JITTER); msecs += prandom_u32() % (2 * BATADV_JITTER);
return jiffies + msecs_to_jiffies(msecs); return jiffies + msecs_to_jiffies(msecs);
} }
...@@ -131,7 +131,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv) ...@@ -131,7 +131,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
/* when do we schedule a ogm packet to be sent */ /* when do we schedule a ogm packet to be sent */
static unsigned long batadv_iv_ogm_fwd_send_time(void) static unsigned long batadv_iv_ogm_fwd_send_time(void)
{ {
return jiffies + msecs_to_jiffies(random32() % (BATADV_JITTER / 2)); return jiffies + msecs_to_jiffies(prandom_u32() % (BATADV_JITTER / 2));
} }
/* apply hop penalty for a normal link */ /* apply hop penalty for a normal link */
......
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2006-2013 B.A.T.M.A.N. contributors:
* *
* Simon Wunderlich, Marek Lindner * Simon Wunderlich, Marek Lindner
* *
......
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2006-2013 B.A.T.M.A.N. contributors:
* *
* Simon Wunderlich, Marek Lindner * Simon Wunderlich, Marek Lindner
* *
......
This diff is collapsed.
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2011-2013 B.A.T.M.A.N. contributors:
* *
* Simon Wunderlich * Simon Wunderlich
* *
......
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2010-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
...@@ -40,13 +40,14 @@ static struct dentry *batadv_debugfs; ...@@ -40,13 +40,14 @@ static struct dentry *batadv_debugfs;
static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN; static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
static char *batadv_log_char_addr(struct batadv_debug_log *debug_log, static char *batadv_log_char_addr(struct batadv_priv_debug_log *debug_log,
size_t idx) size_t idx)
{ {
return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK]; return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK];
} }
static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c) static void batadv_emit_log_char(struct batadv_priv_debug_log *debug_log,
char c)
{ {
char *char_addr; char *char_addr;
...@@ -59,7 +60,7 @@ static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c) ...@@ -59,7 +60,7 @@ static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c)
} }
__printf(2, 3) __printf(2, 3)
static int batadv_fdebug_log(struct batadv_debug_log *debug_log, static int batadv_fdebug_log(struct batadv_priv_debug_log *debug_log,
const char *fmt, ...) const char *fmt, ...)
{ {
va_list args; va_list args;
...@@ -114,7 +115,7 @@ static int batadv_log_release(struct inode *inode, struct file *file) ...@@ -114,7 +115,7 @@ static int batadv_log_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
static int batadv_log_empty(struct batadv_debug_log *debug_log) static int batadv_log_empty(struct batadv_priv_debug_log *debug_log)
{ {
return !(debug_log->log_start - debug_log->log_end); return !(debug_log->log_start - debug_log->log_end);
} }
...@@ -123,7 +124,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, ...@@ -123,7 +124,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct batadv_priv *bat_priv = file->private_data; struct batadv_priv *bat_priv = file->private_data;
struct batadv_debug_log *debug_log = bat_priv->debug_log; struct batadv_priv_debug_log *debug_log = bat_priv->debug_log;
int error, i = 0; int error, i = 0;
char *char_addr; char *char_addr;
char c; char c;
...@@ -177,7 +178,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, ...@@ -177,7 +178,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
static unsigned int batadv_log_poll(struct file *file, poll_table *wait) static unsigned int batadv_log_poll(struct file *file, poll_table *wait)
{ {
struct batadv_priv *bat_priv = file->private_data; struct batadv_priv *bat_priv = file->private_data;
struct batadv_debug_log *debug_log = bat_priv->debug_log; struct batadv_priv_debug_log *debug_log = bat_priv->debug_log;
poll_wait(file, &debug_log->queue_wait, wait); poll_wait(file, &debug_log->queue_wait, wait);
......
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2010-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2011-2013 B.A.T.M.A.N. contributors:
* *
* Antonio Quartulli * Antonio Quartulli
* *
......
/* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2011-2013 B.A.T.M.A.N. contributors:
* *
* Antonio Quartulli * Antonio Quartulli
* *
......
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2009-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2009-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2009-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2009-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
...@@ -457,6 +457,24 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface) ...@@ -457,6 +457,24 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface)
batadv_hardif_free_ref(primary_if); batadv_hardif_free_ref(primary_if);
} }
/**
* batadv_hardif_remove_interface_finish - cleans up the remains of a hardif
* @work: work queue item
*
* Free the parts of the hard interface which can not be removed under
* rtnl lock (to prevent deadlock situations).
*/
static void batadv_hardif_remove_interface_finish(struct work_struct *work)
{
struct batadv_hard_iface *hard_iface;
hard_iface = container_of(work, struct batadv_hard_iface,
cleanup_work);
batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
batadv_hardif_free_ref(hard_iface);
}
static struct batadv_hard_iface * static struct batadv_hard_iface *
batadv_hardif_add_interface(struct net_device *net_dev) batadv_hardif_add_interface(struct net_device *net_dev)
{ {
...@@ -484,6 +502,9 @@ batadv_hardif_add_interface(struct net_device *net_dev) ...@@ -484,6 +502,9 @@ batadv_hardif_add_interface(struct net_device *net_dev)
hard_iface->soft_iface = NULL; hard_iface->soft_iface = NULL;
hard_iface->if_status = BATADV_IF_NOT_IN_USE; hard_iface->if_status = BATADV_IF_NOT_IN_USE;
INIT_LIST_HEAD(&hard_iface->list); INIT_LIST_HEAD(&hard_iface->list);
INIT_WORK(&hard_iface->cleanup_work,
batadv_hardif_remove_interface_finish);
/* extra reference for return */ /* extra reference for return */
atomic_set(&hard_iface->refcount, 2); atomic_set(&hard_iface->refcount, 2);
...@@ -518,8 +539,7 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) ...@@ -518,8 +539,7 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
return; return;
hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; hard_iface->if_status = BATADV_IF_TO_BE_REMOVED;
batadv_sysfs_del_hardif(&hard_iface->hardif_obj); queue_work(batadv_event_workqueue, &hard_iface->cleanup_work);
batadv_hardif_free_ref(hard_iface);
} }
void batadv_hardif_remove_interfaces(void) void batadv_hardif_remove_interfaces(void)
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
......
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2006-2013 B.A.T.M.A.N. contributors:
* *
* Simon Wunderlich, Marek Lindner * Simon Wunderlich, Marek Lindner
* *
......
/* Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2006-2013 B.A.T.M.A.N. contributors:
* *
* Simon Wunderlich, Marek Lindner * Simon Wunderlich, Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define BATADV_DRIVER_DEVICE "batman-adv" #define BATADV_DRIVER_DEVICE "batman-adv"
#ifndef BATADV_SOURCE_VERSION #ifndef BATADV_SOURCE_VERSION
#define BATADV_SOURCE_VERSION "2012.5.0" #define BATADV_SOURCE_VERSION "2013.1.0"
#endif #endif
/* B.A.T.M.A.N. parameters */ /* B.A.T.M.A.N. parameters */
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */ #define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */ #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */ #define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */
#define BATADV_TT_WORK_PERIOD 5000 /* 5 seconds */
#define BATADV_ORIG_WORK_PERIOD 1000 /* 1 second */
#define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */ #define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */
/* sliding packet range of received originator messages in sequence numbers /* sliding packet range of received originator messages in sequence numbers
* (should be a multiple of our word size) * (should be a multiple of our word size)
......
/* Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2009-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
...@@ -34,13 +34,6 @@ static struct lock_class_key batadv_orig_hash_lock_class_key; ...@@ -34,13 +34,6 @@ static struct lock_class_key batadv_orig_hash_lock_class_key;
static void batadv_purge_orig(struct work_struct *work); static void batadv_purge_orig(struct work_struct *work);
static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work, msecs_to_jiffies(1000));
}
/* returns 1 if they are the same originator */ /* returns 1 if they are the same originator */
static int batadv_compare_orig(const struct hlist_node *node, const void *data2) static int batadv_compare_orig(const struct hlist_node *node, const void *data2)
{ {
...@@ -63,7 +56,11 @@ int batadv_originator_init(struct batadv_priv *bat_priv) ...@@ -63,7 +56,11 @@ int batadv_originator_init(struct batadv_priv *bat_priv)
batadv_hash_set_lock_class(bat_priv->orig_hash, batadv_hash_set_lock_class(bat_priv->orig_hash,
&batadv_orig_hash_lock_class_key); &batadv_orig_hash_lock_class_key);
batadv_start_purge_timer(bat_priv); INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work,
msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD));
return 0; return 0;
err: err:
...@@ -396,7 +393,9 @@ static void batadv_purge_orig(struct work_struct *work) ...@@ -396,7 +393,9 @@ static void batadv_purge_orig(struct work_struct *work)
delayed_work = container_of(work, struct delayed_work, work); delayed_work = container_of(work, struct delayed_work, work);
bat_priv = container_of(delayed_work, struct batadv_priv, orig_work); bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);
_batadv_purge_orig(bat_priv); _batadv_purge_orig(bat_priv);
batadv_start_purge_timer(bat_priv); queue_delayed_work(batadv_event_workqueue,
&bat_priv->orig_work,
msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD));
} }
void batadv_purge_orig_ref(struct batadv_priv *bat_priv) void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
...@@ -155,8 +155,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, ...@@ -155,8 +155,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
spin_unlock_bh(&bat_priv->forw_bcast_list_lock); spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
/* start timer for this packet */ /* start timer for this packet */
INIT_DELAYED_WORK(&forw_packet->delayed_work,
batadv_send_outstanding_bcast_packet);
queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work, queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work,
send_time); send_time);
} }
...@@ -210,6 +208,9 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, ...@@ -210,6 +208,9 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
/* how often did we send the bcast packet ? */ /* how often did we send the bcast packet ? */
forw_packet->num_packets = 0; forw_packet->num_packets = 0;
INIT_DELAYED_WORK(&forw_packet->delayed_work,
batadv_send_outstanding_bcast_packet);
_batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay); _batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay);
return NETDEV_TX_OK; return NETDEV_TX_OK;
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich * Marek Lindner, Simon Wunderlich
* *
...@@ -449,6 +449,30 @@ static void batadv_interface_setup(struct net_device *dev) ...@@ -449,6 +449,30 @@ static void batadv_interface_setup(struct net_device *dev)
memset(priv, 0, sizeof(*priv)); memset(priv, 0, sizeof(*priv));
} }
/**
* batadv_softif_destroy_finish - cleans up the remains of a softif
* @work: work queue item
*
* Free the parts of the soft interface which can not be removed under
* rtnl lock (to prevent deadlock situations).
*/
static void batadv_softif_destroy_finish(struct work_struct *work)
{
struct batadv_priv *bat_priv;
struct net_device *soft_iface;
bat_priv = container_of(work, struct batadv_priv,
cleanup_work);
soft_iface = bat_priv->soft_iface;
batadv_debugfs_del_meshif(soft_iface);
batadv_sysfs_del_meshif(soft_iface);
rtnl_lock();
unregister_netdevice(soft_iface);
rtnl_unlock();
}
struct net_device *batadv_softif_create(const char *name) struct net_device *batadv_softif_create(const char *name)
{ {
struct net_device *soft_iface; struct net_device *soft_iface;
...@@ -463,6 +487,8 @@ struct net_device *batadv_softif_create(const char *name) ...@@ -463,6 +487,8 @@ struct net_device *batadv_softif_create(const char *name)
goto out; goto out;
bat_priv = netdev_priv(soft_iface); bat_priv = netdev_priv(soft_iface);
bat_priv->soft_iface = soft_iface;
INIT_WORK(&bat_priv->cleanup_work, batadv_softif_destroy_finish);
/* batadv_interface_stats() needs to be available as soon as /* batadv_interface_stats() needs to be available as soon as
* register_netdevice() has been called * register_netdevice() has been called
...@@ -551,10 +577,10 @@ struct net_device *batadv_softif_create(const char *name) ...@@ -551,10 +577,10 @@ struct net_device *batadv_softif_create(const char *name)
void batadv_softif_destroy(struct net_device *soft_iface) void batadv_softif_destroy(struct net_device *soft_iface)
{ {
batadv_debugfs_del_meshif(soft_iface); struct batadv_priv *bat_priv = netdev_priv(soft_iface);
batadv_sysfs_del_meshif(soft_iface);
batadv_mesh_free(soft_iface); batadv_mesh_free(soft_iface);
unregister_netdevice(soft_iface); queue_work(batadv_event_workqueue, &bat_priv->cleanup_work);
} }
int batadv_softif_is_valid(const struct net_device *net_dev) int batadv_softif_is_valid(const struct net_device *net_dev)
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2010-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2010-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner * Marek Lindner
* *
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich, Antonio Quartulli * Marek Lindner, Simon Wunderlich, Antonio Quartulli
* *
...@@ -52,13 +52,6 @@ static int batadv_compare_tt(const struct hlist_node *node, const void *data2) ...@@ -52,13 +52,6 @@ static int batadv_compare_tt(const struct hlist_node *node, const void *data2)
return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
} }
static void batadv_tt_start_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge);
queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
msecs_to_jiffies(5000));
}
static struct batadv_tt_common_entry * static struct batadv_tt_common_entry *
batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data) batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data)
{ {
...@@ -2136,7 +2129,9 @@ int batadv_tt_init(struct batadv_priv *bat_priv) ...@@ -2136,7 +2129,9 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
if (ret < 0) if (ret < 0)
return ret; return ret;
batadv_tt_start_timer(bat_priv); INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge);
queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
msecs_to_jiffies(BATADV_TT_WORK_PERIOD));
return 1; return 1;
} }
...@@ -2286,7 +2281,8 @@ static void batadv_tt_purge(struct work_struct *work) ...@@ -2286,7 +2281,8 @@ static void batadv_tt_purge(struct work_struct *work)
batadv_tt_req_purge(bat_priv); batadv_tt_req_purge(bat_priv);
batadv_tt_roam_purge(bat_priv); batadv_tt_roam_purge(bat_priv);
batadv_tt_start_timer(bat_priv); queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
msecs_to_jiffies(BATADV_TT_WORK_PERIOD));
} }
void batadv_tt_free(struct batadv_priv *bat_priv) void batadv_tt_free(struct batadv_priv *bat_priv)
......
/* Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
* *
* Marek Lindner, Simon Wunderlich, Antonio Quartulli * Marek Lindner, Simon Wunderlich, Antonio Quartulli
* *
......
This diff is collapsed.
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2010-2013 B.A.T.M.A.N. contributors:
* *
* Andreas Langer * Andreas Langer
* *
......
/* Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2010-2013 B.A.T.M.A.N. contributors:
* *
* Andreas Langer * Andreas Langer
* *
......
/* Copyright (C) 2008-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2008-2013 B.A.T.M.A.N. contributors:
* *
* Simon Wunderlich * Simon Wunderlich
* *
...@@ -31,14 +31,12 @@ ...@@ -31,14 +31,12 @@
/* hash class keys */ /* hash class keys */
static struct lock_class_key batadv_vis_hash_lock_class_key; static struct lock_class_key batadv_vis_hash_lock_class_key;
static void batadv_start_vis_timer(struct batadv_priv *bat_priv);
/* free the info */ /* free the info */
static void batadv_free_info(struct kref *ref) static void batadv_free_info(struct kref *ref)
{ {
struct batadv_vis_info *info; struct batadv_vis_info *info;
struct batadv_priv *bat_priv; struct batadv_priv *bat_priv;
struct batadv_recvlist_node *entry, *tmp; struct batadv_vis_recvlist_node *entry, *tmp;
info = container_of(ref, struct batadv_vis_info, refcount); info = container_of(ref, struct batadv_vis_info, refcount);
bat_priv = info->bat_priv; bat_priv = info->bat_priv;
...@@ -129,7 +127,7 @@ static void batadv_vis_data_insert_interface(const uint8_t *interface, ...@@ -129,7 +127,7 @@ static void batadv_vis_data_insert_interface(const uint8_t *interface,
struct hlist_head *if_list, struct hlist_head *if_list,
bool primary) bool primary)
{ {
struct batadv_if_list_entry *entry; struct batadv_vis_if_list_entry *entry;
struct hlist_node *pos; struct hlist_node *pos;
hlist_for_each_entry(entry, pos, if_list, list) { hlist_for_each_entry(entry, pos, if_list, list) {
...@@ -149,7 +147,7 @@ static void batadv_vis_data_insert_interface(const uint8_t *interface, ...@@ -149,7 +147,7 @@ static void batadv_vis_data_insert_interface(const uint8_t *interface,
static void batadv_vis_data_read_prim_sec(struct seq_file *seq, static void batadv_vis_data_read_prim_sec(struct seq_file *seq,
const struct hlist_head *if_list) const struct hlist_head *if_list)
{ {
struct batadv_if_list_entry *entry; struct batadv_vis_if_list_entry *entry;
struct hlist_node *pos; struct hlist_node *pos;
hlist_for_each_entry(entry, pos, if_list, list) { hlist_for_each_entry(entry, pos, if_list, list) {
...@@ -199,7 +197,7 @@ static void batadv_vis_data_read_entries(struct seq_file *seq, ...@@ -199,7 +197,7 @@ static void batadv_vis_data_read_entries(struct seq_file *seq,
struct batadv_vis_info_entry *entries) struct batadv_vis_info_entry *entries)
{ {
int i; int i;
struct batadv_if_list_entry *entry; struct batadv_vis_if_list_entry *entry;
struct hlist_node *pos; struct hlist_node *pos;
hlist_for_each_entry(entry, pos, list, list) { hlist_for_each_entry(entry, pos, list, list) {
...@@ -225,7 +223,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq, ...@@ -225,7 +223,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
struct batadv_vis_packet *packet; struct batadv_vis_packet *packet;
uint8_t *entries_pos; uint8_t *entries_pos;
struct batadv_vis_info_entry *entries; struct batadv_vis_info_entry *entries;
struct batadv_if_list_entry *entry; struct batadv_vis_if_list_entry *entry;
struct hlist_node *pos, *n; struct hlist_node *pos, *n;
HLIST_HEAD(vis_if_list); HLIST_HEAD(vis_if_list);
...@@ -307,7 +305,7 @@ static void batadv_send_list_del(struct batadv_vis_info *info) ...@@ -307,7 +305,7 @@ static void batadv_send_list_del(struct batadv_vis_info *info)
static void batadv_recv_list_add(struct batadv_priv *bat_priv, static void batadv_recv_list_add(struct batadv_priv *bat_priv,
struct list_head *recv_list, const char *mac) struct list_head *recv_list, const char *mac)
{ {
struct batadv_recvlist_node *entry; struct batadv_vis_recvlist_node *entry;
entry = kmalloc(sizeof(*entry), GFP_ATOMIC); entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) if (!entry)
...@@ -324,7 +322,7 @@ static int batadv_recv_list_is_in(struct batadv_priv *bat_priv, ...@@ -324,7 +322,7 @@ static int batadv_recv_list_is_in(struct batadv_priv *bat_priv,
const struct list_head *recv_list, const struct list_head *recv_list,
const char *mac) const char *mac)
{ {
const struct batadv_recvlist_node *entry; const struct batadv_vis_recvlist_node *entry;
spin_lock_bh(&bat_priv->vis.list_lock); spin_lock_bh(&bat_priv->vis.list_lock);
list_for_each_entry(entry, recv_list, list) { list_for_each_entry(entry, recv_list, list) {
...@@ -830,7 +828,9 @@ static void batadv_send_vis_packets(struct work_struct *work) ...@@ -830,7 +828,9 @@ static void batadv_send_vis_packets(struct work_struct *work)
kref_put(&info->refcount, batadv_free_info); kref_put(&info->refcount, batadv_free_info);
} }
spin_unlock_bh(&bat_priv->vis.hash_lock); spin_unlock_bh(&bat_priv->vis.hash_lock);
batadv_start_vis_timer(bat_priv);
queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
msecs_to_jiffies(BATADV_VIS_INTERVAL));
} }
/* init the vis server. this may only be called when if_list is already /* init the vis server. this may only be called when if_list is already
...@@ -900,7 +900,11 @@ int batadv_vis_init(struct batadv_priv *bat_priv) ...@@ -900,7 +900,11 @@ int batadv_vis_init(struct batadv_priv *bat_priv)
} }
spin_unlock_bh(&bat_priv->vis.hash_lock); spin_unlock_bh(&bat_priv->vis.hash_lock);
batadv_start_vis_timer(bat_priv);
INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets);
queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
msecs_to_jiffies(BATADV_VIS_INTERVAL));
return 0; return 0;
free_info: free_info:
...@@ -937,11 +941,3 @@ void batadv_vis_quit(struct batadv_priv *bat_priv) ...@@ -937,11 +941,3 @@ void batadv_vis_quit(struct batadv_priv *bat_priv)
bat_priv->vis.my_info = NULL; bat_priv->vis.my_info = NULL;
spin_unlock_bh(&bat_priv->vis.hash_lock); spin_unlock_bh(&bat_priv->vis.hash_lock);
} }
/* schedule packets for (re)transmission */
static void batadv_start_vis_timer(struct batadv_priv *bat_priv)
{
INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets);
queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
msecs_to_jiffies(BATADV_VIS_INTERVAL));
}
/* Copyright (C) 2008-2012 B.A.T.M.A.N. contributors: /* Copyright (C) 2008-2013 B.A.T.M.A.N. contributors:
* *
* Simon Wunderlich, Marek Lindner * Simon Wunderlich, Marek Lindner
* *
......
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