Thread (24 messages) 24 messages, 3 authors, 2012-02-12

Re: [B.A.T.M.A.N.] [PATCH 3/8] batman-adv: randomize initial seqno to avoid collision

From: Marek Lindner <hidden>
Date: 2012-02-07 11:10:59

On Tuesday, February 07, 2012 17:33:14 Martin Hundebøll wrote:
On 2012-02-07 10:20, Marek Lindner wrote:
quoted
Signed-off-by: Marek Lindner<redacted>
---

  bat_iv_ogm.c |    5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 3eff7f0..4ac2d1d 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -33,6 +33,11 @@

  static void bat_iv_ogm_iface_enable(struct hard_iface *hard_iface)
  {
  
  	struct batman_ogm_packet *batman_ogm_packet;

+	unsigned long random_seqno;
+
+	/* randomize initial seqno to avoid collision */
+	get_random_bytes(&random_seqno, sizeof(unsigned long));
+	atomic_set(&hard_iface->seqno, (uint32_t)random_seqno);
Wouldn't it be better to cast "unsigned long" in the call to atomic_set()?
Why should it better ?

Regards,
Marek
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help