* [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
@ 2023-03-09 14:59 Petr Vorel
2023-03-09 14:59 ` Andrea Cervesato via ltp
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Petr Vorel @ 2023-03-09 14:59 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/containers/share/ns_ifmove.c | 98 ++++++-------------
1 file changed, 28 insertions(+), 70 deletions(-)
diff --git a/testcases/kernel/containers/share/ns_ifmove.c b/testcases/kernel/containers/share/ns_ifmove.c
index 12642c6f4..60dda94d3 100644
--- a/testcases/kernel/containers/share/ns_ifmove.c
+++ b/testcases/kernel/containers/share/ns_ifmove.c
@@ -1,43 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/* Copyright (c) 2015 Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of version 2 the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * Copyright (c) Linux Test Project, 2015-2022
+ * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
* Written by Matus Marhefka <mmarhefk@redhat.com>
+ */
+
+/*\
+ * [Description]
*
- ***********************************************************************
* Moves a network interface to the namespace of a process specified by a PID.
- *
*/
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <asm/types.h>
-#include <sys/socket.h>
-#include <linux/rtnetlink.h>
-#include <sys/ioctl.h>
-#include <linux/if.h>
-#include <net/ethernet.h>
-#include <arpa/inet.h>
-#include "test.h"
-
#include "config.h"
-char *TCID = "ns_ifmove";
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+#include "tst_safe_macros.h"
+#include "tst_safe_net.h"
+
+#include <linux/if.h>
+#include <linux/rtnetlink.h>
+#include <net/ethernet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-#if HAVE_DECL_IFLA_NET_NS_PID
+#ifdef HAVE_DECL_IFLA_NET_NS_PID
struct {
struct nlmsghdr nh;
@@ -55,50 +43,28 @@ int get_intf_index_from_name(const char *intf_name)
strncpy(ifr.ifr_name, intf_name, sizeof(ifr.ifr_name) - 1);
ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';
- sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
- if (sock_fd == -1) {
- tst_resm(TINFO | TERRNO, "socket");
- return -1;
- }
+ sock_fd = SAFE_SOCKET(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
- /* gets interface index */
- if (ioctl(sock_fd, SIOCGIFINDEX, &ifr) == -1) {
- tst_resm(TINFO | TERRNO, "ioctl");
- close(sock_fd);
- return -1;
- }
+ /* interface index */
+ SAFE_IOCTL(sock_fd, SIOCGIFINDEX, &ifr);
+ SAFE_CLOSE(sock_fd);
- close(sock_fd);
return ifr.ifr_ifindex;
}
-/*
- * ./ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>
- */
int main(int argc, char **argv)
{
struct rtattr *rta;
int intf_index, pid, rtnetlink_socket;
if (argc != 3) {
- tst_resm(TINFO, "%s <INTERFACE_NAME> <NAMESPACE_PID>",
- argv[0]);
+ printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
return 1;
}
intf_index = get_intf_index_from_name(argv[1]);
- if (intf_index == -1) {
- tst_resm(TINFO , "unable to get interface index");
- return 1;
- }
-
pid = atoi(argv[2]);
-
- rtnetlink_socket = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
- if (rtnetlink_socket == -1) {
- tst_resm(TINFO | TERRNO, "socket");
- return 1;
- }
+ rtnetlink_socket = SAFE_SOCKET(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
memset(&req, 0, sizeof(req));
req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
@@ -115,20 +81,12 @@ int main(int argc, char **argv)
RTA_LENGTH(sizeof(pid));
memcpy(RTA_DATA(rta), &pid, sizeof(pid));
- if (send(rtnetlink_socket, &req, req.nh.nlmsg_len, 0) == -1) {
- tst_resm(TINFO | TERRNO, "send");
- return 1;
- }
+ SAFE_SEND(1, rtnetlink_socket, &req, req.nh.nlmsg_len, 0);
+ SAFE_CLOSE(rtnetlink_socket);
- close(rtnetlink_socket);
return 0;
}
#else
-
-int main(void)
-{
- tst_brkm(TCONF, NULL, "IFLA_NET_NS_PID not defined in linux/if_link.h");
-}
-
+ TST_TEST_TCONF("IFLA_NET_NS_PID not defined in linux/if_link.h");
#endif
--
2.39.2
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-09 14:59 [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API Petr Vorel
@ 2023-03-09 14:59 ` Andrea Cervesato via ltp
2023-03-10 2:54 ` Bird, Tim
2023-03-15 0:56 ` Wei Gao via ltp
2 siblings, 0 replies; 12+ messages in thread
From: Andrea Cervesato via ltp @ 2023-03-09 14:59 UTC (permalink / raw)
To: Petr Vorel, ltp
Hi Petr,
looks fine to me.
Acked-by: Andrea Cervesato <andrea.cervesato@suse.com>
On 3/9/23 15:59, Petr Vorel wrote:
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> testcases/kernel/containers/share/ns_ifmove.c | 98 ++++++-------------
> 1 file changed, 28 insertions(+), 70 deletions(-)
>
> diff --git a/testcases/kernel/containers/share/ns_ifmove.c b/testcases/kernel/containers/share/ns_ifmove.c
> index 12642c6f4..60dda94d3 100644
> --- a/testcases/kernel/containers/share/ns_ifmove.c
> +++ b/testcases/kernel/containers/share/ns_ifmove.c
> @@ -1,43 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> /* Copyright (c) 2015 Red Hat, Inc.
> - *
> - * This program is free software: you can redistribute it and/or modify
> - * it under the terms of version 2 the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program. If not, see <http://www.gnu.org/licenses/>.
> - *
> + * Copyright (c) Linux Test Project, 2015-2022
> + * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
> * Written by Matus Marhefka <mmarhefk@redhat.com>
> + */
> +
> +/*\
> + * [Description]
> *
> - ***********************************************************************
> * Moves a network interface to the namespace of a process specified by a PID.
> - *
> */
>
> -#define _GNU_SOURCE
> -#include <stdlib.h>
> -#include <string.h>
> -#include <errno.h>
> -#include <unistd.h>
> -#include <asm/types.h>
> -#include <sys/socket.h>
> -#include <linux/rtnetlink.h>
> -#include <sys/ioctl.h>
> -#include <linux/if.h>
> -#include <net/ethernet.h>
> -#include <arpa/inet.h>
> -#include "test.h"
> -
> #include "config.h"
>
> -char *TCID = "ns_ifmove";
> +#define TST_NO_DEFAULT_MAIN
> +#include "tst_test.h"
> +#include "tst_safe_macros.h"
> +#include "tst_safe_net.h"
> +
> +#include <linux/if.h>
> +#include <linux/rtnetlink.h>
> +#include <net/ethernet.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
>
> -#if HAVE_DECL_IFLA_NET_NS_PID
> +#ifdef HAVE_DECL_IFLA_NET_NS_PID
>
> struct {
> struct nlmsghdr nh;
> @@ -55,50 +43,28 @@ int get_intf_index_from_name(const char *intf_name)
> strncpy(ifr.ifr_name, intf_name, sizeof(ifr.ifr_name) - 1);
> ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';
>
> - sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
> - if (sock_fd == -1) {
> - tst_resm(TINFO | TERRNO, "socket");
> - return -1;
> - }
> + sock_fd = SAFE_SOCKET(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
>
> - /* gets interface index */
> - if (ioctl(sock_fd, SIOCGIFINDEX, &ifr) == -1) {
> - tst_resm(TINFO | TERRNO, "ioctl");
> - close(sock_fd);
> - return -1;
> - }
> + /* interface index */
> + SAFE_IOCTL(sock_fd, SIOCGIFINDEX, &ifr);
> + SAFE_CLOSE(sock_fd);
>
> - close(sock_fd);
> return ifr.ifr_ifindex;
> }
>
> -/*
> - * ./ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>
> - */
> int main(int argc, char **argv)
> {
> struct rtattr *rta;
> int intf_index, pid, rtnetlink_socket;
>
> if (argc != 3) {
> - tst_resm(TINFO, "%s <INTERFACE_NAME> <NAMESPACE_PID>",
> - argv[0]);
> + printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
> return 1;
> }
>
> intf_index = get_intf_index_from_name(argv[1]);
> - if (intf_index == -1) {
> - tst_resm(TINFO , "unable to get interface index");
> - return 1;
> - }
> -
> pid = atoi(argv[2]);
> -
> - rtnetlink_socket = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
> - if (rtnetlink_socket == -1) {
> - tst_resm(TINFO | TERRNO, "socket");
> - return 1;
> - }
> + rtnetlink_socket = SAFE_SOCKET(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
>
> memset(&req, 0, sizeof(req));
> req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
> @@ -115,20 +81,12 @@ int main(int argc, char **argv)
> RTA_LENGTH(sizeof(pid));
> memcpy(RTA_DATA(rta), &pid, sizeof(pid));
>
> - if (send(rtnetlink_socket, &req, req.nh.nlmsg_len, 0) == -1) {
> - tst_resm(TINFO | TERRNO, "send");
> - return 1;
> - }
> + SAFE_SEND(1, rtnetlink_socket, &req, req.nh.nlmsg_len, 0);
> + SAFE_CLOSE(rtnetlink_socket);
>
> - close(rtnetlink_socket);
> return 0;
> }
>
> #else
> -
> -int main(void)
> -{
> - tst_brkm(TCONF, NULL, "IFLA_NET_NS_PID not defined in linux/if_link.h");
> -}
> -
> + TST_TEST_TCONF("IFLA_NET_NS_PID not defined in linux/if_link.h");
> #endif
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-09 14:59 [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API Petr Vorel
2023-03-09 14:59 ` Andrea Cervesato via ltp
@ 2023-03-10 2:54 ` Bird, Tim
2023-03-10 7:34 ` Petr Vorel
2023-03-15 0:56 ` Wei Gao via ltp
2 siblings, 1 reply; 12+ messages in thread
From: Bird, Tim @ 2023-03-10 2:54 UTC (permalink / raw)
To: Petr Vorel, ltp@lists.linux.it
> -----Original Message-----
> From: ltp <ltp-bounces+tim.bird=sony.com@lists.linux.it> On Behalf Of Petr Vorel
> Sent: Thursday, March 9, 2023 7:59 AM
> To: ltp@lists.linux.it
> Subject: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> testcases/kernel/containers/share/ns_ifmove.c | 98 ++++++-------------
> 1 file changed, 28 insertions(+), 70 deletions(-)
>
> diff --git a/testcases/kernel/containers/share/ns_ifmove.c b/testcases/kernel/containers/share/ns_ifmove.c
> index 12642c6f4..60dda94d3 100644
> --- a/testcases/kernel/containers/share/ns_ifmove.c
> +++ b/testcases/kernel/containers/share/ns_ifmove.c
> @@ -1,43 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
I don't see "or later" anywhere in the license header that was removed.
Is this the correct SPDX license identifier?
Maybe it should be 'GPL-2.0-only'
-- Tim
> /* Copyright (c) 2015 Red Hat, Inc.
> - *
> - * This program is free software: you can redistribute it and/or modify
> - * it under the terms of version 2 the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program. If not, see <http://www.gnu.org/licenses/>.
> - *
> + * Copyright (c) Linux Test Project, 2015-2022
> + * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
> * Written by Matus Marhefka <mmarhefk@redhat.com>
> + */
> +
> +/*\
> + * [Description]
> *
> - ***********************************************************************
> * Moves a network interface to the namespace of a process specified by a PID.
> - *
> */
>
> -#define _GNU_SOURCE
> -#include <stdlib.h>
> -#include <string.h>
> -#include <errno.h>
> -#include <unistd.h>
> -#include <asm/types.h>
> -#include <sys/socket.h>
> -#include <linux/rtnetlink.h>
> -#include <sys/ioctl.h>
> -#include <linux/if.h>
> -#include <net/ethernet.h>
> -#include <arpa/inet.h>
> -#include "test.h"
> -
> #include "config.h"
>
> -char *TCID = "ns_ifmove";
> +#define TST_NO_DEFAULT_MAIN
> +#include "tst_test.h"
> +#include "tst_safe_macros.h"
> +#include "tst_safe_net.h"
> +
> +#include <linux/if.h>
> +#include <linux/rtnetlink.h>
> +#include <net/ethernet.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
>
> -#if HAVE_DECL_IFLA_NET_NS_PID
> +#ifdef HAVE_DECL_IFLA_NET_NS_PID
>
> struct {
> struct nlmsghdr nh;
> @@ -55,50 +43,28 @@ int get_intf_index_from_name(const char *intf_name)
> strncpy(ifr.ifr_name, intf_name, sizeof(ifr.ifr_name) - 1);
> ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';
>
> - sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
> - if (sock_fd == -1) {
> - tst_resm(TINFO | TERRNO, "socket");
> - return -1;
> - }
> + sock_fd = SAFE_SOCKET(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
>
> - /* gets interface index */
> - if (ioctl(sock_fd, SIOCGIFINDEX, &ifr) == -1) {
> - tst_resm(TINFO | TERRNO, "ioctl");
> - close(sock_fd);
> - return -1;
> - }
> + /* interface index */
> + SAFE_IOCTL(sock_fd, SIOCGIFINDEX, &ifr);
> + SAFE_CLOSE(sock_fd);
>
> - close(sock_fd);
> return ifr.ifr_ifindex;
> }
>
> -/*
> - * ./ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>
> - */
> int main(int argc, char **argv)
> {
> struct rtattr *rta;
> int intf_index, pid, rtnetlink_socket;
>
> if (argc != 3) {
> - tst_resm(TINFO, "%s <INTERFACE_NAME> <NAMESPACE_PID>",
> - argv[0]);
> + printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
> return 1;
> }
>
> intf_index = get_intf_index_from_name(argv[1]);
> - if (intf_index == -1) {
> - tst_resm(TINFO , "unable to get interface index");
> - return 1;
> - }
> -
> pid = atoi(argv[2]);
> -
> - rtnetlink_socket = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
> - if (rtnetlink_socket == -1) {
> - tst_resm(TINFO | TERRNO, "socket");
> - return 1;
> - }
> + rtnetlink_socket = SAFE_SOCKET(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
>
> memset(&req, 0, sizeof(req));
> req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
> @@ -115,20 +81,12 @@ int main(int argc, char **argv)
> RTA_LENGTH(sizeof(pid));
> memcpy(RTA_DATA(rta), &pid, sizeof(pid));
>
> - if (send(rtnetlink_socket, &req, req.nh.nlmsg_len, 0) == -1) {
> - tst_resm(TINFO | TERRNO, "send");
> - return 1;
> - }
> + SAFE_SEND(1, rtnetlink_socket, &req, req.nh.nlmsg_len, 0);
> + SAFE_CLOSE(rtnetlink_socket);
>
> - close(rtnetlink_socket);
> return 0;
> }
>
> #else
> -
> -int main(void)
> -{
> - tst_brkm(TCONF, NULL, "IFLA_NET_NS_PID not defined in linux/if_link.h");
> -}
> -
> + TST_TEST_TCONF("IFLA_NET_NS_PID not defined in linux/if_link.h");
> #endif
> --
> 2.39.2
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-10 2:54 ` Bird, Tim
@ 2023-03-10 7:34 ` Petr Vorel
2023-03-10 11:47 ` Petr Vorel
0 siblings, 1 reply; 12+ messages in thread
From: Petr Vorel @ 2023-03-10 7:34 UTC (permalink / raw)
To: Bird, Tim; +Cc: ltp@lists.linux.it
Hi Tim,
> > +++ b/testcases/kernel/containers/share/ns_ifmove.c
> > @@ -1,43 +1,31 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> I don't see "or later" anywhere in the license header that was removed.
> Is this the correct SPDX license identifier?
> Maybe it should be 'GPL-2.0-only'
Good catch, thank you!
Kind regards,
Petr
> -- Tim
> > /* Copyright (c) 2015 Red Hat, Inc.
> > - *
> > - * This program is free software: you can redistribute it and/or modify
> > - * it under the terms of version 2 the GNU General Public License as
> > - * published by the Free Software Foundation.
> > - *
> > - * This program is distributed in the hope that it will be useful,
> > - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > - * GNU General Public License for more details.
> > - *
> > - * You should have received a copy of the GNU General Public License
> > - * along with this program. If not, see <http://www.gnu.org/licenses/>.
> > - *
> > + * Copyright (c) Linux Test Project, 2015-2022
> > + * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
> > * Written by Matus Marhefka <mmarhefk@redhat.com>
> > + */
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-10 7:34 ` Petr Vorel
@ 2023-03-10 11:47 ` Petr Vorel
2023-03-10 18:11 ` Bird, Tim
0 siblings, 1 reply; 12+ messages in thread
From: Petr Vorel @ 2023-03-10 11:47 UTC (permalink / raw)
To: Bird, Tim, ltp@lists.linux.it; +Cc: Matus Marhefka
Hi all,
> Hi Tim,
> > > +++ b/testcases/kernel/containers/share/ns_ifmove.c
> > > @@ -1,43 +1,31 @@
> > > +// SPDX-License-Identifier: GPL-2.0-or-later
> > I don't see "or later" anywhere in the license header that was removed.
> > Is this the correct SPDX license identifier?
> > Maybe it should be 'GPL-2.0-only'
> Good catch, thank you!
FYI I contacted Matus Marhefka privately and got his ack:
I am not on that mailing list anymore. Anyway, feel free to re-license any
of my tests to GPL-v2+, you have my agreement :)
=> going to use the original version.
Kind regards,
Petr
> Kind regards,
> Petr
> > -- Tim
> > > /* Copyright (c) 2015 Red Hat, Inc.
> > > - *
> > > - * This program is free software: you can redistribute it and/or modify
> > > - * it under the terms of version 2 the GNU General Public License as
> > > - * published by the Free Software Foundation.
> > > - *
> > > - * This program is distributed in the hope that it will be useful,
> > > - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > - * GNU General Public License for more details.
> > > - *
> > > - * You should have received a copy of the GNU General Public License
> > > - * along with this program. If not, see <http://www.gnu.org/licenses/>.
> > > - *
> > > + * Copyright (c) Linux Test Project, 2015-2022
> > > + * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
> > > * Written by Matus Marhefka <mmarhefk@redhat.com>
> > > + */
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-10 11:47 ` Petr Vorel
@ 2023-03-10 18:11 ` Bird, Tim
2023-03-13 20:53 ` Petr Vorel
2023-03-23 15:59 ` Petr Vorel
0 siblings, 2 replies; 12+ messages in thread
From: Bird, Tim @ 2023-03-10 18:11 UTC (permalink / raw)
To: Petr Vorel, ltp@lists.linux.it; +Cc: Matus Marhefka
> -----Original Message-----
> From: Petr Vorel <pvorel@suse.cz>
>
> Hi all,
>
> > Hi Tim,
>
> > > > +++ b/testcases/kernel/containers/share/ns_ifmove.c
> > > > @@ -1,43 +1,31 @@
> > > > +// SPDX-License-Identifier: GPL-2.0-or-later
>
> > > I don't see "or later" anywhere in the license header that was removed.
>
> > > Is this the correct SPDX license identifier?
> > > Maybe it should be 'GPL-2.0-only'
> > Good catch, thank you!
>
> FYI I contacted Matus Marhefka privately and got his ack:
>
> I am not on that mailing list anymore. Anyway, feel free to re-license any
> of my tests to GPL-v2+, you have my agreement :)
>
> => going to use the original version.
Sounds good. You may want to note this authorization to change the
license, in the commit message for this patch.
-- Tim
>
> Kind regards,
> Petr
>
> > Kind regards,
> > Petr
>
> > > -- Tim
>
> > > > /* Copyright (c) 2015 Red Hat, Inc.
> > > > - *
> > > > - * This program is free software: you can redistribute it and/or modify
> > > > - * it under the terms of version 2 the GNU General Public License as
> > > > - * published by the Free Software Foundation.
> > > > - *
> > > > - * This program is distributed in the hope that it will be useful,
> > > > - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > > - * GNU General Public License for more details.
> > > > - *
> > > > - * You should have received a copy of the GNU General Public License
> > > > - * along with this program. If not, see <http://www.gnu.org/licenses/>.
> > > > - *
> > > > + * Copyright (c) Linux Test Project, 2015-2022
> > > > + * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
> > > > * Written by Matus Marhefka <mmarhefk@redhat.com>
> > > > + */
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-10 18:11 ` Bird, Tim
@ 2023-03-13 20:53 ` Petr Vorel
2023-03-23 15:59 ` Petr Vorel
1 sibling, 0 replies; 12+ messages in thread
From: Petr Vorel @ 2023-03-13 20:53 UTC (permalink / raw)
To: Bird, Tim; +Cc: ltp@lists.linux.it, Matus Marhefka
> > -----Original Message-----
> > From: Petr Vorel <pvorel@suse.cz>
> > Hi all,
> > > Hi Tim,
> > > > > +++ b/testcases/kernel/containers/share/ns_ifmove.c
> > > > > @@ -1,43 +1,31 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0-or-later
> > > > I don't see "or later" anywhere in the license header that was removed.
> > > > Is this the correct SPDX license identifier?
> > > > Maybe it should be 'GPL-2.0-only'
> > > Good catch, thank you!
> > FYI I contacted Matus Marhefka privately and got his ack:
> > I am not on that mailing list anymore. Anyway, feel free to re-license any
> > of my tests to GPL-v2+, you have my agreement :)
> > => going to use the original version.
> Sounds good. You may want to note this authorization to change the
> license, in the commit message for this patch.
Hi Tim,
Make sense, I'll do. Thanks for paying attention to license, it's important.
Kind regards,
Petr
> -- Tim
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-10 18:11 ` Bird, Tim
2023-03-13 20:53 ` Petr Vorel
@ 2023-03-23 15:59 ` Petr Vorel
1 sibling, 0 replies; 12+ messages in thread
From: Petr Vorel @ 2023-03-23 15:59 UTC (permalink / raw)
To: Bird, Tim; +Cc: ltp@lists.linux.it, Matus Marhefka
Hi all,
FYI merged. Thanks for your comments.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-09 14:59 [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API Petr Vorel
2023-03-09 14:59 ` Andrea Cervesato via ltp
2023-03-10 2:54 ` Bird, Tim
@ 2023-03-15 0:56 ` Wei Gao via ltp
2023-03-15 2:01 ` Petr Vorel
2 siblings, 1 reply; 12+ messages in thread
From: Wei Gao via ltp @ 2023-03-15 0:56 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Thu, Mar 09, 2023 at 03:59:17PM +0100, Petr Vorel wrote:
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> testcases/kernel/containers/share/ns_ifmove.c | 98 ++++++-------------
> 1 file changed, 28 insertions(+), 70 deletions(-)
>
> int intf_index, pid, rtnetlink_socket;
>
> if (argc != 3) {
> - tst_resm(TINFO, "%s <INTERFACE_NAME> <NAMESPACE_PID>",
> - argv[0]);
> + printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
> return 1;
> }
>
should we use tst_res(TINFO) instead of printf?
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-15 0:56 ` Wei Gao via ltp
@ 2023-03-15 2:01 ` Petr Vorel
2023-03-15 4:38 ` Wei Gao via ltp
0 siblings, 1 reply; 12+ messages in thread
From: Petr Vorel @ 2023-03-15 2:01 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
> On Thu, Mar 09, 2023 at 03:59:17PM +0100, Petr Vorel wrote:
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > testcases/kernel/containers/share/ns_ifmove.c | 98 ++++++-------------
> > 1 file changed, 28 insertions(+), 70 deletions(-)
> > int intf_index, pid, rtnetlink_socket;
> > if (argc != 3) {
> > - tst_resm(TINFO, "%s <INTERFACE_NAME> <NAMESPACE_PID>",
> > - argv[0]);
> > + printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
> > return 1;
> > }
> should we use tst_res(TINFO) instead of printf?
NO. If you look into testcases/lib/, none of *.c tools use tst_res().
The only separation between API for tests and API for tools / library
than TST_NO_DEFAULT_MAIN.
Actually, unless SAFE_*() are useful to use (here SAFE_SOCKET() and
SAFE_IOCTL()), we prefer to not use tst_test.h at all (see tst_cgctl.c,
tst_device.c, ...)
I also think that tst_get_free_pids.c does not need TST_NO_DEFAULT_MAIN and
tst_test workarounds.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-15 2:01 ` Petr Vorel
@ 2023-03-15 4:38 ` Wei Gao via ltp
2023-03-15 10:35 ` Petr Vorel
0 siblings, 1 reply; 12+ messages in thread
From: Wei Gao via ltp @ 2023-03-15 4:38 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Wed, Mar 15, 2023 at 03:01:40AM +0100, Petr Vorel wrote:
> > On Thu, Mar 09, 2023 at 03:59:17PM +0100, Petr Vorel wrote:
> > > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > > ---
> > > testcases/kernel/containers/share/ns_ifmove.c | 98 ++++++-------------
> > > 1 file changed, 28 insertions(+), 70 deletions(-)
>
> > > int intf_index, pid, rtnetlink_socket;
>
> > > if (argc != 3) {
> > > - tst_resm(TINFO, "%s <INTERFACE_NAME> <NAMESPACE_PID>",
> > > - argv[0]);
> > > + printf("ns_ifmove <INTERFACE_NAME> <NAMESPACE_PID>\n");
> > > return 1;
> > > }
>
> > should we use tst_res(TINFO) instead of printf?
>
> NO. If you look into testcases/lib/, none of *.c tools use tst_res().
> The only separation between API for tests and API for tools / library
> than TST_NO_DEFAULT_MAIN.
Got it, this is lib API. Why ns_ifmove.c's parent directory name is
"share" instead of "lib" or at least contain "lib" key word?
>
> Actually, unless SAFE_*() are useful to use (here SAFE_SOCKET() and
> SAFE_IOCTL()), we prefer to not use tst_test.h at all (see tst_cgctl.c,
> tst_device.c, ...)
>
> I also think that tst_get_free_pids.c does not need TST_NO_DEFAULT_MAIN and
> tst_test workarounds.
Is there possible split current tst_test.h to two files and remove
TST_NO_DEFAULT_MAIN workaround? Such as tst_tools.h(include SAFE*) for lib api
and main.h for testcase.
>
> Kind regards,
> Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API
2023-03-15 4:38 ` Wei Gao via ltp
@ 2023-03-15 10:35 ` Petr Vorel
0 siblings, 0 replies; 12+ messages in thread
From: Petr Vorel @ 2023-03-15 10:35 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi Wei,
> > > should we use tst_res(TINFO) instead of printf?
> > NO. If you look into testcases/lib/, none of *.c tools use tst_res().
> > The only separation between API for tests and API for tools / library
> > than TST_NO_DEFAULT_MAIN.
> Got it, this is lib API. Why ns_ifmove.c's parent directory name is
> "share" instead of "lib" or at least contain "lib" key word?
The move is in another patchset:
https://lore.kernel.org/ltp/20230310124125.14279-1-pvorel@suse.cz/
> > Actually, unless SAFE_*() are useful to use (here SAFE_SOCKET() and
> > SAFE_IOCTL()), we prefer to not use tst_test.h at all (see tst_cgctl.c,
> > tst_device.c, ...)
> > I also think that tst_get_free_pids.c does not need TST_NO_DEFAULT_MAIN and
> > tst_test workarounds.
> Is there possible split current tst_test.h to two files and remove
> TST_NO_DEFAULT_MAIN workaround? Such as tst_tools.h(include SAFE*) for lib api
> and main.h for testcase.
IMHO that would not be trivial, i.e. not worth of the effort.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-03-23 16:00 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-09 14:59 [LTP] [PATCH 1/1] ns_ifmove.c: Rewrite to new API Petr Vorel
2023-03-09 14:59 ` Andrea Cervesato via ltp
2023-03-10 2:54 ` Bird, Tim
2023-03-10 7:34 ` Petr Vorel
2023-03-10 11:47 ` Petr Vorel
2023-03-10 18:11 ` Bird, Tim
2023-03-13 20:53 ` Petr Vorel
2023-03-23 15:59 ` Petr Vorel
2023-03-15 0:56 ` Wei Gao via ltp
2023-03-15 2:01 ` Petr Vorel
2023-03-15 4:38 ` Wei Gao via ltp
2023-03-15 10:35 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox