From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
linux-can@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH 09/14] can: raw: use struct sock::sk_bound_dev_if instead of struct raw_sock::ifindex
Date: Sun, 27 Aug 2017 16:27:26 +0200 [thread overview]
Message-ID: <e1f0b97a-201e-8c33-f6d4-e6b9b5e96af8@hartkopp.net> (raw)
In-Reply-To: <20170825184644.GB6602@airbook.vandijck-laurijssen.be>
On 08/25/2017 08:46 PM, Kurt Van Dijck wrote:
> Hey Oliver,
>
>> On 08/25/2017 11:34 AM, Kurt Van Dijck wrote:
>>>> On 08/24/2017 04:11 PM, Kurt Van Dijck wrote:
>>>>>>> This patch removes the struct raw_sock::ifindex from the CAN raw socket
>>>>>>> and uses the already existing sock::sk_bound_dev_if instead.
>>>>>>
>>>>>> I would like to omit this patch.
>>>>>>
>>>>>> 1. It does NOT increase the readability ;-)
>>>>>>
>>>>>> ifindex points out that we are handling an interface index.
>>>>>> sk_bound_dev_if could be anything.
>>>>>
>>>>> See http://elixir.free-electrons.com/linux/v4.12.8/source/net/core/sock.c#L617
>>>>> sk_bound_dev_if may be a difficult name, but could not be anything.
>>>>> It allow to use SO_BINDTODEVICE (man 7 socket) to work properly for can raw sockets too.
>>>>
>>>> When ro->ifindex = 0 it can still be bound in the case of CAN sockets.
>>>> There is a different semantic as ifindex = zero means 'all CAN interfaces'
>>>> and not 'no interface'.
>>>
>>> ro->ifindex = 0: accept traffic from all interfaces
>>> ro->ifindex != 0: accept traffic only from 1 iface
>>>
>>> sk_bound_dev_if = 0: accept traffic from all interfaces
>>> sk_bound_dev_if != 0: accept traffic only from 1 iface
>>>
>>> What is the semantic difference?
>>
>> man 7 socket
>>
>> SO_BINDTODEVICE
>>
>> Bind this socket to a particular device like “eth0”, as specified in the
>> passed interface name. If the name is an empty string or the option
>> length is zero, the socket device binding is removed. The passed option is
>> a variable-length null-terminated interface name string with the maximum
>> size of IFNAMSIZ. If a socket is bound to an interface, only packets
>> received from that particular interface are processed by the socket. Note
>> that this works only for some socket types, particularly AF_INET sockets.
>> It is not supported for packet sockets (use normal bind(2) there).
>
> A verbatim copy of the man page isn't helping. I have read it.
>
>>
>> Especially "If the name is an empty string or the option length is zero,
>> the socket device binding is removed." is wrong.
>
> Do you mean the man page is wrong?
> Or do you mean that the semantic difference is wrong?
Yes. It tells us:
"If the name is an empty string or the option length is zero, the
socket device binding is removed."
Which means the status of 'bind' is NOT decoupled from the number in
ifindex.
A provided empty string leads to an unbound socket - and not to a socket
bound to ifindex=0 which is intended with CAN sockets.
> Or ?
>
>>
>> A bound CAN_RAW socket can have ifindex = 0.
>
> I see no reason why a bound UDP socket can not have sk_bound_dev_if = 0.
> I see no reason why a bound CAN_RAW socket can not either.
> I start to think here that the word 'device binding' confuses you with
> bind(2), but I have not seen any reference that SO_BINDTODEVICE
> conflicts/interacts with bind() so far.
>
>>
>> And "It is not supported for packet sockets (use normal bind(2) there)"
>> - the CAN_RAW socket is based on PF_PACKET sockets with the device binding
>> and addressing concept.
>>
>> The more I look into this, the more I'm sure that we should leave it as-is.
>
>>>>>> I would like to omit this patch.
>
> Well, I feel it may block the others, so indeed, omitting may be the
> best by lack of consensus.
Ok. We should omit this patch.
But I'm more interested in convincing you than just omitting this patch
to not block the upstream process ;-)
Best regards,
Oliver
next prev parent reply other threads:[~2017-08-27 14:27 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 17:44 [00/14] can: cleanup of af_can/raw + simplifying of ndev->ml_priv handling Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 01/14] can: af_can: can_pernet_init(): add missing error handling for kzalloc returning NULL Marc Kleine-Budde
2017-08-24 12:42 ` Oliver Hartkopp
2017-08-25 8:31 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 02/14] can: give structs holding the CAN statistics a sensible name Marc Kleine-Budde
2017-08-24 12:58 ` Oliver Hartkopp
2017-08-25 13:08 ` Marc Kleine-Budde
2017-08-25 17:32 ` Oliver Hartkopp
2017-08-28 7:25 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 03/14] can: af_can: give struct holding the CAN per device receive lists " Marc Kleine-Budde
2017-08-24 12:59 ` Oliver Hartkopp
2017-08-28 10:58 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 04/14] can: af_can: give variable " Marc Kleine-Budde
2017-08-24 13:03 ` Oliver Hartkopp
2017-08-28 13:39 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 05/14] can: proc: " Marc Kleine-Budde
2017-08-24 13:05 ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 06/14] can: af_can: rename find_rcv_list() to can_rcv_list_find() Marc Kleine-Budde
2017-08-24 13:11 ` Oliver Hartkopp
2017-08-28 11:53 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 07/14] can: af_can: give variable holding the CAN receiver and the receiver list a sensible name Marc Kleine-Budde
2017-08-24 13:27 ` Oliver Hartkopp
2017-08-28 15:24 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 08/14] can: af_can: can_rx_register(): use max() instead of open coding it Marc Kleine-Budde
2017-08-24 13:28 ` Oliver Hartkopp
2017-08-28 15:24 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 09/14] can: raw: use struct sock::sk_bound_dev_if instead of struct raw_sock::ifindex Marc Kleine-Budde
2017-08-24 13:39 ` Oliver Hartkopp
2017-08-24 14:11 ` Kurt Van Dijck
2017-08-25 8:43 ` Oliver Hartkopp
2017-08-25 9:34 ` Kurt Van Dijck
2017-08-25 17:54 ` Oliver Hartkopp
2017-08-25 18:46 ` Kurt Van Dijck
2017-08-27 14:27 ` Oliver Hartkopp [this message]
2017-08-02 17:44 ` [PATCH 10/14] can: raw: raw_bind: bail out if can_family is not AF_CAN Marc Kleine-Budde
2017-08-24 13:40 ` Oliver Hartkopp
2017-08-28 15:25 ` Marc Kleine-Budde
2017-08-02 17:44 ` [PATCH 11/14] can: af_can: can_pernet_exit(): no need to iterate over and cleanup registered CAN devices Marc Kleine-Budde
2017-08-24 13:48 ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 12/14] can: introduce CAN midlayer private and allocate it automatically Marc Kleine-Budde
2017-08-24 13:51 ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 13/14] can: make use of preallocated can_ml_priv for per device struct can_dev_rcv_lists Marc Kleine-Budde
2017-08-24 13:55 ` Oliver Hartkopp
2017-08-02 17:44 ` [PATCH 14/14] can: af_can: remove NULL-ptr checks from users of can_dev_rcv_lists_find() Marc Kleine-Budde
2017-08-24 13:58 ` Oliver Hartkopp
2017-08-03 5:03 ` [00/14] can: cleanup of af_can/raw + simplifying of ndev->ml_priv handling Oliver Hartkopp
2017-08-03 7:39 ` Marc Kleine-Budde
2017-08-17 11:57 ` Marc Kleine-Budde
2017-08-17 12:57 ` Oliver Hartkopp
2017-08-17 13:02 ` Marc Kleine-Budde
2017-08-17 13:03 ` Marc Kleine-Budde
2017-08-17 13:06 ` Marc Kleine-Budde
2017-08-17 13:13 ` Oliver Hartkopp
2017-08-17 13:17 ` Marc Kleine-Budde
2017-08-17 13:54 ` Oliver Hartkopp
2017-08-17 14:08 ` Marc Kleine-Budde
2017-08-24 12:31 ` Oliver Hartkopp
2017-08-17 13:08 ` Oliver Hartkopp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1f0b97a-201e-8c33-f6d4-e6b9b5e96af8@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.