080-24-fib_trie-Move-fib_find_alias-to-file-where-it-is-use.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From: Alexander Duyck <alexander.h.duyck@redhat.com>
  2. Date: Thu, 22 Jan 2015 15:51:39 -0800
  3. Subject: [PATCH] fib_trie: Move fib_find_alias to file where it is used
  4. The function fib_find_alias is only accessed by functions in fib_trie.c as
  5. such it makes sense to relocate it and cast it as static so that the
  6. compiler can take advantage of optimizations it can do to it as a local
  7. function.
  8. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
  9. Signed-off-by: David S. Miller <davem@davemloft.net>
  10. ---
  11. --- a/net/ipv4/fib_lookup.h
  12. +++ b/net/ipv4/fib_lookup.h
  13. @@ -32,7 +32,6 @@ int fib_dump_info(struct sk_buff *skb, u
  14. unsigned int);
  15. void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, int dst_len,
  16. u32 tb_id, const struct nl_info *info, unsigned int nlm_flags);
  17. -struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio);
  18. static inline void fib_result_assign(struct fib_result *res,
  19. struct fib_info *fi)
  20. --- a/net/ipv4/fib_semantics.c
  21. +++ b/net/ipv4/fib_semantics.c
  22. @@ -410,24 +410,6 @@ errout:
  23. rtnl_set_sk_err(info->nl_net, RTNLGRP_IPV4_ROUTE, err);
  24. }
  25. -/* Return the first fib alias matching TOS with
  26. - * priority less than or equal to PRIO.
  27. - */
  28. -struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
  29. -{
  30. - if (fah) {
  31. - struct fib_alias *fa;
  32. - list_for_each_entry(fa, fah, fa_list) {
  33. - if (fa->fa_tos > tos)
  34. - continue;
  35. - if (fa->fa_info->fib_priority >= prio ||
  36. - fa->fa_tos < tos)
  37. - return fa;
  38. - }
  39. - }
  40. - return NULL;
  41. -}
  42. -
  43. static int fib_detect_death(struct fib_info *fi, int order,
  44. struct fib_info **last_resort, int *last_idx,
  45. int dflt)
  46. --- a/net/ipv4/fib_trie.c
  47. +++ b/net/ipv4/fib_trie.c
  48. @@ -998,6 +998,26 @@ static struct tnode *fib_find_node(struc
  49. return n;
  50. }
  51. +/* Return the first fib alias matching TOS with
  52. + * priority less than or equal to PRIO.
  53. + */
  54. +static struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
  55. +{
  56. + struct fib_alias *fa;
  57. +
  58. + if (!fah)
  59. + return NULL;
  60. +
  61. + list_for_each_entry(fa, fah, fa_list) {
  62. + if (fa->fa_tos > tos)
  63. + continue;
  64. + if (fa->fa_info->fib_priority >= prio || fa->fa_tos < tos)
  65. + return fa;
  66. + }
  67. +
  68. + return NULL;
  69. +}
  70. +
  71. static void trie_rebalance(struct trie *t, struct tnode *tn)
  72. {
  73. struct tnode *tp;