> char path[1024]; Probably your array is overflowing the stack. - KK |---------+-------------------------------> | | "Adam Flizikowski" | | | <adam_fli@poczta.one| | | t.pl> | | | Sent by: | | | linux-net-owner@vger| | | .kernel.org | | | | | | | | | 07/13/2003 10:05 AM | | | | |---------+-------------------------------> >-----------------------------------------------------------------------------------------------------------------| | | | To: <linux-net@vger.kernel.org> | | cc: | | Subject: dev.c question - 100 points for one who knows where is the problem | | | >-----------------------------------------------------------------------------------------------------------------| Hi, i am fithting with this all day. i have modified dev.c code to be able to dump some details on packet processing. I did this in the code: ... added include after the original includes block // ********************************************* #include <asm/spinlock.h> // ********************************************* ... somewhere in the file i put // ********************************************* #define ELEMENT_MAX 256 #define write(f, buf, sz) (f->f_op->write(f, buf, sz, &f->f_pos)) struct element { int data[16]; }; struct element *ptr; unsigned int c_element = 0; int c_swap = 0; void af_add(struct element t) { int i; struct file *f; char path[1024]; spinlock_t af_add_lock = SPIN_LOCK_UNLOCKED; spin_lock(&af_add_lock); if (!c_swap) { c_swap = 1; ptr = kmalloc(ELEMENT_MAX * sizeof(struct element), GFP_KERNEL); if (!ptr) { printk("nie moge zaalokowac wystarczajacej ilosci pamieci..\n"); c_swap = 0; } } if ((c_element + 1) != ELEMENT_MAX) memcpy(ptr + c_element, &t, sizeof(struct element)); else { set_fs(KERNEL_DS); // snprintf(path, sizeof(path), "/tmp/log-%d", c_swap); snprintf(path, sizeof(path), "/tmp/dumplog"); f = filp_open(path, O_CREAT | O_APPEND, 00600); printk("write: %d\n", write(f, (void *) ptr, sizeof(struct element) * ELEMENT_MAX)); filp_close(f, 0); set_fs(USER_DS); c_element = 0; } c_element++; spin_unlock(&af_add_lock); } // ********************************************* ..and finally put a call to af_add function inside >int __init net_dev_init(void){}< function int __init net_dev_init(void) { .... struct element test; int ii; for(ii=0; ii<4; ii+)af_add(test); //**************************** af_add function should put some test values into kmallocated memory, but when there is no room in the memory it should do kind of swap.... When i recompile kernel, while booting i get kernel oops saying: that it failed before >>f = filp_open(path, O_CREAT | O_APPEND, 00600); line. (i just put printk() before this line, so this is the last information that is printed to stdout). PLEASE help regards adam - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html