Lines Matching full:tcp
371 struct tcphdr *tcp; member
397 hdr->tcp = (void *)hdr->ipv4 + hdr->ipv4->ihl * 4; in tcp_dissect()
414 hdr->tcp = (void *)hdr->ipv6 + sizeof(*hdr->ipv6); in tcp_dissect()
421 if (hdr->tcp + 1 > data_end) in tcp_dissect()
423 hdr->tcp_len = hdr->tcp->doff * 4; in tcp_dissect()
424 if (hdr->tcp_len < sizeof(*hdr->tcp)) in tcp_dissect()
441 /* TCP doesn't normally use fragments, and XDP can't reassemble in tcp_lookup()
449 tup.ipv4.sport = hdr->tcp->source; in tcp_lookup()
450 tup.ipv4.dport = hdr->tcp->dest; in tcp_lookup()
455 tup.ipv6.sport = hdr->tcp->source; in tcp_lookup()
456 tup.ipv6.dport = hdr->tcp->dest; in tcp_lookup()
552 tcp_gen_synack(hdr->tcp, cookie, tsopt, mss, wscale); in tcpv4_gen_synack()
554 hdr->tcp_len = hdr->tcp->doff * 4; in tcpv4_gen_synack()
573 tcp_gen_synack(hdr->tcp, cookie, tsopt, mss, wscale); in tcpv6_gen_synack()
575 hdr->tcp_len = hdr->tcp->doff * 4; in tcpv6_gen_synack()
607 /* Checksum is not yet verified, but both checksum failure and TCP in syncookie_handle_syn()
610 if (hdr->tcp->fin || hdr->tcp->rst) in syncookie_handle_syn()
616 if (!check_port_allowed(bpf_ntohs(hdr->tcp->dest))) in syncookie_handle_syn()
620 /* Check the IPv4 and TCP checksums before creating a SYNACK. */ in syncookie_handle_syn()
627 value = bpf_csum_diff(0, 0, (void *)hdr->tcp, hdr->tcp_len, 0); in syncookie_handle_syn()
632 return XDP_DROP; /* Bad TCP checksum. */ in syncookie_handle_syn()
636 value = bpf_tcp_raw_gen_syncookie_ipv4(hdr->ipv4, hdr->tcp, in syncookie_handle_syn()
639 /* Check the TCP checksum before creating a SYNACK. */ in syncookie_handle_syn()
640 value = bpf_csum_diff(0, 0, (void *)hdr->tcp, hdr->tcp_len, 0); in syncookie_handle_syn()
645 return XDP_DROP; /* Bad TCP checksum. */ in syncookie_handle_syn()
649 value = bpf_tcp_raw_gen_syncookie_ipv6(hdr->ipv6, hdr->tcp, in syncookie_handle_syn()
659 if (tscookie_init((void *)hdr->tcp, hdr->tcp_len, in syncookie_handle_syn()
675 __builtin_memmove(new_tcp_header, hdr->tcp, sizeof(*hdr->tcp)); in syncookie_handle_syn()
676 hdr->tcp = new_tcp_header; in syncookie_handle_syn()
689 hdr->tcp->check = 0; in syncookie_handle_syn()
690 value = bpf_csum_diff(0, 0, (void *)hdr->tcp, hdr->tcp_len, 0); in syncookie_handle_syn()
694 hdr->tcp->check = csum_tcpudp_magic(hdr->ipv4->saddr, in syncookie_handle_syn()
706 hdr->tcp->check = csum_ipv6_magic(&hdr->ipv6->saddr, in syncookie_handle_syn()
717 new_pkt_size = sizeof(*hdr->eth) + ip_len + hdr->tcp->doff * 4; in syncookie_handle_syn()
735 if (hdr->tcp->rst) in syncookie_handle_ack()
739 err = bpf_tcp_raw_check_syncookie_ipv4(hdr->ipv4, hdr->tcp); in syncookie_handle_ack()
741 err = bpf_tcp_raw_check_syncookie_ipv6(hdr->ipv6, hdr->tcp); in syncookie_handle_ack()
763 /* Packet is TCP and doesn't belong to an established connection. */ in syncookie_part1()
765 if ((hdr->tcp->syn ^ hdr->tcp->ack) != 1) in syncookie_part1()
768 /* Grow the TCP header to TCP_MAXLEN to be able to pass any hdr->tcp_len in syncookie_part1()
798 hdr->tcp = (void *)hdr->ipv4 + hdr->ipv4->ihl * 4; in syncookie_part2()
802 hdr->tcp = (void *)hdr->ipv6 + sizeof(*hdr->ipv6); in syncookie_part2()
807 if ((void *)hdr->tcp + TCP_MAXLEN > data_end) in syncookie_part2()
813 hdr->tcp_len = hdr->tcp->doff * 4; in syncookie_part2()
814 if (hdr->tcp_len < sizeof(*hdr->tcp)) in syncookie_part2()
817 return hdr->tcp->syn ? syncookie_handle_syn(hdr, ctx, data, data_end, xdp) : in syncookie_part2()