Guest User

Untitled

a guest
Oct 29th, 2017
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. commit 749f63ed9bf702e588000f1d1ce6290e6c156289
  2. Author: Eric Dumazet <eric.dumazet@gmail.com>
  3. Date: Wed Sep 8 05:08:44 2010 +0000
  4.  
  5. udp: add rehash on connect()
  6.  
  7. commit 719f835853a92f6090258114a72ffe41f09155cd upstream
  8.  
  9. commit 30fff923 introduced in linux-2.6.33 (udp: bind() optimisation)
  10. added a secondary hash on UDP, hashed on (local addr, local port).
  11.  
  12. Problem is that following sequence :
  13.  
  14. fd = socket(...)
  15. connect(fd, &remote, ...)
  16.  
  17. not only selects remote end point (address and port), but also sets
  18. local address, while UDP stack stored in secondary hash table the socket
  19. while its local address was INADDR_ANY (or ipv6 equivalent)
  20.  
  21. Sequence is :
  22. - autobind() : choose a random local port, insert socket in hash tables
  23. [while local address is INADDR_ANY]
  24. - connect() : set remote address and port, change local address to IP
  25. given by a route lookup.
  26.  
  27. When an incoming UDP frame comes, if more than 10 sockets are found in
  28. primary hash table, we switch to secondary table, and fail to find
  29. socket because its local address changed.
  30.  
  31. One solution to this problem is to rehash datagram socket if needed.
  32.  
  33. We add a new rehash(struct socket *) method in "struct proto", and
  34. implement this method for UDP v4 & v6, using a common helper.
  35.  
  36. This rehashing only takes care of secondary hash table, since primary
  37. hash (based on local port only) is not changed.
  38.  
  39. Reported-by: Krzysztof Piotr Oledzki <ole@ans.pl>
  40. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
  41. Tested-by: Krzysztof Piotr Oledzki <ole@ans.pl>
  42. Signed-off-by: David S. Miller <davem@davemloft.net>
  43. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Add Comment
Please, Sign In to add comment