| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_bpf.c,v 1.2 2011/01/03 02:53:15 christos Exp $ */ | | 1 | /* $NetBSD: t_bpf.c,v 1.3 2011/12/18 22:51:00 joerg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2010 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -66,35 +66,33 @@ getmtdata(void) | | | @@ -66,35 +66,33 @@ getmtdata(void) |
66 | size_t mbstatlen = sizeof(mbstat); | | 66 | size_t mbstatlen = sizeof(mbstat); |
67 | const int mbstat_mib[] = { CTL_KERN, KERN_MBUF, MBUF_STATS }; | | 67 | const int mbstat_mib[] = { CTL_KERN, KERN_MBUF, MBUF_STATS }; |
68 | | | 68 | |
69 | RL(rump_sys___sysctl(mbstat_mib, __arraycount(mbstat_mib), | | 69 | RL(rump_sys___sysctl(mbstat_mib, __arraycount(mbstat_mib), |
70 | &mbstat, &mbstatlen, NULL, 0)); | | 70 | &mbstat, &mbstatlen, NULL, 0)); |
71 | return mbstat.m_mtypes[MT_DATA]; | | 71 | return mbstat.m_mtypes[MT_DATA]; |
72 | } | | 72 | } |
73 | | | 73 | |
74 | ATF_TC_BODY(bpfwriteleak, tc) | | 74 | ATF_TC_BODY(bpfwriteleak, tc) |
75 | { | | 75 | { |
76 | char buf[28]; /* sizeof(garbage) > etherhdrlen */ | | 76 | char buf[28]; /* sizeof(garbage) > etherhdrlen */ |
77 | struct ifreq ifr; | | 77 | struct ifreq ifr; |
78 | int ifnum, bpfd; | | 78 | int ifnum, bpfd; |
79 | u_int x; | | | |
80 | | | 79 | |
81 | RZ(rump_init()); | | 80 | RZ(rump_init()); |
82 | RZ(rump_pub_shmif_create(NULL, &ifnum)); | | 81 | RZ(rump_pub_shmif_create(NULL, &ifnum)); |
83 | sprintf(ifr.ifr_name, "shmif%d", ifnum); | | 82 | sprintf(ifr.ifr_name, "shmif%d", ifnum); |
84 | | | 83 | |
85 | RL(bpfd = rump_sys_open("/dev/bpf", O_RDWR)); | | 84 | RL(bpfd = rump_sys_open("/dev/bpf", O_RDWR)); |
86 | RL(rump_sys_ioctl(bpfd, BIOCSETIF, &ifr)); | | 85 | RL(rump_sys_ioctl(bpfd, BIOCSETIF, &ifr)); |
87 | x = 1; | | | |
88 | RL(rump_sys_ioctl(bpfd, BIOCSFEEDBACK, &ifr)); | | 86 | RL(rump_sys_ioctl(bpfd, BIOCSFEEDBACK, &ifr)); |
89 | | | 87 | |
90 | if (getmtdata() != 0) | | 88 | if (getmtdata() != 0) |
91 | atf_tc_fail("test precondition failed: MT_DATA mbufs != 0"); | | 89 | atf_tc_fail("test precondition failed: MT_DATA mbufs != 0"); |
92 | | | 90 | |
93 | ATF_REQUIRE_ERRNO(ENETDOWN, rump_sys_write(bpfd, buf, sizeof(buf))==-1); | | 91 | ATF_REQUIRE_ERRNO(ENETDOWN, rump_sys_write(bpfd, buf, sizeof(buf))==-1); |
94 | | | 92 | |
95 | atf_tc_expect_fail("PR kern/44196"); | | 93 | atf_tc_expect_fail("PR kern/44196"); |
96 | ATF_REQUIRE_EQ(getmtdata(), 0); | | 94 | ATF_REQUIRE_EQ(getmtdata(), 0); |
97 | } | | 95 | } |
98 | | | 96 | |
99 | #if (SIZE_MAX > UINT_MAX) | | 97 | #if (SIZE_MAX > UINT_MAX) |
100 | ATF_TC(bpfwritetrunc); | | 98 | ATF_TC(bpfwritetrunc); |