Skip to contentSkip to conversation

Do and Don'ts for socket programming from kernel module/kernel-thread

DISCUSSION Nalin Gupta 1 participant 1 message Mar 20, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Dear Srinivas,

If you refer the oops msg I posted.

http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0437.html

Probably, I am at mistake, as I am calling "sock_sendmsg" for UDP socket. from my netdevice::hard_start_xmit (micdev_xmit) function.

What is my mistake is not clear to me ?

Further, as we know netdevice::hard_start_xmit function is called through Net Tx Tasklet function net_tx_action through do_softirq.

I am just taking care masking __GFP_WAIT for sock->sk->allocation. I also tried by merely assigned GFP_ATOMIC.

And also set MSG_DONTWAIT flag for "msg" parameter to sock_sendmsg.

Do I need to disable interrupts too.
I was assuming that "local_irq_save" in skb_head_from_pool will take care.

I recompiled kernel with quite a few printk, but it seems only my invocation to sock_sendmsg cause this panic.

thanks,
regards,
- nalin

Quoted 114 lines · v.nagasrinivas

Hi Nalin,

I am just putting my idea , like inline function you
are mentioning
from the header file, could you copy and make it as a macro in that header file
and the original inline function you put like commenting for the time being..
and in the macro just

---------------------------------------------------------
extern __inline__ struct sk_buff *__skb_dequeue(struct sk_buff_head *list)

{
        struct sk_buff *next, *prev, *result;

        prev = (struct sk_buff *) list;
        next = prev->next;
        result = NULL;
        if (next != prev) {
                result = next;
                next = next->next;
                list->qlen--;
                next->prev = prev;
                prev->next = next;
                result->next = NULL;
                result->prev = NULL;
                result->list = NULL;
        }
        return result;
}

extern struct sk_buff *__skb_dequeue(struct sk_buff_head *list)\

{\
        struct sk_buff *next, *prev, *result;\

        prev = (struct sk_buff *) list;\
        printk("%d%s", __LINE__ ,  __FILE__);  <----like this some more
also.......
        next = prev->next;\
        result = NULL;\
        if (next != prev) {\
                result = next;\
                next = next->next;\
                list->qlen--;\
                next->prev = prev;\
                prev->next = next;\
                result->next = NULL;\
                result->prev = NULL;\
                result->list = NULL;\
        }\
        return result;\
}\

will give actually at what line and which file is causing causing the problem..
So can debug the problem easily..

I am waiting to hear if this works out....to solve the problem.....

regards,
srinivas.

Path: uni-berlin.de!fu-berlin.de!bofh.it!robomod
From: <[email protected]>
Newsgroups: linux.kernel
Subject: Do and Don'ts for socket programming from kernel module/kernel-thread
Date: Thu, 20 Mar 2003 07:10:06 +0100
Message-ID: <[email protected]>
X-Mailer: TWIG 2.7.4
X-Client-IP: 202.9.179.70
Sender: [email protected]
X-Mailing-List: [email protected]
Approved: [email protected]
Organization: linux.* mail to news gateway
X-Original-Date: Thu, 20 Mar 2003 06:04:02 -0000
X-Original-Message-ID: <[email protected]>
X-Original-Sender: [email protected]
X-Original-To: <[email protected]>
Xref: uni-berlin.de linux.kernel:120670

Friends,

Where could I find some tips and tricks for correctly doing socket programming from a kernel module and a kernel thread.

I am totally stuck and not able to proceed.

I am invariably getting kernel panic from __skb_dequeue inline function called from alloc_skb.

In detail I posted following mail, but unfortunately it could not attract anyones attention.

Sub : alloc_skb panic oops / virtual network interface
URL:  http://www.uwsg.iu.edu/hypermail/linux/kernel/0303.2/0437.html

Hope to get some response and much need guidance from linux gurus.

thanks in advance,

regards
- nalin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/