Lines Matching full:tcp

369 	struct tcphdr *tcp;  member
395 hdr->tcp = (void *)hdr->ipv4 + hdr->ipv4->ihl * 4; in tcp_dissect()
412 hdr->tcp = (void *)hdr->ipv6 + sizeof(*hdr->ipv6); in tcp_dissect()
419 if (hdr->tcp + 1 > data_end) in tcp_dissect()
421 hdr->tcp_len = hdr->tcp->doff * 4; in tcp_dissect()
422 if (hdr->tcp_len < sizeof(*hdr->tcp)) in tcp_dissect()
439 /* TCP doesn't normally use fragments, and XDP can't reassemble in tcp_lookup()
447 tup.ipv4.sport = hdr->tcp->source; in tcp_lookup()
448 tup.ipv4.dport = hdr->tcp->dest; in tcp_lookup()
453 tup.ipv6.sport = hdr->tcp->source; in tcp_lookup()
454 tup.ipv6.dport = hdr->tcp->dest; in tcp_lookup()
550 tcp_gen_synack(hdr->tcp, cookie, tsopt, mss, wscale); in tcpv4_gen_synack()
552 hdr->tcp_len = hdr->tcp->doff * 4; in tcpv4_gen_synack()
571 tcp_gen_synack(hdr->tcp, cookie, tsopt, mss, wscale); in tcpv6_gen_synack()
573 hdr->tcp_len = hdr->tcp->doff * 4; in tcpv6_gen_synack()
605 /* Checksum is not yet verified, but both checksum failure and TCP in syncookie_handle_syn()
608 if (hdr->tcp->fin || hdr->tcp->rst) in syncookie_handle_syn()
614 if (!check_port_allowed(bpf_ntohs(hdr->tcp->dest))) in syncookie_handle_syn()
618 /* Check the IPv4 and TCP checksums before creating a SYNACK. */ in syncookie_handle_syn()
625 value = bpf_csum_diff(0, 0, (void *)hdr->tcp, hdr->tcp_len, 0); in syncookie_handle_syn()
630 return XDP_DROP; /* Bad TCP checksum. */ in syncookie_handle_syn()
634 value = bpf_tcp_raw_gen_syncookie_ipv4(hdr->ipv4, hdr->tcp, in syncookie_handle_syn()
637 /* Check the TCP checksum before creating a SYNACK. */ in syncookie_handle_syn()
638 value = bpf_csum_diff(0, 0, (void *)hdr->tcp, hdr->tcp_len, 0); in syncookie_handle_syn()
643 return XDP_DROP; /* Bad TCP checksum. */ in syncookie_handle_syn()
647 value = bpf_tcp_raw_gen_syncookie_ipv6(hdr->ipv6, hdr->tcp, in syncookie_handle_syn()
657 if (tscookie_init((void *)hdr->tcp, hdr->tcp_len, in syncookie_handle_syn()
673 __builtin_memmove(new_tcp_header, hdr->tcp, sizeof(*hdr->tcp)); in syncookie_handle_syn()
674 hdr->tcp = new_tcp_header; in syncookie_handle_syn()
687 hdr->tcp->check = 0; in syncookie_handle_syn()
688 value = bpf_csum_diff(0, 0, (void *)hdr->tcp, hdr->tcp_len, 0); in syncookie_handle_syn()
692 hdr->tcp->check = csum_tcpudp_magic(hdr->ipv4->saddr, in syncookie_handle_syn()
704 hdr->tcp->check = csum_ipv6_magic(&hdr->ipv6->saddr, in syncookie_handle_syn()
715 new_pkt_size = sizeof(*hdr->eth) + ip_len + hdr->tcp->doff * 4; in syncookie_handle_syn()
733 if (hdr->tcp->rst) in syncookie_handle_ack()
737 err = bpf_tcp_raw_check_syncookie_ipv4(hdr->ipv4, hdr->tcp); in syncookie_handle_ack()
739 err = bpf_tcp_raw_check_syncookie_ipv6(hdr->ipv6, hdr->tcp); in syncookie_handle_ack()
761 /* Packet is TCP and doesn't belong to an established connection. */ in syncookie_part1()
763 if ((hdr->tcp->syn ^ hdr->tcp->ack) != 1) in syncookie_part1()
766 /* Grow the TCP header to TCP_MAXLEN to be able to pass any hdr->tcp_len in syncookie_part1()
796 hdr->tcp = (void *)hdr->ipv4 + hdr->ipv4->ihl * 4; in syncookie_part2()
800 hdr->tcp = (void *)hdr->ipv6 + sizeof(*hdr->ipv6); in syncookie_part2()
805 if ((void *)hdr->tcp + TCP_MAXLEN > data_end) in syncookie_part2()
811 hdr->tcp_len = hdr->tcp->doff * 4; in syncookie_part2()
812 if (hdr->tcp_len < sizeof(*hdr->tcp)) in syncookie_part2()
815 return hdr->tcp->syn ? syncookie_handle_syn(hdr, ctx, data, data_end, xdp) : in syncookie_part2()