1#!/bin/sh 2 3# 4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD 5# 6# Copyright (c) 2018 Dell EMC Isilon 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 11# 1. Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# 2. Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in the 15# documentation and/or other materials provided with the distribution. 16# 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27# SUCH DAMAGE. 28# 29 30# UNIX datagram socket test. 31 32# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen: 33# https://people.freebsd.org/~pho/stress/log/datagram.txt 34# Fixed by r334756. 35 36. ../default.cfg 37 38cd /tmp 39cat > datagram.c <<EOF 40#include <sys/param.h> 41#include <sys/socket.h> 42#include <sys/un.h> 43#include <sys/wait.h> 44 45#include <netinet/in.h> 46 47#include <err.h> 48#include <errno.h> 49#include <netdb.h> 50#include <signal.h> 51#include <stdio.h> 52#include <stdlib.h> 53#include <string.h> 54#include <unistd.h> 55 56char *filename = "/tmp/datagram.socket"; 57 58int 59main(void) { 60 61 struct sockaddr_un addr; 62 int sockfd; 63 char buf[1024]; 64 65 unlink(filename); 66 memset(&addr, 0, sizeof(addr)); 67 addr.sun_family = AF_UNIX; 68 strncpy(addr.sun_path, filename, 104); 69 70 if ((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) 71 err(1, "socket"); 72 73 if (bind(sockfd, (struct sockaddr *) &addr, 74 sizeof(addr)) == -1) 75 err(1, "bind"); 76 77 if (connect(sockfd, (struct sockaddr *) &addr, 78 sizeof(addr)) == -1) 79 err(1, "connect"); 80 81 (void)read(sockfd, buf, sizeof(buf)); 82 83 return (0); 84} 85EOF 86 87mycc -o datagram -Wall -Wextra -O2 -g datagram.c || exit 1 88rm datagram.c 89 90./datagram & 91sleep 1 92kill $! 93wait 94 95rm -f datagram /tmp/datagram.socket 96exit 0 97