On Fri, 2002-08-02 at 14:50, Jeremy Andrus wrote:
> OK. I've written some code based on Trevor Hamm's suggestions, but it
> segfaults. Here's what I have:
>
> ----- BEGIN CODE -----
[...]
>
> printk("making dword . . .\n");
> in.s_addr = ifa->ifa_local;
> pci_ip_dword = (unsigned long)in.s_addr;
> pci_ip_dword = (pci_ip_dword << 15);
> pci_ip_dword = (pci_ip_dword & 0x7F800000);
> printk("My IP address dword is: %lx\n", (unsigned long)pci_ip_dword);
>
> ----- END CODE -----
I'm not sure exactly what you're trying to do with the IP address here,
but remember that the IP address in ifa_local is in network byte order.
Perhaps making the initial assignment to pci_ip_dword as:
pci_ip_dword = ntohl(in.s_addr);
will give you the expected result.
>
> When I modprobe my netfilter target, dmesg has this in it:
>
> ----- BEGIN DMESG DUMP -----
> Looking for 'eth0' . . .
> making dword . . .
> My IP address dword is: 54000000
> making a note of it . . .
> Unable to handle kernel NULL pointer dereference at virtual address
> 00000011
> printing eip:
> e0840a02
> *pde = 00000000
> Oops: 0002
> CPU: 0
> EIP: 0010:[<e0840a02>] Not tainted
> EFLAGS: 00010286
> eax: 00000001 ebx: e08480b0 ecx: 30687465 edx: 00000001
> esi: 00000070 edi: e0848040 ebp: 00000000 esp: def73d74
> ds: 0018 es: 0018 ss: 0018
> Process iptables (pid: 102, stackpage=def73000)
> Stack: def73e08 e0848040 e08480d0 00000000 00000002 00000000 00000163
> e084a040
> 00000000 def73dc0 e084b000 c0126c4f def73dc0 00000000 e084833c
> e0848040
> 00000000 0004b000 00000000 00000000 e0841149 def73e08 0000000e
> e0848000
> Call Trace: [<c0126c4f>] [<e0841149>] [<e084161b>] [<e0842880>]
> [<c01bf540>]
> [<c01bf5a2>] [<c01cabef>] [<c010ff03>] [<c01e0318>] [<c01e5c7a>]
> [<c01b42f1>]
> [<c01b4996>] [<c0106c5b>]
>
> Code: ff 40 10 8b 42 34 80 48 14 18 89 53 04 b9 80 27 84 e0 ff 05
>
> ----- END DMESG DUMP -----
>
If possible, try inputting the Oops message into ksymoops (see the man
page for ksymoops), which will attempt to translate those cryptic
numbers into meaningful symbol names. That should hopefully give you a
better idea of where the problem lies. (From your DMESG DUMP, it looks
like the faulty code lies somewhere after your printk("making a note of
it...") statement, which doesn't show up in your code snippet.)
--
Trevor Hamm
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/