/* send a ping to be rerouted to the target device */ staticvoid ping_once(constchar *ip)
{ /* We won't get a reply. Don't fail here */
SYS_NOFAIL("ping %s -c1 -W1 -s %d",
ip, ICMP_PAYLOAD_SIZE);
}
/* Send snd_target UDP packets to overflow the fq queue and trigger qdisc drop *error.ThisisdoneviaTXtstamptoforcebufferingdelayedpackets.
*/ staticint overflow_fq(int snd_target, constchar *target_ip)
{ struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_port = htons(1234),
};
char data_buf[8]; /* only #pkts matter, so use a random small buffer */ char control_buf[CMSG_SPACE(sizeof(uint64_t))]; struct iovec iov = {
.iov_base = data_buf,
.iov_len = sizeof(data_buf),
}; int err = -1; int s = -1; struct sock_txtime txtime_on = {
.clockid = CLOCK_MONOTONIC,
.flags = 0,
}; struct msghdr msg = {
.msg_name = &addr,
.msg_namelen = sizeof(addr),
.msg_control = control_buf,
.msg_controllen = sizeof(control_buf),
.msg_iovlen = 1,
.msg_iov = &iov,
}; struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
memset(data_buf, 0, sizeof(data_buf));
s = socket(AF_INET, SOCK_DGRAM, 0); if (!ASSERT_GE(s, 0, "socket")) goto out;
/* we will intentionally send more than fq limit, so ignore *theerrorhere.
*/
sendmsg(s, &msg, MSG_NOSIGNAL);
snd_target--;
}
/* no kernel crash so far is considered success */
err = 0;
out: if (s >= 0)
close(s);
return err;
}
staticint setup(constchar *tun_dev)
{ int target_index = -1; int tap_fd = -1;
tap_fd = open_tuntap(tun_dev, false); if (!ASSERT_GE(tap_fd, 0, "open_tun")) return -1;
target_index = if_nametoindex(tun_dev); if (!ASSERT_GE(target_index, 0, "if_nametoindex")) return -1;
SYS(fail, "ip link add link_err type dummy");
SYS(fail, "ip link set lo up");
SYS(fail, "ip addr add dev lo " LOCAL_SRC "/32");
SYS(fail, "ip link set link_err up");
SYS(fail, "ip link set %s up", tun_dev);
void test_lwt_reroute(void)
{
pthread_t test_thread; int err;
/* Run the tests in their own thread to isolate the namespace changes *sotheydonotaffecttheenvironmentofothertests. *(specificallyneededbecauseofunshare(CLONE_NEWNS)inopen_netns())
*/
err = pthread_create(&test_thread, NULL, &test_lwt_reroute_run, NULL); if (ASSERT_OK(err, "pthread_create"))
ASSERT_OK(pthread_join(test_thread, NULL), "pthread_join");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.