Modify tcp header in ipf_output / ipf_input callbacks

Hi,


I'm trying to modify the tcp header in the ipf_output or ipf_input callbacks. The code looks something like this:


struct tcphdr *tcphdr;
struct ip   *iphdr;

iphdr = (struct ip*)mbuf_data(*data);
tcphdr = (struct tcphdr*)((char*)mbuf_data(*data)+sizeof(*iphdr));

if(send_fin){
     tcphdr->th_flags |= TH_FIN;
     buf_outbound_finalize(*data, AF_INET, sizeof(*iphdr));
     ipf_inject_output(*data, s_ip4_ref, options);
     return EJUSTRETURN;
}

return 0;
}


FIN flag is ignored, even thogh the send_fin is true and ipf_reinject_output returns 0.

I checked with Wireshark and indeed, the FIN packet is not set. What should I do in order to correctly modify IP or TCP headers?


Thanks