350-v4.18-ipv6-make-ip6_dst_mtu_forward-inline.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Fri, 16 Feb 2018 10:54:24 +0100
  3. Subject: [PATCH] ipv6: make ip6_dst_mtu_forward inline
  4. Removes a direct dependency on ipv6.ko
  5. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  6. ---
  7. --- a/include/net/ip6_route.h
  8. +++ b/include/net/ip6_route.h
  9. @@ -253,4 +253,26 @@ static inline bool rt6_duplicate_nexthop
  10. ipv6_addr_equal(&a->rt6i_gateway, &b->rt6i_gateway) &&
  11. !lwtunnel_cmp_encap(a->dst.lwtstate, b->dst.lwtstate);
  12. }
  13. +
  14. +static inline unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
  15. +{
  16. + unsigned int mtu;
  17. + struct inet6_dev *idev;
  18. +
  19. + if (dst_metric_locked(dst, RTAX_MTU)) {
  20. + mtu = dst_metric_raw(dst, RTAX_MTU);
  21. + if (mtu)
  22. + return mtu;
  23. + }
  24. +
  25. + mtu = IPV6_MIN_MTU;
  26. + rcu_read_lock();
  27. + idev = __in6_dev_get(dst->dev);
  28. + if (idev)
  29. + mtu = idev->cnf.mtu6;
  30. + rcu_read_unlock();
  31. +
  32. + return mtu;
  33. +}
  34. +
  35. #endif
  36. --- a/include/net/ipv6.h
  37. +++ b/include/net/ipv6.h
  38. @@ -860,8 +860,6 @@ static inline struct sk_buff *ip6_finish
  39. &inet6_sk(sk)->cork);
  40. }
  41. -unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst);
  42. -
  43. int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst,
  44. struct flowi6 *fl6);
  45. struct dst_entry *ip6_dst_lookup_flow(struct net *net, const struct sock *sk, struct flowi6 *fl6,
  46. --- a/net/ipv6/ip6_output.c
  47. +++ b/net/ipv6/ip6_output.c
  48. @@ -381,28 +381,6 @@ static inline int ip6_forward_finish(str
  49. return dst_output(net, sk, skb);
  50. }
  51. -unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
  52. -{
  53. - unsigned int mtu;
  54. - struct inet6_dev *idev;
  55. -
  56. - if (dst_metric_locked(dst, RTAX_MTU)) {
  57. - mtu = dst_metric_raw(dst, RTAX_MTU);
  58. - if (mtu)
  59. - return mtu;
  60. - }
  61. -
  62. - mtu = IPV6_MIN_MTU;
  63. - rcu_read_lock();
  64. - idev = __in6_dev_get(dst->dev);
  65. - if (idev)
  66. - mtu = idev->cnf.mtu6;
  67. - rcu_read_unlock();
  68. -
  69. - return mtu;
  70. -}
  71. -EXPORT_SYMBOL_GPL(ip6_dst_mtu_forward);
  72. -
  73. static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
  74. {
  75. if (skb->len <= mtu)