PERFORCE change 125257 for review

Zhouyi ZHOU zhouzhouyi at FreeBSD.org
Thu Aug 16 23:49:45 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=125257

Change 125257 by zhouzhouyi at zhouzhouyi_mactest on 2007/08/17 06:49:29

	test cases for inpcb deliver, socket relabel

Affected files ...

.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/macping.c#3 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/netinet/01.t#2 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/netinet/02.t#1 add
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/netinet/03.t#1 add

Differences ...

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/macping.c#3 (text+ko) ====

@@ -97,7 +97,7 @@
 usage(void)
 {
 
-	fprintf(stderr, "usage: macping -m label_string "
+	fprintf(stderr, "usage: macping -m label_string -s socket_label "
 		" -f macconf_file -t timeout target\n");
 	exit(1);
 }
@@ -208,6 +208,7 @@
 
 	int		ch;
 	const char     *label_string = NULL;
+	const char     *socket_label = NULL;
 	char     *target = NULL;
 	const char     *macconf_file = NULL;
 	int		pid;
@@ -228,7 +229,7 @@
 	struct iovec iov;
 	struct sockaddr_in from;
 
-	while ((ch = getopt(argc, argv, "m:f:t:")) != -1) {
+	while ((ch = getopt(argc, argv, "m:f:t:s:")) != -1) {
 		switch (ch) {
 		case 'm':
 			label_string = optarg;
@@ -236,6 +237,9 @@
 		case 'f':
 			macconf_file = optarg;
 			break;
+		case 's':
+			socket_label = optarg;
+			break;
 		case 't':
                         alarmtimeout = strtoul(optarg, &ep, 0);
                         if ((alarmtimeout < 1) || (alarmtimeout == ULONG_MAX))
@@ -277,6 +281,24 @@
 
 	s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
 
+	if (socket_label) {
+		mac_t		label;
+
+		if (mac_from_text(&label, socket_label) == -1) {
+			exit(-1);
+		}
+		if (mac_set_fd(s, label) == -1)
+			error = errno;
+		else
+			error = 0;
+		if (error){
+			printf("error relabelling socket!\n");
+			close(logfd);
+			exit(1);
+		}
+		mac_free(label);
+	}
+
 	outpack = outpackhdr + sizeof(struct ip);
 	icmp_len = sizeof(struct ip) + ICMP_MINLEN + phdr_len;
 	send_len = icmp_len + datalen;

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/netinet/01.t#2 (text+ko) ====

@@ -1,7 +1,7 @@
 #!/bin/sh
 # $FreeBSD: src/tools/regression/mactest/tests/netinet/01.t,v 1.2 2007/01/25 20:50:02 zhouzhouyi Exp $
 
-desc="manipulate fifo files"
+desc="test the ifnet transmit"
 
 
 dir=`dirname $0`


More information about the p4-projects mailing list