Re: Problem with a UDP server implements

2011-10-15 Thread michi1
Hi!

On 01:51 Sat 15 Oct , jiangtao.jit wrote:
 Hi:
 
 I'm writing a UDP server and meet a problem
 the UDP server program is run on a box with single card but has multi ip:
 likeeth010.0.0.1
 eth0:1 10.0.0.2
   eth0:2  11.0.0.1
 
 I bind the server socket with INADDR_ANY
...
 when a client send a request to 10.0.0.1(eth0); the server use 10.0.0.1 to 
 response
 and another client send a request to 10.0.0.2(eth0:1); the server use 
 10.0.0.2 to response

Well, is seems there is neither a variant of recvfrom() which tells you your
local address nor a variant of sendto() which allows you to specify your local
address. I guess you have to call getaddrinfo() and create a socket for every
address you want to bind to. If you want to stay single threaded you can
switch them to nonblocking and use epoll to wait for packets.

-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Problem with a UDP server implements

2011-10-15 Thread tao jiang
michi:

1.
Is that to create two sockets
and one bind to 10.0.0.1 the other bind to 10.0.0.2
then use epoll wait these two sockets ?

2.
Is there any way to find out the turple like TCP
then the UDP server can reply with exactly the ip it recieved the
client's request ?

Thanks.



2011/10/15  mic...@michaelblizek.twilightparadox.com:
 Hi!

 On 01:51 Sat 15 Oct     , jiangtao.jit wrote:
 Hi:

 I'm writing a UDP server and meet a problem
 the UDP server program is run on a box with single card but has multi ip:
 like    eth0        10.0.0.1
         eth0:1     10.0.0.2
               eth0:2          11.0.0.1

 I bind the server socket with INADDR_ANY
 ...
 when a client send a request to 10.0.0.1(eth0); the server use 10.0.0.1 to 
 response
 and another client send a request to 10.0.0.2(eth0:1); the server use 
 10.0.0.2 to response

 Well, is seems there is neither a variant of recvfrom() which tells you your
 local address nor a variant of sendto() which allows you to specify your local
 address. I guess you have to call getaddrinfo() and create a socket for every
 address you want to bind to. If you want to stay single threaded you can
 switch them to nonblocking and use epoll to wait for packets.

        -Michi
 --
 programing a layer 3+4 network protocol for mesh networks
 see http://michaelblizek.twilightparadox.com


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Getting 'bad file number' error writing to device driver

2011-10-15 Thread Daniel Baluta
On Sat, Oct 15, 2011 at 2:42 AM, Philip Anil-QBW348
anil.phi...@motorolasolutions.com wrote:
 I am calling the driver from an Android program (OMAP4/Blaze). It calls a
 c++ program via JNI which then calls the device driver.
 Someone suggested it might be a permissions problem - the program is running
 in user mode.

 on Blaze board, /system/bin
 # ls -l
 -rwxrwxrwx system   system   7636 2011-09-30 03:53 mydriver

 Will strace still be useful?
 In general, in Linux, how does one enable a user program to call a custom
 device driver?

Please don't top post! :)

strace will be useful to check the parameters for open, write system calls.

EBADF  fd is not a valid file descriptor or is not open for writing.
Ok, so either open fails, or you don't have the permission to write
into /dev/mydriver file.

Another thing that I can think of, is that your driver's write
function is wrong, and returns
-EBADF in some case ?

Can you give us a pointer to your driver?

thanks,
Daniel.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Problem with a UDP server implements

2011-10-15 Thread tao jiang
michi:

Thanks for your help.
Much appreciated.



2011/10/15  mic...@michaelblizek.twilightparadox.com:
 Hi!

 On 16:29 Sat 15 Oct     , tao jiang wrote:
 michi:

 1.
 Is that to create two sockets
 and one bind to 10.0.0.1 the other bind to 10.0.0.2
 then use epoll wait these two sockets ?

 Yes, exactly.

 2.
 Is there any way to find out the turple like TCP
 then the UDP server can reply with exactly the ip it recieved the
 client's request ?

 You should receive the packet only on the socket which is bound to the
 address. You can save the bind address somewhere, so you know the local
 address. You will know the client address because it is passed back by
 recvfrom.

        -Michi
 --
 programing a layer 3+4 network protocol for mesh networks
 see http://michaelblizek.twilightparadox.com


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Query on Rx Frame processing

2011-10-15 Thread amit mehta
I'm trying to understand Linux Network subsystem and after
reading some documents, my broad level understanding for
Rx Path is as follows:

1: Card receives the packet.
2: Assume everything is fine, the card DMAs the frame for
the driver to process it further.
3: Driver allocate an skb buffer, adjusts the headroom.
4: Fills the buffer and pass it to the Network layer.

Now in step 4 above, driver passes this packet to the
network layer by calling netif_receive_skb()  which may return
NET_RX_DROP (packet was dropped), but most
(I checked some of the network driver code) of the network
drivers do not do this check.
Hence,
Q1: Shouldn't drivers be doing that ?

Q2: Suppose the Card keeps pushing the frames at very high rate
(10 Gig adapters are already in the market and maybe in near future
we might have even faster ethernet adapters) then how the driver
and the networking stack will handle such rapid frames arrivals?
Will NAPI, interrupt coalescing be enough ?

I'm referring kernel version 2.6.31

-Amit

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Query on Rx Frame processing

2011-10-15 Thread michi1
Hi!

On 19:45 Sat 15 Oct , amit mehta wrote:
...
 Now in step 4 above, driver passes this packet to the
 network layer by calling netif_receive_skb()  which may return
 NET_RX_DROP (packet was dropped), but most
 (I checked some of the network driver code) of the network
 drivers do not do this check.
 Hence,
 Q1: Shouldn't drivers be doing that ?

The return value NET_RX_DROP seems to be used in various places where no
congestion exists:
http://lxr.linux.no/linux+v3.0.4/net/ipv4/ip_forward.c#L131
http://lxr.linux.no/linux+v3.0.4/net/ipv4/ip_input.c#L369
http://lxr.linux.no/linux+v3.0.4/net/ipv4/ip_input.c#L451

What should network drivers do with this info?

Also, there might be multiple layer 3 protocols. If one of them would signal
congestion, should the driver slow down receiving?

Maybe the question is rather why does this variable exist at all. I guess it
is just to got statistic data.

 Q2: Suppose the Card keeps pushing the frames at very high rate
 (10 Gig adapters are already in the market and maybe in near future
 we might have even faster ethernet adapters) then how the driver
 and the networking stack will handle such rapid frames arrivals?
 Will NAPI, interrupt coalescing be enough ?

It seems like net_rx_action does some throttling:
http://lxr.linux.no/linux+v3.0.4/net/core/dev.c#L3764

-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Heap memory is not re-claiming.

2011-10-15 Thread Srivatsa Bhat
On Fri, Oct 14, 2011 at 10:28 AM, rohan puri rohan.pur...@gmail.com wrote:


 *Reference to an article by Mulayadi Santosa :-

 http://linuxdevcenter.com/pub/a/linux/2006/11/30/linux-out-of-memory.html
 *


Rohan, thanks a lot for sharing this link.
Mulyadi, the article is just superb, very well-written and extremely useful
:)

Regards,
Srivatsa S. Bhat
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies