Lines Matching refs:encap

273 static ret_t accept_locally(struct __sk_buff *skb, encap_headers_t *encap)
276 sizeof(*encap) +
277 sizeof(struct in_addr) * encap->unigue.hop_count;
281 if (encap->gue.proto_ctype == IPPROTO_IPV6)
282 encap->eth.h_proto = bpf_htons(ETH_P_IPV6);
294 encap_headers_t *encap, struct in_addr *next_hop,
298 sizeof(*encap) +
299 sizeof(struct in_addr) * encap->unigue.hop_count;
316 if (encap->gue.proto_ctype == IPPROTO_IPV6) {
421 encap_headers_t *encap, struct in_addr *next_hop,
430 memcpy(temp, encap->eth.h_dest, sizeof(temp));
431 memcpy(encap->eth.h_dest, encap->eth.h_source,
432 sizeof(encap->eth.h_dest));
433 memcpy(encap->eth.h_source, temp, sizeof(encap->eth.h_source));
435 if (encap->unigue.next_hop == encap->unigue.hop_count - 1 &&
436 encap->unigue.last_hop_gre) {
437 return forward_with_gre(skb, dynptr, encap, next_hop, metrics);
441 uint32_t old_saddr = encap->ip.saddr;
442 encap->ip.saddr = encap->ip.daddr;
443 encap->ip.daddr = next_hop->s_addr;
444 if (encap->unigue.next_hop < encap->unigue.hop_count) {
445 encap->unigue.next_hop++;
449 const uint64_t off = offsetof(typeof(*encap), ip.check);
477 static ret_t get_next_hop(struct bpf_dynptr *dynptr, __u64 *offset, encap_headers_t *encap,
480 if (encap->unigue.next_hop > encap->unigue.hop_count)
484 MAYBE_RETURN(skip_next_hops(offset, encap->unigue.next_hop));
486 if (encap->unigue.next_hop == encap->unigue.hop_count) {
498 return skip_next_hops(offset, encap->unigue.hop_count - encap->unigue.next_hop - 1);
860 encap_headers_t *encap;
865 if (bpf_skb_pull_data(skb, sizeof(*encap)))
868 encap = bpf_dynptr_slice_rdwr(&dynptr, 0, encap_buffer, sizeof(encap_buffer));
869 if (!encap)
872 off += sizeof(*encap);
874 if (encap->ip.ihl != 5)
878 if (encap->ip.daddr != ENCAPSULATION_IP ||
879 encap->ip.protocol != IPPROTO_UDP)
883 if (encap->udp.dest != ENCAPSULATION_PORT)
889 if (ipv4_is_fragment((void *)&encap->ip)) {
894 if (encap->gue.variant != 0) {
899 if (encap->gue.control != 0) {
904 if (encap->gue.flags != 0) {
909 if (encap->gue.hlen !=
910 sizeof(encap->unigue) / 4 + encap->unigue.hop_count) {
915 if (encap->unigue.version != 0) {
920 if (encap->unigue.reserved != 0)
923 MAYBE_RETURN(get_next_hop(&dynptr, &off, encap, &next_hop));
927 return accept_locally(skb, encap);
931 switch (encap->gue.proto_ctype) {
951 return forward_to_next_hop(skb, &dynptr, encap, &next_hop, metrics);
958 if (encap->unigue.forward_syn) {
959 return forward_to_next_hop(skb, &dynptr, encap, &next_hop,
975 ret = accept_locally(skb, encap);
977 if (encap == encap_buffer)