From owner-p4-projects@FreeBSD.ORG Fri Aug 17 06:49:45 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 59F0616A41B; Fri, 17 Aug 2007 06:49:45 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D299216A417 for ; Fri, 17 Aug 2007 06:49:44 +0000 (UTC) (envelope-from zhouzhouyi@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C551413C465 for ; Fri, 17 Aug 2007 06:49:44 +0000 (UTC) (envelope-from zhouzhouyi@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7H6niaW091509 for ; Fri, 17 Aug 2007 06:49:44 GMT (envelope-from zhouzhouyi@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7H6nikr091506 for perforce@freebsd.org; Fri, 17 Aug 2007 06:49:44 GMT (envelope-from zhouzhouyi@FreeBSD.org) Date: Fri, 17 Aug 2007 06:49:44 GMT Message-Id: <200708170649.l7H6nikr091506@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zhouzhouyi@FreeBSD.org using -f From: Zhouyi ZHOU To: Perforce Change Reviews Cc: Subject: PERFORCE change 125257 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2007 06:49:45 -0000 http://perforce.freebsd.org/chv.cgi?CH=125257 Change 125257 by zhouzhouyi@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`