title: how xdp ebpf change checksum tcphdr after update dest port
body: <p>how xdp ebpf change checksum tcphdr after update dest port ? </p>
  
  <pre class="lang-c prettyprint-override"><code>// Check tcp header size
  struct tcphdr *tcph = data + nh_off;
  nh_off += sizeof(struct tcphdr);
  if (data + nh_off &gt; data_end) {
      return XDP_PASS;
  }
  tcph-&gt;dest = bpf_ntohs(5555);
  // ... i'm trying change checksum of tcphdr, it's not work for me. 
  tcph-&gt;check = 0;
  tcph-&gt;check = checksum((unsigned short *)tcph, sizeof(struct tcphdr));
  
  return XDP_TX;
  </code></pre>
  
  <p>this is the function code with which i am trying to change the checksum of a tcp packet</p>
  
  <pre class="lang-c prettyprint-override"><code>static inline unsigned short checksum(unsigned short *buf, int bufsz) {
      unsigned long sum = 0;
  
      while (bufsz &gt; 1) {
          sum += *buf;
          buf++;
          bufsz -= 2;
      }
  
      if (bufsz == 1) {
          sum += *(unsigned char *)buf;
      }
  
      sum = (sum &amp; 0xffff) + (sum &gt;&gt; 16);
      sum = (sum &amp; 0xffff) + (sum &gt;&gt; 16);
  
      return ~sum;
  }
  </code></pre>
  
  <p>I load an xdp program for the <code>lo</code> interface, and I want to proxy the packet to port 5555 in the same network interface. </p>