Index: user/pho/stress2/misc/datagram.sh =================================================================== --- user/pho/stress2/misc/datagram.sh (nonexistent) +++ user/pho/stress2/misc/datagram.sh (revision 334473) @@ -0,0 +1,97 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2018 Dell EMC Isilon +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# UNIX datagram socket test. + +# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen: +# https://people.freebsd.org/~pho/stress/log/datagram.txt + +. ../default.cfg + +cd /tmp +cat > datagram.c < +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +char *filename = "/tmp/datagram.socket"; + +int +main(void) { + + struct sockaddr_un addr; + int bytes, sockfd; + char buf[1024]; + + unlink(filename); + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, filename, 104); + + if ((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) + err(1, "socket"); + + if (bind(sockfd, (struct sockaddr *) &addr, + sizeof(addr)) == -1) + err(1, "bind"); + + if (connect(sockfd, (struct sockaddr *) &addr, + sizeof(addr)) == -1) + err(1, "connect"); + + bytes = read(sockfd, buf, sizeof(buf)); + + return (0); +} +EOF + +mycc -o datagram -Wall -Wextra -O2 -g datagram.c || exit 1 +rm datagram.c + +./datagram & +sleep 1 +kill $! +wait + +rm -f datagram /tmp/datagram.socket +exit 0 Property changes on: user/pho/stress2/misc/datagram.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: user/pho/stress2/misc/datagram2.sh =================================================================== --- user/pho/stress2/misc/datagram2.sh (nonexistent) +++ user/pho/stress2/misc/datagram2.sh (revision 334473) @@ -0,0 +1,105 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2018 Dell EMC Isilon +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# UNIX datagram socket test. + +# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen. + +. ../default.cfg + +cd /tmp +cat > datagram2.c < +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +char *filename = "/tmp/datagram2.socket"; + +int +main(void) { + + struct message { struct cmsghdr msg_hdr; int fd; } m; + struct msghdr mh; + struct sockaddr_un addr; + ssize_t len; + int sockfd; + + unlink(filename); + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, filename, 104); + + if ((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) + err(1, "socket"); + + if (bind(sockfd, (struct sockaddr *) &addr, + sizeof(addr)) == -1) + err(1, "bind"); + + if (connect(sockfd, (struct sockaddr *) &addr, + sizeof(addr)) == -1) + err(1, "connect"); + + bzero(&mh, sizeof(mh)); + bzero(&m, sizeof(m)); + mh.msg_control = &m; + mh.msg_controllen = sizeof(m); + m.msg_hdr.cmsg_len = sizeof(m); + m.msg_hdr.cmsg_level = SOL_SOCKET; + m.msg_hdr.cmsg_type = SCM_RIGHTS; + m.fd = sockfd; + len = sendmsg(sockfd, &mh, 0); + if (len < 0) + err(1, "sendmsg"); + + return (0); +} +EOF + +cc -o datagram2 -Wall -Wextra -O2 -g datagram2.c || exit 1 +rm -f datagram2.c datagram2.socket + +./datagram2 + +rm datagram2 datagram2.socket +exit 0 Property changes on: user/pho/stress2/misc/datagram2.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: user/pho/stress2/misc/datagram3.sh =================================================================== --- user/pho/stress2/misc/datagram3.sh (nonexistent) +++ user/pho/stress2/misc/datagram3.sh (revision 334473) @@ -0,0 +1,107 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2018 Dell EMC Isilon +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# UNIX datagram socket test. + +# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen. + +. ../default.cfg + +cd /tmp +cat > datagram3.c < +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +char *filename = "/tmp/datagram3.socket"; + +int +main(void) { + + struct message { struct cmsghdr msg_hdr; int fd; } m; + struct msghdr mh; + struct sockaddr_un addr; + ssize_t len; + int i, sockfd; + + unlink(filename); + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, filename, 104); + + if ((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) + err(1, "socket"); + + if (bind(sockfd, (struct sockaddr *) &addr, + sizeof(addr)) == -1) + err(1, "bind"); + + if (connect(sockfd, (struct sockaddr *) &addr, + sizeof(addr)) == -1) + err(1, "connect"); + + for (i = 0; i < 32; i++) { + bzero(&mh, sizeof(mh)); + bzero(&m, sizeof(m)); + mh.msg_control = &m; + mh.msg_controllen = sizeof(m); + m.msg_hdr.cmsg_len = sizeof(m); + m.msg_hdr.cmsg_level = SOL_SOCKET; + m.msg_hdr.cmsg_type = SCM_RIGHTS; + m.fd = sockfd; + len = sendmsg(sockfd, &mh, 0); + if (len < 0) + err(1, "sendmsg"); + } + + return (0); +} +EOF + +mycc -o datagram3 -Wall -Wextra -O2 -g datagram3.c || exit 1 +rm -f datagram3.c datagram3.socket + +./datagram3 + +rm datagram3 datagram3.socket +exit 0 Property changes on: user/pho/stress2/misc/datagram3.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: user/pho/stress2/misc/unix_socket.sh =================================================================== --- user/pho/stress2/misc/unix_socket.sh (nonexistent) +++ user/pho/stress2/misc/unix_socket.sh (revision 334473) @@ -0,0 +1,162 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2018 Dell EMC Isilon +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen: +# https://people.freebsd.org/~pho/stress/log/mmacy018.txt + +. ../default.cfg + +cd /tmp +cat > unix_socket.c < +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SOCK_FILE "/tmp/unix_socket.socket" + +static int +client(void) { + struct sockaddr_un addr; + int fd, len; + char buff[8192]; + + if ((fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) + err(1, "socket"); + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, SOCK_FILE); + unlink(SOCK_FILE); + if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) + err(1, "bind"); + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, SOCK_FILE); + if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) + err(1, "connect"); + + strcpy (buff, "1234567890"); + if (send(fd, buff, strlen(buff)+1, 0) == -1) + err(1, "send"); + printf ("sent i1234567890\n"); + + if ((len = recv(fd, buff, 8192, 0)) < 0) + err(1, "recv"); + printf ("receive %d %s\n", len, buff); + + if (fd >= 0) { + close(fd); + } + unlink (SOCK_FILE); + + return(0); +} + +static int +server() { + struct sockaddr_un addr; + struct sockaddr_un from; + socklen_t fromlen = sizeof(from); + int fd, len, ret; + char buff[8192]; + + unlink(SOCK_FILE); + if ((fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) + err(1, "socket"); + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, SOCK_FILE); + unlink(SOCK_FILE); + if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) + err(1, "bind"); + + alarm(2); + while ((len = recvfrom(fd, buff, 8192, 0, (struct sockaddr *)&from, + &fromlen)) > 0) { + printf ("recvfrom: %s\n", buff); + strcpy (buff, "transmit good!"); + ret = sendto(fd, buff, strlen(buff)+1, 0, + (struct sockaddr *)&from, fromlen); + if (ret < 0) { + perror("sendto"); + break; + } + } + + if (fd != -1) + close(fd); + + return (0); +} + +int +main(void) +{ + pid_t pid; + + if ((pid = fork()) == -1) + err(1, "fork"); + + if (pid == 0) { + server(); + _exit(0); + } + sleep(2); + client(); + + if (waitpid(pid, NULL, 0) != pid) + err(1, "waitpid"); + + return (0); +} +EOF + +cc -o unix_socket -Wall -Wextra -O2 -g unix_socket.c || exit +rm unix_socket.c + +./unix_socket > /dev/null + +rm unix_socket +exit 0 Property changes on: user/pho/stress2/misc/unix_socket.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property