Re: [PATCH rtems-libbsd v2 3/4] rtemsbsd: Made TTCP command build for RTEMS

2021-06-15 Thread Christian Mauderer

On 15/06/2021 20:03, Joel Sherrill wrote:



On Tue, Jun 15, 2021 at 10:25 AM Gedare Bloom > wrote:


On Fri, Jun 11, 2021 at 11:19 AM Stephen Clark
mailto:stephen.cl...@oarcorp.com>> wrote:
 >
 > Updated ttcp.c to build for RTEMS 6, in addition to the machines
 > it originally built for. Also fixed ttcp.c to close network sockets
 > after completion. Defined a shell command for TTCP in
 > rtems-bsd-shell-ttcp.c. Added TTCP to the list of RTEMS network
 > commands in netcmds-config.h. Added declaration of the TTCP shell
 > command to rtems-bsd-commands.h. Modified libbsd.py to make waf
 > build TTCP and its shell command.
 > ---


[...]


 >
 >  char Usage[] = "\
 >  Usage: ttcp -t [-options] host [ < in ]\n\
 > @@ -173,16 +220,34 @@ void millisleep(long msec)
 >    nanosleep( , NULL );
 >  #endif
 >  }
 > +
Avoid making own changes outside of the __rtems__ guards if you're
trying to preserve compatibility with the upstream. Please read
contributing.md.


This one is a weird case. To run the ttcp benchmark, you must have two
systems running it. One is the Tx and the other is the Rx. This usually
means you are running TTCP on your RTEMS target and on your development
system. Some of these are needed to be clean on the native build. Other
parts are specific to RTEMS.

As you can tell from the date on the code it is quite old and it is 
questionable
if there is a maintained upstream.for this implementation. In answering 
this,
I found https://en.wikipedia.org/wiki/Ttcp 
 which points to nuttcp.net 
 and that
appears to be maintained since there was a release last year. But that's 
GPLv2

so we won't be using that.


Benchmarking is a quite specific use case and normally only added during 
testing and not in a final application. I think if nuttcp is an 
interesting tool, GPLv2 shouldn't be a big problem in this case. The 
only problem: It would have to be in a separate repository and not in 
libbsd. Alternatively the maintainers might accept patches that allow 
using nuttcp as a library so that we don't have to add a clone of the 
sources in RTEMS at all.




We need some changes to make it clean natively and some to make it work
on RTEMS. And I don't think there is really an active upstream for this. 
This

was a new port based on newer ways of doing things in RTEMS. What
do you think is best?



Normally I would start with the version that is provided by the FreeBSD 
ports collection (which would be from 06.04.2021 at 
https://www.freshports.org/benchmarks/ttcp/), apply the FreeBSD patches 
to it and then use the normal __rtems__ markers. With that we can use 
the FreeBSD patches for that if there are updates necessary.


Like I said: That would be my method. Don't feel forced to use that.


It occurred to me as I typed this that perhaps the native version should
be built as part of rtems-tools instead of assuming the end user would
compile this source by hand from libbsd. But then we would be duplicating
the file.



We now have two network stak repos and maybe someone adds lwip to a 
separate repository somewhen. Wouldn't it be better in that case to have 
a fork of ttcp in a separate repository anyway so that it can be used 
with all stacks and (maybe) also build as a host tool with rtems-tools?


I didn't have a look at ttcp (or nuttcp) and I'm not sure whether it 
depends heavily on the host operating system or not. If it is heavily 
adapted to the FreeBSD stack, compiling it as a stack-independent 
library won't work. Please just say so if that is the case.


Please note that I don't want to insist on that (or any of the other 
points above). It just might would be a possibility to avoid duplicating 
code to every network stack repo and the host.


Best regards

Christian


Not a good solution all around. I suspect we really cloned and owned.

--joel



[...]
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH rtems-libbsd v2 3/4] rtemsbsd: Made TTCP command build for RTEMS

2021-06-15 Thread Joel Sherrill
On Tue, Jun 15, 2021 at 10:25 AM Gedare Bloom  wrote:

