mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2.5] : ir252_lap_unique_saddr.diff
@ 2002-08-29 22:48 Jean Tourrilhes
  0 siblings, 0 replies; only message in thread
From: Jean Tourrilhes @ 2002-08-29 22:48 UTC (permalink / raw)
  To: Linus Torvalds, Jeff Garzik, Linux kernel mailing list, irda-users

ir252_lap_unique_saddr.diff :
---------------------------
	o [CORRECT] Make sure LAP address is sane, which mean not NULL,
		not BROADCAST and not already in use by another link.


diff -u -p linux/net/irda/irlap.d5.c linux/net/irda/irlap.c
--- linux/net/irda/irlap.d5.c	Wed Aug 21 15:37:52 2002
+++ linux/net/irda/irlap.c	Wed Aug 21 15:42:05 2002
@@ -139,7 +139,15 @@ struct irlap_cb *irlap_open(struct net_d
 	skb_queue_head_init(&self->wx_list);
 
 	/* My unique IrLAP device address! */
-	get_random_bytes(&self->saddr, sizeof(self->saddr));
+	/* We don't want the broadcast address, neither the NULL address
+	 * (most often used to signify "invalid"), and we don't want an
+	 * address already in use (otherwise connect won't be able
+	 * to select the proper link). - Jean II */
+	do {
+		get_random_bytes(&self->saddr, sizeof(self->saddr));
+	} while ((self->saddr == 0x0) || (self->saddr == BROADCAST) ||
+		 (hashbin_find(irlap, self->saddr, NULL)) );
+	/* Copy to the driver */
 	memcpy(dev->dev_addr, &self->saddr, 4);
 
 	init_timer(&self->slot_timer);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-08-29 22:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-29 22:48 [PATCH 2.5] : ir252_lap_unique_saddr.diff Jean Tourrilhes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®