From: Richard Palethorpe <rpalethorpe@suse.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>, Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it, linux-can@vger.kernel.org,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: Re: [PATCH v3 2/7] can: Add can_common.h for vcan device setup
Date: Mon, 25 Jan 2021 10:59:37 +0000 [thread overview]
Message-ID: <87bldd9t9i.fsf@suse.de> (raw)
In-Reply-To: <058a6f05-d5ca-0746-dc4e-007253d3a84d@hartkopp.net>
Hello Oliver and Petr,
Oliver Hartkopp <socketcan@hartkopp.net> writes:
> Hello Richard,
>
> On 20.01.21 15:37, Richard Palethorpe wrote:
>> Note that we call modprobe to set echo=1. However this does seem to be
>> necessary for the current tests on 5.10. It has been kept to avoid
>> changing the test behavior unnecessarily, but can most likely be
>> safely removed if it causes problems.
>
> Without echo=1 a shortcut in af_can.c is used.
>
> I just checked that it works too - but with echo=1 we increase the
> test coverage to a test of the message flow down to the virtual CAN
> driver vcan.
Ah, thanks, I will amend the comments.
>
>> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
>> ---
>> .../network/can/filter-tests/can_common.h | 75 +++++++++++++++++++
>> 1 file changed, 75 insertions(+)
>> create mode 100644 testcases/network/can/filter-tests/can_common.h
>> diff --git a/testcases/network/can/filter-tests/can_common.h
>> b/testcases/network/can/filter-tests/can_common.h
>> new file mode 100644
>> index 000000000..f15145f30
>> --- /dev/null
>> +++ b/testcases/network/can/filter-tests/can_common.h
>> @@ -0,0 +1,75 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (c) 2021 SUSE LLC
>> + */
>> +
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <unistd.h>
>> +#include <string.h>
>> +
>> +#include <sys/types.h>
>> +#include <sys/socket.h>
>> +#include <sys/ioctl.h>
>> +#include <sys/time.h>
>> +
>> +#include "tst_cmd.h"
>> +#include "tst_safe_stdio.h"
>> +#include "tst_safe_file_ops.h"
>> +
>> +#include <linux/if.h>
>> +#include <linux/can.h>
>> +#include <linux/can/raw.h>
>> +
>> +#ifndef IFF_ECHO
>> +# define IFF_ECHO (1<<18)
>> +#endif
>
> IFF_ECHO was included into Linux 2.6.25 together with the CAN
> subsystem itself.
>
> So when you run the tests on Kernels < 2.6.25 you don't have CAN
> support and don't need IFF_ECHO too.
Petr, what kernel version and/or distro version did compilation fail on?
There is a small chance someone might be compiling with old kernel
headers relative to their kernel. However it is a challenge to compile
LTP with such an old user land.
>
> Regards,
> Oliver
>
>> +
>> +static char *can_dev_name;
>> +static int can_created_dev;
>> +
>> +static void can_cmd(const char *const argv[])
>> +{
>> + tst_cmd(argv, NULL, NULL, TST_CMD_TCONF_ON_MISSING);
>> +}
>> +
>> +#define CAN_CMD(...) can_cmd((const char *const[]){ __VA_ARGS__, NULL })
>> +
>> +static void can_setup_vcan(void)
>> +{
>> + unsigned int flags;
>> + char *path;
>> +
>> + if (can_dev_name)
>> + goto check_echo;
>> +
>> + can_dev_name = "vcan0";
>> +
>> + tst_res(TINFO, "Creating vcan0 device; use -D option to avoid this");
>> +
>> + CAN_CMD("modprobe", "-r", "vcan");
>> + CAN_CMD("modprobe", "vcan", "echo=1");
>> +
>> + can_created_dev = 1;
>> +
>> + CAN_CMD("ip", "link", "add", "dev", "vcan0", "type", "vcan");
>> + CAN_CMD("ip", "link", "set", "dev", "vcan0", "up");
>> +
>> +check_echo:
>> + /* Precondition for the frame flow test? */
>> + SAFE_ASPRINTF(&path, "/sys/class/net/%s/flags", can_dev_name);
>> + if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO)) {
>> + tst_res(TWARN, "Could not determine if ECHO is set on %s",
>> + can_dev_name);
>> + }
>> +}
>> +
>> +static void can_cleanup_vcan(void)
>> +{
>> + if (!can_created_dev)
>> + return;
>> +
>> + CAN_CMD("ip", "link", "set", "dev", "vcan0", "down");
>> + CAN_CMD("ip", "link", "del", "dev", "vcan0");
>> + CAN_CMD("modprobe", "-r", "vcan");
>> +}
>>
--
Thank you,
Richard.
WARNING: multiple messages have this Message-ID (diff)
From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 2/7] can: Add can_common.h for vcan device setup
Date: Mon, 25 Jan 2021 10:59:37 +0000 [thread overview]
Message-ID: <87bldd9t9i.fsf@suse.de> (raw)
In-Reply-To: <058a6f05-d5ca-0746-dc4e-007253d3a84d@hartkopp.net>
Hello Oliver and Petr,
Oliver Hartkopp <socketcan@hartkopp.net> writes:
> Hello Richard,
>
> On 20.01.21 15:37, Richard Palethorpe wrote:
>> Note that we call modprobe to set echo=1. However this does seem to be
>> necessary for the current tests on 5.10. It has been kept to avoid
>> changing the test behavior unnecessarily, but can most likely be
>> safely removed if it causes problems.
>
> Without echo=1 a shortcut in af_can.c is used.
>
> I just checked that it works too - but with echo=1 we increase the
> test coverage to a test of the message flow down to the virtual CAN
> driver vcan.
Ah, thanks, I will amend the comments.
>
>> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
>> ---
>> .../network/can/filter-tests/can_common.h | 75 +++++++++++++++++++
>> 1 file changed, 75 insertions(+)
>> create mode 100644 testcases/network/can/filter-tests/can_common.h
>> diff --git a/testcases/network/can/filter-tests/can_common.h
>> b/testcases/network/can/filter-tests/can_common.h
>> new file mode 100644
>> index 000000000..f15145f30
>> --- /dev/null
>> +++ b/testcases/network/can/filter-tests/can_common.h
>> @@ -0,0 +1,75 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (c) 2021 SUSE LLC
>> + */
>> +
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <unistd.h>
>> +#include <string.h>
>> +
>> +#include <sys/types.h>
>> +#include <sys/socket.h>
>> +#include <sys/ioctl.h>
>> +#include <sys/time.h>
>> +
>> +#include "tst_cmd.h"
>> +#include "tst_safe_stdio.h"
>> +#include "tst_safe_file_ops.h"
>> +
>> +#include <linux/if.h>
>> +#include <linux/can.h>
>> +#include <linux/can/raw.h>
>> +
>> +#ifndef IFF_ECHO
>> +# define IFF_ECHO (1<<18)
>> +#endif
>
> IFF_ECHO was included into Linux 2.6.25 together with the CAN
> subsystem itself.
>
> So when you run the tests on Kernels < 2.6.25 you don't have CAN
> support and don't need IFF_ECHO too.
Petr, what kernel version and/or distro version did compilation fail on?
There is a small chance someone might be compiling with old kernel
headers relative to their kernel. However it is a challenge to compile
LTP with such an old user land.
>
> Regards,
> Oliver
>
>> +
>> +static char *can_dev_name;
>> +static int can_created_dev;
>> +
>> +static void can_cmd(const char *const argv[])
>> +{
>> + tst_cmd(argv, NULL, NULL, TST_CMD_TCONF_ON_MISSING);
>> +}
>> +
>> +#define CAN_CMD(...) can_cmd((const char *const[]){ __VA_ARGS__, NULL })
>> +
>> +static void can_setup_vcan(void)
>> +{
>> + unsigned int flags;
>> + char *path;
>> +
>> + if (can_dev_name)
>> + goto check_echo;
>> +
>> + can_dev_name = "vcan0";
>> +
>> + tst_res(TINFO, "Creating vcan0 device; use -D option to avoid this");
>> +
>> + CAN_CMD("modprobe", "-r", "vcan");
>> + CAN_CMD("modprobe", "vcan", "echo=1");
>> +
>> + can_created_dev = 1;
>> +
>> + CAN_CMD("ip", "link", "add", "dev", "vcan0", "type", "vcan");
>> + CAN_CMD("ip", "link", "set", "dev", "vcan0", "up");
>> +
>> +check_echo:
>> + /* Precondition for the frame flow test? */
>> + SAFE_ASPRINTF(&path, "/sys/class/net/%s/flags", can_dev_name);
>> + if (FILE_SCANF(path, "%x", &flags) || !(flags & IFF_ECHO)) {
>> + tst_res(TWARN, "Could not determine if ECHO is set on %s",
>> + can_dev_name);
>> + }
>> +}
>> +
>> +static void can_cleanup_vcan(void)
>> +{
>> + if (!can_created_dev)
>> + return;
>> +
>> + CAN_CMD("ip", "link", "set", "dev", "vcan0", "down");
>> + CAN_CMD("ip", "link", "del", "dev", "vcan0");
>> + CAN_CMD("modprobe", "-r", "vcan");
>> +}
>>
--
Thank you,
Richard.
next prev parent reply other threads:[~2021-01-25 11:02 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 14:37 [PATCH v3 0/7] Convert CAN tests to new LTP API Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-20 14:37 ` [PATCH v3 1/7] API: Add FILE_SCANF to new lib Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-20 14:37 ` [PATCH v3 2/7] can: Add can_common.h for vcan device setup Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-25 10:20 ` Oliver Hartkopp
2021-01-25 10:20 ` [LTP] " Oliver Hartkopp
2021-01-25 10:59 ` Richard Palethorpe [this message]
2021-01-25 10:59 ` Richard Palethorpe
2021-01-26 21:28 ` Petr Vorel
2021-01-26 21:28 ` [LTP] " Petr Vorel
2021-01-27 7:52 ` Oliver Hartkopp
2021-01-27 7:52 ` [LTP] " Oliver Hartkopp
2021-01-27 8:18 ` Richard Palethorpe
2021-01-27 8:18 ` [LTP] " Richard Palethorpe
2021-01-27 12:13 ` Petr Vorel
2021-01-27 12:13 ` [LTP] " Petr Vorel
2021-01-27 15:07 ` Petr Vorel
2021-01-27 15:07 ` Petr Vorel
2021-01-20 14:37 ` [PATCH v3 3/7] can: Add COPYING with dual license text Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-20 14:37 ` [PATCH v3 4/7] can_filter: Convert to new library Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-20 14:37 ` [PATCH v3 5/7] can_recv_own_msgs: " Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-25 14:29 ` Cyril Hrubis
2021-01-25 14:29 ` Cyril Hrubis
2021-01-20 14:37 ` [PATCH v3 6/7] can: Remove obsolete test wrapper script Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-25 9:10 ` Petr Vorel
2021-01-25 9:10 ` Petr Vorel
2021-01-20 14:37 ` [PATCH v3 7/7] can: Update contact details Richard Palethorpe
2021-01-20 14:37 ` [LTP] " Richard Palethorpe
2021-01-25 10:25 ` Oliver Hartkopp
2021-01-25 10:25 ` [LTP] " Oliver Hartkopp
2021-01-25 14:30 ` Cyril Hrubis
2021-01-25 14:30 ` Cyril Hrubis
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=87bldd9t9i.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=linux-can@vger.kernel.org \
--cc=ltp@lists.linux.it \
--cc=mkl@pengutronix.de \
--cc=pvorel@suse.cz \
--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.