> On Fri, Jun 11, 2021 at 11:19 AM Stephen Clark
>  wrote:
> >
> > Updated ttcp.c to build for RTEMS 6, in addition to the machines
> > it originally built for. Also fixed ttcp.c to close network sockets
> > after completion. Defined a shell command for TTCP in
> > rtems-bsd-shell-ttcp.c. Added TTCP to the list of RTEMS network
> > commands in netcmds-config.h. Added declaration of the TTCP shell
> > command to rtems-bsd-commands.h. Modified libbsd.py to make waf
> > build TTCP and its shell command.
> > ---
> >  libbsd.py |   2 +
> >  rtemsbsd/include/machine/rtems-bsd-commands.h |   2 +
> >  rtemsbsd/include/rtems/netcmds-config.h   |   2 +
> >  rtemsbsd/rtems/rtems-bsd-shell-ttcp.c |  39 +++
> >  rtemsbsd/ttcp/README  |  11 +-
> >  rtemsbsd/ttcp/ttcp.c  | 266 ++
> >  6 files changed, 262 insertions(+), 60 deletions(-)
> >  create mode 100644 rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
> >
> > diff --git a/libbsd.py b/libbsd.py
> > index b367d94e..2badfdee 100644
> > --- a/libbsd.py
> > +++ b/libbsd.py
> > @@ -269,6 +269,7 @@ class rtems(builder.Module):
> >  'rtems/rtems-bsd-shell-tcpdump.c',
> >  'rtems/rtems-bsd-shell-vmstat.c',
> >  'rtems/rtems-bsd-shell-wlanstats.c',
> > +'rtems/rtems-bsd-shell-ttcp.c',
> >  'rtems/rtems-kvm.c',
> >  'rtems/rtems-program.c',
> >  'rtems/rtems-program-socket.c',
> > @@ -292,6 +293,7 @@ class rtems(builder.Module):
> >  'pppd/upap.c',
> >  'pppd/utils.c',
> >  'telnetd/telnetd-service.c',
> > +'ttcp/ttcp.c',
> >  ],
> >  mm.generator['source']()
> >  )
> > diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h
> b/rtemsbsd/include/machine/rtems-bsd-commands.h
> > index d314471f..d82c274c 100644
> > --- a/rtemsbsd/include/machine/rtems-bsd-commands.h
> > +++ b/rtemsbsd/include/machine/rtems-bsd-commands.h
> > @@ -84,6 +84,8 @@ int rtems_bsd_command_setkey(int argc, char **argv);
> >
> >  int rtems_bsd_command_openssl(int argc, char **argv);
> >
> > +int rtems_shell_main_ttcp(int argc, char **argv);
> > +
> >  __END_DECLS
> >
> >  #endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_COMMANDS_H_ */
> > diff --git a/rtemsbsd/include/rtems/netcmds-config.h
> b/rtemsbsd/include/rtems/netcmds-config.h
> > index bc493af4..c1d56eb3 100644
> > --- a/rtemsbsd/include/rtems/netcmds-config.h
> > +++ b/rtemsbsd/include/rtems/netcmds-config.h
> > @@ -29,6 +29,8 @@ extern rtems_shell_cmd_t rtems_shell_PFCTL_Command;
> >  extern rtems_shell_cmd_t rtems_shell_PING_Command;
> >  extern rtems_shell_cmd_t rtems_shell_PING6_Command;
> >
> > +extern rtems_shell_cmd_t rtems_shell_TTCP_Command;
> > +
> >  extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
> >
> >  extern rtems_shell_cmd_t rtems_shell_IFMCSTAT_Command;
> > diff --git a/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
> b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
> > new file mode 100644
> > index ..babaa011
> > --- /dev/null
> > +++ b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
> > @@ -0,0 +1,39 @@
> > +/* SPDX-License-Identifier: BSD-2-Clause */
> > +
> > +/*
> > + * COPYRIGHT (c) 2021. On-Line Applications Research Corporation (OAR).
> > + * All rights reserved.
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions
> > + * are met:
> > + * 1. Redistributions of source code must retain the above copyright
> > + *notice, this list of conditions and the following disclaimer.
> > + * 2. Redistributions in binary form must reproduce the above copyright
> > + *notice, this list of conditions and the following disclaimer in
> the
> > + *documentation and/or other materials provided with the
> distribution.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
> AND
> > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
> PURPOSE
> > + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
> LIABLE
> > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> CONSEQUENTIAL
> > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
> GOODS
> > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
> STRICT
> > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
> ANY WAY
> > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
> OF
> > + * SUCH DAMAGE.
> > + */
> > +
> > +#include 
> > +#include 
> > +
> > +rtems_shell_cmd_t rtems_shell_TTCP_Command = {
> > +  "ttcp",   

Re: [PATCH rtems-libbsd v2 3/4] rtemsbsd: Made TTCP command build for RTEMS

2021-06-15 Thread Gedare Bloom
On Fri, Jun 11, 2021 at 11:19 AM Stephen Clark
 wrote:
>
> Updated ttcp.c to build for RTEMS 6, in addition to the machines
> it originally built for. Also fixed ttcp.c to close network sockets
> after completion. Defined a shell command for TTCP in
> rtems-bsd-shell-ttcp.c. Added TTCP to the list of RTEMS network
> commands in netcmds-config.h. Added declaration of the TTCP shell
> command to rtems-bsd-commands.h. Modified libbsd.py to make waf
> build TTCP and its shell command.
> ---
>  libbsd.py |   2 +
>  rtemsbsd/include/machine/rtems-bsd-commands.h |   2 +
>  rtemsbsd/include/rtems/netcmds-config.h   |   2 +
>  rtemsbsd/rtems/rtems-bsd-shell-ttcp.c |  39 +++
>  rtemsbsd/ttcp/README  |  11 +-
>  rtemsbsd/ttcp/ttcp.c  | 266 ++
>  6 files changed, 262 insertions(+), 60 deletions(-)
>  create mode 100644 rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
>
> diff --git a/libbsd.py b/libbsd.py
> index b367d94e..2badfdee 100644
> --- a/libbsd.py
> +++ b/libbsd.py
> @@ -269,6 +269,7 @@ class rtems(builder.Module):
>  'rtems/rtems-bsd-shell-tcpdump.c',
>  'rtems/rtems-bsd-shell-vmstat.c',
>  'rtems/rtems-bsd-shell-wlanstats.c',
> +'rtems/rtems-bsd-shell-ttcp.c',
>  'rtems/rtems-kvm.c',
>  'rtems/rtems-program.c',
>  'rtems/rtems-program-socket.c',
> @@ -292,6 +293,7 @@ class rtems(builder.Module):
>  'pppd/upap.c',
>  'pppd/utils.c',
>  'telnetd/telnetd-service.c',
> +'ttcp/ttcp.c',
>  ],
>  mm.generator['source']()
>  )
> diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h 
> b/rtemsbsd/include/machine/rtems-bsd-commands.h
> index d314471f..d82c274c 100644
> --- a/rtemsbsd/include/machine/rtems-bsd-commands.h
> +++ b/rtemsbsd/include/machine/rtems-bsd-commands.h
> @@ -84,6 +84,8 @@ int rtems_bsd_command_setkey(int argc, char **argv);
>
>  int rtems_bsd_command_openssl(int argc, char **argv);
>
> +int rtems_shell_main_ttcp(int argc, char **argv);
> +
>  __END_DECLS
>
>  #endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_COMMANDS_H_ */
> diff --git a/rtemsbsd/include/rtems/netcmds-config.h 
> b/rtemsbsd/include/rtems/netcmds-config.h
> index bc493af4..c1d56eb3 100644
> --- a/rtemsbsd/include/rtems/netcmds-config.h
> +++ b/rtemsbsd/include/rtems/netcmds-config.h
> @@ -29,6 +29,8 @@ extern rtems_shell_cmd_t rtems_shell_PFCTL_Command;
>  extern rtems_shell_cmd_t rtems_shell_PING_Command;
>  extern rtems_shell_cmd_t rtems_shell_PING6_Command;
>
> +extern rtems_shell_cmd_t rtems_shell_TTCP_Command;
> +
>  extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
>
>  extern rtems_shell_cmd_t rtems_shell_IFMCSTAT_Command;
> diff --git a/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c 
> b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
> new file mode 100644
> index ..babaa011
> --- /dev/null
> +++ b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
> @@ -0,0 +1,39 @@
> +/* SPDX-License-Identifier: BSD-2-Clause */
> +
> +/*
> + * COPYRIGHT (c) 2021. On-Line Applications Research Corporation (OAR).
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#include 
> +#include 
> +
> +rtems_shell_cmd_t rtems_shell_TTCP_Command = {
> +  "ttcp",   /* name */
> +  "ttcp -h # to get help",  /* usage */
> +  "net",/* topic */
> +  rtems_shell_main_ttcp,/* command */
> +  NULL,  

[PATCH rtems-libbsd v2 3/4] rtemsbsd: Made TTCP command build for RTEMS

2021-06-11 Thread Stephen Clark
Updated ttcp.c to build for RTEMS 6, in addition to the machines
it originally built for. Also fixed ttcp.c to close network sockets
after completion. Defined a shell command for TTCP in
rtems-bsd-shell-ttcp.c. Added TTCP to the list of RTEMS network
commands in netcmds-config.h. Added declaration of the TTCP shell
command to rtems-bsd-commands.h. Modified libbsd.py to make waf
build TTCP and its shell command.
---
 libbsd.py |   2 +
 rtemsbsd/include/machine/rtems-bsd-commands.h |   2 +
 rtemsbsd/include/rtems/netcmds-config.h   |   2 +
 rtemsbsd/rtems/rtems-bsd-shell-ttcp.c |  39 +++
 rtemsbsd/ttcp/README  |  11 +-
 rtemsbsd/ttcp/ttcp.c  | 266 ++
 6 files changed, 262 insertions(+), 60 deletions(-)
 create mode 100644 rtemsbsd/rtems/rtems-bsd-shell-ttcp.c

diff --git a/libbsd.py b/libbsd.py
index b367d94e..2badfdee 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -269,6 +269,7 @@ class rtems(builder.Module):
 'rtems/rtems-bsd-shell-tcpdump.c',
 'rtems/rtems-bsd-shell-vmstat.c',
 'rtems/rtems-bsd-shell-wlanstats.c',
