xdp-project / xdp-tutorial

XDP tutorial
2.33k stars 562 forks source link

does anyone know how to do crc32 on ipv6hdr->saddr? #337

Open kolinfluence opened 1 year ago

kolinfluence commented 1 year ago

does anyone know how to do crc32 on ipv6hdr->saddr? i cant convert ipv6hdr->saddr to something crc32 can digest. how shld i do this?

tcphdr->dest = bpf_htons(80 + (ipv6hdr->saddr % nr_cpus));

    if (eth_type == bpf_htons(ETH_P_IP)) {
        ip_type = parse_iphdr(&nh, data_end, &iphdr);

                tcphdr->dest = bpf_htons(80 + (iphdr->saddr % nr_cpus));

    } else if (eth_type == bpf_htons(ETH_P_IPV6)) {

        ip_type = parse_ip6hdr(&nh, data_end, &ipv6hdr);

        //tcphdr->dest = bpf_htons(80 + (ipv6hdr->saddr % nr_cpus));

    }