* [LTP] [RFC PATCH v2 0/4] Add headers in lapi
@ 2017-12-21 19:27 Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 1/4] lapi: Add lapi/tcp.h with definitions moved from netstress.c Petr Vorel
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Petr Vorel @ 2017-12-21 19:27 UTC (permalink / raw)
To: ltp
Hi,
any comments on this cleanup patch-set?
I haven't figured how to rename include/lapi/in.h.
The rest should be ok.
As Alexey updates testcases/network/netstress/netstress.c quite often,
I'd like to get rid of rebasing patch :-).
Kind regards,
Petr
Petr Vorel (4):
lapi: Add lapi/tcp.h with definitions moved from netstress.c
lapi/socket.h: Move definitions from netstress.c
lapi: Add lapi/in.h with definition moved from netstress.c
lapi: Add lapi/dccp.h with definition moved from netstress.c
include/lapi/dccp.h | 27 ++++++++++++++++++++++++
include/lapi/in.h | 27 ++++++++++++++++++++++++
include/lapi/socket.h | 18 ++++++++++++++++
include/lapi/tcp.h | 31 +++++++++++++++++++++++++++
testcases/network/netstress/netstress.c | 37 ++++++---------------------------
5 files changed, 109 insertions(+), 31 deletions(-)
create mode 100644 include/lapi/dccp.h
create mode 100644 include/lapi/in.h
create mode 100644 include/lapi/tcp.h
--
2.15.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [RFC PATCH v2 1/4] lapi: Add lapi/tcp.h with definitions moved from netstress.c
2017-12-21 19:27 [LTP] [RFC PATCH v2 0/4] Add headers in lapi Petr Vorel
@ 2017-12-21 19:27 ` Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions " Petr Vorel
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2017-12-21 19:27 UTC (permalink / raw)
To: ltp
+ include <netinet/tcp.h> in netstress.c.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
include/lapi/tcp.h | 31 +++++++++++++++++++++++++++++++
testcases/network/netstress/netstress.c | 11 ++---------
2 files changed, 33 insertions(+), 9 deletions(-)
create mode 100644 include/lapi/tcp.h
diff --git a/include/lapi/tcp.h b/include/lapi/tcp.h
new file mode 100644
index 000000000..ebb0d79b2
--- /dev/null
+++ b/include/lapi/tcp.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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/>.
+ */
+
+#ifndef LAPI_TCP_H__
+#define LAPI_TCP_H__
+
+#include <netinet/tcp.h>
+
+#ifndef TCP_FASTOPEN
+# define TCP_FASTOPEN 23
+#endif
+
+#ifndef TCP_FASTOPEN_CONNECT
+# define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect */
+#endif
+
+#endif /* LAPI_TCP_H__ */
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index c6726306a..cc07e9fd5 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -25,6 +25,7 @@
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <poll.h>
#include <time.h>
@@ -33,6 +34,7 @@
#include <errno.h>
#include "lapi/posix_clocks.h"
+#include "lapi/tcp.h"
#include "tst_safe_stdio.h"
#include "tst_safe_pthread.h"
#include "tst_test.h"
@@ -53,15 +55,6 @@ static const int min_msg_len = 5;
#define DCCP_SOCKOPT_SERVICE 2
#endif
-/* TCP server requiers */
-#ifndef TCP_FASTOPEN
-#define TCP_FASTOPEN 23
-#endif
-
-#ifndef TCP_FASTOPEN_CONNECT
-#define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect */
-#endif
-
#ifndef SO_BUSY_POLL
#define SO_BUSY_POLL 46
#endif
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions from netstress.c
2017-12-21 19:27 [LTP] [RFC PATCH v2 0/4] Add headers in lapi Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 1/4] lapi: Add lapi/tcp.h with definitions moved from netstress.c Petr Vorel
@ 2017-12-21 19:27 ` Petr Vorel
2017-12-25 9:50 ` Alexey Kodanev
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 3/4] lapi: Add lapi/in.h with definition moved " Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 4/4] lapi: Add lapi/dccp.h " Petr Vorel
3 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2017-12-21 19:27 UTC (permalink / raw)
To: ltp
and use lapi/socket.h in netstress.c.
+ include <sys/socket.h> in lapi/socket.h
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
include/lapi/socket.h | 18 ++++++++++++++++++
testcases/network/netstress/netstress.c | 17 ++---------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/include/lapi/socket.h b/include/lapi/socket.h
index 98263105e..d97d29f36 100644
--- a/include/lapi/socket.h
+++ b/include/lapi/socket.h
@@ -19,8 +19,26 @@
#ifndef __LAPI_SOCKET_H__
#define __LAPI_SOCKET_H__
+#include <sys/socket.h>
+
+#ifndef MSG_FASTOPEN
+# define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
+#endif
+
+#ifndef SO_BUSY_POLL
+# define SO_BUSY_POLL 46
+#endif
+
#ifndef SOCK_CLOEXEC
# define SOCK_CLOEXEC 02000000
#endif
+#ifndef SOCK_DCCP
+# define SOCK_DCCP 6
+#endif
+
+#ifndef SOL_DCCP
+# define SOL_DCCP 269
+#endif
+
#endif /* __LAPI_SOCKET_H__ */
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index cc07e9fd5..6a6b57c1f 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include "lapi/posix_clocks.h"
+#include "lapi/socket.h"
#include "lapi/tcp.h"
#include "tst_safe_stdio.h"
#include "tst_safe_pthread.h"
@@ -42,28 +43,14 @@
static const int max_msg_len = (1 << 16) - 1;
static const int min_msg_len = 5;
-#ifndef SOCK_DCCP
-#define SOCK_DCCP 6
-#endif
#ifndef IPPROTO_DCCP
#define IPPROTO_DCCP 33
#endif
-#ifndef SOL_DCCP
-#define SOL_DCCP 269
-#endif
+
#ifndef DCCP_SOCKOPT_SERVICE
#define DCCP_SOCKOPT_SERVICE 2
#endif
-#ifndef SO_BUSY_POLL
-#define SO_BUSY_POLL 46
-#endif
-
-/* TCP client requiers */
-#ifndef MSG_FASTOPEN
-#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
-#endif
-
enum {
SERVER_HOST = 0,
CLIENT_HOST,
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [RFC PATCH v2 3/4] lapi: Add lapi/in.h with definition moved from netstress.c
2017-12-21 19:27 [LTP] [RFC PATCH v2 0/4] Add headers in lapi Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 1/4] lapi: Add lapi/tcp.h with definitions moved from netstress.c Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions " Petr Vorel
@ 2017-12-21 19:27 ` Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 4/4] lapi: Add lapi/dccp.h " Petr Vorel
3 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2017-12-21 19:27 UTC (permalink / raw)
To: ltp
and use lapi/in.h in netstress.c.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
include/lapi/in.h | 27 +++++++++++++++++++++++++++
testcases/network/netstress/netstress.c | 5 +----
2 files changed, 28 insertions(+), 4 deletions(-)
create mode 100644 include/lapi/in.h
diff --git a/include/lapi/in.h b/include/lapi/in.h
new file mode 100644
index 000000000..84aca4d2a
--- /dev/null
+++ b/include/lapi/in.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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/>.
+ */
+
+#ifndef LAPI_IN_H__
+#define LAPI_IN_H__
+
+#include <netinet/in.h>
+
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
+
+#endif /* LAPI_IN_H__ */
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 6a6b57c1f..ccf5af24c 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <errno.h>
+#include "lapi/in.h"
#include "lapi/posix_clocks.h"
#include "lapi/socket.h"
#include "lapi/tcp.h"
@@ -43,10 +44,6 @@
static const int max_msg_len = (1 << 16) - 1;
static const int min_msg_len = 5;
-#ifndef IPPROTO_DCCP
-#define IPPROTO_DCCP 33
-#endif
-
#ifndef DCCP_SOCKOPT_SERVICE
#define DCCP_SOCKOPT_SERVICE 2
#endif
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [RFC PATCH v2 4/4] lapi: Add lapi/dccp.h with definition moved from netstress.c
2017-12-21 19:27 [LTP] [RFC PATCH v2 0/4] Add headers in lapi Petr Vorel
` (2 preceding siblings ...)
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 3/4] lapi: Add lapi/in.h with definition moved " Petr Vorel
@ 2017-12-21 19:27 ` Petr Vorel
3 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2017-12-21 19:27 UTC (permalink / raw)
To: ltp
and use lapi/dccp.h in netstress.c.
+ include <linux/dccp.h> in netstress.c.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
include/lapi/dccp.h | 27 +++++++++++++++++++++++++++
testcases/network/netstress/netstress.c | 6 ++----
2 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 include/lapi/dccp.h
diff --git a/include/lapi/dccp.h b/include/lapi/dccp.h
new file mode 100644
index 000000000..1d7fa0522
--- /dev/null
+++ b/include/lapi/dccp.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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/>.
+ */
+
+#ifndef LAPI_DCCP_H__
+#define LAPI_DCCP_H__
+
+#include <linux/dccp.h>
+
+#ifndef DCCP_SOCKOPT_SERVICE
+# define DCCP_SOCKOPT_SERVICE 2
+#endif
+
+#endif /* LAPI_DCCP_H__ */
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index ccf5af24c..66efb50b2 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -21,6 +21,7 @@
#include <pthread.h>
#include <stdlib.h>
#include <limits.h>
+#include <linux/dccp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
@@ -33,6 +34,7 @@
#include <unistd.h>
#include <errno.h>
+#include "lapi/dccp.h"
#include "lapi/in.h"
#include "lapi/posix_clocks.h"
#include "lapi/socket.h"
@@ -44,10 +46,6 @@
static const int max_msg_len = (1 << 16) - 1;
static const int min_msg_len = 5;
-#ifndef DCCP_SOCKOPT_SERVICE
-#define DCCP_SOCKOPT_SERVICE 2
-#endif
-
enum {
SERVER_HOST = 0,
CLIENT_HOST,
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions from netstress.c
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions " Petr Vorel
@ 2017-12-25 9:50 ` Alexey Kodanev
2017-12-27 8:42 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Alexey Kodanev @ 2017-12-25 9:50 UTC (permalink / raw)
To: ltp
On 12/21/2017 10:27 PM, Petr Vorel wrote:
> and use lapi/socket.h in netstress.c.
>
> + include <sys/socket.h> in lapi/socket.h
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> include/lapi/socket.h | 18 ++++++++++++++++++
> testcases/network/netstress/netstress.c | 17 ++---------------
> 2 files changed, 20 insertions(+), 15 deletions(-)
>
> diff --git a/include/lapi/socket.h b/include/lapi/socket.h
> index 98263105e..d97d29f36 100644
> --- a/include/lapi/socket.h
> +++ b/include/lapi/socket.h
> @@ -19,8 +19,26 @@
> #ifndef __LAPI_SOCKET_H__
> #define __LAPI_SOCKET_H__
>
> +#include <sys/socket.h>
> +
> +#ifndef MSG_FASTOPEN
> +# define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
> +#endif
> +
> +#ifndef SO_BUSY_POLL
> +# define SO_BUSY_POLL 46
> +#endif
> +
> #ifndef SOCK_CLOEXEC
> # define SOCK_CLOEXEC 02000000
> #endif
>
> +#ifndef SOCK_DCCP
> +# define SOCK_DCCP 6
> +#endif
I would move it above SOCK_CLOEXEC, so we can keep the order
of these flags similarly to bits/socket.h.
The other patches in this set look good, thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions from netstress.c
2017-12-25 9:50 ` Alexey Kodanev
@ 2017-12-27 8:42 ` Petr Vorel
2018-01-04 8:19 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2017-12-27 8:42 UTC (permalink / raw)
To: ltp
Hi Alexey,
thanks for your review.
> > #ifndef SOCK_CLOEXEC
> > # define SOCK_CLOEXEC 02000000
> > #endif
> > +#ifndef SOCK_DCCP
> > +# define SOCK_DCCP 6
> > +#endif
> I would move it above SOCK_CLOEXEC, so we can keep the order
> of these flags similarly to bits/socket.h.
You probably mean bits/socket_type.h. Sure.
> The other patches in this set look good, thanks!
Just one exception, if you don't mind:
I use lapi/netinet_in.h instead of lapi/in.h. I don't like inconsistency (other headers in
lapi don't use prefix), but using just in.h is confusing, as there is also linux/in.h, as
Cyril pointed out.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions from netstress.c
2017-12-27 8:42 ` Petr Vorel
@ 2018-01-04 8:19 ` Petr Vorel
0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-01-04 8:19 UTC (permalink / raw)
To: ltp
Hi Alexey, Cyril,
> > The other patches in this set look good, thanks!
> Just one exception, if you don't mind:
> I use lapi/netinet_in.h instead of lapi/in.h. I don't like inconsistency (other headers in
> lapi don't use prefix), but using just in.h is confusing, as there is also linux/in.h, as
> Cyril pointed out.
Merged whole patche-set.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-01-04 8:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-21 19:27 [LTP] [RFC PATCH v2 0/4] Add headers in lapi Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 1/4] lapi: Add lapi/tcp.h with definitions moved from netstress.c Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 2/4] lapi/socket.h: Move definitions " Petr Vorel
2017-12-25 9:50 ` Alexey Kodanev
2017-12-27 8:42 ` Petr Vorel
2018-01-04 8:19 ` Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 3/4] lapi: Add lapi/in.h with definition moved " Petr Vorel
2017-12-21 19:27 ` [LTP] [RFC PATCH v2 4/4] lapi: Add lapi/dccp.h " Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox