seg6.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * SR-IPv6 implementation
  3. *
  4. * Author:
  5. * David Lebrun <david.lebrun@uclouvain.be>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #ifndef _NET_SEG6_H
  14. #define _NET_SEG6_H
  15. #include <linux/net.h>
  16. #include <linux/ipv6.h>
  17. #include <net/lwtunnel.h>
  18. #include <linux/seg6.h>
  19. #include <linux/rhashtable-types.h>
  20. static inline void update_csum_diff4(struct sk_buff *skb, __be32 from,
  21. __be32 to)
  22. {
  23. __be32 diff[] = { ~from, to };
  24. skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
  25. }
  26. static inline void update_csum_diff16(struct sk_buff *skb, __be32 *from,
  27. __be32 *to)
  28. {
  29. __be32 diff[] = {
  30. ~from[0], ~from[1], ~from[2], ~from[3],
  31. to[0], to[1], to[2], to[3],
  32. };
  33. skb->csum = ~csum_partial((char *)diff, sizeof(diff), ~skb->csum);
  34. }
  35. struct seg6_pernet_data {
  36. struct mutex lock;
  37. struct in6_addr __rcu *tun_src;
  38. #ifdef CONFIG_IPV6_SEG6_HMAC
  39. struct rhashtable hmac_infos;
  40. #endif
  41. };
  42. static inline struct seg6_pernet_data *seg6_pernet(struct net *net)
  43. {
  44. #if IS_ENABLED(CONFIG_IPV6)
  45. return net->ipv6.seg6_data;
  46. #else
  47. return NULL;
  48. #endif
  49. }
  50. extern int seg6_init(void);
  51. extern void seg6_exit(void);
  52. extern int seg6_iptunnel_init(void);
  53. extern void seg6_iptunnel_exit(void);
  54. extern int seg6_local_init(void);
  55. extern void seg6_local_exit(void);
  56. extern bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len);
  57. extern int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh,
  58. int proto);
  59. extern int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh);
  60. extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
  61. u32 tbl_id);
  62. #endif