All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ahmed S. Darwish" <darwish.07@gmail.com>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH v2 2/2] can: introduce new raw socket option to join the given CAN filters
Date: Wed, 18 Mar 2015 23:47:15 +0200	[thread overview]
Message-ID: <20150318214715.GA2602@Darwish.PC> (raw)
In-Reply-To: <1426659036-4628-2-git-send-email-socketcan@hartkopp.net>

Hi Oliver,

On Wed, Mar 18, 2015 at 07:10:35AM +0100, Oliver Hartkopp wrote:
> The CAN_RAW socket can set multiple CAN identifier specific filters that lead
> to multiple filters in the af_can.c filter processing. These filters are
> indenpendent from each other which leads to logical OR'ed filters when applied.
> 
> This socket option joines the given CAN filters in the way that only CAN frames
> are passed to user space that matched *all* given CAN filters. The semantic for
> the applied filters is therefore changed to a logical AND.
> 
> This is useful especially when the filterset is a combination of filters where
> the CAN_INV_FILTER flag is set in order to notch single CAN IDs or CAN ID
> ranges from the incoming traffic.
> 
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> ---
> 
> v2: fix first reception of joint filter CAN frame
> 

I've done some very basic smoke tests on 4.0.0-rc4+, and
everything seems to work just as it says on the tin :-)

Before applying the two kernel patches:

$ cangen vcan0 -Di -Ii -L4 &

$ candump vcan0,0:0,0:0,0:0

  /* 3 filters, 3 times repeat for each frame */
  vcan0  000   [4]  00 00 00 00
  vcan0  000   [4]  00 00 00 00
  vcan0  000   [4]  00 00 00 00
  vcan0  001   [4]  01 00 00 00
  vcan0  001   [4]  01 00 00 00
  vcan0  001   [4]  01 00 00 00
  vcan0  002   [4]  02 00 00 00
  vcan0  002   [4]  02 00 00 00
  vcan0  002   [4]  02 00 00 00
  vcan0  003   [4]  03 00 00 00
  vcan0  003   [4]  03 00 00 00
  vcan0  003   [4]  03 00 00 00

$ candump vcan0,0:0,0:0,0:0,J

  setsockopt CAN_RAW_JOIN_FILTERS not supported by your
  Linux Kernel: Protocol not available

##########################################

After applying the two kernel patches:

$ cangen vcan0 -Di -Ii -L4 &

$ candump vcan0,0:0,0:0,0:0

  /* 3 filters, no repeat for each frame (great!) */
  vcan0  000   [4]  00 00 00 00
  vcan0  001   [4]  01 00 00 00
  vcan0  002   [4]  02 00 00 00
  vcan0  003   [4]  03 00 00 00
  vcan0  004   [4]  04 00 00 00
  vcan0  005   [4]  05 00 00 00
  vcan0  006   [4]  06 00 00 00

$ cangen vcan0 -Di -I 123 -L 4

$ candump vcan0,123~7FF

  /* Basic case: no output as all CAN IDs matches 123 */

$ candump vcan0,123~7FF,111~7FF

  /* OR operator working as expected */
  vcan0  123   [4]  00 00 00 00
  vcan0  123   [4]  01 00 00 00
  vcan0  123   [4]  02 00 00 00
  vcan0  123   [4]  03 00 00 00
  vcan0  123   [4]  04 00 00 00
  vcan0  123   [4]  05 00 00 00
  vcan0  123   [4]  06 00 00 00

$ candump vcan0,123~7FF,111~7FF,J

  /* No output; AND operator working as expected */


Regards,
Darwish

  reply	other threads:[~2015-03-18 21:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18  6:10 [PATCH v2 1/2] can: fix multiple delivery of a single CAN frame for overlapping CAN filters Oliver Hartkopp
2015-03-18  6:10 ` [PATCH v2 2/2] can: introduce new raw socket option to join the given " Oliver Hartkopp
2015-03-18 21:47   ` Ahmed S. Darwish [this message]
2015-03-18 22:17 ` [PATCH v2 1/2] can: fix multiple delivery of a single CAN frame for overlapping " Ahmed S. Darwish
2015-03-19  8:06   ` 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=20150318214715.GA2602@Darwish.PC \
    --to=darwish.07@gmail.com \
    --cc=linux-can@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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.