Subject: Re: [net-next PATCH v2] llc enhancements

From: Eric Dumazet <[email-masked]>
Date: Thu, 24 Dec 2009 09:35:31 +0100

Le 24/12/2009 00:45, Octavian Purdila a écrit :
> This patch modifies the LLC code to scale the socket lookup code for a
> large number of interfaces and large number of sockets bound to the
> same SAP. We use it for STP traffic generation from a large number of
> virtual STP ports, via virtual network interfaces.
> 
> In the process we converted the socket lookup code and sap list to use
> RCU. It also contains some general cleanups (use dev_hard_header
> instead of handcrafting the headers) and enhancements (LLC_OPT_PKTINFO).
> 
> This is the 2nd version. Changes from the previous version:
> 
> - added SO_BINDTODEVICE support for faster bind operations
> - converted the socket lookup code and sap list to RCU
> - optimized multicast delivery ala Eric
> - remove some unused APIs (which should be private anyway)
> 
> Many thanks to Eric Dumazet for his continuous guidance and to Jarek
> Poplawski for spotting a locking bug in the previous version.
> 
> 

Pretty impressive work Octavian !

My only concerns (before drinking my coffee, I might be wrong...) are :

1) Patch 7/9 : __llc_lookup_established()
   Checking slot number is not enough I am afraid. A socket can be freed,
   re-allocated, inserted in another sap hash list on _same_ slot number.
   We dont have this problem with UDP/TCP since we have only
   one hash table on machine, but with llc, we might have many sap hash tables.

   So before if (llc_estab_match(sap, daddr, laddr, rc)) test, you probably
   need to check if we found a socket hashed on a different hash table and
   restart the lookup.

2) the WARN_ON() removal in patch 7/9 :

 void llc_sap_close(struct llc_sap *sap)
 {
-	WARN_ON(!hlist_nulls_empty(&sap->sk_list));
 	llc_del_sap(sap);
 	kfree(sap);
 }

I believe we should keep the sanity test some time, converted to sk_laddr_hash[] variant.

Thanks