All of lore.kernel.org
 help / color / mirror / Atom feed
* nfhook, sk_buff and change data
@ 2006-03-12 14:40 nebi senol yilmaz
  2006-03-12 14:46 ` Patrick McHardy
  0 siblings, 1 reply; 3+ messages in thread
From: nebi senol yilmaz @ 2006-03-12 14:40 UTC (permalink / raw)
  To: netfilter-devel


hello;

i've a problem about sk_buff checksum (tcp checksum).

I've coded a kernel module that makes some changes at some packets ,
which are read at NF_IP_FORWARD hook.
My module changes data of the packetand returns  NF_ACCEPT...

but the packet with changed data can not be accepted by the target
machine.

i'm calculating both ip header checksum and tcp checksum, but still
i've problem..

does anybody know about my problem? can you give me some advice
whether you have  any solutions about it.


related piece of code is below:


===================
unsigned int hook_pool(unsigned int hooknum,
                               struct sk_buff **skb,
                               const struct net_device *in,
                               const struct net_device *out,
                               int (*okfn)(struct sk_buff*)){



       struct tcphdr *tcp;
       char *data;
       struct sk_buff *sock_buff;
       int i=0;
       char *findGzip;

       sock_buff=*skb;

       tcp = (struct tcphdr *)(sock_buff->data + (sock_buff->nh.iph->ihl * 4));
       data = (char *)((int)tcp + (int)(tcp->doff * 4));


       if (findGzip=(strstr(data,"senol1763"))){
               printk("%d Data CheckSum 1 = %u\n",hooknum,sock_buff->csum);
               printk("%d TCP CheckSum 1 = %u\n",hooknum,sock_buff->h.th->check);
               printk("%d IP CheckSum 1 = %u\n",hooknum,sock_buff->nh.iph->check);
               printk("\n");

               findGzip[1]='n'; /* when i find a related str, i change a char*/
/* here, i'm calculating ne csum.*/
               sock_buff->h.th->check=0;
sock_buff->h.th->check=in_cksum_tcp(sock_buff->nh.iph->saddr,sock_buff->nh.iph->daddr,(unsigned short *)sock_buff->h.th , sizeof(*sock_buff->h.th) );

        }

return NF_ACCEPT;
}
===================


thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-03-12 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-12 14:40 nfhook, sk_buff and change data nebi senol yilmaz
2006-03-12 14:46 ` Patrick McHardy
2006-03-12 14:59   ` nebi senol yilmaz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.