[B.A.T.M.A.N.] batman-adv: Unable to add interface in LXC
by Pau Koning
I am running LXC (SID) under Debian SID and the current git version of
batman-adv (v3.7-rc7-1325-gaf5d4f7) +batctl (v2012.4.0-30-ga395164).
But it fails to add any of my interfaces and non-batman-adv interfaces
can be created without problems
# ip link
13: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP mode DEFAULT qlen 1000
link/ether 00:ff:aa:00:00:01 brd ff:ff:ff:ff:ff:ff
15: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
# batctl if add eth0
Error - can't open file '/sys/class/net/eth0/batman_adv/mesh_iface':
Read-only file system
# ls -l /sys/class/net/eth0/batman_adv/mesh_iface
-rw-r--r-- 1 root root 4096 Dec 30 18:26
/sys/class/net/eth0/batman_adv/mesh_iface
# id
uid=0(root) gid=0(root) groups=0(root)
# ip link add dev br0 type bridge
# ip link set dev eth0 master br0
# ip link
18: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
master br0 state UP mode DEFAULT qlen 1000
link/ether 00:ff:aa:00:00:01 brd ff:ff:ff:ff:ff:ff
20: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
21: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
link/ether 00:ff:aa:00:00:01 brd ff:ff:ff:ff:ff:ff
9 years, 5 months
[B.A.T.M.A.N.] Unterstanding gateway-mode - why does node have a "sticky" gateway
by Jan Lühr
Hello,
I started using batman-adv's gateway mode. Sadly, I ran into some trouble - A client is connected to two gateways via vpn (fastd):
# batctl gw_mode
client (selection class: 1)
# batctl gwl
Gateway (#/255) Nexthop [outgoingIF]: gw_class ... [B.A.T.M.A.N. adv 2012.4.0, MainIF/MAC: wlan0-1/f6:ec:38:e9:72:35 (bat0)]
6a:4b:93:de:00:84 (255) 6a:4b:93:de:00:84 [ mesh-vpn]: 207 - 48MBit/48MBit
=> aa:31:0e:4a:0f:1d (254) aa:31:0e:4a:0f:1d [ mesh-vpn]: 39 - 1024KBit/1024KBit
# batctl o
[B.A.T.M.A.N. adv 2012.4.0, MainIF/MAC: wlan0-1/f6:ec:38:e9:72:35 (bat0)]
Originator last-seen (#/255) Nexthop [outgoingIF]: Potential nexthops ...
aa:31:0e:4a:0f:1d 0.500s (255) aa:31:0e:4a:0f:1d [ mesh-vpn]: aa:31:0e:4a:0f:1d (255)
6a:4b:93:de:00:84 0.940s (255) 6a:4b:93:de:00:84 [ mesh-vpn]: 6a:4b:93:de:00:84 (255)
The client should use 6a:4b:93:de:00:84 as a gatway, since it provides much higher data rates - however, it is stuck at aa:31:0e:4a:0f:1d.
Why is that? How can I make the client choosing 6a:4b:93:de:00:84?
Thanks in advance,
Keep smiling
yanosz
9 years, 5 months
[B.A.T.M.A.N.] [PATCH] batman-adv: postpone sysfs removal when unregistering
by Simon Wunderlich
When processing the unregister notify for a hard interface, removing
the sysfs files may lead to a circular deadlock (rtnl mutex <->
s_active).
To overcome this problem, postpone the sysfs removal in a worker.
Reported-by: Sasha Levin <sasha.levin(a)oracle.com>
Reported-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
---
Changes from RFCv1:
* use work_struct properly, instead of delayed_work
* postpone for softifs as well as for hardifs
Postponing the sysfs removal for the hardif unregister is easier than
other alternatives involving deferring. This should bring us to the
same level to the bridge code, which also messes with sysfs in the
notifier processing function, and uses rtnl_trylock when called
from within sysfs.
As far as I could understand the net/core code, only the unregister
case is the critical one, so the original bug should hopefully be
fixed.
---
hard-interface.c | 16 ++++++++++++++--
soft-interface.c | 26 +++++++++++++++++++++++---
types.h | 3 +++
3 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/hard-interface.c b/hard-interface.c
index f1d37cd..eb3a12d 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -506,6 +506,17 @@ out:
return NULL;
}
+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 void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
{
ASSERT_RTNL();
@@ -518,8 +529,9 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
return;
hard_iface->if_status = BATADV_IF_TO_BE_REMOVED;
- batadv_sysfs_del_hardif(&hard_iface->hardif_obj);
- batadv_hardif_free_ref(hard_iface);
+ INIT_WORK(&hard_iface->cleanup_work,
+ batadv_hardif_remove_interface_finish);
+ queue_work(batadv_event_workqueue, &hard_iface->cleanup_work);
}
void batadv_hardif_remove_interfaces(void)
diff --git a/soft-interface.c b/soft-interface.c
index a8eb963..b8a307b 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -464,6 +464,7 @@ struct net_device *batadv_softif_create(const char *name)
goto out;
bat_priv = netdev_priv(soft_iface);
+ bat_priv->soft_iface = soft_iface;
/* batadv_interface_stats() needs to be available as soon as
* register_netdevice() has been called
@@ -550,12 +551,31 @@ out:
return NULL;
}
+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();
+}
+
void batadv_softif_destroy(struct net_device *soft_iface)
{
- batadv_debugfs_del_meshif(soft_iface);
- batadv_sysfs_del_meshif(soft_iface);
+ struct batadv_priv *bat_priv = netdev_priv(soft_iface);
+
batadv_mesh_free(soft_iface);
- unregister_netdevice(soft_iface);
+
+ INIT_WORK(&bat_priv->cleanup_work, batadv_softif_destroy_finish);
+ queue_work(batadv_event_workqueue, &bat_priv->cleanup_work);
}
int batadv_softif_is_valid(const struct net_device *net_dev)
diff --git a/types.h b/types.h
index d8061ac..a9800ee 100644
--- a/types.h
+++ b/types.h
@@ -63,6 +63,7 @@ struct batadv_hard_iface {
struct net_device *soft_iface;
struct rcu_head rcu;
struct batadv_hard_iface_bat_iv bat_iv;
+ struct work_struct cleanup_work;
};
/**
@@ -266,6 +267,7 @@ struct batadv_priv_dat {
struct batadv_priv {
atomic_t mesh_state;
+ struct net_device *soft_iface;
struct net_device_stats stats;
uint64_t __percpu *bat_counters; /* Per cpu counters */
atomic_t aggregated_ogms; /* boolean */
@@ -302,6 +304,7 @@ struct batadv_priv {
spinlock_t forw_bat_list_lock; /* protects forw_bat_list */
spinlock_t forw_bcast_list_lock; /* protects forw_bcast_list */
struct delayed_work orig_work;
+ struct work_struct cleanup_work;
struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */
struct batadv_algo_ops *bat_algo_ops;
#ifdef CONFIG_BATMAN_ADV_BLA
--
1.7.10.4
9 years, 5 months
[B.A.T.M.A.N.] [PATCHv3] batman-adv: postpone OGM preparation to sending time
by Antonio Quartulli
OGMs are currently prepared 1 originator interval in advance
then the time they are used to be sent. This means that once
in the air they carry old information (like TT announcements
and possibly other flags).
To fix this, postpone the OGM creation to the same time of
sending, in this way the OGM is first created and then
immediately sent.
This patch also removes a "magic" -2 operation that was
introduced in the past to address the fact that batman-adv
was sending "delayed OGM" plus the fact that the OGM seqno
was increased right after having sent a new packet. Since
this change is removing both the behaviours, the "magic"
operation is not needed anymore.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
v3:
* add more kernel doc
v2:
* added kernel doc
* fixed sending time computation: previously msecs were summed to jiffies and
max_aggregation_time was wrongly summed twice
bat_iv_ogm.c | 139 +++++++++++++++++++++++++++++++++++++----------------------
types.h | 1 +
2 files changed, 89 insertions(+), 51 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index ff56fd5..244751c 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -54,39 +54,6 @@ out:
return neigh_node;
}
-static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
-{
- struct batadv_ogm_packet *batadv_ogm_packet;
- unsigned char *ogm_buff;
- uint32_t random_seqno;
- int res = -ENOMEM;
-
- /* randomize initial seqno to avoid collision */
- get_random_bytes(&random_seqno, sizeof(random_seqno));
- atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
-
- hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
- ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
- if (!ogm_buff)
- goto out;
-
- hard_iface->bat_iv.ogm_buff = ogm_buff;
-
- batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
- batadv_ogm_packet->header.packet_type = BATADV_IV_OGM;
- batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION;
- batadv_ogm_packet->header.ttl = 2;
- batadv_ogm_packet->flags = BATADV_NO_FLAGS;
- batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
- batadv_ogm_packet->tt_num_changes = 0;
- batadv_ogm_packet->ttvn = 0;
-
- res = 0;
-
-out:
- return res;
-}
-
static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface)
{
kfree(hard_iface->bat_iv.ogm_buff);
@@ -116,16 +83,22 @@ batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
batadv_ogm_packet->header.ttl = BATADV_TTL;
}
-/* when do we schedule our own ogm to be sent */
+/**
+ * batadv_iv_ogm_emit_wait_time - compute the OGM preparation waiting time
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Returns the amount of jiffies to wait before preparing and sending the next
+ * own OGM
+ */
static unsigned long
-batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
+batadv_iv_ogm_emit_wait_time(const struct batadv_priv *bat_priv)
{
unsigned int msecs;
msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
msecs += (random32() % 2 * BATADV_JITTER);
- return jiffies + msecs_to_jiffies(msecs);
+ return msecs_to_jiffies(msecs);
}
/* when do we schedule a ogm packet to be sent */
@@ -459,7 +432,8 @@ out:
/* aggregate a new packet into the existing ogm packet */
static void batadv_iv_ogm_aggregate(struct batadv_forw_packet *forw_packet_aggr,
const unsigned char *packet_buff,
- int packet_len, bool direct_link)
+ int packet_len, bool direct_link,
+ int own_packet)
{
unsigned char *skb_buff;
unsigned long new_direct_link_flag;
@@ -468,6 +442,7 @@ static void batadv_iv_ogm_aggregate(struct batadv_forw_packet *forw_packet_aggr,
memcpy(skb_buff, packet_buff, packet_len);
forw_packet_aggr->packet_len += packet_len;
forw_packet_aggr->num_packets++;
+ forw_packet_aggr->own |= own_packet;
/* save packet direct link flag status */
if (direct_link) {
@@ -498,8 +473,7 @@ static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,
/* find position for the packet in the forward queue */
spin_lock_bh(&bat_priv->forw_bat_list_lock);
- /* own packets are not to be aggregated */
- if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
+ if ((atomic_read(&bat_priv->aggregated_ogms))) {
hlist_for_each_entry(forw_packet_pos, tmp_node,
&bat_priv->forw_bat_list, list) {
if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet,
@@ -532,7 +506,7 @@ static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,
if_incoming, own_packet);
} else {
batadv_iv_ogm_aggregate(forw_packet_aggr, packet_buff,
- packet_len, direct_link);
+ packet_len, direct_link, own_packet);
spin_unlock_bh(&bat_priv->forw_bat_list_lock);
}
}
@@ -593,14 +567,39 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
{
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
- unsigned char **ogm_buff = &hard_iface->bat_iv.ogm_buff;
+
+ queue_delayed_work(batadv_event_workqueue, &hard_iface->bat_iv.work,
+ batadv_iv_ogm_emit_wait_time(bat_priv));
+}
+
+/**
+ * batadv_iv_ogm_send - prepare an send an own OGM
+ * @work: kernel work struct
+ *
+ * Prepare the OGM and immediately enqueue it for sending
+ */
+static void batadv_iv_ogm_send(struct work_struct *work)
+{
+ struct delayed_work *delayed_work;
+ struct batadv_hard_iface_bat_iv *bat_iv;
+ struct batadv_hard_iface *primary_if, *hard_iface;
+ struct batadv_priv *bat_priv;
+ unsigned char **ogm_buff;
struct batadv_ogm_packet *batadv_ogm_packet;
- struct batadv_hard_iface *primary_if;
- int *ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len;
+ int *ogm_buff_len;
int vis_server, tt_num_changes = 0;
uint32_t seqno;
uint8_t bandwidth;
+ delayed_work = container_of(work, struct delayed_work, work);
+ bat_iv = container_of(delayed_work, struct batadv_hard_iface_bat_iv,
+ work);
+ hard_iface = container_of(bat_iv, struct batadv_hard_iface, bat_iv);
+
+ bat_priv = netdev_priv(hard_iface->soft_iface);
+ ogm_buff = &hard_iface->bat_iv.ogm_buff;
+ ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len;
+
vis_server = atomic_read(&bat_priv->vis_mode);
primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -611,10 +610,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
+ seqno = (uint32_t)atomic_add_return(1, &hard_iface->bat_iv.ogm_seqno);
/* change sequence number to network order */
- seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
batadv_ogm_packet->seqno = htonl(seqno);
- atomic_inc(&hard_iface->bat_iv.ogm_seqno);
batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
@@ -637,12 +635,55 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
batadv_slide_own_bcast_window(hard_iface);
batadv_iv_ogm_queue_add(bat_priv, hard_iface->bat_iv.ogm_buff,
hard_iface->bat_iv.ogm_buff_len, hard_iface, 1,
- batadv_iv_ogm_emit_send_time(bat_priv));
+ batadv_iv_ogm_fwd_send_time());
if (primary_if)
batadv_hardif_free_ref(primary_if);
}
+/**
+ * batadv_iv_ogm_iface_enable - initialize protocol specific hard_iface members
+ * @hard_iface: the interface getting enabled
+ *
+ * Returns 0 on success and a negative value representing the error in case of
+ * failure
+ *
+ */
+static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
+{
+ struct batadv_ogm_packet *batadv_ogm_packet;
+ unsigned char *ogm_buff;
+ uint32_t random_seqno;
+ int res = -ENOMEM;
+
+ /* randomize initial seqno to avoid collision */
+ get_random_bytes(&random_seqno, sizeof(random_seqno));
+ atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
+
+ hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
+ ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
+ if (!ogm_buff)
+ goto out;
+
+ hard_iface->bat_iv.ogm_buff = ogm_buff;
+
+ batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
+ batadv_ogm_packet->header.packet_type = BATADV_IV_OGM;
+ batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION;
+ batadv_ogm_packet->header.ttl = 2;
+ batadv_ogm_packet->flags = BATADV_NO_FLAGS;
+ batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
+ batadv_ogm_packet->tt_num_changes = 0;
+ batadv_ogm_packet->ttvn = 0;
+
+ INIT_DELAYED_WORK(&hard_iface->bat_iv.work, batadv_iv_ogm_send);
+
+ res = 0;
+
+out:
+ return res;
+}
+
static void
batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
@@ -998,7 +1039,6 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
bool is_single_hop_neigh = false;
bool is_from_best_next_hop = false;
int is_duplicate, sameseq, simlar_ttl;
- uint32_t if_incoming_seqno;
uint8_t *prev_sender;
/* Silently drop when the batman packet is actually not a
@@ -1016,9 +1056,6 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
if (batadv_ogm_packet->header.packet_type != BATADV_IV_OGM)
return;
- /* could be changed by schedule_own_packet() */
- if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
-
if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
has_directlink_flag = 1;
else
@@ -1108,7 +1145,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
spin_lock_bh(&orig_neigh_node->ogm_cnt_lock);
word = &(orig_neigh_node->bcast_own[offset]);
- bit_pos = if_incoming_seqno - 2;
+ bit_pos = atomic_read(&if_incoming->bat_iv.ogm_seqno);
bit_pos -= ntohl(batadv_ogm_packet->seqno);
batadv_set_bit(word, bit_pos);
weight = &orig_neigh_node->bcast_own_sum[if_num];
diff --git a/types.h b/types.h
index 030ce41..978381a 100644
--- a/types.h
+++ b/types.h
@@ -49,6 +49,7 @@ struct batadv_hard_iface_bat_iv {
unsigned char *ogm_buff;
int ogm_buff_len;
atomic_t ogm_seqno;
+ struct delayed_work work;
};
struct batadv_hard_iface {
--
1.8.0.2
9 years, 5 months
[B.A.T.M.A.N.] [PATCH 20/29] batman-adv: rename random32() to prandom_u32()
by Akinobu Mita
Use more preferable function name which implies using a pseudo-random
number generator.
Signed-off-by: Akinobu Mita <akinobu.mita(a)gmail.com>
Cc: Marek Lindner <lindner_marek(a)yahoo.de>
Cc: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Cc: Antonio Quartulli <ordex(a)autistici.org>
Cc: b.a.t.m.a.n(a)lists.open-mesh.org
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: netdev(a)vger.kernel.org
---
net/batman-adv/bat_iv_ogm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 7d02ebd..bc434c4 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -123,7 +123,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
unsigned int msecs;
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);
}
@@ -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 */
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 */
--
1.7.11.7
9 years, 5 months
[B.A.T.M.A.N.] [PATCH 1/8] batman-adv: align kernel doc properly
by Marek Lindner
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
---
types.h | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/types.h b/types.h
index d8061ac..dffbdff 100644
--- a/types.h
+++ b/types.h
@@ -66,19 +66,18 @@ struct batadv_hard_iface {
};
/**
- * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh
- * @primary_addr: hosts primary interface address
- * @last_seen: when last packet from this node was received
- * @bcast_seqno_reset: time when the broadcast seqno window was reset
- * @batman_seqno_reset: time when the batman seqno window was reset
- * @gw_flags: flags related to gateway class
- * @flags: for now only VIS_SERVER flag
- * @last_real_seqno: last and best known sequence number
- * @last_ttl: ttl of last received packet
- * @last_bcast_seqno: last broadcast sequence number received by this host
- *
- * @candidates: how many candidates are available
- * @selected: next bonding candidate
+ * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh
+ * @primary_addr: hosts primary interface address
+ * @last_seen: when last packet from this node was received
+ * @bcast_seqno_reset: time when the broadcast seqno window was reset
+ * @batman_seqno_reset: time when the batman seqno window was reset
+ * @gw_flags: flags related to gateway class
+ * @flags: for now only VIS_SERVER flag
+ * @last_real_seqno: last and best known sequence number
+ * @last_ttl: ttl of last received packet
+ * @last_bcast_seqno: last broadcast sequence number received by this host
+ * @candidates: how many candidates are available
+ * @selected: next bonding candidate
*/
struct batadv_orig_node {
uint8_t orig[ETH_ALEN];
--
1.7.10.4
9 years, 5 months
[B.A.T.M.A.N.] Batman-Adv & iptables mac filtering
by HeXiLeD
This is probably a openwrt question but even so it might have some
impact on batman-adv.
I am planing to use mac filtering through iptables on openwrt with a
default policy of deny all, allowing only by white list the clients that
will be allowed t connect.
My question to the batman team is if by applying this idea and since
batman-adv uses MACs to manage the routing; if i will have to white list
the other router MACs on the router or routers that will be filtering
MACs with iptables or batman-adv is not affected by mac filtering.
9 years, 5 months
[B.A.T.M.A.N.] [PATCH] batman-adv: fix random jitter calculation
by Akinobu Mita
batadv_iv_ogm_emit_send_time() attempts to calculates a random integer
in the range of 'orig_interval +- BATADV_JITTER' by the below lines.
msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
msecs += (random32() % 2 * BATADV_JITTER);
But it actually gets 'orig_interval' or 'orig_interval - BATADV_JITTER'
because '%' and '*' have same precedence and associativity is
left-to-right.
This adds the parentheses at the appropriate position so that it matches
original intension.
Signed-off-by: Akinobu Mita <akinobu.mita(a)gmail.com>
Acked-by: Antonio Quartulli <ordex(a)autistici.org>
Cc: Marek Lindner <lindner_marek(a)yahoo.de>
Cc: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Cc: Antonio Quartulli <ordex(a)autistici.org>
Cc: b.a.t.m.a.n(a)lists.open-mesh.org
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: netdev(a)vger.kernel.org
---
This patch is extracted from the patch series "rename random32 and
net_random to prandom" since it is a fix.
net/batman-adv/bat_iv_ogm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 9f3925a..7d02ebd 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -123,7 +123,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
unsigned int msecs;
msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
- msecs += (random32() % 2 * BATADV_JITTER);
+ msecs += random32() % (2 * BATADV_JITTER);
return jiffies + msecs_to_jiffies(msecs);
}
--
1.7.11.7
9 years, 6 months
[B.A.T.M.A.N.] [PATCH 19/29] batman-adv: fix random jitter calculation
by Akinobu Mita
batadv_iv_ogm_emit_send_time() attempts to calculates a random integer
in the range of 'orig_interval +- BATADV_JITTER' by the below lines.
msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
msecs += (random32() % 2 * BATADV_JITTER);
But it actually gets 'orig_interval' or 'orig_interval - BATADV_JITTER'
because '%' and '*' have same precedence and associativity is
left-to-right.
This adds the parentheses at the appropriate position so that it matches
original intension.
Signed-off-by: Akinobu Mita <akinobu.mita(a)gmail.com>
Cc: Marek Lindner <lindner_marek(a)yahoo.de>
Cc: Simon Wunderlich <siwu(a)hrz.tu-chemnitz.de>
Cc: Antonio Quartulli <ordex(a)autistici.org>
Cc: b.a.t.m.a.n(a)lists.open-mesh.org
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: netdev(a)vger.kernel.org
---
net/batman-adv/bat_iv_ogm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 9f3925a..7d02ebd 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -123,7 +123,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
unsigned int msecs;
msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
- msecs += (random32() % 2 * BATADV_JITTER);
+ msecs += random32() % (2 * BATADV_JITTER);
return jiffies + msecs_to_jiffies(msecs);
}
--
1.7.11.7
9 years, 6 months
[B.A.T.M.A.N.] [PATCH] batman-adv: a delayed_work has to be initialised once
by Antonio Quartulli
A delayed_work struct does not need to be initialized each
every time before being enqueued. Therefore the
INIT_DELAYED_WORK() macro should be used during the
initialization process only.
Signed-off-by: Antonio Quartulli <ordex(a)autistici.org>
---
bridge_loop_avoidance.c | 18 ++++++------------
originator.c | 15 ++++++---------
send.c | 5 +++--
translation-table.c | 14 +++++---------
vis.c | 20 ++++++++------------
5 files changed, 28 insertions(+), 44 deletions(-)
diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
index 5e834c1..bb5fbd6 100644
--- a/bridge_loop_avoidance.c
+++ b/bridge_loop_avoidance.c
@@ -1100,16 +1100,6 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
}
}
-
-
-/* (re)start the timer */
-static void batadv_bla_start_timer(struct batadv_priv *bat_priv)
-{
- INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
- queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
- msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
-}
-
/* periodic work to do:
* * purge structures when they are too old
* * send announcements
@@ -1180,7 +1170,8 @@ out:
if (primary_if)
batadv_hardif_free_ref(primary_if);
- batadv_bla_start_timer(bat_priv);
+ queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
+ msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
}
/* The hash for claim and backbone hash receive the same key because they
@@ -1238,7 +1229,10 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
- batadv_bla_start_timer(bat_priv);
+ INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
+
+ queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
+ msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
return 0;
}
diff --git a/originator.c b/originator.c
index fa88b2b..505bbf6 100644
--- a/originator.c
+++ b/originator.c
@@ -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_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 */
static int batadv_compare_orig(const struct hlist_node *node, const void *data2)
{
@@ -63,7 +56,10 @@ int batadv_originator_init(struct batadv_priv *bat_priv)
batadv_hash_set_lock_class(bat_priv->orig_hash,
&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(1000));
+
return 0;
err:
@@ -396,7 +392,8 @@ static void batadv_purge_orig(struct work_struct *work)
delayed_work = container_of(work, struct delayed_work, work);
bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);
_batadv_purge_orig(bat_priv);
- batadv_start_purge_timer(bat_priv);
+ queue_delayed_work(batadv_event_workqueue,
+ &bat_priv->orig_work, msecs_to_jiffies(1000));
}
void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
diff --git a/send.c b/send.c
index 89810ce..0b6f65b 100644
--- a/send.c
+++ b/send.c
@@ -155,8 +155,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
/* 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,
send_time);
}
@@ -210,6 +208,9 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
/* how often did we send the bcast packet ? */
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);
return NETDEV_TX_OK;
diff --git a/translation-table.c b/translation-table.c
index d4b27b6..076a1b9 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -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);
}
-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 *
batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data)
{
@@ -2136,7 +2129,9 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
if (ret < 0)
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(5000));
return 1;
}
@@ -2286,7 +2281,8 @@ static void batadv_tt_purge(struct work_struct *work)
batadv_tt_req_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(5000));
}
void batadv_tt_free(struct batadv_priv *bat_priv)
diff --git a/vis.c b/vis.c
index 60eb9b7..51e2bf0 100644
--- a/vis.c
+++ b/vis.c
@@ -31,8 +31,6 @@
/* hash class keys */
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 */
static void batadv_free_info(struct kref *ref)
{
@@ -830,7 +828,9 @@ static void batadv_send_vis_packets(struct work_struct *work)
kref_put(&info->refcount, batadv_free_info);
}
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
@@ -900,7 +900,11 @@ int batadv_vis_init(struct batadv_priv *bat_priv)
}
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;
free_info:
@@ -937,11 +941,3 @@ void batadv_vis_quit(struct batadv_priv *bat_priv)
bat_priv->vis.my_info = NULL;
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));
-}
--
1.8.0.2
9 years, 6 months