+'rtems/rtems-bsd-shell-ttcp.c',
 'rtems/rtems-kvm.c',
 'rtems/rtems-program.c',
 'rtems/rtems-program-socket.c',
@@ -292,6 +293,7 @@ class rtems(builder.Module):
 'pppd/upap.c',
 'pppd/utils.c',
 'telnetd/telnetd-service.c',
+'ttcp/ttcp.c',
 ],
 mm.generator['source']()
 )
diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h 
b/rtemsbsd/include/machine/rtems-bsd-commands.h
index d314471f..d82c274c 100644
--- a/rtemsbsd/include/machine/rtems-bsd-commands.h
+++ b/rtemsbsd/include/machine/rtems-bsd-commands.h
@@ -84,6 +84,8 @@ int rtems_bsd_command_setkey(int argc, char **argv);
 
 int rtems_bsd_command_openssl(int argc, char **argv);
 
+int rtems_shell_main_ttcp(int argc, char **argv);
+
 __END_DECLS
 
 #endif /* _RTEMS_BSD_MACHINE_RTEMS_BSD_COMMANDS_H_ */
diff --git a/rtemsbsd/include/rtems/netcmds-config.h 
b/rtemsbsd/include/rtems/netcmds-config.h
index bc493af4..c1d56eb3 100644
--- a/rtemsbsd/include/rtems/netcmds-config.h
+++ b/rtemsbsd/include/rtems/netcmds-config.h
@@ -29,6 +29,8 @@ extern rtems_shell_cmd_t rtems_shell_PFCTL_Command;
 extern rtems_shell_cmd_t rtems_shell_PING_Command;
 extern rtems_shell_cmd_t rtems_shell_PING6_Command;
 
+extern rtems_shell_cmd_t rtems_shell_TTCP_Command;
+
 extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
 
 extern rtems_shell_cmd_t rtems_shell_IFMCSTAT_Command;
diff --git a/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c 
b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
new file mode 100644
index ..babaa011
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-shell-ttcp.c
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * COPYRIGHT (c) 2021. On-Line Applications Research Corporation (OAR).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+#include 
+
+rtems_shell_cmd_t rtems_shell_TTCP_Command = {
+  "ttcp",   /* name */
+  "ttcp -h # to get help",  /* usage */
+  "net",/* topic */
+  rtems_shell_main_ttcp,/* command */
+  NULL, /* alias */
+  NULL  /* next */
+};
diff --git a/rtemsbsd/ttcp/README b/rtemsbsd/ttcp/README
index 215ddacc..8a9bf017 100644
--- a/rtemsbsd/ttcp/README
+++ b/rtemsbsd/ttcp/README
@@ -7,14 +7,9 @@ but please