From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACD84C433DB for ; Mon, 25 Jan 2021 11:02:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75A6221D81 for ; Mon, 25 Jan 2021 11:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727676AbhAYLCS (ORCPT ); Mon, 25 Jan 2021 06:02:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:55500 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbhAYLAU (ORCPT ); Mon, 25 Jan 2021 06:00:20 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6C6CEAD8C; Mon, 25 Jan 2021 10:59:38 +0000 (UTC) References: <20210120143723.26483-1-rpalethorpe@suse.com> <20210120143723.26483-3-rpalethorpe@suse.com> <058a6f05-d5ca-0746-dc4e-007253d3a84d@hartkopp.net> User-agent: mu4e 1.4.14; emacs 27.1 From: Richard Palethorpe To: Oliver Hartkopp , Petr Vorel Cc: ltp@lists.linux.it, linux-can@vger.kernel.org, Marc Kleine-Budde Subject: Re: [PATCH v3 2/7] can: Add can_common.h for vcan device setup Reply-To: rpalethorpe@suse.de In-reply-to: <058a6f05-d5ca-0746-dc4e-007253d3a84d@hartkopp.net> Date: Mon, 25 Jan 2021 10:59:37 +0000 Message-ID: <87bldd9t9i.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-can@vger.kernel.org Hello Oliver and Petr, Oliver Hartkopp 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 >> --- >> .../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 >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> + >> +#include "tst_cmd.h" >> +#include "tst_safe_stdio.h" >> +#include "tst_safe_file_ops.h" >> + >> +#include >> +#include >> +#include >> + >> +#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.