kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* struct sock change in kernel 2.6
@ 2010-12-22  6:17 lijin liu
  2010-12-22 16:31 ` Bharath H S
  0 siblings, 1 reply; 5+ messages in thread
From: lijin liu @ 2010-12-22  6:17 UTC (permalink / raw)
  To: kernelnewbies

Hello everyone!

I am trying to implement a simple tcp server in the kernel. I read the
ktcpvs's source code, but it works under kernel 2.4.

The  struct sock changed in kernel 2.6, I have two questions about the struct:

1. Is sk_wq field in 2.6 equals to sk_sleep field in 2.4?
2. How can I access the tcp accept queue in kernel 2.6? (In kernel
2.4, we could use tp_pinfo.af_tcp.accept_queue, but it was removed in
2.6)


PS: Should sk_receive_queue in the struct sock be used as
tp_pinfo.af_tcp.accept_queue?

Thanks a lot!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* struct sock change in kernel 2.6
  2010-12-22  6:17 struct sock change in kernel 2.6 lijin liu
@ 2010-12-22 16:31 ` Bharath H S
  2010-12-23  0:18   ` lijin liu
  0 siblings, 1 reply; 5+ messages in thread
From: Bharath H S @ 2010-12-22 16:31 UTC (permalink / raw)
  To: kernelnewbies

Hi Lijin liu,
There is sk_sleep function in include/net/sock.h line 1241 This might help.
*- Bharath H S*



On Wed, Dec 22, 2010 at 11:47 AM, lijin liu <llj098@gmail.com> wrote:

> Hello everyone!
>
> I am trying to implement a simple tcp server in the kernel. I read the
> ktcpvs's source code, but it works under kernel 2.4.
>
> The  struct sock changed in kernel 2.6, I have two questions about the
> struct:
>
> 1. Is sk_wq field in 2.6 equals to sk_sleep field in 2.4?
> 2. How can I access the tcp accept queue in kernel 2.6? (In kernel
> 2.4, we could use tp_pinfo.af_tcp.accept_queue, but it was removed in
> 2.6)
>
>
> PS: Should sk_receive_queue in the struct sock be used as
> tp_pinfo.af_tcp.accept_queue?
>
> Thanks a lot!
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20101222/76ae88ec/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* struct sock change in kernel 2.6
  2010-12-22 16:31 ` Bharath H S
@ 2010-12-23  0:18   ` lijin liu
  2010-12-23  5:16     ` Mulyadi Santosa
  0 siblings, 1 reply; 5+ messages in thread
From: lijin liu @ 2010-12-23  0:18 UTC (permalink / raw)
  To: kernelnewbies

Hi Bharath,all,

On Thu, Dec 23, 2010 at 12:31 AM, Bharath H S <bhslinker@gmail.com> wrote:
>
> Hi Lijin liu,
> There is sk_sleep function in include/net/sock.h line 1241 This might help.
> - Bharath H S
>
>
>
> On Wed, Dec 22, 2010 at 11:47 AM, lijin liu <llj098@gmail.com> wrote:
>>
>> Hello everyone!
>>
>> I am trying to implement a simple tcp server in the kernel. I read the
>> ktcpvs's source code, but it works under kernel 2.4.
>>
>> The ?struct sock changed in kernel 2.6, I have two questions about the struct:
>>
>> 1. Is sk_wq field in 2.6 equals to sk_sleep field in 2.4?
>> 2. How can I access the tcp accept queue in kernel 2.6? (In kernel
>> 2.4, we could use tp_pinfo.af_tcp.accept_queue, but it was removed in
>> 2.6)
>>
>>
>> PS: Should sk_receive_queue in the struct sock be used as
>> tp_pinfo.af_tcp.accept_queue?
>>
>> Thanks a lot!
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>


It seems that I found the answer.

After reading the source code, comparing the codes of the two versions
I got the answer:

1.We can use sk_wq->wait instead of sk_wait.
2.Use reqsk_queue_empty(struct request_sock_queue*) to check if there
is a new connection to accept. (thsi method is in net/request_sock.h)
we can use it like:

 	struct inet_connection_sock *isock = inet_csk(socket->sk);
	if(reqsk_queue_empty(&isock->icsk_accept_queue)){
                 //sleep here
        }

I test them in my code, works well.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* struct sock change in kernel 2.6
  2010-12-23  0:18   ` lijin liu
@ 2010-12-23  5:16     ` Mulyadi Santosa
  2010-12-23  5:19       ` lijin liu
  0 siblings, 1 reply; 5+ messages in thread
From: Mulyadi Santosa @ 2010-12-23  5:16 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Dec 23, 2010 at 07:18, lijin liu <llj098@gmail.com> wrote:
> After reading the source code, comparing the codes of the two versions
> I got the answer:
>
> 1.We can use sk_wq->wait instead of sk_wait.
> 2.Use reqsk_queue_empty(struct request_sock_queue*) to check if there
> is a new connection to accept. (thsi method is in net/request_sock.h)
> we can use it like:
>
> ? ? ? ?struct inet_connection_sock *isock = inet_csk(socket->sk);
> ? ? ? ?if(reqsk_queue_empty(&isock->icsk_accept_queue)){
> ? ? ? ? ? ? ? ? //sleep here
> ? ? ? ?}

Thanks for sharing :) I believe you're intention is porting that code
to latest kernel version, right?

Then, i humbly suggest that you contribute the porting back to the
original project. Who knows, that way many people will get the
advantage and indirectly you got the benefit too: you become popular
:)

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* struct sock change in kernel 2.6
  2010-12-23  5:16     ` Mulyadi Santosa
@ 2010-12-23  5:19       ` lijin liu
  0 siblings, 0 replies; 5+ messages in thread
From: lijin liu @ 2010-12-23  5:19 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Dec 23, 2010 at 1:16 PM, Mulyadi Santosa
<mulyadi.santosa@gmail.com> wrote:
> On Thu, Dec 23, 2010 at 07:18, lijin liu <llj098@gmail.com> wrote:
>> After reading the source code, comparing the codes of the two versions
>> I got the answer:
>>
>> 1.We can use sk_wq->wait instead of sk_wait.
>> 2.Use reqsk_queue_empty(struct request_sock_queue*) to check if there
>> is a new connection to accept. (thsi method is in net/request_sock.h)
>> we can use it like:
>>
>> ? ? ? ?struct inet_connection_sock *isock = inet_csk(socket->sk);
>> ? ? ? ?if(reqsk_queue_empty(&isock->icsk_accept_queue)){
>> ? ? ? ? ? ? ? ? //sleep here
>> ? ? ? ?}
>
> Thanks for sharing :) I believe you're intention is porting that code
> to latest kernel version, right?
>
> Then, i humbly suggest that you contribute the porting back to the
> original project. Who knows, that way many people will get the
> advantage and indirectly you got the benefit too: you become popular
> :)
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>

I will try when I am free. Thanks!

:)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-23  5:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-22  6:17 struct sock change in kernel 2.6 lijin liu
2010-12-22 16:31 ` Bharath H S
2010-12-23  0:18   ` lijin liu
2010-12-23  5:16     ` Mulyadi Santosa
2010-12-23  5:19       ` lijin liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).