Re: [ovs-dev] [RFC v2 8/9] tests: Add test-psample testing utility.

2024-06-28 Thread Adrián Moreno
On Wed, Jun 26, 2024 at 02:14:27PM GMT, Eelco Chaudron wrote:
> On 5 Jun 2024, at 22:23, Adrian Moreno wrote:
>
> > This simple program reads from psample and prints the packets to stdout.
>
> Some comments below.
>
> //Eelco
>
> > Signed-off-by: Adrian Moreno 
> > ---
> >  include/linux/automake.mk |   1 +
> >  include/linux/psample.h   |  68 +
> >  tests/automake.mk |   3 +-
> >  tests/test-psample.c  | 282 ++
> >  4 files changed, 353 insertions(+), 1 deletion(-)
> >  create mode 100644 include/linux/psample.h
> >  create mode 100644 tests/test-psample.c
> >
> > diff --git a/include/linux/automake.mk b/include/linux/automake.mk
> > index cdae5eedc..ac306b53c 100644
> > --- a/include/linux/automake.mk
> > +++ b/include/linux/automake.mk
> > @@ -3,6 +3,7 @@ noinst_HEADERS += \
> > include/linux/netfilter/nf_conntrack_sctp.h \
> > include/linux/openvswitch.h \
> > include/linux/pkt_cls.h \
> > +   include/linux/psample.h \
> > include/linux/gen_stats.h \
> > include/linux/tc_act/tc_mpls.h \
> > include/linux/tc_act/tc_pedit.h \
> > diff --git a/include/linux/psample.h b/include/linux/psample.h
> > new file mode 100644
> > index 0..d5761b730
> > --- /dev/null
> > +++ b/include/linux/psample.h
> > @@ -0,0 +1,68 @@
> > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> > +#ifndef __LINUX_PSAMPLE_H
> > +#define __LINUX_PSAMPLE_H
> > +
> > +enum {
> > +   PSAMPLE_ATTR_IIFINDEX,
> > +   PSAMPLE_ATTR_OIFINDEX,
> > +   PSAMPLE_ATTR_ORIGSIZE,
> > +   PSAMPLE_ATTR_SAMPLE_GROUP,
> > +   PSAMPLE_ATTR_GROUP_SEQ,
> > +   PSAMPLE_ATTR_SAMPLE_RATE,
> > +   PSAMPLE_ATTR_DATA,
> > +   PSAMPLE_ATTR_GROUP_REFCOUNT,
> > +   PSAMPLE_ATTR_TUNNEL,
> > +
> > +   PSAMPLE_ATTR_PAD,
> > +   PSAMPLE_ATTR_OUT_TC,/* u16 */
> > +   PSAMPLE_ATTR_OUT_TC_OCC,/* u64, bytes */
> > +   PSAMPLE_ATTR_LATENCY,   /* u64, nanoseconds */
> > +   PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */
> > +   PSAMPLE_ATTR_PROTO, /* u16 */
> > +   PSAMPLE_ATTR_USER_COOKIE,   /* binary, user provided data */
> > +   PSAMPLE_ATTR_SAMPLE_PROBABILITY,/* no argument, interpret rate in
> > +* PSAMPLE_ATTR_SAMPLE_RATE as a
> > +* probability scaled 0 - U32_MAX.
> > +*/
> > +
> > +   __PSAMPLE_ATTR_MAX
> > +};
> > +
> > +enum psample_command {
> > +   PSAMPLE_CMD_SAMPLE,
> > +   PSAMPLE_CMD_GET_GROUP,
> > +   PSAMPLE_CMD_NEW_GROUP,
> > +   PSAMPLE_CMD_DEL_GROUP,
> > +   PSAMPLE_CMD_SAMPLE_FILTER_SET,
> > +};
> > +
> > +enum psample_tunnel_key_attr {
> > +   PSAMPLE_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_IPV4_SRC,   /* be32 src IP address. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_IPV4_DST,   /* be32 dst IP address. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_TOS,/* u8 Tunnel IP ToS. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_TTL,/* u8 Tunnel IP TTL. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_DONT_FRAGMENT,  /* No argument, set DF. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_CSUM,   /* No argument. CSUM 
> > packet. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_OAM,/* No argument. OAM frame.  
> > */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_GENEVE_OPTS,/* Array of Geneve options. 
> > */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. 
> > */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. 
> > */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested VXLAN opts* */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_IPV6_SRC,   /* struct in6_addr src IPv6 
> > address. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_IPV6_DST,   /* struct in6_addr dst IPv6 
> > address. */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_PAD,
> > +   PSAMPLE_TUNNEL_KEY_ATTR_ERSPAN_OPTS,/* struct erspan_metadata */
> > +   PSAMPLE_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE,   /* No argument. 
> > IPV4_INFO_BRIDGE mode.*/
> > +   __PSAMPLE_TUNNEL_KEY_ATTR_MAX
> > +};
> > +
> > +/* Can be overridden at runtime by module option */
> > +#define PSAMPLE_ATTR_MAX (__PSAMPLE_ATTR_MAX - 1)
> > +
> > +#define PSAMPLE_NL_MCGRP_CONFIG_NAME "config"
> > +#define PSAMPLE_NL_MCGRP_SAMPLE_NAME "packets"
> > +#define PSAMPLE_GENL_NAME "psample"
> > +#define PSAMPLE_GENL_VERSION 1
> > +
> > +#endif
> > diff --git a/tests/automake.mk b/tests/automake.mk
> > index 04f48f2d8..edfc2cb33 100644
> > --- a/tests/automake.mk
> > +++ b/tests/automake.mk
> > @@ -499,7 +499,8 @@ endif
> >  if LINUX
> >  tests_ovstest_SOURCES += \
> > tests/test-netlink-conntrack.c \
> > -   tests/test-netlink-policy.c
> > +   tests/test-netlink-policy.c \
> > +   tests/test-psample.c
> >  endif
> >
> >  tests_ovstest_LDADD = lib/libopenvswitch.la
> > diff --git a/tests/test-psample.c b/tests/test-psample.c
> > new file mode 100644
> > index 0..f04d903

Re: [ovs-dev] [RFC v2 8/9] tests: Add test-psample testing utility.

2024-06-26 Thread Eelco Chaudron
On 5 Jun 2024, at 22:23, Adrian Moreno wrote:

> This simple program reads from psample and prints the packets to stdout.

Some comments below.

//Eelco

> Signed-off-by: Adrian Moreno 
> ---
>  include/linux/automake.mk |   1 +
>  include/linux/psample.h   |  68 +
>  tests/automake.mk |   3 +-
>  tests/test-psample.c  | 282 ++
>  4 files changed, 353 insertions(+), 1 deletion(-)
>  create mode 100644 include/linux/psample.h
>  create mode 100644 tests/test-psample.c
>
> diff --git a/include/linux/automake.mk b/include/linux/automake.mk
> index cdae5eedc..ac306b53c 100644
> --- a/include/linux/automake.mk
> +++ b/include/linux/automake.mk
> @@ -3,6 +3,7 @@ noinst_HEADERS += \
>   include/linux/netfilter/nf_conntrack_sctp.h \
>   include/linux/openvswitch.h \
>   include/linux/pkt_cls.h \
> + include/linux/psample.h \
>   include/linux/gen_stats.h \
>   include/linux/tc_act/tc_mpls.h \
>   include/linux/tc_act/tc_pedit.h \
> diff --git a/include/linux/psample.h b/include/linux/psample.h
> new file mode 100644
> index 0..d5761b730
> --- /dev/null
> +++ b/include/linux/psample.h
> @@ -0,0 +1,68 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +#ifndef __LINUX_PSAMPLE_H
> +#define __LINUX_PSAMPLE_H
> +
> +enum {
> + PSAMPLE_ATTR_IIFINDEX,
> + PSAMPLE_ATTR_OIFINDEX,
> + PSAMPLE_ATTR_ORIGSIZE,
> + PSAMPLE_ATTR_SAMPLE_GROUP,
> + PSAMPLE_ATTR_GROUP_SEQ,
> + PSAMPLE_ATTR_SAMPLE_RATE,
> + PSAMPLE_ATTR_DATA,
> + PSAMPLE_ATTR_GROUP_REFCOUNT,
> + PSAMPLE_ATTR_TUNNEL,
> +
> + PSAMPLE_ATTR_PAD,
> + PSAMPLE_ATTR_OUT_TC,/* u16 */
> + PSAMPLE_ATTR_OUT_TC_OCC,/* u64, bytes */
> + PSAMPLE_ATTR_LATENCY,   /* u64, nanoseconds */
> + PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */
> + PSAMPLE_ATTR_PROTO, /* u16 */
> + PSAMPLE_ATTR_USER_COOKIE,   /* binary, user provided data */
> + PSAMPLE_ATTR_SAMPLE_PROBABILITY,/* no argument, interpret rate in
> +  * PSAMPLE_ATTR_SAMPLE_RATE as a
> +  * probability scaled 0 - U32_MAX.
> +  */
> +
> + __PSAMPLE_ATTR_MAX
> +};
> +
> +enum psample_command {
> + PSAMPLE_CMD_SAMPLE,
> + PSAMPLE_CMD_GET_GROUP,
> + PSAMPLE_CMD_NEW_GROUP,
> + PSAMPLE_CMD_DEL_GROUP,
> + PSAMPLE_CMD_SAMPLE_FILTER_SET,
> +};
> +
> +enum psample_tunnel_key_attr {
> + PSAMPLE_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */
> + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_SRC,   /* be32 src IP address. */
> + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_DST,   /* be32 dst IP address. */
> + PSAMPLE_TUNNEL_KEY_ATTR_TOS,/* u8 Tunnel IP ToS. */
> + PSAMPLE_TUNNEL_KEY_ATTR_TTL,/* u8 Tunnel IP TTL. */
> + PSAMPLE_TUNNEL_KEY_ATTR_DONT_FRAGMENT,  /* No argument, set DF. */
> + PSAMPLE_TUNNEL_KEY_ATTR_CSUM,   /* No argument. CSUM 
> packet. */
> + PSAMPLE_TUNNEL_KEY_ATTR_OAM,/* No argument. OAM frame.  
> */
> + PSAMPLE_TUNNEL_KEY_ATTR_GENEVE_OPTS,/* Array of Geneve options. 
> */
> + PSAMPLE_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. 
> */
> + PSAMPLE_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. 
> */
> + PSAMPLE_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested VXLAN opts* */
> + PSAMPLE_TUNNEL_KEY_ATTR_IPV6_SRC,   /* struct in6_addr src IPv6 
> address. */
> + PSAMPLE_TUNNEL_KEY_ATTR_IPV6_DST,   /* struct in6_addr dst IPv6 
> address. */
> + PSAMPLE_TUNNEL_KEY_ATTR_PAD,
> + PSAMPLE_TUNNEL_KEY_ATTR_ERSPAN_OPTS,/* struct erspan_metadata */
> + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE,   /* No argument. 
> IPV4_INFO_BRIDGE mode.*/
> + __PSAMPLE_TUNNEL_KEY_ATTR_MAX
> +};
> +
> +/* Can be overridden at runtime by module option */
> +#define PSAMPLE_ATTR_MAX (__PSAMPLE_ATTR_MAX - 1)
> +
> +#define PSAMPLE_NL_MCGRP_CONFIG_NAME "config"
> +#define PSAMPLE_NL_MCGRP_SAMPLE_NAME "packets"
> +#define PSAMPLE_GENL_NAME "psample"
> +#define PSAMPLE_GENL_VERSION 1
> +
> +#endif
> diff --git a/tests/automake.mk b/tests/automake.mk
> index 04f48f2d8..edfc2cb33 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -499,7 +499,8 @@ endif
>  if LINUX
>  tests_ovstest_SOURCES += \
>   tests/test-netlink-conntrack.c \
> - tests/test-netlink-policy.c
> + tests/test-netlink-policy.c \
> + tests/test-psample.c
>  endif
>
>  tests_ovstest_LDADD = lib/libopenvswitch.la
> diff --git a/tests/test-psample.c b/tests/test-psample.c
> new file mode 100644
> index 0..f04d903b1
> --- /dev/null
> +++ b/tests/test-psample.c
> @@ -0,0 +1,282 @@
> +/*
> + * Copyright (c) 2024 Red Hat, Inc.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not

Re: [ovs-dev] [RFC v2 8/9] tests: Add test-psample testing utility.

2024-06-05 Thread 0-day Robot
Bleep bloop.  Greetings Adrian Moreno, I am a robot and I have tried out your 
patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


Patch skipped due to previous failure.

Please check this out.  If you feel there has been an error, please email 
acon...@redhat.com

Thanks,
0-day Robot
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [RFC v2 8/9] tests: Add test-psample testing utility.

2024-06-05 Thread Adrian Moreno
This simple program reads from psample and prints the packets to stdout.

Signed-off-by: Adrian Moreno 
---
 include/linux/automake.mk |   1 +
 include/linux/psample.h   |  68 +
 tests/automake.mk |   3 +-
 tests/test-psample.c  | 282 ++
 4 files changed, 353 insertions(+), 1 deletion(-)
 create mode 100644 include/linux/psample.h
 create mode 100644 tests/test-psample.c

diff --git a/include/linux/automake.mk b/include/linux/automake.mk
index cdae5eedc..ac306b53c 100644
--- a/include/linux/automake.mk
+++ b/include/linux/automake.mk
@@ -3,6 +3,7 @@ noinst_HEADERS += \
include/linux/netfilter/nf_conntrack_sctp.h \
include/linux/openvswitch.h \
include/linux/pkt_cls.h \
+   include/linux/psample.h \
include/linux/gen_stats.h \
include/linux/tc_act/tc_mpls.h \
include/linux/tc_act/tc_pedit.h \
diff --git a/include/linux/psample.h b/include/linux/psample.h
new file mode 100644
index 0..d5761b730
--- /dev/null
+++ b/include/linux/psample.h
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __LINUX_PSAMPLE_H
+#define __LINUX_PSAMPLE_H
+
+enum {
+   PSAMPLE_ATTR_IIFINDEX,
+   PSAMPLE_ATTR_OIFINDEX,
+   PSAMPLE_ATTR_ORIGSIZE,
+   PSAMPLE_ATTR_SAMPLE_GROUP,
+   PSAMPLE_ATTR_GROUP_SEQ,
+   PSAMPLE_ATTR_SAMPLE_RATE,
+   PSAMPLE_ATTR_DATA,
+   PSAMPLE_ATTR_GROUP_REFCOUNT,
+   PSAMPLE_ATTR_TUNNEL,
+
+   PSAMPLE_ATTR_PAD,
+   PSAMPLE_ATTR_OUT_TC,/* u16 */
+   PSAMPLE_ATTR_OUT_TC_OCC,/* u64, bytes */
+   PSAMPLE_ATTR_LATENCY,   /* u64, nanoseconds */
+   PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */
+   PSAMPLE_ATTR_PROTO, /* u16 */
+   PSAMPLE_ATTR_USER_COOKIE,   /* binary, user provided data */
+   PSAMPLE_ATTR_SAMPLE_PROBABILITY,/* no argument, interpret rate in
+* PSAMPLE_ATTR_SAMPLE_RATE as a
+* probability scaled 0 - U32_MAX.
+*/
+
+   __PSAMPLE_ATTR_MAX
+};
+
+enum psample_command {
+   PSAMPLE_CMD_SAMPLE,
+   PSAMPLE_CMD_GET_GROUP,
+   PSAMPLE_CMD_NEW_GROUP,
+   PSAMPLE_CMD_DEL_GROUP,
+   PSAMPLE_CMD_SAMPLE_FILTER_SET,
+};
+
+enum psample_tunnel_key_attr {
+   PSAMPLE_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */
+   PSAMPLE_TUNNEL_KEY_ATTR_IPV4_SRC,   /* be32 src IP address. */
+   PSAMPLE_TUNNEL_KEY_ATTR_IPV4_DST,   /* be32 dst IP address. */
+   PSAMPLE_TUNNEL_KEY_ATTR_TOS,/* u8 Tunnel IP ToS. */
+   PSAMPLE_TUNNEL_KEY_ATTR_TTL,/* u8 Tunnel IP TTL. */
+   PSAMPLE_TUNNEL_KEY_ATTR_DONT_FRAGMENT,  /* No argument, set DF. */
+   PSAMPLE_TUNNEL_KEY_ATTR_CSUM,   /* No argument. CSUM 
packet. */
+   PSAMPLE_TUNNEL_KEY_ATTR_OAM,/* No argument. OAM frame.  
*/
+   PSAMPLE_TUNNEL_KEY_ATTR_GENEVE_OPTS,/* Array of Geneve options. 
*/
+   PSAMPLE_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. 
*/
+   PSAMPLE_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. 
*/
+   PSAMPLE_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested VXLAN opts* */
+   PSAMPLE_TUNNEL_KEY_ATTR_IPV6_SRC,   /* struct in6_addr src IPv6 
address. */
+   PSAMPLE_TUNNEL_KEY_ATTR_IPV6_DST,   /* struct in6_addr dst IPv6 
address. */
+   PSAMPLE_TUNNEL_KEY_ATTR_PAD,
+   PSAMPLE_TUNNEL_KEY_ATTR_ERSPAN_OPTS,/* struct erspan_metadata */
+   PSAMPLE_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE,   /* No argument. 
IPV4_INFO_BRIDGE mode.*/
+   __PSAMPLE_TUNNEL_KEY_ATTR_MAX
+};
+
+/* Can be overridden at runtime by module option */
+#define PSAMPLE_ATTR_MAX (__PSAMPLE_ATTR_MAX - 1)
+
+#define PSAMPLE_NL_MCGRP_CONFIG_NAME "config"
+#define PSAMPLE_NL_MCGRP_SAMPLE_NAME "packets"
+#define PSAMPLE_GENL_NAME "psample"
+#define PSAMPLE_GENL_VERSION 1
+
+#endif
diff --git a/tests/automake.mk b/tests/automake.mk
index 04f48f2d8..edfc2cb33 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -499,7 +499,8 @@ endif
 if LINUX
 tests_ovstest_SOURCES += \
tests/test-netlink-conntrack.c \
-   tests/test-netlink-policy.c
+   tests/test-netlink-policy.c \
+   tests/test-psample.c
 endif
 
 tests_ovstest_LDADD = lib/libopenvswitch.la
diff --git a/tests/test-psample.c b/tests/test-psample.c
new file mode 100644
index 0..f04d903b1
--- /dev/null
+++ b/tests/test-psample.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2024 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, soft