login
Header Space

 
 

Re: [PATCH 2/7] CAN: Add PF_CAN core module

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Patrick McHardy <kaber@...>
Cc: <netdev@...>, David Miller <davem@...>, Thomas Gleixner <tglx@...>, Oliver Hartkopp <oliver@...>, Oliver Hartkopp <oliver.hartkopp@...>, Urs Thuermann <urs@...>
Date: Tuesday, September 18, 2007 - 5:20 pm

Patrick McHardy <kaber@trash.net> writes:



No, this file contains the interface to user space.


These functions have been declared returning void originally, but in
the review process with Thomas we changed them since they can fail.
Even if the current users, i.e. raw.c and bcm.c don't use the return
value, others might do.  I therefore prefer to keep the int return
value.  Rather we should check whether we can do something useful with
the return value in raw.c and bcm.c.  At least we can put a WARN_ON
there.


Same as above.


af_can.h declares the interface between af_can.c and proc.c.  There
should be nothing in af_can.h which is only used in af_can.c


Right.  Will be changed.


Yes, I will check these also.


Can't be static since it's used in proc.c.  But __read_mostly might
make sense.

What exactly is the effect of __read_mostly?  Is that in a separate
ELF section?  Where is that finally located?


Hm, I don't think DBG() would be right here, since the messages show
problems in the installation to the admin.  OTOH, I see that a user
can flood the log by opening sockets with invalid proto numbers.  Rate
limiting might solve this, or we should print the message only once
per proto number.  I will think about this.



When the module is unloaded it calls can_proto_unregister() which
clears the pointer.  Do you see a race condition here?


Yes, you're right.


We have chosen EPERM because a user shouldn't be allowed to open a raw
CAN socket and then send arbitrary frames to other non-CAN interfaces.
This is also because the raw and bcm protocols can be configured to
grant access to non-root users.


CAN is a broadcast message network, so every frame should be (usually)
sent to all receivers, on remote hosts and to all local sockets.  If
the driver for the interface is not able to loop back the frame for
local delivery, the can_send() function will do this as a fallback.
For real CAN devices it is preferred that the driver does loopback.
For vcan it makes no difference where loopback is done.  The module
paramenter for vcan is therefore only useful to test and debug the CAN
core module.  It is nothing a normal user will ever use.


find_dev_rcv_lists() is called in one place from can_rcv() with RCU
lock held, as you write.  The other two calls to find_dev_rcv_lists()
are from can_rx_register/unregister() functions which change the
receive lists.  Therefore, we can't only use RCU but need protection
against simultanous writes.  We do this with the spin_lock_bh().  The
_bh variant, because can_rcv() runs in interrupt and we need to block
that.  I thought this is pretty standard.

I'll check this again tomorrow, but I have put much time in these
locking issues already, changed it quite a few times and hoped to have
got it right finally.

...

I have just looked at the code again and I think we're right here.  
Please reply if you think otherwise and we must fix it.



Hm, I seem to remember we had such an occurance with hot-pluggable
devices, i.e. USB.  But I may be wrong.  In what context is
NETDEV_REGISTER called for e.g. USB devices?  Can we safely write
just GFP_KERNEL here?


OK.


Yes.  We don't depend on exact times relative to module load time, but
we would like to have the timer expirations 1 second apart.  But we
would still get this with round_jiffies(), right?


Yep.  Thanks.


Yes, like above.


That has already been on my TODO list.  There was some problem which I
don't remember ATM, which is why I dropped it temporarily.  Now on my
TODO list again.


Thank you for your feedback.
urs
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Mon Sep 17, 6:03 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Tue Sep 18, 9:31 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Tue Sep 18, 5:20 pm)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Wed Sep 19, 4:27 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Thu Sep 20, 4:53 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Thu Sep 20, 6:33 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Thu Sep 20, 7:30 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Thu Sep 20, 7:43 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Tue Sep 18, 10:54 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Tue Sep 18, 11:07 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Paul E. McKenney, (Mon Sep 17, 11:50 am)
speck-geostationary