summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-06-20 18:13:20 +0000
committerrwatson <rwatson@FreeBSD.org>2009-06-20 18:13:20 +0000
commit5b52f69d528a1efaa839cad2a056eafab123a2d8 (patch)
tree20b122a96d64e2fbc4d710444b2ed95345abc88e /tools/regression
parent54387df05ffd2fc7b79ca9fd0d98c13ed5030c87 (diff)
downloadFreeBSD-src-5b52f69d528a1efaa839cad2a056eafab123a2d8.zip
FreeBSD-src-5b52f69d528a1efaa839cad2a056eafab123a2d8.tar.gz
Up the scale of the SPX loopback check a bit: use much larger data sizes
so that we need to do segmentation.
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/netipx/spxloopback/spxloopback.c97
1 files changed, 38 insertions, 59 deletions
diff --git a/tools/regression/netipx/spxloopback/spxloopback.c b/tools/regression/netipx/spxloopback/spxloopback.c
index 9561cff..0f3f156 100644
--- a/tools/regression/netipx/spxloopback/spxloopback.c
+++ b/tools/regression/netipx/spxloopback/spxloopback.c
@@ -46,11 +46,7 @@
#include <unistd.h>
#define IPX_ENDPOINT "0xbebe.1.0x8a13"
-#define PACKETLEN 128
-
-#if 0
-#define SPX_SUPPORTS_SENDTO_WITH_CONNECT
-#endif
+#define PACKETLEN 16 * (1024 * 1024)
static void
packet_fill(u_char *packet)
@@ -62,61 +58,40 @@ packet_fill(u_char *packet)
}
static int
-packet_check(u_char *packet)
+packet_check(u_char *packet, size_t totlen, ssize_t len)
{
- int i;
+ size_t i;
- for (i = 0; i < PACKETLEN; i++) {
+ for (i = totlen; i < totlen + len; i++) {
if (packet[i] != (i & 0xff))
return (-1);
}
return (0);
}
-#ifdef SPX_SUPPORTS_SENDTO_WITH_CONNECT
-static void
-my_sendto(int sock, const char *who, pid_t pid, struct sockaddr *sa,
- socklen_t sa_len)
-{
- u_char packet[PACKETLEN];
- ssize_t len;
- int error;
-
- packet_fill(packet);
- len = sendto(sock, packet, sizeof(packet), 0, sa, sa_len);
- if (len < 0) {
- error = errno;
- (void)kill(pid, SIGTERM);
- errno = error;
- err(-1, "%s: sendto()", who);
- }
- if (len != sizeof(packet)) {
- (void)kill(pid, SIGTERM);
- errx(-1, "%s: sendto(): short send (%d length, %d sent)",
- who, sizeof(packet), len);
- }
-}
-#endif
-
static void
my_send(int sock, const char *who, pid_t pid)
{
u_char packet[PACKETLEN];
ssize_t len;
+ size_t totlen;
int error;
+ totlen = 0;
packet_fill(packet);
- len = send(sock, packet, sizeof(packet), 0);
- if (len < 0) {
- error = errno;
- (void)kill(pid, SIGTERM);
- errno = error;
- err(-1, "%s: send()", who);
- }
- if (len != sizeof(packet)) {
- (void)kill(pid, SIGTERM);
- errx(-1, "%s: send(): short send (%d length, %d sent)", who,
- sizeof(packet), len);
+ while (totlen < PACKETLEN) {
+ len = send(sock, packet + totlen, PACKETLEN - totlen, 0);
+ if (len < 0) {
+ error = errno;
+ (void)kill(pid, SIGTERM);
+ errno = error;
+ err(-1, "%s: send()", who);
+ }
+ if (len == 0) {
+ (void)kill(pid, SIGTERM);
+ errx(-1, "%s: send(): EOF", who);
+ }
+ totlen += len;
}
}
@@ -125,24 +100,28 @@ my_recv(int sock, const char *who, pid_t pid)
{
u_char packet[PACKETLEN];
ssize_t len;
+ size_t totlen;
int error;
+ totlen = 0;
bzero(packet, sizeof(packet));
- len = recv(sock, packet, sizeof(packet), 0);
- if (len < 0) {
- errno = error;
- (void)kill(pid, SIGTERM);
- errno = error;
- err(-1, "%s: recv()", who);
- }
- if (len != sizeof(packet)) {
- (void)kill(pid, SIGTERM);
- errx(-1, "%s: recv(): got %d expected %d", who, len,
- sizeof(packet));
- }
- if (packet_check(packet) < 0) {
- (void)kill(pid, SIGTERM);
- errx(-1, "%s: recv(): got bad data", who);
+ while (totlen < PACKETLEN) {
+ len = recv(sock, packet + totlen, sizeof(packet) - totlen, 0);
+ if (len < 0) {
+ errno = error;
+ (void)kill(pid, SIGTERM);
+ errno = error;
+ err(-1, "%s: recv()", who);
+ }
+ if (len == 0) {
+ (void)kill(pid, SIGTERM);
+ errx(-1, "%s: recv(): EOF", who);
+ }
+ if (packet_check(packet, totlen, len) < 0) {
+ (void)kill(pid, SIGTERM);
+ errx(-1, "%s: recv(): got bad data", who);
+ }
+ totlen += len;
}
}
OpenPOWER on IntegriCloud