title: Fast bi-directional hash of two integers in C
body: <p>I am writing a Linux kernel module and I need to come up with a hashing function that takes two integers for input. Because the code runs in kernel space, none of the standard libraries are available to me.</p>
  
  <p>Basically, I need a hashing function where:</p>
  
  <pre><code>hash(a, b) = c
  hash(b, a) = c
  </code></pre>
  
  <p>Where acceptable inputs for a and b are unsigned 32-bit integers. The hashing function should return an unsigned 64-bit integer. Collision (i.e. hash(a, b) = c and hash(d, f) = c as well) is not desirable as these values will be used in a binary search tree. The result of the search is a linked list of possible results that is then iterated over where a and b are actually compared. So some collision is acceptable, but the less collisions, the less iterations required, and the faster it will run.</p>
  
  <p>Performance is also of extreme importance, this lookup will be used for every packet received in a system as I am writing a firewall application (the integers are actually packet source and destination addresses). This function is used to lookup existing network sessions.</p>
  
  <p>Thank you for your time.</p>