[PATCH 5/6] Add hash support to neigh cache

Thomas Graf tgraf at suug.ch
Tue Nov 6 13:46:09 EST 2012


On 11/06/12 at 10:38am, Shrijeet Mukherjee wrote:
> Hi Thomas, 
> 
> ACK on the link object, will allocate that on the stack.
> 
> For the variable length keys, alloca can lead to strange situations if you overflow the stack, which is why calloc is a little safer. But more importantly, and we should figure out a way to make this clearer in the API, the key needs to be either packed or memset to zero before use. This is why we used a calloc.
> 
> Wondering if a malloc followed by a memset and a comment would be better to make that clear.

Agree, let's avoid alloca() for the sake of side effect freeness.

Thinking about this more, using __attribtue__((packed)) would not
only solve the problem of zeroing out the padding but it would
avoid introducing a lot of static 0's in the key that might weaken
the hash.



More information about the libnl mailing list