[clug] help me

=?gb2312?B?uN+35UDN+NLX?= zpeak at 163.com
Fri Apr 25 16:22:27 EST 2003


Hello:
    I program the firewall used the iptable under linux ,The kernel is 2.4.18 ,
I coun't call the system call ,example sys_open ,sys_close, 
The problem is i could't write file ,what can i do ,

the error is :

error .... 
kernel panic :Aiee,killing interrupt handler! 
In interrupt handler - not syncing 

    Please help me ,Thank you .
                                                            yours zpeak 
                                                            

/*-----------------------------------------------------------------------------------------------------
 *Atteched the source and the problem 
----------------------------------------------------------------------------------------------------*/
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif

#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/config.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/spinlock.h>
#include <asm-i386/segment.h>
#include <asm-i386/uaccess.h>
#include <linux/netfilter_ipv4.h>




static unsigned int myfirewall(unsigned int hooknum,struct sk_buff **skb,
  const struct net_device *in,
  const struct net_device *out,int (*okfn)(struct sk_buff*))
{
 mm_segment_t old_fs =get_fs() ;
 mm_segment_t new_fs =get_ds();
 printk("The old fs is [%lu]\n",old_fs.seg) ;
 printk("The neww fs is [%lu]\n ",new_fs.seg) ;

/* I found the old_fs and  new_fs is in the same address  
  * But in other module is different ,why,can you tell me 
*/ 
 
 
 int fd = 0;
 char pathname[50] ="/test/log/8.mail" ;

set_fs(new_fs) ;

 fd = sys_open(pathname,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
 printk("fd is [%d]",fd);
 sys_write(fd,"Mail has develope sucesses , ",20) ; 
 sys_close(fd);
 
set_fs(old_fs) ;
 
 
 return NF_ACCEPT;

}

static struct nf_hook_ops iplimitfilter=
{
 {NULL,NULL},
 myfirewall,
 PF_INET,
 NF_IP_PRE_ROUTING,
 NF_IP_PRI_FILTER
};

int init_module(void)
{
 mm_segment_t old_fs =get_fs() ;
 mm_segment_t new_fs =get_ds();
 printk("The** old fs is [%lu]\n",old_fs.seg) ;
 printk("The** neww fs is [%lu]\n ",new_fs.seg) ;
 return nf_register_hook(&iplimitfilter);
}

void cleanup_module(void)
{
 nf_unregister_hook(&iplimitfilter);
}

------------------------------------------------------------
gcc -D__KERNEL__ -WALL -I /usr/src/linux.2.4.18/include  myfirewall.c 
-------------- next part --------------
3j?Zr??????y??v?????


More information about the linux mailing list