netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ratheesh k <ratheesh.ksz@gmail.com>
To: Netfilter mailing list <netfilter@vger.kernel.org>
Subject: printk mac address --hangs
Date: Thu, 13 May 2010 21:15:41 +0530	[thread overview]
Message-ID: <AANLkTinl1GZIOHaxfD7WgXPc2miKkRi3MDkkcaW4P6Zj@mail.gmail.com> (raw)

Why this program cause kernel crash ? , If i comment out "memcpy " ,
it works fine


*******************************************************************************************
 #include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
# include <linux/skbuff.h>

# include <linux/ip.h>
# include <linux/tcp.h>
MODULE_LICENSE("Dual BSD/GPL");

#define NF_IP_LOCAL_OUT     3


/* This is the structure we shall use to register our function */

static struct nf_hook_ops nfho;

/* This is the hook function itself */
unsigned int hook_func(unsigned int hooknum,
                       struct sk_buff *skb,
                       const struct net_device *in,
                       const struct net_device *out,
                       int (*okfn)(struct sk_buff *))
{
    struct iphdr* ip_header;
    struct tcphdr* tcp_header;
    struct ethhdr * eth_header ;
    char src[ETH_ALEN+2];
    char dst[ETH_ALEN+2];
      src[ETH_ALEN+1]='\0';
      dst[ETH_ALEN+1]='\0' ;

     ip_header  = ip_hdr(skb);
    tcp_header = tcp_hdr(skb);
    eth_header = eth_hdr(skb);


      memcpy(src , eth_header->h_source , ETH_ALEN );
      memcpy(dst , eth_header->h_dest , ETH_ALEN );

    return NF_ACCEPT;           /* Drop ALL packets */
}

/* Initialisation routine */
int init_module()
{
    /* Fill in our hook structure */
    nfho.hook = hook_func;         /* Handler function */

    nfho.hooknum  = NF_IP_LOCAL_OUT; /* First hook for IPv4 */

    nfho.pf       = PF_INET;

    nfho.priority = NF_IP_PRI_FIRST;   /* Make our function first */

    nf_register_hook(&nfho);

    return 0;
}
	
/* Cleanup routine */
void cleanup_module()
{
    nf_unregister_hook(&nfho);
}
***********************************

             reply	other threads:[~2010-05-13 15:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13 15:45 ratheesh k [this message]
2010-05-13 16:19 ` printk mac address --hangs Jan Engelhardt
2010-05-13 17:07   ` ratheesh k
2010-05-13 17:16     ` Jan Engelhardt
2010-05-13 17:24       ` ratheesh k
2010-05-13 19:26         ` Jan Engelhardt
2010-05-14  2:37           ` ratheesh k
2010-05-14  3:41             ` ratheesh k

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=AANLkTinl1GZIOHaxfD7WgXPc2miKkRi3MDkkcaW4P6Zj@mail.gmail.com \
    --to=ratheesh.ksz@gmail.com \
    --cc=netfilter@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).