Compare commits

...

No commits in common. "c8" and "c10s" have entirely different histories.
c8 ... c10s

70 changed files with 3267 additions and 1875 deletions

27
.gitignore vendored
View File

@ -1 +1,26 @@
SOURCES/iproute2-6.2.0.tar.xz
/iproute2-4.18.0.tar.xz
/iproute2-4.20.0.tar.xz
/iproute2-5.0.0.tar.xz
/iproute2-5.1.0.tar.xz
/iproute2-5.2.0.tar.xz
/iproute2-5.3.0.tar.xz
/iproute2-5.4.0.tar.xz
/iproute2-5.5.0.tar.xz
/iproute2-5.7.0.tar.xz
/iproute2-5.8.0.tar.xz
/iproute2-5.9.0.tar.xz
/iproute2-5.10.0.tar.xz
/iproute2-5.11.0.tar.xz
/iproute2-5.12.0.tar.xz
/iproute2-5.13.0.tar.xz
/iproute2-5.14.0.tar.xz
/iproute2-5.15.0.tar.xz
/iproute2-5.17.0.tar.xz
/iproute2-5.18.0.tar.xz
/iproute2-6.0.0.tar.xz
/iproute2-6.1.0.tar.xz
/iproute2-6.2.0.tar.xz
/iproute2-6.3.0.tar.xz
/iproute2-6.4.0.tar.xz
/iproute2-6.5.0.tar.xz
/iproute2-6.7.0.tar.xz

View File

@ -1 +0,0 @@
f4e339800fe15b88cfa516cabcc9e883dda245d7 SOURCES/iproute2-6.2.0.tar.xz

View File

@ -0,0 +1,66 @@
From ac4e9bd66d9c8461024dfd3698e120c678eb6cfc Mon Sep 17 00:00:00 2001
Message-ID: <ac4e9bd66d9c8461024dfd3698e120c678eb6cfc.1707519557.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Fri, 9 Feb 2024 23:56:20 +0100
Subject: [PATCH] iproute2: fix build failure on ppc64le
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2261250
Upstream Status: posted upstream
commit d13ef7c00b60a50a5e8ddbb7ff138399689d3483
Author: Andrea Claudi <aclaudi@redhat.com>
Date: Fri Feb 9 10:44:55 2024 +0100
iproute2: fix build failure on ppc64le
ppc64le build fails with error on ifstat.c when
-Wincompatible-pointer-types is enabled:
ifstat.c: In function dump_raw_db:
ifstat.c:323:44: error: initialization of long long unsigned int * from incompatible pointer type __u64 * {aka long unsigned int *} [-Wincompatible-pointer-types]
323 | unsigned long long *vals = n->val;
Several other warnings are produced when -Wformat= is set, for example:
ss.c:3244:34: warning: format %llu expects argument of type long long unsigned int, but argument 2 has type __u64 {aka long unsigned int} [-Wformat=]
3244 | out(" rcv_nxt:%llu", s->mptcpi_rcv_nxt);
| ~~~^ ~~~~~~~~~~~~~~~~~
| | |
| | __u64 {aka long unsigned int}
| long long unsigned int
| %lu
This happens because __u64 is defined as long unsigned on ppc64le. As
pointed out by Florian Weimar, we should use -D__SANE_USERSPACE_TYPES__
if we really want to use long long unsigned in iproute2.
This fix the build failure and all the warnings without any change on
the code itself.
Suggested-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 8024d45e..3b9daede 100644
--- a/Makefile
+++ b/Makefile
@@ -60,7 +60,7 @@ CC := gcc
HOSTCC ?= $(CC)
DEFINES += -D_GNU_SOURCE
# Turn on transparent support for LFS
-DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__SANE_USERSPACE_TYPES__
CCOPTS = -O2 -pipe
WFLAGS := -Wall -Wstrict-prototypes -Wmissing-prototypes
WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
--
2.43.0

View File

@ -1,38 +0,0 @@
From 6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b Mon Sep 17 00:00:00 2001
Message-Id: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1683117490.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 3 May 2023 11:19:24 +0200
Subject: [PATCH] Update kernel headers
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2188134
Upstream Status: iproute2-next.git commit 88786cd1
commit 88786cd1a96a89427bc22061c7736eb2eac31121
Author: David Ahern <dsahern@kernel.org>
Date: Thu Mar 30 09:43:49 2023 -0600
Update kernel headers
Update kernel headers to commit:
da617cd8d906 ("smsc911x: remove superfluous variable init")
Signed-off-by: David Ahern <dsahern@kernel.org>
---
include/uapi/linux/if_link.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 147ad0a3..644d3554 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -628,6 +628,7 @@ enum {
IFLA_MACVLAN_MACADDR_COUNT,
IFLA_MACVLAN_BC_QUEUE_LEN,
IFLA_MACVLAN_BC_QUEUE_LEN_USED,
+ IFLA_MACVLAN_BC_CUTOFF,
__IFLA_MACVLAN_MAX,
};
--
2.40.1

View File

@ -1,149 +0,0 @@
From 1638c2909a2911f981ee437dafde70e5e8d721f8 Mon Sep 17 00:00:00 2001
Message-Id: <1638c2909a2911f981ee437dafde70e5e8d721f8.1683117490.git.aclaudi@redhat.com>
In-Reply-To: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1683117490.git.aclaudi@redhat.com>
References: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1683117490.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 3 May 2023 11:19:24 +0200
Subject: [PATCH] macvlan: Add bclim parameter
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2188134
Upstream Status: iproute2-next.git commit e8a3fb47
commit e8a3fb470b4e96aa35a2731c7cc175b946c0a62d
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu Mar 30 11:07:25 2023 +0800
macvlan: Add bclim parameter
This patch adds support for setting the broadcast queueing threshold
on macvlan devices. This controls which multicast packets will be
processed in a workqueue instead of inline.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
ip/iplink_macvlan.c | 26 ++++++++++++++++++++++++--
man/man8/ip-link.8.in | 18 ++++++++++++++++++
3 files changed, 43 insertions(+), 2 deletions(-)
Signed-off-by: David Ahern <dsahern@kernel.org>
---
ip/iplink_macvlan.c | 26 ++++++++++++++++++++++++--
man/man8/ip-link.8.in | 18 ++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/ip/iplink_macvlan.c b/ip/iplink_macvlan.c
index 0f13637d..6bdc76d1 100644
--- a/ip/iplink_macvlan.c
+++ b/ip/iplink_macvlan.c
@@ -26,13 +26,14 @@
static void print_explain(struct link_util *lu, FILE *f)
{
fprintf(f,
- "Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS [bcqueuelen BC_QUEUE_LEN]\n"
+ "Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS [bcqueuelen BC_QUEUE_LEN] [bclim BCLIM]\n"
"\n"
"MODE: private | vepa | bridge | passthru | source\n"
"MODE_FLAG: null | nopromisc | nodst\n"
"MODE_OPTS: for mode \"source\":\n"
"\tmacaddr { { add | del } <macaddr> | set [ <macaddr> [ <macaddr> ... ] ] | flush }\n"
- "BC_QUEUE_LEN: Length of the rx queue for broadcast/multicast: [0-4294967295]\n",
+ "BC_QUEUE_LEN: Length of the rx queue for broadcast/multicast: [0-4294967295]\n"
+ "BCLIM: Threshold for broadcast queueing: 32-bit integer\n",
lu->id
);
}
@@ -67,6 +68,12 @@ static int bc_queue_len_arg(const char *arg)
return -1;
}
+static int bclim_arg(const char *arg)
+{
+ fprintf(stderr, "Error: illegal value for \"bclim\": \"%s\"\n", arg);
+ return -1;
+}
+
static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
@@ -168,6 +175,15 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
return bc_queue_len_arg(*argv);
}
addattr32(n, 1024, IFLA_MACVLAN_BC_QUEUE_LEN, bc_queue_len);
+ } else if (!strcmp(*argv, "bclim")) {
+ __s32 bclim;
+ NEXT_ARG();
+
+ if (get_s32(&bclim, *argv, 0)) {
+ return bclim_arg(*argv);
+ }
+ addattr_l(n, 1024, IFLA_MACVLAN_BC_CUTOFF,
+ &bclim, sizeof(bclim));
} else if (matches(*argv, "help") == 0) {
explain(lu);
return -1;
@@ -245,6 +261,12 @@ static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
print_luint(PRINT_ANY, "usedbcqueuelen", "usedbcqueuelen %lu ", bc_queue_len);
}
+ if (tb[IFLA_MACVLAN_BC_CUTOFF] &&
+ RTA_PAYLOAD(tb[IFLA_MACVLAN_BC_CUTOFF]) >= sizeof(__s32)) {
+ __s32 bclim = rta_getattr_s32(tb[IFLA_MACVLAN_BC_CUTOFF]);
+ print_int(PRINT_ANY, "bclim", "bclim %d ", bclim);
+ }
+
/* in source mode, there are more options to print */
if (mode != MACVLAN_MODE_SOURCE)
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index eeddf493..62aebabd 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -1455,6 +1455,7 @@ the following additional arguments are supported:
.BR mode " { " private " | " vepa " | " bridge " | " passthru
.RB " [ " nopromisc " ] | " source " [ " nodst " ] } "
.RB " [ " bcqueuelen " { " LENGTH " } ] "
+.RB " [ " bclim " " LIMIT " ] "
.in +8
.sp
@@ -1513,6 +1514,13 @@ will be the maximum length that any macvlan interface has requested.
When listing device parameters both the bcqueuelen parameter
as well as the actual used bcqueuelen are listed to better help
the user understand the setting.
+
+.BR bclim " " LIMIT
+- Set the threshold for broadcast queueing.
+.BR LIMIT " must be a 32-bit integer."
+Setting this to -1 disables broadcast queueing altogether. Otherwise
+a multicast address will be queued as broadcast if the number of devices
+using it is greater than the given value.
.in -8
.TP
@@ -2675,6 +2683,9 @@ Update the broadcast/multicast queue length.
[
.BI bcqueuelen " LENGTH "
]
+[
+.BI bclim " LIMIT "
+]
.in +8
.BI bcqueuelen " LENGTH "
@@ -2688,6 +2699,13 @@ will be the maximum length that any macvlan interface has requested.
When listing device parameters both the bcqueuelen parameter
as well as the actual used bcqueuelen are listed to better help
the user understand the setting.
+
+.BI bclim " LIMIT "
+- Set the threshold for broadcast queueing.
+.IR LIMIT " must be a 32-bit integer."
+Setting this to -1 disables broadcast queueing altogether. Otherwise
+a multicast address will be queued as broadcast if the number of devices
+using it is greater than the given value.
.in -8
.TP
--
2.40.1

View File

@ -1,43 +0,0 @@
From 4c2e1768c0d446345796dc058d1e114147a1029a Mon Sep 17 00:00:00 2001
Message-Id: <4c2e1768c0d446345796dc058d1e114147a1029a.1686090191.git.aclaudi@redhat.com>
In-Reply-To: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1686090191.git.aclaudi@redhat.com>
References: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1686090191.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 7 Jun 2023 00:15:59 +0200
Subject: [PATCH] tc: add missing separator
Jira: https://issues.redhat.com/browse/RHEL-487
Upstream Status: iproute2-next.git commit 4e0e56e0
commit 4e0e56e0ef05387f7f5d8ab41fe6ec6a1897b26d
Author: Christian Hesse <mail@eworm.de>
Date: Thu Feb 23 11:15:03 2023 +0100
tc: add missing separator
This is missing a separator, that was accidently removed
when JSON was added.
Fixes: 010a8388aea1 ("tc: Add JSON output to tc-class")
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/tc_class.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tc/tc_class.c b/tc/tc_class.c
index c1feb009..096fa2ec 100644
--- a/tc/tc_class.c
+++ b/tc/tc_class.c
@@ -356,7 +356,7 @@ int print_class(struct nlmsghdr *n, void *arg)
print_string(PRINT_ANY, "parent", "parent %s ", abuf);
}
if (t->tcm_info)
- print_0xhex(PRINT_ANY, "leaf", "leaf %x", t->tcm_info>>16);
+ print_0xhex(PRINT_ANY, "leaf", "leaf %x: ", t->tcm_info>>16);
q = get_qdisc_kind(RTA_DATA(tb[TCA_KIND]));
if (tb[TCA_OPTIONS]) {
--
2.40.1

View File

@ -1,55 +0,0 @@
From dcff6d4c73cd9c33b4103a4505ecebe6852f63df Mon Sep 17 00:00:00 2001
Message-ID: <dcff6d4c73cd9c33b4103a4505ecebe6852f63df.1695227714.git.aclaudi@redhat.com>
In-Reply-To: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
References: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 5 Sep 2023 12:44:19 +0200
Subject: [PATCH] ss: make is_selinux_enabled stub work like in SELinux
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1780023
Upstream Status: iproute2-next.git commit c8970828
commit c8970828b6509af3ab0f2982da335fb6a6c846af
Author: Andrea Claudi <aclaudi@redhat.com>
Date: Wed Aug 23 19:29:59 2023 +0200
ss: make is_selinux_enabled stub work like in SELinux
From the is_selinux_enabled() manpage:
is_selinux_enabled() returns 1 if SELinux is running or 0 if it is not.
This makes the is_selinux_enabled() stub functions works exactly like
the SELinux function it is supposed to replace.
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
misc/ss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index de02fccb..d2dffbf8 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -77,7 +77,7 @@
/* Stubs for SELinux functions */
static int is_selinux_enabled(void)
{
- return -1;
+ return 0;
}
static int getpidcon(pid_t pid, char **context)
@@ -5684,7 +5684,7 @@ int main(int argc, char *argv[])
show_sock_ctx++;
/* fall through */
case 'Z':
- if (is_selinux_enabled() <= 0) {
+ if (!is_selinux_enabled()) {
fprintf(stderr, "ss: SELinux is not enabled.\n");
exit(1);
}
--
2.41.0

View File

@ -1,52 +0,0 @@
From d59fc35f66f5d0d6e7b3209c21f2c891a2ba0768 Mon Sep 17 00:00:00 2001
Message-ID: <d59fc35f66f5d0d6e7b3209c21f2c891a2ba0768.1695227714.git.aclaudi@redhat.com>
In-Reply-To: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
References: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 5 Sep 2023 12:44:19 +0200
Subject: [PATCH] ss: make SELinux stub functions conformant to API definitions
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1780023
Upstream Status: iproute2-next.git commit 61c6882c
commit 61c6882ce21c1247c06cd61783120be0a2e2019c
Author: Andrea Claudi <aclaudi@redhat.com>
Date: Wed Aug 23 19:30:00 2023 +0200
ss: make SELinux stub functions conformant to API definitions
getfilecon() and security_get_initial_context() use the const qualifier
for their first paramater in SELinux APIs.
This commit adds the const qualifier to these functions, making them
conformant to API definitions.
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
misc/ss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index d2dffbf8..fe19f489 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -86,13 +86,13 @@ static int getpidcon(pid_t pid, char **context)
return -1;
}
-static int getfilecon(char *path, char **context)
+static int getfilecon(const char *path, char **context)
{
*context = NULL;
return -1;
}
-static int security_get_initial_context(char *name, char **context)
+static int security_get_initial_context(const char *name, char **context)
{
*context = NULL;
return -1;
--
2.41.0

View File

@ -1,156 +0,0 @@
From 0e71f7774a764c0a19037b79b71d7146769082ac Mon Sep 17 00:00:00 2001
Message-ID: <0e71f7774a764c0a19037b79b71d7146769082ac.1695227714.git.aclaudi@redhat.com>
In-Reply-To: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
References: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 5 Sep 2023 12:44:19 +0200
Subject: [PATCH] lib: add SELinux include and stub functions
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1780023
Upstream Status: iproute2-next.git commit e246ebc3
commit e246ebc3b7f1f438310ad6fd1d5976ba6ccf7a69
Author: Andrea Claudi <aclaudi@redhat.com>
Date: Wed Aug 23 19:30:01 2023 +0200
lib: add SELinux include and stub functions
ss provides some selinux stub functions, useful when iproute2 is
compiled without selinux support.
Move them to lib/ so we can use them in other iproute2 tools.
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
include/selinux.h | 9 +++++++++
lib/Makefile | 4 ++++
lib/selinux.c | 32 ++++++++++++++++++++++++++++++++
misc/ss.c | 34 +---------------------------------
4 files changed, 46 insertions(+), 33 deletions(-)
create mode 100644 include/selinux.h
create mode 100644 lib/selinux.c
diff --git a/include/selinux.h b/include/selinux.h
new file mode 100644
index 00000000..499aa966
--- /dev/null
+++ b/include/selinux.h
@@ -0,0 +1,9 @@
+#if HAVE_SELINUX
+#include <selinux/selinux.h>
+#else
+int is_selinux_enabled(void);
+void freecon(char *context);
+int getpidcon(pid_t pid, char **context);
+int getfilecon(const char *path, char **context);
+int security_get_initial_context(const char *name, char **context);
+#endif
diff --git a/lib/Makefile b/lib/Makefile
index ddedd37f..aa7bbd2e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -13,6 +13,10 @@ UTILOBJ += bpf_libbpf.o
endif
endif
+ifneq ($(HAVE_SELINUX),y)
+UTILOBJ += selinux.o
+endif
+
NLOBJ=libgenl.o libnetlink.o
ifeq ($(HAVE_MNL),y)
NLOBJ += mnl_utils.o
diff --git a/lib/selinux.c b/lib/selinux.c
new file mode 100644
index 00000000..4e6805fc
--- /dev/null
+++ b/lib/selinux.c
@@ -0,0 +1,32 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include "selinux.h"
+
+/* Stubs for SELinux functions */
+int is_selinux_enabled(void)
+{
+ return 0;
+}
+
+void freecon(char *context)
+{
+ free(context);
+}
+
+int getpidcon(pid_t pid, char **context)
+{
+ *context = NULL;
+ return -1;
+}
+
+int getfilecon(const char *path, char **context)
+{
+ *context = NULL;
+ return -1;
+}
+
+int security_get_initial_context(const char *name, char **context)
+{
+ *context = NULL;
+ return -1;
+}
diff --git a/misc/ss.c b/misc/ss.c
index fe19f489..6e18bf0c 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -33,6 +33,7 @@
#include "version.h"
#include "rt_names.h"
#include "cg_map.h"
+#include "selinux.h"
#include <linux/tcp.h>
#include <linux/unix_diag.h>
@@ -71,39 +72,6 @@
#define BUF_CHUNKS_MAX 5 /* Maximum number of allocated buffer chunks */
#define LEN_ALIGN(x) (((x) + 1) & ~1)
-#if HAVE_SELINUX
-#include <selinux/selinux.h>
-#else
-/* Stubs for SELinux functions */
-static int is_selinux_enabled(void)
-{
- return 0;
-}
-
-static int getpidcon(pid_t pid, char **context)
-{
- *context = NULL;
- return -1;
-}
-
-static int getfilecon(const char *path, char **context)
-{
- *context = NULL;
- return -1;
-}
-
-static int security_get_initial_context(const char *name, char **context)
-{
- *context = NULL;
- return -1;
-}
-
-static void freecon(char *context)
-{
- free(context);
-}
-#endif
-
int preferred_family = AF_UNSPEC;
static int show_options;
int show_details;
--
2.41.0

View File

@ -1,81 +0,0 @@
From 6bfcc5679d601c393e7d6ca6c78c2d7680c3e4f2 Mon Sep 17 00:00:00 2001
Message-ID: <6bfcc5679d601c393e7d6ca6c78c2d7680c3e4f2.1695227714.git.aclaudi@redhat.com>
In-Reply-To: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
References: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1695227714.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 5 Sep 2023 12:44:19 +0200
Subject: [PATCH] ip vrf: make ipvrf_exec SELinux-aware
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1780023
Upstream Status: iproute2-next.git commit 0d0eeaa6
commit 0d0eeaa6cb9218e57ce910fc3a8991b80da6393e
Author: Andrea Claudi <aclaudi@redhat.com>
Date: Wed Aug 23 19:30:02 2023 +0200
ip vrf: make ipvrf_exec SELinux-aware
When using ip vrf and SELinux is enabled, make sure to set the exec file
context before calling cmd_exec.
This ensures that the command is executed with the right context,
falling back to the ifconfig_t context when needed.
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
include/selinux.h | 1 +
ip/ipvrf.c | 6 ++++++
lib/selinux.c | 5 +++++
3 files changed, 12 insertions(+)
diff --git a/include/selinux.h b/include/selinux.h
index 499aa966..592c7680 100644
--- a/include/selinux.h
+++ b/include/selinux.h
@@ -6,4 +6,5 @@ void freecon(char *context);
int getpidcon(pid_t pid, char **context);
int getfilecon(const char *path, char **context);
int security_get_initial_context(const char *name, char **context);
+int setexecfilecon(const char *filename, const char *fallback_type);
#endif
diff --git a/ip/ipvrf.c b/ip/ipvrf.c
index 0718bea8..b0dd2abe 100644
--- a/ip/ipvrf.c
+++ b/ip/ipvrf.c
@@ -24,6 +24,7 @@
#include "utils.h"
#include "ip_common.h"
#include "bpf_util.h"
+#include "selinux.h"
#define CGRP_PROC_FILE "/cgroup.procs"
@@ -455,6 +456,11 @@ static int ipvrf_exec(int argc, char **argv)
return -1;
}
+ if (is_selinux_enabled() && setexecfilecon(argv[1], "ifconfig_t")) {
+ fprintf(stderr, "setexecfilecon for \"%s\" failed\n", argv[1]);
+ return -1;
+ }
+
return -cmd_exec(argv[1], argv + 1, !!batch_mode, do_switch, argv[0]);
}
diff --git a/lib/selinux.c b/lib/selinux.c
index 4e6805fc..7e5dd16d 100644
--- a/lib/selinux.c
+++ b/lib/selinux.c
@@ -30,3 +30,8 @@ int security_get_initial_context(const char *name, char **context)
*context = NULL;
return -1;
}
+
+int setexecfilecon(const char *filename, const char *fallback_type)
+{
+ return -1;
+}
--
2.41.0

View File

@ -1,158 +0,0 @@
From e4e31412a2cdf90a08a7d5ab1a889f27ee13f7c9 Mon Sep 17 00:00:00 2001
Message-ID: <e4e31412a2cdf90a08a7d5ab1a889f27ee13f7c9.1710441171.git.aclaudi@redhat.com>
In-Reply-To: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1710441171.git.aclaudi@redhat.com>
References: <6a3ecf4fd80f7dcecb72b6c83781f5aed463a75b.1710441171.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
Date: Thu, 14 Mar 2024 19:26:55 +0100
Subject: [PATCH] ss: Add support for dumping TCP bound-inactive sockets.
JIRA: https://issues.redhat.com/browse/RHEL-21017
Upstream Status: iproute2.git commit ae447da64975ad02e40a93ccbc440a6477af96c0
commit ae447da64975ad02e40a93ccbc440a6477af96c0
Author: Guillaume Nault <gnault@redhat.com>
Date: Tue Dec 19 14:18:13 2023 +0100
ss: Add support for dumping TCP bound-inactive sockets.
Make ss aware of the new "bound-inactive" pseudo-state for TCP (see
Linux commit 91051f003948 ("tcp: Dump bound-only sockets in inet_diag.")).
These are TCP sockets that have been bound, but are neither listening nor
connecting.
With this patch, these sockets can now be dumped with:
* the existing -a (--all) option, to dump all sockets, including
bound-inactive ones,
* the new -B (--bound-inactive) option, to dump them exclusively,
* the new "bound-inactive" state, to be used in a STATE-FILTER.
Note that the SS_BOUND_INACTIVE state is a pseudo-state used for queries
only. The kernel returns them as SS_CLOSE.
The SS_NEW_SYN_RECV pseudo-state is added in this patch only because we
have to set its entry in the sstate_namel array (in scan_state()). Care
is taken not to make it visible by users.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
---
man/man8/ss.8 | 7 +++++++
misc/ss.c | 20 +++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/man/man8/ss.8 b/man/man8/ss.8
index d413e570..2bc42b85 100644
--- a/man/man8/ss.8
+++ b/man/man8/ss.8
@@ -40,6 +40,10 @@ established connections) sockets.
.B \-l, \-\-listening
Display only listening sockets (these are omitted by default).
.TP
+.B \-B, \-\-bound-inactive
+Display only TCP bound but inactive (not listening, connecting, etc.) sockets
+(these are omitted by default).
+.TP
.B \-o, \-\-options
Show timer information. For TCP protocol, the output format is:
.RS
@@ -458,6 +462,9 @@ states except for
- opposite to
.B bucket
+.B bound-inactive
+- bound but otherwise inactive sockets (not listening, connecting, etc.)
+
.SH EXPRESSION
.B EXPRESSION
diff --git a/misc/ss.c b/misc/ss.c
index 6e18bf0c..232178e6 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -210,6 +210,8 @@ enum {
SS_LAST_ACK,
SS_LISTEN,
SS_CLOSING,
+ SS_NEW_SYN_RECV, /* Kernel only value, not for use in user space */
+ SS_BOUND_INACTIVE,
SS_MAX
};
@@ -1377,6 +1379,8 @@ static void sock_state_print(struct sockstat *s)
[SS_LAST_ACK] = "LAST-ACK",
[SS_LISTEN] = "LISTEN",
[SS_CLOSING] = "CLOSING",
+ [SS_NEW_SYN_RECV] = "UNDEF", /* Never returned by kernel */
+ [SS_BOUND_INACTIVE] = "UNDEF", /* Never returned by kernel */
};
switch (s->local.family) {
@@ -5310,6 +5314,7 @@ static void _usage(FILE *dest)
" -r, --resolve resolve host names\n"
" -a, --all display all sockets\n"
" -l, --listening display listening sockets\n"
+" -B, --bound-inactive display TCP bound but inactive sockets\n"
" -o, --options show timer information\n"
" -e, --extended show detailed socket information\n"
" -m, --memory show socket memory usage\n"
@@ -5392,9 +5397,17 @@ static int scan_state(const char *state)
[SS_LAST_ACK] = "last-ack",
[SS_LISTEN] = "listening",
[SS_CLOSING] = "closing",
+ [SS_NEW_SYN_RECV] = "new-syn-recv",
+ [SS_BOUND_INACTIVE] = "bound-inactive",
};
int i;
+ /* NEW_SYN_RECV is a kernel implementation detail. It shouldn't be used
+ * or even be visible by users.
+ */
+ if (strcasecmp(state, "new-syn-recv") == 0)
+ goto wrong_state;
+
if (strcasecmp(state, "close") == 0 ||
strcasecmp(state, "closed") == 0)
return (1<<SS_CLOSE);
@@ -5417,6 +5430,7 @@ static int scan_state(const char *state)
return (1<<i);
}
+wrong_state:
fprintf(stderr, "ss: wrong state name: %s\n", state);
exit(-1);
}
@@ -5458,6 +5472,7 @@ static const struct option long_opts[] = {
{ "vsock", 0, 0, OPT_VSOCK },
{ "all", 0, 0, 'a' },
{ "listening", 0, 0, 'l' },
+ { "bound-inactive", 0, 0, 'B' },
{ "ipv4", 0, 0, '4' },
{ "ipv6", 0, 0, '6' },
{ "packet", 0, 0, '0' },
@@ -5496,7 +5511,7 @@ int main(int argc, char *argv[])
int state_filter = 0;
while ((ch = getopt_long(argc, argv,
- "dhaletuwxnro460spTbEf:mMiA:D:F:vVzZN:KHSO",
+ "dhalBetuwxnro460spTbEf:mMiA:D:F:vVzZN:KHSO",
long_opts, NULL)) != EOF) {
switch (ch) {
case 'n':
@@ -5561,6 +5576,9 @@ int main(int argc, char *argv[])
case 'l':
state_filter = (1 << SS_LISTEN) | (1 << SS_CLOSE);
break;
+ case 'B':
+ state_filter = 1 << SS_BOUND_INACTIVE;
+ break;
case '4':
filter_af_set(&current_filter, AF_INET);
break;
--
2.44.0

File diff suppressed because it is too large Load Diff

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier1-gating.functional}

130
iproute.spec Normal file
View File

@ -0,0 +1,130 @@
Summary: Advanced IP routing and network device configuration tools
Name: iproute
Version: 6.7.0
Release: %autorelease
URL: https://kernel.org/pub/linux/utils/net/%{name}2/
Source0: https://kernel.org/pub/linux/utils/net/%{name}2/%{name}2-%{version}.tar.xz
Source1: rt_dsfield.deprecated
Patch0: 0001-iproute2-fix-build-failure-on-ppc64le.patch
License: GPL-2.0-or-later AND NIST-PD
BuildRequires: bison
BuildRequires: elfutils-libelf-devel
BuildRequires: flex
BuildRequires: gcc
BuildRequires: iptables-devel >= 1.4.5
BuildRequires: libbpf-devel
BuildRequires: libcap-devel
BuildRequires: libmnl-devel
BuildRequires: libselinux-devel
BuildRequires: make
BuildRequires: pkgconfig
%if ! 0%{?_module_build}
%if 0%{?fedora}
BuildRequires: linux-atm-libs-devel
%endif
%endif
Requires: libbpf
Requires: psmisc
Provides: /sbin/ip
%description
The iproute package contains networking utilities (ip and rtmon, for example)
which are designed to use the advanced networking capabilities of the Linux
kernel.
%package tc
Summary: Linux Traffic Control utility
License: GPL-2.0-or-later
Requires: %{name}%{?_isa} = %{version}-%{release}
Provides: /sbin/tc
%description tc
The Traffic Control utility manages queueing disciplines, their classes and
attached filters and actions. It is the standard tool to configure QoS in
Linux.
%if ! 0%{?_module_build}
%package doc
Summary: Documentation for iproute2 utilities with examples
License: GPL-2.0-or-later
Requires: %{name} = %{version}-%{release}
%description doc
The iproute documentation contains howtos and examples of settings.
%endif
%package devel
Summary: iproute development files
License: GPL-2.0-or-later
Requires: %{name} = %{version}-%{release}
Provides: iproute-static = %{version}-%{release}
%description devel
The libnetlink static library.
%prep
%autosetup -p1 -n %{name}2-%{version}
%build
%configure --color auto
echo -e "\nSBINDIR=%{_sbindir}" >> config.mk
%make_build
%install
%make_install
echo '.so man8/tc-cbq.8' > %{buildroot}%{_mandir}/man8/cbq.8
# libnetlink
install -D -m644 include/libnetlink.h %{buildroot}%{_includedir}/libnetlink.h
install -D -m644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
# drop these files, iproute-doc package extracts files directly from _builddir
rm -rf '%{buildroot}%{_docdir}'
# append deprecated values to rt_dsfield for compatibility reasons
%if 0%{?rhel} && ! 0%{?eln}
cat %{SOURCE1} >>%{buildroot}%{_datadir}/iproute2/rt_dsfield
%endif
%files
%dir %{_datadir}/iproute2
%license COPYING
%doc README README.devel
%{_mandir}/man7/*
%exclude %{_mandir}/man7/tc-*
%{_mandir}/man8/*
%exclude %{_mandir}/man8/tc*
%exclude %{_mandir}/man8/cbq*
%attr(644,root,root) %config(noreplace) %{_datadir}/iproute2/*
%{_sbindir}/*
%exclude %{_sbindir}/tc
%exclude %{_sbindir}/routel
%{_datadir}/bash-completion/completions/devlink
%files tc
%license COPYING
%{_mandir}/man7/tc-*
%{_mandir}/man8/tc*
%{_mandir}/man8/cbq*
%dir %{_libdir}/tc/
%{_libdir}/tc/*
%{_sbindir}/tc
%{_datadir}/bash-completion/completions/tc
%if ! 0%{?_module_build}
%files doc
%license COPYING
%doc examples
%endif
%files devel
%license COPYING
%{_mandir}/man3/*
%{_libdir}/libnetlink.a
%{_includedir}/libnetlink.h
%{_includedir}/iproute2/bpf_elf.h
%changelog
%autochangelog

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (iproute2-6.7.0.tar.xz) = 5d8dca139b1b980dac6c841f477b951dd199074cb078b5ea8df23b3532eeb235cca1df9f6628b0f81b7edd62aaf4e95bad15a851843bd61e5715215da97cc546

View File

@ -0,0 +1,64 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/iproute/Sanity/bridge-utility
# Description: Test basic bridge funcionality
# Author: David Spurek <dspurek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/iproute/Sanity/bridge-utility
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: David Spurek <dspurek@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic bridge funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Requires: bridge-utils" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/bridge-utility
Description: Test basic bridge funcionality
Author: David Spurek <dspurek@redhat.com>

267
tests/bridge-utility/runtest.sh Executable file
View File

@ -0,0 +1,267 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/iproute/Sanity/bridge-utility
# Description: Test basic bridge funcionality
# Author: David Spurek <dspurek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
PACKAGES="$PACKAGE"
rlIsRHEL 6 && PACKAGES=( ${PACKAGES[@]} "bridge-utils" )
vxlan_name="testvxlan"
bridge_name="testbridge"
lsmod | grep dummy
dummy_loaded=$?
rlJournalStart
rlPhaseStartSetup
# Check reqiured packages.
for P in ${PACKAGES[@]}; do rlCheckRpm $P || rlDie "Package $P is missing"; done
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
no_dummy=0
if [ $dummy_loaded -eq 1 ] ; then
# dummy module doesn't loaded before the test
modprobe dummy numdummies=2
else
# dummy module loaded before the test, backup number of loaded dummy devices (nmdumies parameter), it is doesn't show under /sys/module/dummy/parameters
dummies_count=`ip a | grep dummy | tail -n 1 | sed -r 's/.*dummy([0-9]+).*/\1/'`
if [ -z $dummies_count ] ; then
# dummy module is loaded but no dummy device exists
no_dummy=1
else
# get correct count, dummy0 is the first
let "dummies_count=$dummies_count+1"
fi
rmmod dummy
modprobe dummy numdummies=2
fi
rlRun "ip addr flush dev dummy0"
rlRun "ip link set dummy0 up"
rlRun "ip addr flush dev dummy1"
rlRun "ip link set dummy1 up"
rlRun "ip addr add 127.0.0.13/24 dev dummy0" 0 "Setting IPv4 address to
dummy0 interface"
rlRun "ip addr add 127.0.0.14/24 dev dummy1" 0 "Setting IPv4 address to
dummy1 interface"
rlPhaseEnd
rlPhaseStartTest "Test bridge fdb basic funcionality with vxlan device"
rlRun "ip link add $vxlan_name type vxlan id 10 group 239.0.0.10 ttl 4 dev dummy0" 0 "add vxlan interface"
rlRun "ip addr add 192.168.1.1/24 broadcast 192.168.1.255 dev $vxlan_name" 0 "setting address to vxlan interface"
rlRun "ip -d link show $vxlan_name" 0 "show details about vxlan device"
vxlan_ether_address=`ip -d link show $vxlan_name | grep link/ether | awk '{print $2}'`
echo "ethernet address of vxlan device is: $vxlan_ether_address"
# add new entry to bridge fdb database (device must by type vxlan)
rlRun "bridge fdb add $vxlan_ether_address dst 192.19.0.2 dev $vxlan_name"
# check if entry was successfuly added
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertGrep "$vxlan_ether_address dst 192.19.0.2" bridge_show.out "-i"
# try replace entry in bridge fdb database
rlRun "bridge fdb replace $vxlan_ether_address dst 192.19.0.3 dev $vxlan_name"
# check if entry was successfuly changed
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertGrep "$vxlan_ether_address dst 192.19.0.3" bridge_show.out "-i"
rlRun "bridge fdb del $vxlan_ether_address dev $vxlan_name"
# check if entry was successfuly deleted
# 'default' entry added by ip link command should be still listed
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertNotGrep "$vxlan_ether_address dst 192.19.0.2" bridge_show.out "-i"
rlAssertGrep "dst 239.0.0.10 via dummy0" bridge_show.out "-i"
# add new entry to bridge fdb database with port,vni and via options
rlRun "bridge fdb add $vxlan_ether_address dst 192.19.0.2 dev $vxlan_name port 10000 vni 100 via dummy0"
# check if entry was successfuly added
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertGrep "$vxlan_ether_address dst 192.19.0.2 port 10000 vni 100 via dummy0" bridge_show.out "-i"
rlRun "bridge fdb del $vxlan_ether_address dev $vxlan_name"
# add new entry to bridge fdb database with self option
rlRun "bridge fdb add $vxlan_ether_address dst 192.19.0.2 dev $vxlan_name self"
# check if entry was successfuly added
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertGrep "$vxlan_ether_address dst 192.19.0.2 self" bridge_show.out "-i"
# replace entry in bridge fdb database with temp option
rlRun "bridge fdb replace $vxlan_ether_address dst 192.19.0.2 dev $vxlan_name temp"
# check if entry was successfuly changed
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertGrep "$vxlan_ether_address dst 192.19.0.2 self static" bridge_show.out "-i"
# replace entry in bridge fdb database with local option
rlRun "bridge fdb replace $vxlan_ether_address dst 192.19.0.2 dev $vxlan_name local"
# check if entry was successfuly changed
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertGrep "$vxlan_ether_address dst 192.19.0.2 self permanent" bridge_show.out "-i"
# replace entry in bridge fdb database with router option
rlRun "bridge fdb replace $vxlan_ether_address dst 192.19.0.2 dev $vxlan_name router"
# check if entry was successfuly changed
bridge fdb show dev $vxlan_name &> bridge_show.out
cat bridge_show.out
rlAssertGrep "$vxlan_ether_address dst 192.19.0.2 self router permanent" bridge_show.out "-i"
rlRun "bridge fdb del $vxlan_ether_address dev $vxlan_name"
rlRun "ip link del $vxlan_name" 0
rlPhaseEnd
rlPhaseStartTest "Test bridge fdb basic funcionality with bridge device, test bridge link set command"
# on rhels < 7 must be bridge device added with brctl (add type bridge is not supported)
rlIsRHEL '>=7' && rlRun "ip link add $bridge_name type bridge" 0 || rlRun "brctl addbr $bridge_name" 0
if rlIsRHEL '>=7'; then
rlRun "ip link set dummy0 master $bridge_name" 0 "Add dummy interface to bridge"
rlRun "bridge link show dev dummy0"
# test bridge link set, command is not supported on rhel < 7 (->ndo_bridge_setlink() is not in our kernel.)
rlRun "bridge link set dev dummy0 cost 10"
rlRun "bridge link show dev dummy0 &> bridge_show.out" 0
cat bridge_show.out
rlAssertGrep "dummy0.*cost 10 $" bridge_show.out "-i"
# add new entry to bridge fdb database with self option
rlRun "bridge fdb add 00:1b:21:55:23:61 dev dummy0 self"
bridge fdb show dev dummy0 &> bridge_show.out
cat bridge_show.out
rlAssertGrep "00:1b:21:55:23:61 self" bridge_show.out "-i"
# add new entry to bridge fdb database with master option
rlRun "bridge fdb add 00:1b:21:55:23:62 dev dummy0 master"
bridge fdb show dev dummy0 &> bridge_show.out
cat bridge_show.out
rlAssertGrep "00:1b:21:55:23:62 vlan 1" bridge_show.out "-i"
# add new entry to bridge fdb database with master and self options (entries for both should be added)
rlRun "bridge fdb add 00:1b:21:55:23:63 dev dummy0 self master"
bridge fdb show dev dummy0 &> bridge_show.out
cat bridge_show.out
rlAssertGrep "00:1b:21:55:23:63 self" bridge_show.out "-i"
rlAssertGrep "00:1b:21:55:23:63 vlan 1" bridge_show.out "-i"
else
rlRun "brctl addif $bridge_name dummy0" 0 "Add dummy interface to bridge"
rlRun "brctl show $bridge_name"
fi
rlIsRHEL '>=7' && rlRun "ip link set dummy0 nomaster" 0 "Remove dummy vlan interface from bridge" || rlRun "brctl delif $bridge_name dummy0" 0 "Remove dummy interface from bridge"
rlIsRHEL '>=7' && rlRun "ip link del $bridge_name" 0 || rlRun "brctl delbr $bridge_name" 0
rlPhaseEnd
rlPhaseStartTest "Test bridge vlan basic funcionality"
# on rhels < 7 must be bridge device added with brctl (add type bridge is not supported)
rlIsRHEL '>=7' && rlRun "ip link add $bridge_name type bridge" 0 || rlRun "brctl addbr $bridge_name" 0
rlRun "ip link add link dummy0 name dummy0.10 type vlan id 10"
if rlIsRHEL '>=7' ; then
rlRun "ip link set dummy0.10 master $bridge_name" 0 "Add dummy vlan interface to bridge"
rlRun "bridge link show dev dummy0.10"
else
rlRun "brctl addif $bridge_name dummy0.10" 0 "Add dummy vlan interface to bridge"
rlRun "brctl show $bridge_name"
fi
# bridge vlan is not supported on rhel < 6.8
if rlIsRHEL '>=7' || rlIsRHEL '>=6.8' || rlIsFedora; then
rlRun "bridge vlan add dev dummy0.10 vid 5" 0
else
rlRun "bridge vlan add dev dummy0.10 vid 5" 2
fi
# test correct funcionality only on rhel 7
if rlIsRHEL '>=7' ; then
bridge vlan &> bridge_vlan.out
cat bridge_vlan.out
#rlAssertGrep "dummy0.10.*5" bridge_vlan.out "-i"
#rlAssertGrep "dummy0.10.*10" bridge_vlan.out "-i"
rlRun "grep -A 2 'dummy0.10' bridge_vlan.out | grep '5'"
rlRun "bridge vlan del dev dummy0.10 vid 5"
bridge vlan &> bridge_vlan.out
cat bridge_vlan.out
#rlAssertNotGrep "dummy0.10" bridge_vlan.out "-i"
rlRun "grep -A 2 'dummy0.10' bridge_vlan.out | grep '5'" 1
fi
rlIsRHEL '>=7' && rlRun "ip link set dummy0.10 nomaster" 0 "Remove dummy vlan interface from bridge" || rlRun "brctl delif $bridge_name dummy0.10" 0 "Remove dummy vlan interface from bridge"
rlRun "ip link del dev dummy0.10"
rlIsRHEL '>=7' && rlRun "ip link del $bridge_name" 0 || rlRun "brctl delbr $bridge_name" 0
rlPhaseEnd
rlPhaseStartTest "Test bridge mdb basic funcionality"
rlRun "bridge mdb show" 0
rlPhaseEnd
if rlIsRHEL '>=7'; then
rlPhaseStartTest
rlRun "ip link add test_bridge type bridge"
rlRun "bridge fdb show | grep 'dev test_bridge' | grep 'master test_bridge'"
rlRun "ip link del test_bridge"
rlPhaseEnd
fi
rlPhaseStartCleanup
rlRun "ip route flush dev dummy0"
rlRun "ip link set dummy0 down"
rlRun "ip addr flush dev dummy0"
rlRun "ip route flush dev dummy1"
rlRun "ip link set dummy1 down"
rlRun "ip addr flush dev dummy1"
if [ $dummy_loaded -eq 1 ] ; then
rmmod dummy
else
rmmod dummy
if [ $no_dummy -eq 1 ] ; then
# load dummy module and delete dummy0 with ip link
modprobe dummy
rlIsRHEL '=7' && rlRun "ip link del dummy0"
else
modprobe dummy numdummies=$dummies_count
fi
fi
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-address-label-sanity-test
# Description: Test basic ip address label funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-address-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip address label funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-address-label-sanity-test
Description: Test basic ip address label funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,89 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-address-label-sanity-test
# Description: Test basic ip addrlabel funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
def add_dummy(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
def del_dummy(self):
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
class IPAddressLabelTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
self.add_dummy()
self.link_exists('dummy-test')
def tearDown(self):
self.del_dummy()
def test_add_address_label(self):
subprocess.call("ip addrlabel add prefix 2001:6f8:12d8:2::/64 label 200", shell=True)
subprocess.call("ip addrlabel add prefix 2001:6f8:900:8cbc::/64 label 300", shell=True)
subprocess.call("ip addrlabel add prefix 2001:4dd0:ff00:834::/64 label 200", shell=True)
subprocess.call("ip addrlabel add prefix 2a01:238:423d:8800::/64 label 300", shell=True)
output=subprocess.check_output(['ip', 'addrlabel']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "prefix 2001:6f8:12d8:2::/64 label 200")
self.assertRegex(output, "prefix 2001:6f8:900:8cbc::/64 label 300")
self.assertRegex(output, "prefix 2001:4dd0:ff00:834::/64 label 200")
self.assertRegex(output, "prefix 2a01:238:423d:8800::/64 label 300")
subprocess.call("ip addrlabel del prefix 2001:6f8:12d8:2::/64 label 200", shell=True)
subprocess.call("ip addrlabel del prefix 2001:6f8:900:8cbc::/64 label 300", shell=True)
subprocess.call("ip addrlabel del prefix 2001:4dd0:ff00:834::/64 label 200", shell=True)
subprocess.call("ip addrlabel del prefix 2a01:238:423d:8800::/64 label 300", shell=True)
def test_add_address_label_dev(self):
subprocess.call("ip addrlabel add prefix 2001:6f8:12d8:2::/64 label 200 dev dummy-test", shell=True)
subprocess.call("ip addrlabel add prefix 2001:6f8:900:8cbc::/64 label 300 dev dummy-test", shell=True)
subprocess.call("ip addrlabel add prefix 2001:4dd0:ff00:834::/64 label 200 dev dummy-test", shell=True)
subprocess.call("ip addrlabel add prefix 2a01:238:423d:8800::/64 label 300 dev dummy-test", shell=True)
output=subprocess.check_output(['ip', 'addrlabel']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "prefix 2001:6f8:12d8:2::/64 dev dummy-test label 200")
self.assertRegex(output, "prefix 2001:6f8:900:8cbc::/64 dev dummy-test label 300")
self.assertRegex(output, "prefix 2001:4dd0:ff00:834::/64 dev dummy-test label 200")
self.assertRegex(output, "prefix 2a01:238:423d:8800::/64 dev dummy-test label 300")
subprocess.call("ip addrlabel del prefix 2001:6f8:12d8:2::/64 label 200 dev dummy-test", shell=True)
subprocess.call("ip addrlabel del prefix 2001:6f8:900:8cbc::/64 label 300 dev dummy-test", shell=True)
subprocess.call("ip addrlabel del prefix 2001:4dd0:ff00:834::/64 label 200 dev dummy-test", shell=True)
subprocess.call("ip addrlabel del prefix 2a01:238:423d:8800::/64 label 300 dev dummy-test", shell=True)
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-address-label-sanity-test
# Description: Test basic ip address label funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-address-label-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip address label tests"
rlRun "/usr/bin/python3 /usr/bin/ip-address-label-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-address-label-tests.py"
rlLog "ip address label tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-address-sanity-test
# Description: Test basic ip address funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-address-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip address funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-address-sanity-test
Description: Test basic ip address funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,109 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-address-sanity-test
# Description: Test basic ip address funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
def add_dummy(self):
""" Setup """
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
def del_dummy(self):
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
class IPAddressTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
self.add_dummy()
def tearDown(self):
self.del_dummy()
def test_add_address(self):
r = subprocess.call("ip address add 192.168.1.200/24 dev dummy-test", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'address', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, "192.168.1.200")
def test_add_broadcast_address_label(self):
r = subprocess.call("ip addr add 192.168.1.50/24 brd + dev dummy-test label dummy-test-Home", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'address', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, "192.168.1.50")
self.assertRegex(output, "192.168.1.255")
self.assertRegex(output, "dummy-test-Home")
def test_del_address(self):
r = subprocess.call("ip address add 192.168.1.200/24 dev dummy-test", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'address', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, "192.168.1.200")
r = subprocess.call("ip address del 192.168.1.200/24 dev dummy-test", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'address', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertNotRegex(output, "192.168.1.200")
def test_add_address_scope(self):
r = subprocess.call("ip address add 192.168.1.200/24 dev dummy-test scope host", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'address', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, "192.168.1.200")
self.assertRegex(output, "host")
def test_add_address_lifetime(self):
r = subprocess.call("ip address add 192.168.1.200/24 dev dummy-test valid_lft 1000 preferred_lft 500", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'address', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, "192.168.1.200")
self.assertRegex(output, "1000sec")
self.assertRegex(output, "500sec")
def test_add_ipv6_address(self):
r = subprocess.call("ip -6 addr add 2001:0db8:0:f101::1/64 dev dummy-test", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'address', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, "2001:db8:0:f101::1")
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-address-sanity-test
# Description: Test basic ip address funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-address-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip address tests"
rlRun "/usr/bin/python3 /usr/bin/ip-address-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-address-tests.py"
rlLog "ip address tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-fou-sanity-test
# Description: Test basic ip fou funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-fou-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE ip-fou-tests.py
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip fou funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-fou-sanity-test
Description: Test basic ip fou funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,74 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-fou-sanity-test
# Description: Test basic ip fou funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPFOUTests(unittest.TestCase):
def test_configure_fou_receive_port_gre(self):
''' Configure a FOU receive port for GRE bound to 7777'''
subprocess.call(" ip fou add port 7777 ipproto 47", shell=True)
output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "port 7777 ipproto 47")
subprocess.call("ip fou del port 7777", shell=True)
def test_configure_fou_receive_port_ipip(self):
''' Configure a FOU receive port for IPIP bound to 8888'''
subprocess.call("ip fou add port 8888 ipproto 4", shell=True)
output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "port 8888 ipproto 4")
subprocess.call("ip fou del port 8888", shell=True)
def test_configure_fou_receive_port_gue(self):
''' Configure a GUE receive port bound to 9999 '''
subprocess.call("ip fou add port 9999 gue", shell=True)
output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "port 9999 gue")
subprocess.call("ip fou del port 9999", shell=True)
def test_configure_fou_with_ipip(self):
''' IP over UDP tunnel '''
subprocess.call("ip fou add port 9000 ipproto 4", shell=True)
output=subprocess.check_output(['ip', 'fou', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "port 9000 ipproto 4")
subprocess.call("ip link add name tunudp type ipip remote 192.168.2.2 local 192.168.2.1 ttl 225 encap fou encap-sport auto encap-dport 9000", shell=True)
output=subprocess.check_output(['ip', '-d', 'link', 'show', 'tunudp']).rstrip().decode('utf-8')
self.assertRegex(output, "encap fou")
subprocess.call("ip link del tunudp", shell=True)
subprocess.call("ip fou del port 9000", shell=True)
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,35 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-fou-sanity-test
# Description: Test basic ip address label funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "modprobe fou"
rlRun "cp ip-fou-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip fou tests"
rlRun "/usr/bin/python3 /usr/bin/ip-fou-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-fou-tests.py"
rlLog "ip fou tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test
# Description: Test basic ip l2tp funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-l2tp-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE ip-l2tp-tests.py
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip l2tp funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test
Description: Test basic ip l2tp funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,149 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test
# Description: Test basic ip l2tp funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
def add_veth(self):
subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'test-peer'])
def del_veth(self):
subprocess.check_output(['ip', 'link', 'del', 'veth-test'])
def add_address(self, address, interface):
subprocess.check_output(['ip', 'address', 'add', address, 'dev', interface])
class IPL2tpTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
self.add_veth()
self.link_exists('veth-test')
self.add_address('192.168.11.12/24', 'veth-test')
self.add_address('192.168.11.13/24', 'test-peer')
def tearDown(self):
self.del_veth()
def test_add_l2tp_add_tunnel(self):
r = subprocess.call("ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 encap udp local 192.168.11.12 remote 192.168.11.13 udp_sport 5000 udp_dport 6000", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "From 192.168.11.12 to 192.168.11.13")
self.assertRegex(output, "Peer tunnel 4000")
self.assertRegex(output, "UDP source / dest ports: 5000/6000")
r = subprocess.call("ip l2tp del tunnel tunnel_id 3000", shell=True)
self.assertEqual(r, 0)
def test_add_l2tp_add_tunnel_session(self):
r = subprocess.call("ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 encap udp local 192.168.11.12 remote 192.168.11.13 udp_sport 5000 udp_dport 6000", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "From 192.168.11.12 to 192.168.11.13")
self.assertRegex(output, "Peer tunnel 4000")
self.assertRegex(output, "UDP source / dest ports: 5000/6000")
r = subprocess.call(" ip l2tp add session tunnel_id 3000 session_id 1000 peer_session_id 2000", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'l2tp', 'show', 'session', 'tunnel_id', '3000', 'session_id' ,'1000']).rstrip().decode('utf-8')
print(output)
r = subprocess.call("ip l2tp del session tunnel_id 3000 session_id 1000", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("ip l2tp del tunnel tunnel_id 3000", shell=True)
self.assertEqual(r, 0)
def test_setup_l2tp(self):
r = subprocess.call("ip l2tp add tunnel tunnel_id 3000 peer_tunnel_id 4000 encap udp local 192.168.11.12 remote 192.168.11.13 udp_sport 5000 udp_dport 6000", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "From 192.168.11.12 to 192.168.11.13")
self.assertRegex(output, "Peer tunnel 4000")
self.assertRegex(output, "UDP source / dest ports: 5000/6000")
r = subprocess.call(" ip l2tp add session tunnel_id 3000 session_id 1000 peer_session_id 2000", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'l2tp', 'show', 'session', 'tunnel_id', '3000', 'session_id' ,'1000']).rstrip().decode('utf-8')
print(output)
r = subprocess.call("ip l2tp add tunnel tunnel_id 4000 peer_tunnel_id 3000 encap udp local 192.168.11.13 remote 192.168.11.12 udp_sport 6000 udp_dport 5000", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel', 'tunnel_id', '3000']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "From 192.168.11.13 to 192.168.11.12")
self.assertRegex(output, "Peer tunnel 4000")
self.assertRegex(output, "UDP source / dest ports: 6000/5000")
r = subprocess.call("ip l2tp add session tunnel_id 4000 session_id 2000 peer_session_id 1000", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'l2tp', 'show', 'session', 'tunnel_id', '4000', 'session_id' ,'2000']).rstrip().decode('utf-8')
print(output)
r = subprocess.call("ip link set l2tpeth0 up mtu 1488", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("ip link set l2tpeth0 up mtu 1488", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("ip addr add 10.42.1.1 peer 10.42.1.2 dev l2tpeth0", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("ip addr add 10.42.1.2 peer 10.42.1.1 dev l2tpeth1", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'link', 'show']).rstrip().decode('utf-8')
print(output)
output=subprocess.check_output(['ping', '10.42.1.2','-c', '5']).rstrip().decode('utf-8')
print(output)
r = subprocess.call("ip l2tp del session tunnel_id 3000 session_id 1000", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("ip l2tp del session tunnel_id 4000 session_id 2000", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("ip l2tp del tunnel tunnel_id 3000", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("ip l2tp del tunnel tunnel_id 4000", shell=True)
self.assertEqual(r, 0)
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,39 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-l2tp-sanity-test
# Description: Test basic ip l2tp funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "modprobe l2tp_core"
rlRun "modprobe l2tp_eth"
rlRun "modprobe l2tp_ip"
rlRun "modprobe l2tp_ip6"
rlRun "modprobe l2tp_netlink"
rlRun "cp ip-l2tp-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip l2tp tests"
rlRun "/usr/bin/python3 /usr/bin/ip-l2tp-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-l2tp-tests.py"
rlLog "ip l2tp tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-link-sanity-test
# Description: Test basic ip link funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-link-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip link funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-link-sanity-test
Description: Test basic ip link funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,334 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-link-sanity-test
# Description: Test basic ip link funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def read_attr(self, link, attribute):
"""Read a link attributed from the sysfs."""
with open(os.path.join('/sys/class/net', link, attribute)) as f:
return f.readline().strip()
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
class IPLinkSetDevTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
""" Setup """
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
def tearDown(self):
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def test_set_dev_mtu(self):
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'mtu', '9000'])
self.assertEqual('9000', self.read_attr('dummy-test', 'mtu'))
def test_set_dev_up_down(self):
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'up'])
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, 'UP,LOWER_UP')
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'down'])
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertNotRegex(output, 'UP,LOWER_UP')
def test_set_dev_address(self):
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'address', '02:01:02:03:04:08'])
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, 'link/ether 02:01:02:03:04:08')
def test_set_dev_alias(self):
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'alias', 'test-test'])
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, 'test-test')
def test_set_dev_name(self):
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'name', 'test-test'])
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'test-test']).rstrip().decode('utf-8')
self.assertRegex(output, 'test-test')
subprocess.check_output(['ip', 'link', 'set', 'dev', 'test-test', 'name', 'dummy-test'])
def test_set_dev_multicast(self):
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'multicast', 'on'])
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, 'MULTICAST')
def test_set_dev_all_multicast(self):
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'allmulticast', 'on'])
output=subprocess.check_output(['ip', 'link', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
self.assertRegex(output, 'ALLMULTI')
class IPLinkKindTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
""" Setup """
pass
def tearDown(self):
pass
def test_add_veth_pair(self):
subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'veth-peer-test'])
self.link_exists('veth-test')
self.link_exists('veth-peer-test')
subprocess.check_output(['ip', 'link', 'del', 'veth-test'])
def test_add_dummy(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def test_add_vcan(self):
subprocess.check_output(['ip', 'link', 'add', 'vcan-test', 'type', 'vcan'])
self.link_exists('vcan-test')
subprocess.check_output(['ip', 'link', 'del', 'vcan-test'])
def test_add_vxcan(self):
subprocess.check_output(['ip', 'link', 'add', 'vxcan-test', 'type', 'vxcan'])
self.link_exists('vxcan-test')
subprocess.check_output(['ip', 'link', 'del', 'vxcan-test'])
def test_add_vlan(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'vlantest.100', 'type', 'vlan', 'id', '100'])
self.link_exists('vlantest.100')
subprocess.check_output(['ip', 'link', 'del', 'vlantest.100'])
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def test_add_macvlan(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'macvlan-test', 'type', 'macvlan', 'mode', 'bridge'])
self.link_exists('macvlan-test')
subprocess.check_output(['ip', 'link', 'del', 'macvlan-test'])
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def test_add_macvtap(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'macvtap-test', 'type', 'macvtap', 'mode', 'bridge'])
self.link_exists('macvtap-test')
subprocess.check_output(['ip', 'link', 'del', 'macvtap-test'])
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def test_add_bridge(self):
subprocess.check_output(['ip', 'link', 'add', 'bridge-test', 'type', 'bridge'])
self.link_exists('bridge-test')
subprocess.check_output(['ip', 'link', 'del', 'bridge-test'])
def test_add_bond(self):
subprocess.check_output(['ip', 'link', 'add', 'bond-test', 'type', 'bond'])
self.link_exists('bond-test')
subprocess.check_output(['ip', 'link', 'del', 'bond-test'])
def test_add_ipip_tunnel(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'test-ipiptun', 'mode', 'ipip', 'remote', '10.3.3.3', 'local', '10.4.4.4', 'ttl' ,'64'])
self.link_exists('test-ipiptun')
subprocess.check_output(['ip', 'link', 'del', 'test-ipiptun'])
def test_add_gre_tunnel(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'test-gretun', 'mode', 'gre', 'remote', '10.3.3.3', 'local', '10.4.4.4', 'ttl' ,'64'])
self.link_exists('test-gretun')
subprocess.check_output(['ip', 'link', 'del', 'test-gretun'])
def test_add_gretap_tunnel(self):
subprocess.check_output(['ip', 'link', 'add', 'test-gretap', 'type', 'gretap', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
self.link_exists('test-gretap')
subprocess.check_output(['ip', 'link', 'del', 'test-gretap'])
def test_add_ip6gre_tunnel(self):
subprocess.check_output(['ip', 'link', 'add', 'test-ip6gre', 'type', 'ip6gre', 'remote', '2a00:ffde:4567:edde::4987', 'local', '2001:473:fece:cafe::5179'])
self.link_exists('test-ip6gre')
subprocess.check_output(['ip', 'link', 'del', 'test-ip6gre'])
def test_add_ip6gretap_tunnel(self):
subprocess.check_output(['ip', 'link', 'add', 'test-ip6gretap', 'type', 'ip6gretap', 'remote', '2a00:ffde:4567:edde::4987', 'local', '2001:473:fece:cafe::5179'])
self.link_exists('test-ip6gretap')
subprocess.check_output(['ip', 'link', 'del', 'test-ip6gretap'])
def test_add_erspan_tunnel(self):
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-erspan', 'type', 'erspan', 'seq', 'key', '100','erspan', '123', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
self.link_exists('test-erspan')
subprocess.check_output(['ip', 'link', 'del', 'test-erspan'])
def test_add_ip6erspan_tunnel(self):
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-ip6erspan', 'type', 'erspan', 'seq', 'key', '101','erspan', '1234', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
self.link_exists('test-ip6erspan')
subprocess.check_output(['ip', 'link', 'del', 'test-ip6erspan'])
def test_add_sit_tunnel(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'test-sittun', 'mode', 'sit', 'remote', '10.3.3.3', 'local', '10.4.4.4', 'ttl' ,'64'])
self.link_exists('test-sittun')
subprocess.check_output(['ip', 'link', 'del', 'test-sittun'])
def test_add_vti_tunnel(self):
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-vtitun', 'type', 'vti', 'remote', '10.3.3.3', 'local', '10.4.4.4'])
self.link_exists('test-vtitun')
subprocess.check_output(['ip', 'link', 'del', 'test-vtitun'])
def test_add_geneve_tunnel(self):
subprocess.check_output(['ip', 'link', 'add', 'dev', 'test-geneve-tun', 'type', 'geneve', 'remote', '10.3.3.3', 'vni', '1234'])
self.link_exists('test-geneve-tun')
subprocess.check_output(['ip', 'link', 'del', 'test-geneve-tun'])
def test_add_ipvlan(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan'])
self.link_exists('test-ipvlan')
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan','mode', 'l2', 'bridge'])
self.link_exists('test-ipvlan')
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan','mode', 'l2', 'private'])
self.link_exists('test-ipvlan')
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'name', 'test-ipvlan', 'type', 'ipvlan','mode', 'l2', 'vepa'])
self.link_exists('test-ipvlan')
subprocess.check_output(['ip', 'link', 'del', 'test-ipvlan'])
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def test_add_vxlan(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'add', 'vxlan-test', 'type', 'vxlan', 'id', '42', 'group', '239.1.1.1', 'dev', 'dummy-test' ,'dstport', '4789'])
self.link_exists('vxlan-test')
subprocess.check_output(['ip', 'link', 'del', 'vxlan-test'])
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def test_add_vrf(self):
subprocess.check_output(['ip', 'link', 'add', 'vrf-test', 'type', 'vrf', 'table', '10'])
self.link_exists('vrf-test')
subprocess.check_output(['ip', 'link', 'del', 'vrf-test'])
def test_add_macsec(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'add', 'link', 'dummy-test', 'test-macsec', 'type', 'macsec'])
self.link_exists('test-macsec')
subprocess.check_output(['ip', 'macsec', 'add', 'test-macsec', 'tx', 'sa', '0', 'pn', '1', 'on', 'key', '02', '09876543210987654321098765432109'])
subprocess.check_output(['ip', 'macsec', 'add', 'test-macsec', 'rx', 'address', '56:68:a5:c2:4c:14', 'port', '1'])
subprocess.check_output(['ip', 'macsec', 'add', 'test-macsec', 'rx', 'address', '56:68:a5:c2:4c:14', 'port', '1', 'sa', '0', 'pn', '1', 'on', 'key', '01', '12345678901234567890123456789012'])
subprocess.check_output(['ip', 'link', 'del', 'test-macsec'])
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,36 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-link-sanity-test
# Description: Test basic ip link funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "dnf install -y kernel-modules-extra"
rlRun "modprobe vcan"
rlRun "cp ip-link-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip link tests"
rlRun "/usr/bin/python3 /usr/bin/ip-link-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-link-tests.py"
rlLog "ip link tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/iproute/Sanity/ip-neigh-sanity-test
# Description: Test basic ip neigh functionality
# Author: Jaroslav Aster <jaster@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/iproute/Sanity/ip-neigh-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Jaroslav Aster <jaster@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip neigh funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-neigh-sanity-test
Description: Test basic ip neigh funcionality
Author: Jaroslav Aster <jaster@redhat.com>

View File

@ -0,0 +1,230 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/iproute/Sanity/ip-neigh-sanity-test
# Description: Test basic ip neigh funcionality
# Author: Jaroslav Aster <jaster@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
TEST_IFACE="test-iface"
TEST_IP4_PREFIX="192.168.100"
TEST_IP6_PREFIX="2000::"
TEST_MAC_PREFIX="00:c0:7b:7d:00"
rlIsRHEL '>=7' && MAN_PAGE="ip-neighbour" || MAN_PAGE="ip"
MESSAGES="/var/log/messages"
TMP_MESSAGES="$(mktemp)"
create_dummy_iface()
{
rlRun "ip link add name ${TEST_IFACE} type dummy" 0 "Creating dummy interface: '${TEST_IFACE}'."
}
delete_dummy_iface()
{
rlRun "ip link del ${TEST_IFACE}" 0 "Removing dummy interface: '${TEST_IFACE}'."
rlRun "rmmod dummy" 0,1 "Removing dummy module."
}
rlJournalStart
rlPhaseStartSetup
rlCheckRpm "$PACKAGE"
create_dummy_iface
rlPhaseEnd
if rlIsRHEL '>=7'; then
rlPhaseStartTest
for word in add del change replace show flush all proxy to dev nud unused permanent reachable probe failed incomplete stale delay noarp none; do
if ! { [ "$word" = "unused" ] || [ "$word" = "all" ]; }; then
rlRun "ip n help 2>&1 | grep -e '[^[:alnum:]]${word}[^[:alnum:]]'" 0 "Checking there is '${word}' in ip neighbour help."
fi
rlRun "man ${MAN_PAGE} | col -b | grep -e '[^[:alnum:]]${word}[^[:alnum:]]'" 0 "Checking there is '${word}' in ${MAN_PAGE} man page."
done
rlPhaseEnd
fi
rlPhaseStartTest "Functional Test"
rlLogInfo "IPv4"
rlRun "ip neigh add ${TEST_IP4_PREFIX}.1 lladdr ${TEST_MAC_PREFIX}:c6 dev ${TEST_IFACE} nud permanent"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.1 | grep 'PERMANENT'"
rlRun "ip neigh add ${TEST_IP4_PREFIX}.2 lladdr ${TEST_MAC_PREFIX}:c7 dev ${TEST_IFACE}"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.2 | grep 'PERMANENT'"
rlRun "ip neigh add ${TEST_IP4_PREFIX}.3 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud noarp"
rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.3 | grep 'NOARP'"
rlRun "ip neigh add ${TEST_IP4_PREFIX}.4 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud noarp"
rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.4 | grep 'NOARP'"
rlRun "ip neigh add lladdr ${TEST_MAC_PREFIX}:ce dev ${TEST_IFACE} proxy ${TEST_IP4_PREFIX}.10"
rlIsRHEL ">=7" && rlRun "ip neigh show proxy | grep ${TEST_IP4_PREFIX}.10"
rlRun "test $(ip neigh show dev ${TEST_IFACE} | wc -l) -eq 2" 0 "There are two items in neighbours."
rlRun "ip neigh del ${TEST_IP4_PREFIX}.1 dev ${TEST_IFACE}"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.1 | grep ." "1"
rlRun "ip neigh change ${TEST_IP4_PREFIX}.2 lladdr ${TEST_MAC_PREFIX}:ca dev ${TEST_IFACE} nud reachable"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.2 | grep 'REACHABLE'"
rlRun "ip neigh replace ${TEST_IP4_PREFIX}.3 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud permanent"
rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.3 | grep 'PERMANENT'"
rlRun "test $(ip neigh show dev ${TEST_IFACE} nud permanent | wc -l) -eq 1" 0 "There is one permanent item in neighbours."
rlRun "test $(ip neigh show dev ${TEST_IFACE} nud reachable | wc -l) -eq 1" 0 "There is one reachable item in neighbours."
rlRun "test $(ip neigh show dev ${TEST_IFACE} nud noarp | wc -l) -eq 1" 0 "There is one noarp item in neighbours."
rlIsRHEL ">=7" && rlRun "test $(ip neigh show dev ${TEST_IFACE} proxy | wc -l) -eq 1" 0 "There is one proxy item in neighbours."
rlRun "test $(ip neigh show dev ${TEST_IFACE} | grep -c -e PERMANENT -e REACHABLE) -eq 2" 0 "There are two permanent or reachable items in neighbours."
rlRun "ip neigh show dev ${TEST_IFACE} unused"
rlRun "ip neigh change ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE} nud delay"
rlRun "ip neigh flush ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE}"
rlRun "ip -s neigh flush ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE}"
rlRun "ip -s -s neigh flush ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE}"
rlRun "ip neigh add ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud permanent"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'PERMANENT'"
rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud reachable"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'REACHABLE'"
rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud probe"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'PROBE'"
rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud failed"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'FAILED'"
rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud incomplete"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'INCOMPLETE'"
rlRun "ip neigh replace ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud stale"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep '${TEST_MAC_PREFIX}:cb' | grep 'STALE'"
rlRun "ip neigh replace ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud delay"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep -e 'DELAY' -e 'PROBE'"
rlRun "ip neigh replace ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud noarp"
rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.11 | grep 'NOARP'"
rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud none"
rlRun "ip neigh show nud none | grep ${TEST_IP4_PREFIX}.11"
rlRun "ip neigh show ${TEST_IP4_PREFIX}.0/24"
rlLogInfo "IPv6"
rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}1 lladdr ${TEST_MAC_PREFIX}:c6 dev ${TEST_IFACE} nud permanent"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}1 | grep 'PERMANENT'"
rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}2 lladdr ${TEST_MAC_PREFIX}:c7 dev ${TEST_IFACE}"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}2 | grep 'PERMANENT'"
rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}3 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud noarp"
rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}3 | grep 'NOARP'"
rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}4 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud noarp"
rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}4 | grep 'NOARP'"
rlRun "ip -6 neigh add lladdr ${TEST_MAC_PREFIX}:ce dev ${TEST_IFACE} proxy ${TEST_IP6_PREFIX}10"
rlIsRHEL ">=7" && rlRun "ip -6 neigh show proxy | grep ${TEST_IP6_PREFIX}10"
rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} | wc -l) -eq 2" 0 "There are two items in neighbours."
rlRun "ip -6 neigh del ${TEST_IP6_PREFIX}1 dev ${TEST_IFACE}"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}1 | grep ." "1"
rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}2 lladdr ${TEST_MAC_PREFIX}:ca dev ${TEST_IFACE} nud reachable"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}2 | grep 'REACHABLE'"
rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}3 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud permanent"
rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}3 | grep 'PERMANENT'"
rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} nud permanent | wc -l) -eq 1" 0 "There is one permanent item in neighbours."
rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} nud reachable | wc -l) -eq 1" 0 "There is one reachable item in neighbours."
rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} nud noarp | wc -l) -eq 1" 0 "There is one noarp item in neighbours."
rlIsRHEL ">=7" && rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} proxy | wc -l) -eq 1" 0 "There is one proxy item in neighbours."
rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} | grep -c -e PERMANENT -e REACHABLE) -eq 2" 0 "There are two permanent or reachable items in neighbours."
rlRun "ip -6 neigh show dev ${TEST_IFACE} unused"
rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE} nud delay"
rlRun "ip -6 neigh flush ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE}"
rlRun "ip -6 -s neigh flush ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE}"
rlRun "ip -6 -s -s neigh flush ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE}"
rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}11 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud permanent"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'PERMANENT'"
rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud reachable"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'REACHABLE'"
rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud probe"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'PROBE'"
rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud failed"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'FAILED'"
rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud incomplete"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'INCOMPLETE'"
rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}11 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud stale"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep '${TEST_MAC_PREFIX}:cb' | grep 'STALE'"
rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud delay"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep -e 'DELAY' -e 'PROBE'"
rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud noarp"
rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}11 | grep 'NOARP'"
rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud none"
rlRun "ip -6 neigh show nud none | grep ${TEST_IP6_PREFIX}11"
rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}0/24"
rlPhaseEnd
rlPhaseStartTest
pushd /tmp # because of coredump file
tail -f -n 0 "$MESSAGES" > "$TMP_MESSAGES" &
tail_pid="$!"
rlRun "ip neigh add ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:c16 dev ${TEST_IFACE} nud permanent" 1,255
kill "$tail_pid"
rlRun "grep -i -e 'segfault' -e 'unhandled signal' -e 'User process fault' ${TMP_MESSAGES}" 1 "Checking there is no segfault in /var/log/messages."
popd
rlPhaseEnd
rlPhaseStartCleanup
delete_dummy_iface
rlRun "rm ${TMP_MESSAGES}" 0 "Removing tmp files and dirs."
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-neighbor-sanity-test
# Description: Test basic ip neighbor funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-neighbor-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip neighbor funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-neighbor-sanity-test
Description: Test basic ip neighbor funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,74 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-neighbour-sanity-test
# Description: Test basic ip neighbour funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
def add_dummy(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
def del_dummy(self):
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
class IPNeighborTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
self.add_dummy()
self.link_exists('dummy-test')
def tearDown(self):
self.del_dummy()
def test_add_neighbor(self):
subprocess.call("ip neighbor add 192.168.100.1 lladdr 00:c0:7b:7d:00:c8 dev dummy-test nud permanent", shell=True)
output=subprocess.check_output(['ip', 'neighbour', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "192.168.100.1 lladdr 00:c0:7b:7d:00:c8 PERMANENT")
subprocess.call("ip neighbor del 192.168.100.1 dev dummy-test", shell=True)
def test_replace_neighbor(self):
subprocess.call("ip neighbor add 192.168.99.254 lladdr 00:80:c8:27:69:2d dev dummy-test", shell=True)
output=subprocess.check_output(['ip', 'neighbour', 'show', 'dev', 'dummy-test']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "192.168.99.254 lladdr 00:80:c8:27:69:2d PERMANENT")
subprocess.call("ip neighbor change 192.168.99.254 lladdr 00:80:c8:27:69:2d dev dummy-test", shell=True)
print(output)
self.assertRegex(output, "192.168.99.254 lladdr 00:80:c8:27:69:2d PERMANENT")
subprocess.call("ip neighbor del 192.168.99.254 dev dummy-test", shell=True)
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-neighbor-sanity-test
# Description: Test basic ip neighbor funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-neighbor-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip neighbor tests"
rlRun "/usr/bin/python3 /usr/bin/ip-neighbor-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-neighbor-tests.py"
rlLog "ip neighbor tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-netns-sanity-test
# Description: Test basic ip netns funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-ns-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip netns funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-netns-sanity-test
Description: Test basic ip netns funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,118 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-netns-sanity-test
# Description: Test basic ip netns funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class GenericUtilities():
def path_exists(self, path):
self.assertTrue(os.path.exists(os.path.join('/var/run/netns', path)))
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
def add_veth(self):
subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'test-peer'])
def del_veth(self):
subprocess.check_output(['ip', 'link', 'del', 'veth-test'])
def add_dummy(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
def del_dummy(self):
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
class IPNsTests(unittest.TestCase, GenericUtilities):
def test_add_ns(self):
subprocess.check_output(['ip', 'netns', 'add', 'net-ns-test'])
self.path_exists('net-ns-test')
output=subprocess.check_output(['ip', 'netns', 'list']).rstrip().decode('utf-8')
self.assertRegex(output, "net-ns-test")
self.addCleanup(subprocess.call, ['ip', 'netns', 'del', 'net-ns-test'])
def test_add_dummy_interface_to_ns(self):
self.add_dummy()
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'netns', 'add', 'net-ns-test'])
self.path_exists('net-ns-test')
output=subprocess.check_output(['ip', 'netns', 'list']).rstrip().decode('utf-8')
self.assertRegex(output, "net-ns-test")
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'netns', 'net-ns-test'])
output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "dummy-test")
self.addCleanup(subprocess.call, ['ip', 'netns', 'del', 'net-ns-test'])
self.addCleanup(subprocess.call, ['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'del', 'dummy-test'])
def test_add_veth_interface_to_ns(self):
self.add_veth()
self.link_exists('veth-test')
subprocess.check_output(['ip', 'netns', 'add', 'net-ns-test'])
self.path_exists('net-ns-test')
output=subprocess.check_output(['ip', 'netns', 'list']).rstrip().decode('utf-8')
self.assertRegex(output, "net-ns-test")
subprocess.check_output(['ip', 'link', 'set', 'dev', 'test-peer', 'netns', 'net-ns-test'])
output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "test-peer")
# Setup IP address of veth-test.
subprocess.check_output(['ip', 'addr', 'add', '10.200.1.1/24', 'dev', 'veth-test'])
subprocess.check_output(['ip', 'link', 'set', 'veth-test', 'up'])
# Setup IP address of v-peer1.
subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'addr', 'add',' 10.200.1.2/24', 'dev', 'test-peer'])
subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'set', 'test-peer', 'up'])
subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'set', 'lo', 'up'])
output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'addr', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "test-peer")
self.assertRegex(output, "lo: <LOOPBACK,UP,LOWER_UP>")
self.assertRegex(output, "inet 10.200.1.2/24")
output=subprocess.check_output(['ip', 'netns', 'exec', 'net-ns-test', 'ping', '10.200.1.1', '-c', '5']).rstrip().decode('utf-8')
print(output)
self.addCleanup(subprocess.call, ['ip', 'netns', 'del', 'net-ns-test'])
self.addCleanup(subprocess.call, ['ip', 'netns', 'exec', 'net-ns-test', 'ip', 'link', 'del', 'test-peer'])
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-Licenetnse-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-netns-sanity-test
# Description: Test basic ip netns funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-netns-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip netns tests"
rlRun "/usr/bin/python3 /usr/bin/ip-netns-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-netns-tests.py"
rlLog "ip netns tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-route-sanity-test
# Description: Test basic ip route funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-route-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip route funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-route-sanity-test
Description: Test basic ip route funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,110 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-route-sanity-test
# Description: Test basic ip route funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
def add_dummy(self):
""" Setup """
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
subprocess.check_output(['ip', 'link', 'set', 'dev', 'dummy-test', 'up'])
def del_dummy(self):
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
class IPRouteTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
self.add_dummy()
def tearDown(self):
self.del_dummy()
def test_add_route(self):
subprocess.check_output(['ip', 'route', 'add', '192.168.1.0/24', 'dev', 'dummy-test'])
output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "192.168.1.0/24 dev dummy-test scope link")
subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24', 'dev', 'dummy-test'])
def test_add_route_table(self):
subprocess.check_output(['ip', 'route', 'add', 'table', '555', '192.168.1.0/24', 'dev', 'dummy-test'])
output=subprocess.check_output(['ip', 'route', 'show', 'table', '555']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "192.168.1.0/24 dev dummy-test scope link")
subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24', 'dev', 'dummy-test', 'table', '555'])
def test_add_blackhole(self):
subprocess.check_output(['ip', 'route', 'add', 'blackhole', '192.168.1.0/24'])
output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "blackhole 192.168.1.0/24")
subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24'])
def test_add_unreachable(self):
subprocess.check_output(['ip', 'route', 'add', 'unreachable', '192.168.1.0/24'])
output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "unreachable 192.168.1.0/24")
subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24'])
def test_add_prohibit(self):
subprocess.check_output(['ip', 'route', 'add', 'prohibit', '192.168.1.0/24'])
output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "prohibit 192.168.1.0/24")
subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24'])
def test_add_throw(self):
subprocess.check_output(['ip', 'route', 'add', 'throw', '192.168.1.0/24'])
output=subprocess.check_output(['ip', 'route', 'show']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "throw 192.168.1.0/24")
subprocess.check_output(['ip', 'route', 'delete', '192.168.1.0/24'])
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-route-sanity-test
# Description: Test basic ip route funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-route-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip route tests"
rlRun "/usr/bin/python3 /usr/bin/ip-route-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-route-tests.py"
rlLog "ip route tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/iproute/Sanity/ip-rule-sanity-test
# Description: Test basic ip rule functionality
# Author: Jaroslav Aster <jaster@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/iproute/Sanity/ip-rule-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Jaroslav Aster <jaster@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip rule funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-rule-sanity-test
Description: Test basic ip rule funcionality
Author: Jaroslav Aster <jaster@redhat.com>

View File

@ -0,0 +1,99 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/iproute/Sanity/ip-rule-sanity-test
# Description: Test basic ip rule funcionality
# Author: Jaroslav Aster <jaster@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
DEFAULT_IFACE="$(ip route show | grep default | sed 's/.*dev \([^ ]\+\) .*/\1/' | head -n 1)"
rlIsRHEL '>=7' && IP_RULE_MANPAGE="ip-rule" || IP_RULE_MANPAGE="ip"
rlJournalStart
rlPhaseStartSetup
rlCheckRpm "$PACKAGE"
rlPhaseEnd
rlPhaseStartTest "Basic sanity test"
rlRun "ip rule list"
rlRun "ip rule add from 172.29.0.0/24 to 172.29.1.0/24 table 1110"
rlRun "ip rule add not from 172.29.0.0/24 to 172.29.1.0/24 table 1111"
rlRun "ip -6 rule add from 2404:6800:4003:801::1015/32 to 2404:6800:4003:801::1014/32 table 1111"
rlIsRHEL '>=7' && rlRun "ip rule add oif ${DEFAULT_IFACE} table 1111"
rlRun "ip rule add iif ${DEFAULT_IFACE} tos 10 table 1112"
rlRun "ip rule add fwmark 123 pref 100 table 1112"
rlRun "ip rule add not fwmark 124 pref 101 unreachable"
rlRun "ip rule add fwmark 125 pref 102 prohibit"
rlRun "ip rule add fwmark 126 pref 103 unicast"
rlRun "ip rule add from 172.29.2.0/24 tos 10 blackhole"
rlRun "ip rule add from 172.29.0.0/24 tos 14 prio 99 goto 103"
rlRun "ip rule list"
rlRun "ip rule list | grep 'from 172.29.0.0/24 to 172.29.1.0/24'"
rlRun "ip rule list | grep 'not from 172.29.0.0/24 to 172.29.1.0/24'"
rlRun "ip -6 rule list | grep 'from 2404:6800:4003:801::1015/32 to 2404:6800:4003:801::1014/32'"
rlIsRHEL '>=7' && rlRun "ip rule list | grep 'oif ${DEFAULT_IFACE}'"
! rlIsFedora && rlRun "ip rule list | grep 'tos lowdelay iif ${DEFAULT_IFACE}'"
rlRun "ip rule list | grep 'from all fwmark 0x7b'"
rlRun "ip rule list | grep 'not from all fwmark 0x7c unreachable'"
rlRun "ip rule list | grep 'from all fwmark 0x7d prohibit'"
rlRun "ip rule list | grep 'from all fwmark 0x7e'"
! rlIsFedora && rlRun "ip rule list | grep 'from 172.29.2.0/24 tos lowdelay blackhole'"
rlRun "ip rule list | grep 'from 172.29.0.0/24 tos 0x14 goto 103'"
rlRun "ip rule list"
rlRun "ip rule del from 172.29.0.0/24 to 172.29.1.0/24"
rlRun "ip rule del not from 172.29.0.0/24 to 172.29.1.0/24"
rlRun "ip -6 rule del from 2404:6800:4003:801::1015/32 to 2404:6800:4003:801::1014/32"
rlIsRHEL '>=7' && rlRun "ip rule del oif ${DEFAULT_IFACE}"
! rlIsFedora && rlRun "ip rule del iif ${DEFAULT_IFACE} tos lowdelay"
rlRun "ip rule del fwmark 123 pref 100"
rlRun "ip rule del not fwmark 124 pref 101 unreachable"
rlRun "ip rule del fwmark 125 pref 102 prohibit"
rlRun "ip rule del fwmark 126 pref 103 unicast"
rlRun "ip rule del from 172.29.2.0/24 tos 10 blackhole"
rlRun "ip rule del from 172.29.0.0/24 tos 14 prio 99 goto 103"
rlRun "ip rule list"
rlPhaseEnd
if rlIsRHEL '>=7'; then
rlPhaseStartTest
saved_rule=$(ip rule list | grep '^0' | cut -d : -f 2 | head -n 1)
rlRun "ip rule del prio 0" 0 "Removing rule with prio 0."
rlRun "ip rule add prio 0 ${saved_rule}" 0 "Re-creating rule with prio 0."
rlRun "man ${IP_RULE_MANPAGE} | col -b | grep 'Rule 0 is special. It cannot be deleted or overridden.'" 1
rlPhaseEnd
fi
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-token-sanity-test
# Description: Test basic ip token funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-token-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip token funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-token-sanity-test
Description: Test basic ip token funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,59 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-token-sanity-test
# Description: Test basic ip token funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
def add_veth(self):
subprocess.check_output(['ip', 'link', 'add', 'veth-test', 'type', 'veth', 'peer', 'name', 'test-peer'])
def del_veth(self):
subprocess.check_output(['ip', 'link', 'del', 'veth-test'])
class IPTokenTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
self.add_veth()
self.link_exists('veth-test')
def tearDown(self):
self.del_veth()
def test_add_token(self):
r = subprocess.call("ip token set ::1a:2b:3c:4d/64 dev veth-test", shell=True)
self.assertEqual(r, 0)
output=subprocess.check_output(['ip', 'token', 'get', 'dev', 'veth-test']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "token ::1a:2b:3c:4d dev veth-test")
r = subprocess.call("ip token del ::1a:2b:3c:4d/64 dev veth-test", shell=True)
self.assertEqual(r, 0)
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-token-sanity-test
# Description: Test basic ip token funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-token-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip token tests"
rlRun "/usr/bin/python3 /usr/bin/ip-token-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-token-tests.py"
rlLog "ip token tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test
# Description: Test basic ip tunnel funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-tunnel-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip tunnel funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test
Description: Test basic ip tunnel funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,104 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test
# Description: Test basic ip tunnel funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def add_dummy(self):
subprocess.check_output(['ip', 'link', 'add', 'dummy-test', 'type', 'dummy'])
self.link_exists('dummy-test')
def del_dummy(self):
subprocess.check_output(['ip', 'link', 'del', 'dummy-test'])
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
class IPTunnelTests(unittest.TestCase, IPLinkUtilities):
def setUp(self):
self.add_dummy()
self.link_exists('dummy-test')
def tearDown(self):
self.del_dummy()
def test_add_ipip(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'ipiptun-test', 'mode', 'ipip', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test'])
self.link_exists('ipiptun-test')
output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "ipiptun-test: ip/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64")
subprocess.check_output(['ip', 'link', 'del', 'ipiptun-test'])
def test_add_gre(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'gretun-test', 'mode', 'gre', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test'])
self.link_exists('gretun-test')
output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "gretun-test: gre/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64")
subprocess.check_output(['ip', 'link', 'del', 'gretun-test'])
def test_add_sit(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'sittun-test', 'mode', 'sit', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test'])
self.link_exists('sittun-test')
output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "sittun-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64")
subprocess.check_output(['ip', 'link', 'del', 'sittun-test'])
def test_add_isatap(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'isatap-test', 'mode', 'sit', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test'])
self.link_exists('isatap-test')
output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "isatap-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64")
subprocess.check_output(['ip', 'link', 'del', 'isatap-test'])
def test_add_vti(self):
subprocess.check_output(['ip', 'tunnel', 'add', 'vti-test', 'mode', 'sit', 'local', '10.3.3.3', 'remote', '10.4.4.4', 'ttl', '64', 'dev', 'dummy-test'])
self.link_exists('vti-test')
output=subprocess.check_output(['ip', 'tunnel']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, "vti-test: ipv6/ip remote 10.4.4.4 local 10.3.3.3 dev dummy-test ttl 64")
subprocess.check_output(['ip', 'link', 'del', 'vti-test'])
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-tunnel-sanity-test
# Description: Test basic ip tunnel funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-tunnel-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip tunnel tests"
rlRun "/usr/bin/python3 /usr/bin/ip-tunnel-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-tunnel-tests.py"
rlLog "ip tunnel tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

View File

@ -0,0 +1,47 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
# Description: Test basic ip tuntap funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
export TEST=/CoreOS/iproute/Sanity/ip-tuntap-sanity-test
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani <susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test basic ip tuntap funcionality" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: iproute" >> $(METADATA)
@echo "Requires: iproute" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
Description: Test basic ip tuntap funcionality
Author: Susant Sahani <susant@redhat.com>

View File

@ -0,0 +1,65 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
# Description: Test basic ip tuntap funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
def setUpModule():
if shutil.which('ip') is None:
raise OSError(errno.ENOENT, 'ip not found')
class IPLinkUtilities():
def link_exists(self, link):
self.assertTrue(os.path.exists(os.path.join('/sys/class/net', link)))
class IPTuntapTests(unittest.TestCase, IPLinkUtilities):
def test_add_tap(self):
subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tap-test', 'mode', 'tap'])
self.link_exists('tap-test')
output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tap-test']).rstrip().decode('utf-8')
self.assertRegex(output, "tap-test: tap")
subprocess.check_output(['ip', 'link', 'del', 'tap-test'])
def test_add_tun(self):
subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tun-test', 'mode', 'tun'])
self.link_exists('tun-test')
output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tun-test']).rstrip().decode('utf-8')
self.assertRegex(output, "tun-test: tun")
subprocess.check_output(['ip', 'link', 'del', 'tun-test'])
def test_add_tun_user_group(self):
subprocess.check_output(['ip', 'tuntap', 'add', 'name', 'tun-test', 'mode', 'tun', 'user', 'root', 'group', 'root'])
self.link_exists('tun-test')
output=subprocess.check_output(['ip', 'tuntap', 'show', 'dev', 'tun-test']).rstrip().decode('utf-8')
self.assertRegex(output, "tun-test: tun")
self.assertRegex(output, "user 0 group 0")
subprocess.check_output(['ip', 'link', 'del', 'tun-test'])
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of /CoreOS/iproute/Sanity/ip-tuntap-sanity-test
# Description: Test basic ip tuntap funcionality
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="iproute"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ip-tuntap-tests.py /usr/bin"
rlPhaseEnd
rlPhaseStartTest
rlLog "ip tuntap tests"
rlRun "/usr/bin/python3 /usr/bin/ip-tuntap-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ip-tuntap-tests.py"
rlLog "ip tuntap tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

26
tests/tests.yml Normal file
View File

@ -0,0 +1,26 @@
---
# Tests that run in all contexts
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
- atomic
tests:
- ip-neigh-sanity-test
- ip-rule-sanity-test
- bridge-utility
- ip-link-sanity-test
- ip-address-sanity-test
- ip-address-label-sanity-test
- ip-token-sanity-test
- ip-tuntap-sanity-test
- ip-tunnel-sanity-test
- ip-l2tp-sanity-test
- ip-netns-sanity-test
- ip-route-sanity-test
- ip-neighbor-sanity-test
required_packages:
- iproute
- python3
- kernel-modules-extra