All of lore.kernel.org
 help / color / mirror / Atom feed
From: KOVACS Krisztian <hidden@sch.bme.hu>
To: netfilter-devel@lists.netfilter.org
Subject: Re: REGISTERING with netfilter hooks - strange behaviour
Date: Mon, 30 Jul 2007 09:44:14 +0200	[thread overview]
Message-ID: <20070730074414.GA10785@sch.bme.hu> (raw)
In-Reply-To: <885896af0707260804l18b7019ai399026d0a8906fe4@mail.gmail.com>


  Hi,

On cs, júl 26, 2007 at 05:04:37 +0200, Giacomo wrote:
> /* THIS IS THE CALLBACK registered by nf_register_hook() */
> unsigned int
> deliver_process_by_direction(unsigned int hooknum,
> 		struct sk_buff **skb,
> 		const struct net_device *in,
> 		const struct net_device *out,
> 		int (*okfn) (struct sk_buff *))
> {
> 	struct tcphdr* tcph;
> 	struct iphdr *iph;
> 	if(*skb != NULL)
> 	{
> 		iph = (struct iphdr*) skb_network_header(*skb);
> 		if(iph != NULL)
> 		{
> 			if (iph->protocol == IPPROTO_TCP)
> 			{
> 				tcph = (struct tcphdr 
> 				*)skb_transport_header(*skb);
> 				printk("SOURCE: %d - DEST: %d ",
> 				       ntohs(tcph->source), 
> 				       ntohs(tcph->dest) );
> 			}
> 		}
> 	}
> 
> 
> /* THE printk() writes  values  that look like they were uninitialized */
> THe same happens with
> 
> ip_hdr(*skb)
> and tcp_hdr();
> 
> This happens in NF_PRE and NF_IN

  I guess the transport header pointer is not initialized properly when
you're checking for it. I don't exactly know how it behaves after
Arnaldo's changes, but skb->th.* used to be invalid on PREROUTING.

-- 
KOVACS Krisztian

  reply	other threads:[~2007-07-30  7:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-26 15:04 REGISTERING with netfilter hooks - strange behaviour Giacomo
2007-07-30  7:44 ` KOVACS Krisztian [this message]
2007-07-30  7:52   ` Giacomo

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=20070730074414.GA10785@sch.bme.hu \
    --to=hidden@sch.bme.hu \
    --cc=netfilter-devel@lists.netfilter.org \
    /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.