21 #ifdef RTE_EXEC_ENV_WINDOWS 24 #include <sys/socket.h> 25 #include <sys/types.h> 26 #include <netinet/in.h> 27 #include <arpa/inet.h> 28 #include <netinet/ip6.h> 43 #define RTE_IPV6_ADDR_SIZE 16 48 #define RTE_IPV6_MAX_DEPTH (RTE_IPV6_ADDR_SIZE * CHAR_BIT) 70 return memcmp(a, b,
sizeof(*a)) == 0;
87 uint8_t d = depth / 8;
88 uint8_t mask = ~(UINT8_MAX >> (depth % 8));
91 memset(&ip->a[d], 0,
sizeof(*ip) - d);
111 uint8_t d = depth / 8;
112 uint8_t mask = ~(UINT8_MAX >> (depth % 8));
114 if ((a->a[d] ^ b->a[d]) & mask)
117 return memcmp(a, b, d) == 0;
130 static inline uint8_t
135 for (
unsigned int i = 0; i <
RTE_DIM(mask->a); i++) {
136 uint8_t m = mask->a[i];
160 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN 161 #define RTE_IPV6_U16_SPLIT(x) \ 162 (uint8_t)((uint16_t)(x) & UINT16_C(0xff)), \ 163 (uint8_t)(((uint16_t)(x) >> 8) & UINT16_C(0xff)) 165 #define RTE_IPV6_U16_SPLIT(x) \ 166 (uint8_t)(((uint16_t)(x) >> 8) & UINT16_C(0xff)), \ 167 (uint8_t)((uint16_t)(x) & UINT16_C(0xff)) 178 #define RTE_IPV6(a, b, c, d, e, f, g, h) \ 180 RTE_IPV6_U16_SPLIT(a), \ 181 RTE_IPV6_U16_SPLIT(b), \ 182 RTE_IPV6_U16_SPLIT(c), \ 183 RTE_IPV6_U16_SPLIT(d), \ 184 RTE_IPV6_U16_SPLIT(e), \ 185 RTE_IPV6_U16_SPLIT(f), \ 186 RTE_IPV6_U16_SPLIT(g), \ 187 RTE_IPV6_U16_SPLIT(h) \ 194 #define RTE_IPV6_ADDR_FMT \ 195 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x" 209 #define RTE_IPV6_ADDR_SPLIT(ip) \ 210 ((uint8_t)(ip)->a[0]), \ 211 ((uint8_t)(ip)->a[1]), \ 212 ((uint8_t)(ip)->a[2]), \ 213 ((uint8_t)(ip)->a[3]), \ 214 ((uint8_t)(ip)->a[4]), \ 215 ((uint8_t)(ip)->a[5]), \ 216 ((uint8_t)(ip)->a[6]), \ 217 ((uint8_t)(ip)->a[7]), \ 218 ((uint8_t)(ip)->a[8]), \ 219 ((uint8_t)(ip)->a[9]), \ 220 ((uint8_t)(ip)->a[10]), \ 221 ((uint8_t)(ip)->a[11]), \ 222 ((uint8_t)(ip)->a[12]), \ 223 ((uint8_t)(ip)->a[13]), \ 224 ((uint8_t)(ip)->a[14]), \ 225 ((uint8_t)(ip)->a[15]) 228 #define RTE_IPV6_MASK_FULL \ 229 RTE_IPV6(0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff) 232 #define RTE_IPV6_ADDR_UNSPEC RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0) 250 #define RTE_IPV6_ADDR_LOOPBACK RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 1) 279 return ip->a[0] == 0xfe && (ip->a[1] & 0xc0) == 0x80;
293 return ip->a[0] == 0xfe && (ip->a[1] & 0xc0) == 0xc0;
312 #define RTE_IPV6_ADDR_PREFIX_V4MAPPED RTE_IPV6(0, 0, 0, 0, 0, 0xffff, 0, 0) 326 const struct rte_ipv6_addr prefix = RTE_IPV6_ADDR_PREFIX_V4MAPPED;
341 return ip->a[0] == 0xff;
382 #define RTE_IPV6_ADDR_ALLNODES_IFACE_LOCAL RTE_IPV6(0xff01, 0, 0, 0, 0, 0, 0, 1) 384 #define RTE_IPV6_ADDR_ALLNODES_LINK_LOCAL RTE_IPV6(0xff02, 0, 0, 0, 0, 0, 0, 1) 386 #define RTE_IPV6_ADDR_ALLROUTERS_IFACE_LOCAL RTE_IPV6(0xff01, 0, 0, 0, 0, 0, 0, 2) 388 #define RTE_IPV6_ADDR_ALLROUTERS_LINK_LOCAL RTE_IPV6(0xff02, 0, 0, 0, 0, 0, 0, 2) 390 #define RTE_IPV6_ADDR_ALLROUTERS_SITE_LOCAL RTE_IPV6(0xff05, 0, 0, 0, 0, 0, 0, 2) 403 rte_ipv6_llocal_from_ethernet(
struct rte_ipv6_addr *ip,
const struct rte_ether_addr *mac)
407 memset(&ip->a[2], 0, 6);
408 ip->a[8] = mac->addr_bytes[0];
409 ip->a[9] = mac->addr_bytes[1];
410 ip->a[10] = mac->addr_bytes[2];
413 ip->a[13] = mac->addr_bytes[3];
414 ip->a[14] = mac->addr_bytes[4];
415 ip->a[15] = mac->addr_bytes[5];
432 memset(&sol->a[2], 0, 9);
435 sol->a[13] = ip->a[13];
436 sol->a[14] = ip->a[14];
437 sol->a[15] = ip->a[15];
452 mac->addr_bytes[0] = 0x33;
453 mac->addr_bytes[1] = 0x33;
454 mac->addr_bytes[2] = ip->a[12];
455 mac->addr_bytes[3] = ip->a[13];
456 mac->addr_bytes[4] = ip->a[14];
457 mac->addr_bytes[5] = ip->a[15];
468 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN 473 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN 477 uint32_t flow_label:20;
498 uint8_t version = ((
const uint8_t *)ip)[0];
499 if ((version & 0xf0) != 0x60)
505 #define RTE_IPV6_SRCRT_TYPE_4 4 528 #define RTE_IPV6_HDR_FL_SHIFT 0 529 #define RTE_IPV6_HDR_TC_SHIFT 20 530 #define RTE_IPV6_HDR_FL_MASK ((1u << RTE_IPV6_HDR_TC_SHIFT) - 1) 531 #define RTE_IPV6_HDR_TC_MASK (0xff << RTE_IPV6_HDR_TC_SHIFT) 532 #define RTE_IPV6_HDR_DSCP_MASK (0xfc << RTE_IPV6_HDR_TC_SHIFT) 533 #define RTE_IPV6_HDR_ECN_MASK (0x03 << RTE_IPV6_HDR_TC_SHIFT) 534 #define RTE_IPV6_HDR_ECN_CE RTE_IPV6_HDR_ECN_MASK 536 #define RTE_IPV6_MIN_MTU 1280 554 static inline uint16_t 563 psd_hdr.proto = (uint32_t)(ipv6_hdr->
proto << 24);
569 sum = __rte_raw_cksum(&ipv6_hdr->
src_addr,
572 sum = __rte_raw_cksum(&psd_hdr,
sizeof(psd_hdr), sum);
573 return __rte_raw_cksum_reduce(sum);
579 static inline uint16_t
580 __rte_ipv6_udptcp_cksum(
const struct rte_ipv6_hdr *ipv6_hdr,
const void *l4_hdr)
590 cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);
592 return (uint16_t)cksum;
608 static inline uint16_t
611 uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr);
620 if (cksum == 0 && ipv6_hdr->
proto == IPPROTO_UDP)
629 static inline uint16_t
630 __rte_ipv6_udptcp_cksum_mbuf(
const struct rte_mbuf *m,
645 cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);
647 return (uint16_t)cksum;
665 static inline uint16_t
669 uint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off);
678 if (cksum == 0 && ipv6_hdr->
proto == IPPROTO_UDP)
702 uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr);
731 uint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off);
740 #define RTE_IPV6_EHDR_MF_SHIFT 0 741 #define RTE_IPV6_EHDR_MF_MASK 1 742 #define RTE_IPV6_EHDR_FO_SHIFT 3 743 #define RTE_IPV6_EHDR_FO_MASK (~((1 << RTE_IPV6_EHDR_FO_SHIFT) - 1)) 744 #define RTE_IPV6_EHDR_FO_ALIGN (1 << RTE_IPV6_EHDR_FO_SHIFT) 746 #define RTE_IPV6_FRAG_USED_MASK (RTE_IPV6_EHDR_MF_MASK | RTE_IPV6_EHDR_FO_MASK) 748 #define RTE_IPV6_GET_MF(x) ((x) & RTE_IPV6_EHDR_MF_MASK) 749 #define RTE_IPV6_GET_FO(x) ((x) >> RTE_IPV6_EHDR_FO_SHIFT) 751 #define RTE_IPV6_SET_FRAG_DATA(fo, mf) \ 752 (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) 754 struct rte_ipv6_fragment_ext {
762 #define RTE_IPV6_FRAG_HDR_SIZE sizeof(struct rte_ipv6_fragment_ext) 788 *ext_len = (*p + 2) *
sizeof(uint32_t);
791 case IPPROTO_HOPOPTS:
792 case IPPROTO_ROUTING:
793 case IPPROTO_DSTOPTS:
795 *ext_len = (*p + 1) *
sizeof(uint64_t);
798 case IPPROTO_FRAGMENT:
800 *ext_len = RTE_IPV6_FRAG_HDR_SIZE;
static uint16_t rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m, const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l4_off)
static uint16_t rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
static bool rte_ipv6_addr_is_linklocal(const struct rte_ipv6_addr *ip)
static int rte_ipv6_get_next_ext(const uint8_t *p, int proto, size_t *ext_len)
static void rte_ipv6_solnode_from_addr(struct rte_ipv6_addr *sol, const struct rte_ipv6_addr *ip)
static int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)
static bool rte_ipv6_addr_is_mcast(const struct rte_ipv6_addr *ip)
#define RTE_MBUF_F_TX_UDP_SEG
#define RTE_IPV6_ADDR_UNSPEC
static int rte_ipv6_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m, const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l4_off)
static uint8_t rte_ipv6_mask_depth(const struct rte_ipv6_addr *mask)
static int rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
static void rte_ipv6_addr_mask(struct rte_ipv6_addr *ip, uint8_t depth)
struct rte_ipv6_addr src_addr
#define RTE_IPV6_ADDR_LOOPBACK
static uint16_t rte_raw_cksum(const void *buf, size_t len)
#define RTE_IPV6_MAX_DEPTH
static bool rte_ipv6_addr_is_v4mapped(const struct rte_ipv6_addr *ip)
static bool rte_ipv6_addr_eq(const struct rte_ipv6_addr *a, const struct rte_ipv6_addr *b)
#define RTE_MBUF_F_TX_TCP_SEG
static bool rte_ipv6_addr_is_unspec(const struct rte_ipv6_addr *ip)
static bool rte_ipv6_addr_eq_prefix(const struct rte_ipv6_addr *a, const struct rte_ipv6_addr *b, uint8_t depth)
static void rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const struct rte_ipv6_addr *ip)
static bool rte_ipv6_addr_is_loopback(const struct rte_ipv6_addr *ip)
static int rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len, uint16_t *cksum)
static uint16_t rte_be_to_cpu_16(rte_be16_t x)
struct rte_ipv6_addr dst_addr
static bool rte_ipv6_addr_is_sitelocal(const struct rte_ipv6_addr *ip)
#define RTE_IPV6_ADDR_SIZE
static bool rte_ipv6_addr_is_v4compat(const struct rte_ipv6_addr *ip)
static uint16_t rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)