Lines Matching refs:encap

271 static ret_t accept_locally(struct __sk_buff *skb, encap_headers_t *encap)  in accept_locally()  argument
274 sizeof(*encap) + in accept_locally()
275 sizeof(struct in_addr) * encap->unigue.hop_count; in accept_locally()
279 if (encap->gue.proto_ctype == IPPROTO_IPV6) in accept_locally()
280 encap->eth.h_proto = bpf_htons(ETH_P_IPV6); in accept_locally()
292 encap_headers_t *encap, struct in_addr *next_hop, in forward_with_gre() argument
296 sizeof(*encap) + in forward_with_gre()
297 sizeof(struct in_addr) * encap->unigue.hop_count; in forward_with_gre()
314 if (encap->gue.proto_ctype == IPPROTO_IPV6) { in forward_with_gre()
419 encap_headers_t *encap, struct in_addr *next_hop, in forward_to_next_hop() argument
428 memcpy(temp, encap->eth.h_dest, sizeof(temp)); in forward_to_next_hop()
429 memcpy(encap->eth.h_dest, encap->eth.h_source, in forward_to_next_hop()
430 sizeof(encap->eth.h_dest)); in forward_to_next_hop()
431 memcpy(encap->eth.h_source, temp, sizeof(encap->eth.h_source)); in forward_to_next_hop()
433 if (encap->unigue.next_hop == encap->unigue.hop_count - 1 && in forward_to_next_hop()
434 encap->unigue.last_hop_gre) { in forward_to_next_hop()
435 return forward_with_gre(skb, dynptr, encap, next_hop, metrics); in forward_to_next_hop()
439 uint32_t old_saddr = encap->ip.saddr; in forward_to_next_hop()
440 encap->ip.saddr = encap->ip.daddr; in forward_to_next_hop()
441 encap->ip.daddr = next_hop->s_addr; in forward_to_next_hop()
442 if (encap->unigue.next_hop < encap->unigue.hop_count) { in forward_to_next_hop()
443 encap->unigue.next_hop++; in forward_to_next_hop()
447 const uint64_t off = offsetof(typeof(*encap), ip.check); in forward_to_next_hop()
475 static ret_t get_next_hop(struct bpf_dynptr *dynptr, __u64 *offset, encap_headers_t *encap, in get_next_hop() argument
478 if (encap->unigue.next_hop > encap->unigue.hop_count) in get_next_hop()
482 MAYBE_RETURN(skip_next_hops(offset, encap->unigue.next_hop)); in get_next_hop()
484 if (encap->unigue.next_hop == encap->unigue.hop_count) { in get_next_hop()
496 return skip_next_hops(offset, encap->unigue.hop_count - encap->unigue.next_hop - 1); in get_next_hop()
858 encap_headers_t *encap; in cls_redirect() local
863 if (bpf_skb_pull_data(skb, sizeof(*encap))) in cls_redirect()
866 encap = bpf_dynptr_slice_rdwr(&dynptr, 0, encap_buffer, sizeof(encap_buffer)); in cls_redirect()
867 if (!encap) in cls_redirect()
870 off += sizeof(*encap); in cls_redirect()
872 if (encap->ip.ihl != 5) in cls_redirect()
876 if (encap->ip.daddr != ENCAPSULATION_IP || in cls_redirect()
877 encap->ip.protocol != IPPROTO_UDP) in cls_redirect()
881 if (encap->udp.dest != ENCAPSULATION_PORT) in cls_redirect()
887 if (ipv4_is_fragment((void *)&encap->ip)) { in cls_redirect()
892 if (encap->gue.variant != 0) { in cls_redirect()
897 if (encap->gue.control != 0) { in cls_redirect()
902 if (encap->gue.flags != 0) { in cls_redirect()
907 if (encap->gue.hlen != in cls_redirect()
908 sizeof(encap->unigue) / 4 + encap->unigue.hop_count) { in cls_redirect()
913 if (encap->unigue.version != 0) { in cls_redirect()
918 if (encap->unigue.reserved != 0) in cls_redirect()
921 MAYBE_RETURN(get_next_hop(&dynptr, &off, encap, &next_hop)); in cls_redirect()
925 return accept_locally(skb, encap); in cls_redirect()
929 switch (encap->gue.proto_ctype) { in cls_redirect()
949 return forward_to_next_hop(skb, &dynptr, encap, &next_hop, metrics); in cls_redirect()
956 if (encap->unigue.forward_syn) { in cls_redirect()
957 return forward_to_next_hop(skb, &dynptr, encap, &next_hop, in cls_redirect()
973 ret = accept_locally(skb, encap); in cls_redirect()
975 if (encap == encap_buffer) in cls_redirect()