From: Patrick McHardy <kaber@trash.net>
To: nebi senol yilmaz <nsyilmaz@metu.edu.tr>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: nfhook, sk_buff and change data
Date: Sun, 12 Mar 2006 15:46:03 +0100 [thread overview]
Message-ID: <4414342B.2060709@trash.net> (raw)
In-Reply-To: <Pine.A41.4.58.0603121634310.753742@beluga.user.services.metu.edu.tr>
nebi senol yilmaz wrote:
> 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) );
In the FORWARD hook skb->h.th doesn't point to the TCP header.
next prev parent reply other threads:[~2006-03-12 14:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-12 14:40 nfhook, sk_buff and change data nebi senol yilmaz
2006-03-12 14:46 ` Patrick McHardy [this message]
2006-03-12 14:59 ` nebi senol yilmaz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4414342B.2060709@trash.net \
--to=kaber@trash.net \
--cc=netfilter-devel@lists.netfilter.org \
--cc=nsyilmaz@metu.edu.tr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.