LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-09-2011, 02:53 PM   #1
rrlangly
Member
 
Registered: Dec 2009
Posts: 47

Rep: Reputation: 0
proto_ops member is null


My kernel module's proto_ops structure is defined as such ...

Code:
static const struct proto_ops my_proto_ops = {
    ...
    .bind = my_bind,
    .listen = my_listen,
    ...
};
And I have function callbacks for each of these ...

Code:
static int my_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) 
{
    ...
}

static int my_listen(struct socket *sock, int backlog)
{
    ...
}
In my net_proto_family structure's create function I have this line ...

Code:
static int my_create(struct net *net, struct socket *sock, int protocol, int kern)
{
    //...
    sock->ops = &my_proto_ops;

    printk(KERN_INFO "my_proto_ops.bind = %p\n", my_proto_ops.bind);
    printk(KERN_INFO "my_proto_ops.listen = %p\n", my_proto_ops.listen);
    //...
}
which prints this output in /var/log/messages when run ...
my_proto_ops.bind = ffffffffa00001c5
my_proto_ops.listen = ffffffffa00000000

What I don't understand is why I see bind w/ a valid address, and the listen is null. This is exactly what I run into when I'm running my kernel module, my_bind is called, but my_listen fails with ...
BUG: unable to handle kernel NULL pointer dereference at 0000000000000040
IP: [<ffffffff81417397>] sys_listen+0x29/0x70
PGD 1edd7067 PUD 1f099067 PMD 0
Oops: 0000 [#1] SMP
last sysfs file: /sys/devices/virtio-pci/virtio0/net/net0/broadcast
CPU 0

my_bind() exits successfully when run, but then it crashes and my_listen is never even called, which seems to be the case as my_proto_ops.listen is null so it therefore can't be called. But I don't see how as "my_proto_ops.listen = my_listen," and "sock->ops = &my_proto_ops" in the create function.


Can anyone help clarify what might be going on? Any help much appreciated.
 
Old 04-09-2011, 06:08 PM   #2
rrlangly
Member
 
Registered: Dec 2009
Posts: 47

Original Poster
Rep: Reputation: 0
I called sk_alloc() and sock_init_data() and that seems to have solved it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/usr/sbin/in.telnetd: getpeername: Socket operation on non-socket vnaveen Linux - Networking 1 05-05-2009 04:42 AM
Can't connect to UNIX socket /var/run/clamav/clamd.socket ganick Linux - Server 8 08-01-2008 01:22 PM
AF_LOCAL domain socket versus AF_INET socket performance zzaappp Linux - General 0 06-19-2008 07:50 AM
cannot read data at server socket, though client socket sends it jacques83 Linux - Networking 0 11-15-2005 01:58 PM
Unable to connect to UNIX socket /tmp/.esd/socket error while using grip dr_zayus69 Linux - Software 4 08-23-2005 07:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration