summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-11-08 21:21:05 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-11-08 21:21:05 -0500
commit0058b0a506e40d9a2c62015fe92eb64a44d78cd9 (patch)
treeb92b6bb31d6308a3f049b49e3780e525ff67a2e5 /tools/testing/selftests
parent5cb8418cb533222709f362d264653a634eb8c7ac (diff)
parenta2582cdc32f071422e0197a6c59bd1235b426ce2 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Pull networking fixes from David Miller: 1) BPF sample build fixes from Björn Töpel 2) Fix powerpc bpf tail call implementation, from Eric Dumazet. 3) DCCP leaks jiffies on the wire, fix also from Eric Dumazet. 4) Fix crash in ebtables when using dnat target, from Florian Westphal. 5) Fix port disable handling whne removing bcm_sf2 driver, from Florian Fainelli. 6) Fix kTLS sk_msg trim on fallback to copy mode, from Jakub Kicinski. 7) Various KCSAN fixes all over the networking, from Eric Dumazet. 8) Memory leaks in mlx5 driver, from Alex Vesker. 9) SMC interface refcounting fix, from Ursula Braun. 10) TSO descriptor handling fixes in stmmac driver, from Jose Abreu. 11) Add a TX lock to synchonize the kTLS TX path properly with crypto operations. From Jakub Kicinski. 12) Sock refcount during shutdown fix in vsock/virtio code, from Stefano Garzarella. 13) Infinite loop in Intel ice driver, from Colin Ian King. * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (108 commits) ixgbe: need_wakeup flag might not be set for Tx i40e: need_wakeup flag might not be set for Tx igb/igc: use ktime accessors for skb->tstamp i40e: Fix for ethtool -m issue on X722 NIC iavf: initialize ITRN registers with correct values ice: fix potential infinite loop because loop counter being too small qede: fix NULL pointer deref in __qede_remove() net: fix data-race in neigh_event_send() vsock/virtio: fix sock refcnt holding during the shutdown net: ethernet: octeon_mgmt: Account for second possible VLAN header mac80211: fix station inactive_time shortly after boot net/fq_impl: Switch to kvmalloc() for memory allocation mac80211: fix ieee80211_txq_setup_flows() failure path ipv4: Fix table id reference in fib_sync_down_addr ipv6: fixes rt6_probe() and fib6_nh->last_probe init net: hns: Fix the stray netpoll locks causing deadlock in NAPI path net: usb: qmi_wwan: add support for DW5821e with eSIM support CDC-NCM: handle incomplete transfer of MTU nfc: netlink: fix double device reference drop NFC: st21nfca: fix double free ...
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r--tools/testing/selftests/bpf/test_sysctl.c8
-rw-r--r--tools/testing/selftests/net/tls.c108
2 files changed, 115 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/test_sysctl.c b/tools/testing/selftests/bpf/test_sysctl.c
index a320e3844b17..7c6e5b173f33 100644
--- a/tools/testing/selftests/bpf/test_sysctl.c
+++ b/tools/testing/selftests/bpf/test_sysctl.c
@@ -161,9 +161,14 @@ static struct sysctl_test tests[] = {
161 .descr = "ctx:file_pos sysctl:read read ok narrow", 161 .descr = "ctx:file_pos sysctl:read read ok narrow",
162 .insns = { 162 .insns = {
163 /* If (file_pos == X) */ 163 /* If (file_pos == X) */
164#if __BYTE_ORDER == __LITTLE_ENDIAN
164 BPF_LDX_MEM(BPF_B, BPF_REG_7, BPF_REG_1, 165 BPF_LDX_MEM(BPF_B, BPF_REG_7, BPF_REG_1,
165 offsetof(struct bpf_sysctl, file_pos)), 166 offsetof(struct bpf_sysctl, file_pos)),
166 BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0, 2), 167#else
168 BPF_LDX_MEM(BPF_B, BPF_REG_7, BPF_REG_1,
169 offsetof(struct bpf_sysctl, file_pos) + 3),
170#endif
171 BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 4, 2),
167 172
168 /* return ALLOW; */ 173 /* return ALLOW; */
169 BPF_MOV64_IMM(BPF_REG_0, 1), 174 BPF_MOV64_IMM(BPF_REG_0, 1),
@@ -176,6 +181,7 @@ static struct sysctl_test tests[] = {
176 .attach_type = BPF_CGROUP_SYSCTL, 181 .attach_type = BPF_CGROUP_SYSCTL,
177 .sysctl = "kernel/ostype", 182 .sysctl = "kernel/ostype",
178 .open_flags = O_RDONLY, 183 .open_flags = O_RDONLY,
184 .seek = 4,
179 .result = SUCCESS, 185 .result = SUCCESS,
180 }, 186 },
181 { 187 {
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index 4c285b6e1db8..1c8f194d6556 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -898,6 +898,114 @@ TEST_F(tls, nonblocking)
898 } 898 }
899} 899}
900 900
901static void
902test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
903 bool sendpg, unsigned int n_readers, unsigned int n_writers)
904{
905 const unsigned int n_children = n_readers + n_writers;
906 const size_t data = 6 * 1000 * 1000;
907 const size_t file_sz = data / 100;
908 size_t read_bias, write_bias;
909 int i, fd, child_id;
910 char buf[file_sz];
911 pid_t pid;
912
913 /* Only allow multiples for simplicity */
914 ASSERT_EQ(!(n_readers % n_writers) || !(n_writers % n_readers), true);
915 read_bias = n_writers / n_readers ?: 1;
916 write_bias = n_readers / n_writers ?: 1;
917
918 /* prep a file to send */
919 fd = open("/tmp/", O_TMPFILE | O_RDWR, 0600);
920 ASSERT_GE(fd, 0);
921
922 memset(buf, 0xac, file_sz);
923 ASSERT_EQ(write(fd, buf, file_sz), file_sz);
924
925 /* spawn children */
926 for (child_id = 0; child_id < n_children; child_id++) {
927 pid = fork();
928 ASSERT_NE(pid, -1);
929 if (!pid)
930 break;
931 }
932
933 /* parent waits for all children */
934 if (pid) {
935 for (i = 0; i < n_children; i++) {
936 int status;
937
938 wait(&status);
939 EXPECT_EQ(status, 0);
940 }
941
942 return;
943 }
944
945 /* Split threads for reading and writing */
946 if (child_id < n_readers) {
947 size_t left = data * read_bias;
948 char rb[8001];
949
950 while (left) {
951 int res;
952
953 res = recv(self->cfd, rb,
954 left > sizeof(rb) ? sizeof(rb) : left, 0);
955
956 EXPECT_GE(res, 0);
957 left -= res;
958 }
959 } else {
960 size_t left = data * write_bias;
961
962 while (left) {
963 int res;
964
965 ASSERT_EQ(lseek(fd, 0, SEEK_SET), 0);
966 if (sendpg)
967 res = sendfile(self->fd, fd, NULL,
968 left > file_sz ? file_sz : left);
969 else
970 res = send(self->fd, buf,
971 left > file_sz ? file_sz : left, 0);
972
973 EXPECT_GE(res, 0);
974 left -= res;
975 }
976 }
977}
978
979TEST_F(tls, mutliproc_even)
980{
981 test_mutliproc(_metadata, self, false, 6, 6);
982}
983
984TEST_F(tls, mutliproc_readers)
985{
986 test_mutliproc(_metadata, self, false, 4, 12);
987}
988
989TEST_F(tls, mutliproc_writers)
990{
991 test_mutliproc(_metadata, self, false, 10, 2);
992}
993
994TEST_F(tls, mutliproc_sendpage_even)
995{
996 test_mutliproc(_metadata, self, true, 6, 6);
997}
998
999TEST_F(tls, mutliproc_sendpage_readers)
1000{
1001 test_mutliproc(_metadata, self, true, 4, 12);
1002}
1003
1004TEST_F(tls, mutliproc_sendpage_writers)
1005{
1006 test_mutliproc(_metadata, self, true, 10, 2);
1007}
1008
901TEST_F(tls, control_msg) 1009TEST_F(tls, control_msg)
902{ 1010{
903 if (self->notls) 1011 if (self->notls)