: ir255_hashbin_fixes-2.diff
PATCH 1/1 : ir255_hashbin_fixes-2.diff
ir255_hashbin_fixes-2.diff :
--------------------------
o [CRITICA] Remove correct IAS Attribute/Object even if name is dup'ed
o [CORRECT] Make irqueue 64 bit compliant (__u32 -> long)
o [FEATURE] Don't use random handle for IrLMP handle, use self Remove dependancy on random generator in stack init
include/net/irda/irqueue.h renamed from include/net/irda/irqueue.d1.h +4 -4
@@ -67,7 +67,7 @@ struct irda_queue {struct irda_queue *q_prev;char q_name[NAME_SIZE ]; -__u32 q_hash; +long q_hash;/* Must be able to cast a (void *) */ };typedef struct irda_queue irda_queue_t ;
@@ -84,10 +84,10 @@ typedef struct hashbin_t {hashbin_t *hashbin_new (int type);int hashbin_delete (hashbin_t * hashbin,FREE_FUNC func);int hashbin_clear (hashbin_t * hashbin,FREE_FUNC free_func); -void hashbin_insert (hashbin_t * hashbin,irda_queue_t * entry,__u32 hashv, +void hashbin_insert (hashbin_t * hashbin,irda_queue_t * entry,long hashv,char * name); -void *hashbin_find (hashbin_t * hashbin,__u32 hashv,char * name); -void *hashbin_remove (hashbin_t * hashbin,__u32 hashv,char * name); +void *hashbin_find (hashbin_t * hashbin,long hashv,char * name); +void *hashbin_remove (hashbin_t * hashbin,long hashv,char * name);void *hashbin_remove_first (hashbin_t *hashbin);void *hashbin_remove_this (hashbin_t * hashbin,irda_queue_t * entry);irda_queue_t *hashbin_get_first (hashbin_t *hashbin);
include/net/irda/irlmp.h renamed from include/net/irda/irlmp.d1.h +5 -5
@@ -197,12 +197,12 @@ struct lsap_cb *irlmp_open_lsap(__u8 slsvoid irlmp_close_lsap (struct lsap_cb *self);__u16 irlmp_service_to_hint (int service); -__u32 irlmp_register_service (__u16 hints); -int irlmp_unregister_service (__u32 handle); -__u32 irlmp_register_client (__u16 hint_mask,DISCOVERY_CALLBACK1 disco_clb, +void *irlmp_register_service (__u16 hints); +int irlmp_unregister_service (void *handle); +void *irlmp_register_client (__u16 hint_mask,DISCOVERY_CALLBACK1 disco_clb,DISCOVERY_CALLBACK1 expir_clb,void *priv); -int irlmp_unregister_client (__u32 handle); -int irlmp_update_client (__u32 handle,__u16 hint_mask, +int irlmp_unregister_client (void *handle); +int irlmp_update_client (void *handle,__u16 hint_mask,DISCOVERY_CALLBACK1 disco_clb,DISCOVERY_CALLBACK1 expir_clb,void *priv);
include/net/irda/af_irda.h renamed from include/net/irda/af_irda.d1.h +2 -2
@@ -55,8 +55,8 @@ struct irda_sock {__u16 mask;/* Hint bits mask */ __u16 hints;/* Hint bits */ -__u32 ckey;/* IrLMP client handle */ -__u32 skey;/* IrLMP service handle */ +void *ckey;/* IrLMP client handle */ +void *skey;/* IrLMP service handle */ struct ias_object *ias_obj;/* Our service name + lsap in IAS */ struct iriap_cb *iriap;/* Used to query remote IAS */
include/net/irda/ircomm_tty.h renamed from include/net/irda/ircomm_tty.d1.h +2 -2
@@ -86,8 +86,8 @@ struct ircomm_tty_cb {struct iriap_cb *iriap;/* Instance used for querying remote IAS */ struct ias_object * obj; -int skey; -int ckey; +void *skey; +void *ckey;struct termios normal_termios;struct termios callout_termios;
net/irda/irqueue.c renamed from net/irda/irqueue.d1.c +27 -4
@@ -34,6 +34,21 @@* ********************************************************************/ +/* +* NOTE : +* There are various problems with this package : +* o the hash function for ints is pathetic (but could be changed) +* o locking is sometime suspicious (especially during enumeration) +* o most users have only a few elements (== overhead) +* o most users never use seach, so don't benefit from hashing +* Problem already fixed : +* o not 64 bit compliant (most users do hashv = (int) self) +* o hashbin_remove() is broken => use hashbin_remove_this() +* I think most users would be better served by a simple linked list +* (like include/linux/list.h) with a global spinlock per list. +* Jean II +*/ +#include <net/irda/irda.h> #include <net/irda/irqueue.h>
@@ -148,7 +163,7 @@ int hashbin_delete( hashbin_t* hashbin,* Insert an entry into the hashbin * */ -void hashbin_insert (hashbin_t * hashbin,irda_queue_t * entry,__u32 hashv,char * name) +void hashbin_insert (hashbin_t * hashbin,irda_queue_t * entry,long hashv,char * name) {unsigned long flags =0 ;int bin;
@@ -209,7 +224,7 @@ void hashbin_insert(hashbin_t* hashbin,* Find item with the given hashv or name * */ -void *hashbin_find (hashbin_t * hashbin,__u32 hashv,char * name ) +void *hashbin_find (hashbin_t * hashbin,long hashv,char * name ) {int bin, found = FALSE;unsigned long flags =0 ;
@@ -300,8 +315,16 @@ void *hashbin_remove_first( hashbin_t *h* * Remove entry with the given name * +* The use of this function is highly discouraged, because the whole +* concept behind hashbin_remove() is broken. In many cases, it's not +* possible to guarantee the unicity of the index (either hashv or name), +* leading to removing the WRONG entry. +* The only simple safe use is : +* hashbin_remove(hasbin, (int) self, NULL); +* In other case, you must think hard to guarantee unicity of the index. +* Jean II */ -void *hashbin_remove (hashbin_t * hashbin,__u32 hashv,char * name) +void *hashbin_remove (hashbin_t * hashbin,long hashv,char * name) {int bin, found = FALSE;unsigned long flags =0 ;
@@ -404,7 +427,7 @@ void* hashbin_remove_this( hashbin_t* ha {unsigned long flags =0 ;int bin; -__u32 hashv; +long hashv;IRDA_DEBUG (4 , __FUNCTION__"()\n" );
net/irda/irlmp.c renamed from net/irda/irlmp.d1.c +38 -47
236 lines not on this page · raw message
net/irda/irlmp_event.c renamed from net/irda/irlmp_event.d1.c +3 -3
@@ -581,15 +581,15 @@ static int irlmp_state_connect(struct ls* Bind this LSAP to the IrLAP link where the connect was * received */ - lsap =hashbin_remove (irlmp->unconnected_lsaps, (int ) self, + lsap =hashbin_remove (irlmp->unconnected_lsaps, (long ) self,NULL ); ASSERT(lsap == self, return -1;); ASSERT(self->lap != NULL, return -1;); ASSERT(self->lap->lsaps != NULL, return -1;); -hashbin_insert (self->lap->lsaps, (irda_queue_t *) self, (int ) self, -NULL ); +hashbin_insert (self->lap->lsaps, (irda_queue_t *) self, + (long ) self,NULL );irlmp_send_lcf_pdu (self->lap, self->dlsap_sel, self->slsap_sel,CONNECT_CNF , skb);
net/irda/irttp.c renamed from net/irda/irttp.d1.c +4 -4
@@ -433,7 +433,7 @@ struct tsap_cb *irttp_open_tsap(__u8 sts self->notify = *notify; self->lsap = lsap; -hashbin_insert (irttp->tsaps, (irda_queue_t *) self, (int ) self,NULL ); +hashbin_insert (irttp->tsaps, (irda_queue_t *) self, (long ) self,NULL );if (credit >TTP_RX_MAX_CREDIT ) self->initial_credit =TTP_RX_MAX_CREDIT ;
@@ -503,7 +503,7 @@ int irttp_close_tsap(struct tsap_cb *selreturn 0 ;/* Will be back! */ } - tsap =hashbin_remove (irttp->tsaps, (int ) self,NULL ); + tsap =hashbin_remove (irttp->tsaps, (long ) self,NULL ); ASSERT(tsap == self, return -1;);
@@ -1368,7 +1368,7 @@ struct tsap_cb *irttp_dup(struct tsap_cbIRDA_DEBUG (1 , __FUNCTION__"()\n" ); -if (!hashbin_find (irttp->tsaps, (int ) orig,NULL )) { +if (!hashbin_find (irttp->tsaps, (long ) orig,NULL )) {IRDA_DEBUG (0 , __FUNCTION__"(), unable to find TSAP\n" );return NULL ; }
@@ -1389,7 +1389,7 @@ struct tsap_cb *irttp_dup(struct tsap_cbskb_queue_head_init (&new->tx_queue);skb_queue_head_init (&new->rx_fragments); -hashbin_insert (irttp->tsaps, (irda_queue_t *) new, (int ) new,NULL ); +hashbin_insert (irttp->tsaps, (irda_queue_t *) new, (long ) new,NULL );return new; }
net/irda/iriap.c renamed from net/irda/iriap.d1.c +3 -3
@@ -58,7 +58,7 @@ static const char *ias_charset_types[] =#endif /* CONFIG_IRDA_DEBUG */ static hashbin_t *iriap =NULL ; -static __u32 service_handle; +static void *service_handle;extern char *lmp_reasons[];
@@ -182,7 +182,7 @@ struct iriap_cb *iriap_open(__u8 slsap_sinit_timer (&self->watchdog_timer); -hashbin_insert (iriap, (irda_queue_t *) self, (int ) self,NULL ); +hashbin_insert (iriap, (irda_queue_t *) self, (long ) self,NULL );/* Initialize state machines */ iriap_next_client_state (self,S_DISCONNECT );
@@ -235,7 +235,7 @@ void iriap_close(struct iriap_cb *self) self->lsap =NULL ; } - entry = (struct iriap_cb *)hashbin_remove (iriap, (int ) self,NULL ); + entry = (struct iriap_cb *)hashbin_remove (iriap, (long ) self,NULL ); ASSERT(entry == self, return;);__iriap_close (self);
net/irda/irias_object.c renamed from net/irda/irias_object.d1.c +2 -2
@@ -147,7 +147,7 @@ int irias_delete_object(struct ias_objec ASSERT(obj != NULL, return -1;); ASSERT(obj->magic == IAS_OBJECT_MAGIC, return -1;); - node =hashbin_remove (objects,0 , obj->name); + node =hashbin_remove_this (objects, (irda_queue_t *) obj);if (!node)return 0 ;/* Already removed */
@@ -172,7 +172,7 @@ int irias_delete_attrib(struct ias_objec ASSERT(attrib != NULL, return -1;);/* Remove attribute from object */ - node =hashbin_remove (obj->attribs,0 , attrib->name); + node =hashbin_remove_this (obj->attribs, (irda_queue_t *) attrib);if (!node)return 0 ;/* Already removed or non-existent */
net/irda/irlan/irlan_common.c renamed from net/irda/irlan/irlan_common.d1.c +2 -1
@@ -64,7 +64,8 @@* Master structure */ hashbin_t *irlan =NULL ; -static __u32 ckey, skey; +static void *ckey; +static void *skey;/* Module parameters */ static int eth =0 ;/* Use "eth" or "irlan" name for devices */
net/irda/irnet/irnet.h renamed from net/irda/irnet/irnet.d1.h +1 -1
@@ -434,7 +434,7 @@ typedef struct irnet_socket/* ------------------- IrLMP and IrIAS part ------------------- */ /* Used for IrDA Discovery and socket name resolution */ -__u32 ckey;/* IrLMP client handle */ +void * ckey;/* IrLMP client handle */ __u16 mask;/* Hint bits mask (filter discov.)*/ int nslots;/* Number of slots for discovery */
net/irda/irnet/irnet_irda.h renamed from net/irda/irnet/irnet_irda.d1.h +1 -1
@@ -53,7 +53,7 @@ typedef struct irnet_root* reentrant, beware... So, we blindly protect all with spinlock */ /* Handle for the hint bit advertised in IrLMP */ -__u32 skey; +void * skey;/* Server socket part */ struct ias_object * ias_obj;/* Our service name + lsap in IAS */
net/irda/irsyms.c renamed from net/irda/irsyms.d1.c +2 -1
@@ -328,7 +328,8 @@ void __exit irda_cleanup(void)* On the other hand, it needs to be initialised *after* the basic * networking, the /proc/net filesystem and sysctl module. Those are * currently initialised in .../init/main.c (before initcalls). -* Also, it needs to be initialised *after* the random number generator. +* Also, IrDA drivers needs to be initialised *after* the random number +* generator (main stack and higher layer init don't need it anymore). * * Jean II */