seg6_iptunnel.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * SR-IPv6 implementation
  4. *
  5. * Author:
  6. * David Lebrun <david.lebrun@uclouvain.be>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #ifndef _UAPI_LINUX_SEG6_IPTUNNEL_H
  15. #define _UAPI_LINUX_SEG6_IPTUNNEL_H
  16. #include <linux/seg6.h> /* For struct ipv6_sr_hdr. */
  17. enum {
  18. SEG6_IPTUNNEL_UNSPEC,
  19. SEG6_IPTUNNEL_SRH,
  20. __SEG6_IPTUNNEL_MAX,
  21. };
  22. #define SEG6_IPTUNNEL_MAX (__SEG6_IPTUNNEL_MAX - 1)
  23. struct seg6_iptunnel_encap {
  24. int mode;
  25. struct ipv6_sr_hdr srh[0];
  26. };
  27. #define SEG6_IPTUN_ENCAP_SIZE(x) ((sizeof(*x)) + (((x)->srh->hdrlen + 1) << 3))
  28. enum {
  29. SEG6_IPTUN_MODE_INLINE,
  30. SEG6_IPTUN_MODE_ENCAP,
  31. SEG6_IPTUN_MODE_L2ENCAP,
  32. };
  33. #ifdef __KERNEL__
  34. static inline size_t seg6_lwt_headroom(struct seg6_iptunnel_encap *tuninfo)
  35. {
  36. int head = 0;
  37. switch (tuninfo->mode) {
  38. case SEG6_IPTUN_MODE_INLINE:
  39. break;
  40. case SEG6_IPTUN_MODE_ENCAP:
  41. head = sizeof(struct ipv6hdr);
  42. break;
  43. case SEG6_IPTUN_MODE_L2ENCAP:
  44. return 0;
  45. }
  46. return ((tuninfo->srh->hdrlen + 1) << 3) + head;
  47. }
  48. #endif
  49. #endif