mpls.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI_MPLS_H
  3. #define _UAPI_MPLS_H
  4. #include <linux/types.h>
  5. #include <asm/byteorder.h>
  6. /* Reference: RFC 5462, RFC 3032
  7. *
  8. * 0 1 2 3
  9. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  10. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  11. * | Label | TC |S| TTL |
  12. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  13. *
  14. * Label: Label Value, 20 bits
  15. * TC: Traffic Class field, 3 bits
  16. * S: Bottom of Stack, 1 bit
  17. * TTL: Time to Live, 8 bits
  18. */
  19. struct mpls_label {
  20. __be32 entry;
  21. };
  22. #define MPLS_LS_LABEL_MASK 0xFFFFF000
  23. #define MPLS_LS_LABEL_SHIFT 12
  24. #define MPLS_LS_TC_MASK 0x00000E00
  25. #define MPLS_LS_TC_SHIFT 9
  26. #define MPLS_LS_S_MASK 0x00000100
  27. #define MPLS_LS_S_SHIFT 8
  28. #define MPLS_LS_TTL_MASK 0x000000FF
  29. #define MPLS_LS_TTL_SHIFT 0
  30. /* Reserved labels */
  31. #define MPLS_LABEL_IPV4NULL 0 /* RFC3032 */
  32. #define MPLS_LABEL_RTALERT 1 /* RFC3032 */
  33. #define MPLS_LABEL_IPV6NULL 2 /* RFC3032 */
  34. #define MPLS_LABEL_IMPLNULL 3 /* RFC3032 */
  35. #define MPLS_LABEL_ENTROPY 7 /* RFC6790 */
  36. #define MPLS_LABEL_GAL 13 /* RFC5586 */
  37. #define MPLS_LABEL_OAMALERT 14 /* RFC3429 */
  38. #define MPLS_LABEL_EXTENSION 15 /* RFC7274 */
  39. #define MPLS_LABEL_FIRST_UNRESERVED 16 /* RFC3032 */
  40. /* These are embedded into IFLA_STATS_AF_SPEC:
  41. * [IFLA_STATS_AF_SPEC]
  42. * -> [AF_MPLS]
  43. * -> [MPLS_STATS_xxx]
  44. *
  45. * Attributes:
  46. * [MPLS_STATS_LINK] = {
  47. * struct mpls_link_stats
  48. * }
  49. */
  50. enum {
  51. MPLS_STATS_UNSPEC, /* also used as 64bit pad attribute */
  52. MPLS_STATS_LINK,
  53. __MPLS_STATS_MAX,
  54. };
  55. #define MPLS_STATS_MAX (__MPLS_STATS_MAX - 1)
  56. struct mpls_link_stats {
  57. __u64 rx_packets; /* total packets received */
  58. __u64 tx_packets; /* total packets transmitted */
  59. __u64 rx_bytes; /* total bytes received */
  60. __u64 tx_bytes; /* total bytes transmitted */
  61. __u64 rx_errors; /* bad packets received */
  62. __u64 tx_errors; /* packet transmit problems */
  63. __u64 rx_dropped; /* packet dropped on receive */
  64. __u64 tx_dropped; /* packet dropped on transmit */
  65. __u64 rx_noroute; /* no route for packet dest */
  66. };
  67. #endif /* _UAPI_MPLS_H */