Commit 3f12817f authored by Willem de Bruijn's avatar Willem de Bruijn Committed by David S. Miller

selftests: udp gso with corking

Corked sockets take a different path to construct a udp datagram than
the lockless fast path. Test this alternate path.
Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e5b2d91c
...@@ -49,6 +49,7 @@ static bool cfg_do_ipv4; ...@@ -49,6 +49,7 @@ static bool cfg_do_ipv4;
static bool cfg_do_ipv6; static bool cfg_do_ipv6;
static bool cfg_do_connected; static bool cfg_do_connected;
static bool cfg_do_connectionless; static bool cfg_do_connectionless;
static bool cfg_do_msgmore;
static bool cfg_do_setsockopt; static bool cfg_do_setsockopt;
static int cfg_specific_test_id = -1; static int cfg_specific_test_id = -1;
...@@ -369,6 +370,23 @@ static void set_route_mtu(int mtu, bool is_ipv4) ...@@ -369,6 +370,23 @@ static void set_route_mtu(int mtu, bool is_ipv4)
fprintf(stderr, "route mtu (test): %u\n", mtu); fprintf(stderr, "route mtu (test): %u\n", mtu);
} }
static bool __send_one(int fd, struct msghdr *msg, int flags)
{
int ret;
ret = sendmsg(fd, msg, flags);
if (ret == -1 && (errno == EMSGSIZE || errno == ENOMEM))
return false;
if (ret == -1)
error(1, errno, "sendmsg");
if (ret != msg->msg_iov->iov_len)
error(1, 0, "sendto: %d != %lu", ret, msg->msg_iov->iov_len);
if (msg->msg_flags)
error(1, 0, "sendmsg: return flags 0x%x\n", msg->msg_flags);
return true;
}
static bool send_one(int fd, int len, int gso_len, static bool send_one(int fd, int len, int gso_len,
struct sockaddr *addr, socklen_t alen) struct sockaddr *addr, socklen_t alen)
{ {
...@@ -376,7 +394,6 @@ static bool send_one(int fd, int len, int gso_len, ...@@ -376,7 +394,6 @@ static bool send_one(int fd, int len, int gso_len,
struct msghdr msg = {0}; struct msghdr msg = {0};
struct iovec iov = {0}; struct iovec iov = {0};
struct cmsghdr *cm; struct cmsghdr *cm;
int ret;
iov.iov_base = buf; iov.iov_base = buf;
iov.iov_len = len; iov.iov_len = len;
...@@ -398,15 +415,17 @@ static bool send_one(int fd, int len, int gso_len, ...@@ -398,15 +415,17 @@ static bool send_one(int fd, int len, int gso_len,
*((uint16_t *) CMSG_DATA(cm)) = gso_len; *((uint16_t *) CMSG_DATA(cm)) = gso_len;
} }
ret = sendmsg(fd, &msg, 0); /* If MSG_MORE, send 1 byte followed by remainder */
if (ret == -1 && (errno == EMSGSIZE || errno == ENOMEM)) if (cfg_do_msgmore && len > 1) {
return false; iov.iov_len = 1;
if (ret == -1) if (!__send_one(fd, &msg, MSG_MORE))
error(1, errno, "sendmsg"); error(1, 0, "send 1B failed");
if (ret != len)
error(1, 0, "sendto: %d != %u", ret, len);
return true; iov.iov_base++;
iov.iov_len = len - 1;
}
return __send_one(fd, &msg, 0);
} }
static int recv_one(int fd, int flags) static int recv_one(int fd, int flags)
...@@ -558,7 +577,7 @@ static void parse_opts(int argc, char **argv) ...@@ -558,7 +577,7 @@ static void parse_opts(int argc, char **argv)
{ {
int c; int c;
while ((c = getopt(argc, argv, "46cCst:")) != -1) { while ((c = getopt(argc, argv, "46cCmst:")) != -1) {
switch (c) { switch (c) {
case '4': case '4':
cfg_do_ipv4 = true; cfg_do_ipv4 = true;
...@@ -572,6 +591,9 @@ static void parse_opts(int argc, char **argv) ...@@ -572,6 +591,9 @@ static void parse_opts(int argc, char **argv)
case 'C': case 'C':
cfg_do_connectionless = true; cfg_do_connectionless = true;
break; break;
case 'm':
cfg_do_msgmore = true;
break;
case 's': case 's':
cfg_do_setsockopt = true; cfg_do_setsockopt = true;
break; break;
......
...@@ -21,3 +21,9 @@ echo "ipv4 connected" ...@@ -21,3 +21,9 @@ echo "ipv4 connected"
# blocked on 2nd loopback address # blocked on 2nd loopback address
# echo "ipv6 connected" # echo "ipv6 connected"
# ./in_netns.sh ./udpgso -6 -c # ./in_netns.sh ./udpgso -6 -c
echo "ipv4 msg_more"
./in_netns.sh ./udpgso -4 -C -m
echo "ipv6 msg_more"
./in_netns.sh ./udpgso -6 -C -m
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment