15211f8dcSMark Johnston /*-
25211f8dcSMark Johnston * Copyright (c) 2018 The FreeBSD Foundation
35211f8dcSMark Johnston *
45211f8dcSMark Johnston * This software was developed by Mark Johnston under sponsorship from
55211f8dcSMark Johnston * the FreeBSD Foundation.
65211f8dcSMark Johnston *
75211f8dcSMark Johnston * Redistribution and use in source and binary forms, with or without
85211f8dcSMark Johnston * modification, are permitted provided that the following conditions are
95211f8dcSMark Johnston * met:
105211f8dcSMark Johnston * 1. Redistributions of source code must retain the above copyright
115211f8dcSMark Johnston * notice, this list of conditions and the following disclaimer.
125211f8dcSMark Johnston * 2. Redistributions in binary form must reproduce the above copyright
135211f8dcSMark Johnston * notice, this list of conditions and the following disclaimer in
145211f8dcSMark Johnston * the documentation and/or other materials provided with the
155211f8dcSMark Johnston * distribution.
165211f8dcSMark Johnston *
175211f8dcSMark Johnston * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
185211f8dcSMark Johnston * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
195211f8dcSMark Johnston * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
205211f8dcSMark Johnston * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
215211f8dcSMark Johnston * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
225211f8dcSMark Johnston * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
235211f8dcSMark Johnston * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
245211f8dcSMark Johnston * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
255211f8dcSMark Johnston * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
265211f8dcSMark Johnston * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
275211f8dcSMark Johnston * SUCH DAMAGE.
285211f8dcSMark Johnston */
295211f8dcSMark Johnston
305211f8dcSMark Johnston #include <sys/param.h>
315211f8dcSMark Johnston #include <sys/ioctl.h>
325211f8dcSMark Johnston #include <sys/socket.h>
335211f8dcSMark Johnston #include <sys/sysctl.h>
345211f8dcSMark Johnston
355211f8dcSMark Johnston #include <net/bpf.h>
365211f8dcSMark Johnston #include <net/if.h>
375211f8dcSMark Johnston #include <netinet/in.h>
385211f8dcSMark Johnston #include <netinet/ip.h>
395211f8dcSMark Johnston #include <netinet/ip_var.h>
405211f8dcSMark Johnston
415211f8dcSMark Johnston #include <err.h>
425211f8dcSMark Johnston #include <errno.h>
435211f8dcSMark Johnston #include <fcntl.h>
445211f8dcSMark Johnston #include <ifaddrs.h>
455211f8dcSMark Johnston #include <stdint.h>
465211f8dcSMark Johnston #include <stdlib.h>
475211f8dcSMark Johnston #include <time.h>
485211f8dcSMark Johnston #include <unistd.h>
495211f8dcSMark Johnston
505211f8dcSMark Johnston #include <atf-c.h>
515211f8dcSMark Johnston
525211f8dcSMark Johnston struct lopacket {
535211f8dcSMark Johnston u_int family;
545211f8dcSMark Johnston struct ip hdr;
555211f8dcSMark Johnston char payload[];
565211f8dcSMark Johnston };
575211f8dcSMark Johnston
585211f8dcSMark Johnston static void
update_cksum(struct ip * ip)595211f8dcSMark Johnston update_cksum(struct ip *ip)
605211f8dcSMark Johnston {
615211f8dcSMark Johnston size_t i;
625211f8dcSMark Johnston uint32_t cksum;
63*9ee759f3SMichal Meloun uint8_t *cksump;
64*9ee759f3SMichal Meloun uint16_t tmp;
655211f8dcSMark Johnston
665211f8dcSMark Johnston ip->ip_sum = 0;
67*9ee759f3SMichal Meloun cksump = (char *)ip;
68*9ee759f3SMichal Meloun for (cksum = 0, i = 0; i < sizeof(*ip) / sizeof(uint16_t); i++) {
69*9ee759f3SMichal Meloun tmp = *cksump++;
70*9ee759f3SMichal Meloun tmp = tmp << 8 | *cksump++;
71*9ee759f3SMichal Meloun cksum += ntohs(tmp);
72*9ee759f3SMichal Meloun }
735211f8dcSMark Johnston cksum = (cksum >> 16) + (cksum & 0xffff);
745211f8dcSMark Johnston cksum = ~(cksum + (cksum >> 16));
755211f8dcSMark Johnston ip->ip_sum = htons((uint16_t)cksum);
765211f8dcSMark Johnston }
775211f8dcSMark Johnston
785211f8dcSMark Johnston static struct lopacket *
alloc_lopacket(in_addr_t dstaddr,size_t payloadlen)795211f8dcSMark Johnston alloc_lopacket(in_addr_t dstaddr, size_t payloadlen)
805211f8dcSMark Johnston {
815211f8dcSMark Johnston struct ip *ip;
825211f8dcSMark Johnston struct lopacket *packet;
835211f8dcSMark Johnston size_t pktlen;
845211f8dcSMark Johnston
855211f8dcSMark Johnston pktlen = sizeof(*packet) + payloadlen;
865211f8dcSMark Johnston packet = malloc(pktlen);
875211f8dcSMark Johnston ATF_REQUIRE(packet != NULL);
885211f8dcSMark Johnston
895211f8dcSMark Johnston memset(packet, 0, pktlen);
905211f8dcSMark Johnston packet->family = AF_INET;
915211f8dcSMark Johnston
925211f8dcSMark Johnston ip = &packet->hdr;
935211f8dcSMark Johnston ip->ip_hl = sizeof(struct ip) >> 2;
945211f8dcSMark Johnston ip->ip_v = 4;
955211f8dcSMark Johnston ip->ip_tos = 0;
965211f8dcSMark Johnston ip->ip_len = htons(sizeof(*ip) + payloadlen);
975211f8dcSMark Johnston ip->ip_id = 0;
985211f8dcSMark Johnston ip->ip_off = 0;
995211f8dcSMark Johnston ip->ip_ttl = 1;
1005211f8dcSMark Johnston ip->ip_p = IPPROTO_IP;
1015211f8dcSMark Johnston ip->ip_sum = 0;
1025211f8dcSMark Johnston ip->ip_src.s_addr = dstaddr;
1035211f8dcSMark Johnston ip->ip_dst.s_addr = dstaddr;
1045211f8dcSMark Johnston update_cksum(ip);
1055211f8dcSMark Johnston
1065211f8dcSMark Johnston return (packet);
1075211f8dcSMark Johnston }
1085211f8dcSMark Johnston
1095211f8dcSMark Johnston static void
free_lopacket(struct lopacket * packet)1105211f8dcSMark Johnston free_lopacket(struct lopacket *packet)
1115211f8dcSMark Johnston {
1125211f8dcSMark Johnston
1135211f8dcSMark Johnston free(packet);
1145211f8dcSMark Johnston }
1155211f8dcSMark Johnston
1165211f8dcSMark Johnston static void
write_lopacket(int bpffd,struct lopacket * packet)1175211f8dcSMark Johnston write_lopacket(int bpffd, struct lopacket *packet)
1185211f8dcSMark Johnston {
1195211f8dcSMark Johnston struct timespec ts;
1205211f8dcSMark Johnston ssize_t n;
1215211f8dcSMark Johnston size_t len;
1225211f8dcSMark Johnston
1235211f8dcSMark Johnston len = sizeof(packet->family) + ntohs(packet->hdr.ip_len);
1245211f8dcSMark Johnston n = write(bpffd, packet, len);
1255211f8dcSMark Johnston ATF_REQUIRE_MSG(n >= 0, "packet write failed: %s", strerror(errno));
1265211f8dcSMark Johnston ATF_REQUIRE_MSG((size_t)n == len, "wrote %zd bytes instead of %zu",
1275211f8dcSMark Johnston n, len);
1285211f8dcSMark Johnston
1295211f8dcSMark Johnston /*
1305211f8dcSMark Johnston * Loopback packets are dispatched asynchronously, give netisr some
1315211f8dcSMark Johnston * time.
1325211f8dcSMark Johnston */
1335211f8dcSMark Johnston ts.tv_sec = 0;
1345211f8dcSMark Johnston ts.tv_nsec = 5000000; /* 5ms */
1355211f8dcSMark Johnston (void)nanosleep(&ts, NULL);
1365211f8dcSMark Johnston }
1375211f8dcSMark Johnston
1385211f8dcSMark Johnston static int
open_lobpf(in_addr_t * addrp)1395211f8dcSMark Johnston open_lobpf(in_addr_t *addrp)
1405211f8dcSMark Johnston {
1415211f8dcSMark Johnston struct ifreq ifr;
1425211f8dcSMark Johnston struct ifaddrs *ifa, *ifap;
1435211f8dcSMark Johnston int error, fd;
1445211f8dcSMark Johnston
1455211f8dcSMark Johnston fd = open("/dev/bpf0", O_RDWR);
1465211f8dcSMark Johnston if (fd < 0 && errno == ENOENT)
1475211f8dcSMark Johnston atf_tc_skip("no BPF device available");
1485211f8dcSMark Johnston ATF_REQUIRE_MSG(fd >= 0, "open(/dev/bpf0): %s", strerror(errno));
1495211f8dcSMark Johnston
1505211f8dcSMark Johnston error = getifaddrs(&ifap);
1515211f8dcSMark Johnston ATF_REQUIRE(error == 0);
1525211f8dcSMark Johnston for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next)
1535211f8dcSMark Johnston if ((ifa->ifa_flags & IFF_LOOPBACK) != 0 &&
1545211f8dcSMark Johnston ifa->ifa_addr->sa_family == AF_INET)
1555211f8dcSMark Johnston break;
1565211f8dcSMark Johnston if (ifa == NULL)
1575211f8dcSMark Johnston atf_tc_skip("no loopback address found");
1585211f8dcSMark Johnston
1595211f8dcSMark Johnston memset(&ifr, 0, sizeof(ifr));
1605211f8dcSMark Johnston strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
1615211f8dcSMark Johnston error = ioctl(fd, BIOCSETIF, &ifr);
1625211f8dcSMark Johnston ATF_REQUIRE_MSG(error == 0, "ioctl(BIOCSETIF): %s", strerror(errno));
1635211f8dcSMark Johnston
1645211f8dcSMark Johnston *addrp = ((struct sockaddr_in *)(void *)ifa->ifa_addr)->sin_addr.s_addr;
1655211f8dcSMark Johnston
1665211f8dcSMark Johnston freeifaddrs(ifap);
1675211f8dcSMark Johnston
1685211f8dcSMark Johnston return (fd);
1695211f8dcSMark Johnston }
1705211f8dcSMark Johnston
1715211f8dcSMark Johnston static void
get_ipstat(struct ipstat * stat)1725211f8dcSMark Johnston get_ipstat(struct ipstat *stat)
1735211f8dcSMark Johnston {
1745211f8dcSMark Johnston size_t len;
1755211f8dcSMark Johnston int error;
1765211f8dcSMark Johnston
1775211f8dcSMark Johnston memset(stat, 0, sizeof(*stat));
1785211f8dcSMark Johnston len = sizeof(*stat);
1795211f8dcSMark Johnston error = sysctlbyname("net.inet.ip.stats", stat, &len, NULL, 0);
1805211f8dcSMark Johnston ATF_REQUIRE_MSG(error == 0, "sysctl(net.inet.ip.stats) failed: %s",
1815211f8dcSMark Johnston strerror(errno));
1825211f8dcSMark Johnston ATF_REQUIRE(len == sizeof(*stat));
1835211f8dcSMark Johnston }
1845211f8dcSMark Johnston
1855211f8dcSMark Johnston #define CHECK_IP_COUNTER(oldp, newp, counter) \
1865211f8dcSMark Johnston ATF_REQUIRE_MSG((oldp)->ips_ ## counter < (newp)->ips_ ## counter, \
1875211f8dcSMark Johnston "ips_" #counter " wasn't incremented (%ju vs. %ju)", \
1885211f8dcSMark Johnston (uintmax_t)old.ips_ ## counter, (uintmax_t)new.ips_## counter);
1895211f8dcSMark Johnston
1905211f8dcSMark Johnston /*
1915211f8dcSMark Johnston * Make sure a fragment with MF set doesn't come after the last fragment of a
1925211f8dcSMark Johnston * packet. Make sure that multiple fragments with MF clear have the same offset
1935211f8dcSMark Johnston * and length.
1945211f8dcSMark Johnston */
1955211f8dcSMark Johnston ATF_TC(ip_reass__multiple_last_fragments);
ATF_TC_HEAD(ip_reass__multiple_last_fragments,tc)1965211f8dcSMark Johnston ATF_TC_HEAD(ip_reass__multiple_last_fragments, tc)
1975211f8dcSMark Johnston {
1985211f8dcSMark Johnston atf_tc_set_md_var(tc, "require.user", "root");
1995211f8dcSMark Johnston }
ATF_TC_BODY(ip_reass__multiple_last_fragments,tc)2005211f8dcSMark Johnston ATF_TC_BODY(ip_reass__multiple_last_fragments, tc)
2015211f8dcSMark Johnston {
2025211f8dcSMark Johnston struct ipstat old, new;
2035211f8dcSMark Johnston struct ip *ip;
2045211f8dcSMark Johnston struct lopacket *packet1, *packet2, *packet3, *packet4;
2055211f8dcSMark Johnston in_addr_t addr;
2065211f8dcSMark Johnston int error, fd;
2075211f8dcSMark Johnston uint16_t ipid;
2085211f8dcSMark Johnston
2095211f8dcSMark Johnston fd = open_lobpf(&addr);
2105211f8dcSMark Johnston ipid = arc4random_uniform(UINT16_MAX + 1);
2115211f8dcSMark Johnston
2125211f8dcSMark Johnston packet1 = alloc_lopacket(addr, 16);
2135211f8dcSMark Johnston ip = &packet1->hdr;
2145211f8dcSMark Johnston ip->ip_id = ipid;
2155211f8dcSMark Johnston ip->ip_off = htons(0x10);
2165211f8dcSMark Johnston update_cksum(ip);
2175211f8dcSMark Johnston
2185211f8dcSMark Johnston packet2 = alloc_lopacket(addr, 16);
2195211f8dcSMark Johnston ip = &packet2->hdr;
2205211f8dcSMark Johnston ip->ip_id = ipid;
2215211f8dcSMark Johnston ip->ip_off = htons(0x20);
2225211f8dcSMark Johnston update_cksum(ip);
2235211f8dcSMark Johnston
2245211f8dcSMark Johnston packet3 = alloc_lopacket(addr, 16);
2255211f8dcSMark Johnston ip = &packet3->hdr;
2265211f8dcSMark Johnston ip->ip_id = ipid;
2275211f8dcSMark Johnston ip->ip_off = htons(0x8);
2285211f8dcSMark Johnston update_cksum(ip);
2295211f8dcSMark Johnston
2305211f8dcSMark Johnston packet4 = alloc_lopacket(addr, 32);
2315211f8dcSMark Johnston ip = &packet4->hdr;
2325211f8dcSMark Johnston ip->ip_id = ipid;
2335211f8dcSMark Johnston ip->ip_off = htons(0x10);
2345211f8dcSMark Johnston update_cksum(ip);
2355211f8dcSMark Johnston
2365211f8dcSMark Johnston write_lopacket(fd, packet1);
2375211f8dcSMark Johnston
2385211f8dcSMark Johnston /* packet2 comes after packet1. */
2395211f8dcSMark Johnston get_ipstat(&old);
2405211f8dcSMark Johnston write_lopacket(fd, packet2);
2415211f8dcSMark Johnston get_ipstat(&new);
2425211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2435211f8dcSMark Johnston
2445211f8dcSMark Johnston /* packet2 comes after packet1 and has MF set. */
2455211f8dcSMark Johnston packet2->hdr.ip_off = htons(IP_MF | 0x20);
2465211f8dcSMark Johnston update_cksum(&packet2->hdr);
2475211f8dcSMark Johnston get_ipstat(&old);
2485211f8dcSMark Johnston write_lopacket(fd, packet2);
2495211f8dcSMark Johnston get_ipstat(&new);
2505211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2515211f8dcSMark Johnston
2525211f8dcSMark Johnston /* packet3 comes before packet1 but overlaps. */
2535211f8dcSMark Johnston get_ipstat(&old);
2545211f8dcSMark Johnston write_lopacket(fd, packet3);
2555211f8dcSMark Johnston get_ipstat(&new);
2565211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2575211f8dcSMark Johnston
2585211f8dcSMark Johnston /* packet4 has the same offset as packet1 but is longer. */
2595211f8dcSMark Johnston get_ipstat(&old);
2605211f8dcSMark Johnston write_lopacket(fd, packet4);
2615211f8dcSMark Johnston get_ipstat(&new);
2625211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2635211f8dcSMark Johnston
2645211f8dcSMark Johnston error = close(fd);
2655211f8dcSMark Johnston ATF_REQUIRE(error == 0);
2665211f8dcSMark Johnston free_lopacket(packet1);
2675211f8dcSMark Johnston free_lopacket(packet2);
2689ed1e4ecSMark Johnston free_lopacket(packet3);
2699ed1e4ecSMark Johnston free_lopacket(packet4);
2705211f8dcSMark Johnston }
2715211f8dcSMark Johnston
2725211f8dcSMark Johnston /*
2735211f8dcSMark Johnston * Make sure that we reject zero-length fragments.
2745211f8dcSMark Johnston */
2755211f8dcSMark Johnston ATF_TC(ip_reass__zero_length_fragment);
ATF_TC_HEAD(ip_reass__zero_length_fragment,tc)2765211f8dcSMark Johnston ATF_TC_HEAD(ip_reass__zero_length_fragment, tc)
2775211f8dcSMark Johnston {
2785211f8dcSMark Johnston atf_tc_set_md_var(tc, "require.user", "root");
2795211f8dcSMark Johnston }
ATF_TC_BODY(ip_reass__zero_length_fragment,tc)2805211f8dcSMark Johnston ATF_TC_BODY(ip_reass__zero_length_fragment, tc)
2815211f8dcSMark Johnston {
2825211f8dcSMark Johnston struct ipstat old, new;
2835211f8dcSMark Johnston struct ip *ip;
2845211f8dcSMark Johnston struct lopacket *packet1, *packet2;
2855211f8dcSMark Johnston in_addr_t addr;
2865211f8dcSMark Johnston int error, fd;
2875211f8dcSMark Johnston uint16_t ipid;
2885211f8dcSMark Johnston
2895211f8dcSMark Johnston fd = open_lobpf(&addr);
2905211f8dcSMark Johnston ipid = arc4random_uniform(UINT16_MAX + 1);
2915211f8dcSMark Johnston
2925211f8dcSMark Johnston /*
2935211f8dcSMark Johnston * Create two packets, one with MF set, one without.
2945211f8dcSMark Johnston */
2955211f8dcSMark Johnston packet1 = alloc_lopacket(addr, 0);
2965211f8dcSMark Johnston ip = &packet1->hdr;
2975211f8dcSMark Johnston ip->ip_id = ipid;
2985211f8dcSMark Johnston ip->ip_off = htons(IP_MF | 0x10);
2995211f8dcSMark Johnston update_cksum(ip);
3005211f8dcSMark Johnston
3015211f8dcSMark Johnston packet2 = alloc_lopacket(addr, 0);
3025211f8dcSMark Johnston ip = &packet2->hdr;
3035211f8dcSMark Johnston ip->ip_id = ~ipid;
3045211f8dcSMark Johnston ip->ip_off = htons(0x10);
3055211f8dcSMark Johnston update_cksum(ip);
3065211f8dcSMark Johnston
3075211f8dcSMark Johnston get_ipstat(&old);
3085211f8dcSMark Johnston write_lopacket(fd, packet1);
3095211f8dcSMark Johnston get_ipstat(&new);
3105211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toosmall);
3115211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3125211f8dcSMark Johnston
3135211f8dcSMark Johnston get_ipstat(&old);
3145211f8dcSMark Johnston write_lopacket(fd, packet2);
3155211f8dcSMark Johnston get_ipstat(&new);
3165211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toosmall);
3175211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3185211f8dcSMark Johnston
3195211f8dcSMark Johnston error = close(fd);
3205211f8dcSMark Johnston ATF_REQUIRE(error == 0);
3215211f8dcSMark Johnston free_lopacket(packet1);
3225211f8dcSMark Johnston free_lopacket(packet2);
3235211f8dcSMark Johnston }
3245211f8dcSMark Johnston
3255211f8dcSMark Johnston ATF_TC(ip_reass__large_fragment);
ATF_TC_HEAD(ip_reass__large_fragment,tc)3265211f8dcSMark Johnston ATF_TC_HEAD(ip_reass__large_fragment, tc)
3275211f8dcSMark Johnston {
3285211f8dcSMark Johnston atf_tc_set_md_var(tc, "require.user", "root");
3295211f8dcSMark Johnston }
ATF_TC_BODY(ip_reass__large_fragment,tc)3305211f8dcSMark Johnston ATF_TC_BODY(ip_reass__large_fragment, tc)
3315211f8dcSMark Johnston {
3325211f8dcSMark Johnston struct ipstat old, new;
3335211f8dcSMark Johnston struct ip *ip;
3345211f8dcSMark Johnston struct lopacket *packet1, *packet2;
3355211f8dcSMark Johnston in_addr_t addr;
3365211f8dcSMark Johnston int error, fd;
3375211f8dcSMark Johnston uint16_t ipid;
3385211f8dcSMark Johnston
3395211f8dcSMark Johnston fd = open_lobpf(&addr);
3405211f8dcSMark Johnston ipid = arc4random_uniform(UINT16_MAX + 1);
3415211f8dcSMark Johnston
3425211f8dcSMark Johnston /*
3435211f8dcSMark Johnston * Create two packets, one with MF set, one without.
3445211f8dcSMark Johnston *
3455211f8dcSMark Johnston * 16 + (0x1fff << 3) > IP_MAXPACKET, so these should fail the check.
3465211f8dcSMark Johnston */
3475211f8dcSMark Johnston packet1 = alloc_lopacket(addr, 16);
3485211f8dcSMark Johnston ip = &packet1->hdr;
3495211f8dcSMark Johnston ip->ip_id = ipid;
3505211f8dcSMark Johnston ip->ip_off = htons(IP_MF | 0x1fff);
3515211f8dcSMark Johnston update_cksum(ip);
3525211f8dcSMark Johnston
3535211f8dcSMark Johnston packet2 = alloc_lopacket(addr, 16);
3545211f8dcSMark Johnston ip = &packet2->hdr;
3555211f8dcSMark Johnston ip->ip_id = ipid;
3565211f8dcSMark Johnston ip->ip_off = htons(0x1fff);
3575211f8dcSMark Johnston update_cksum(ip);
3585211f8dcSMark Johnston
3595211f8dcSMark Johnston get_ipstat(&old);
3605211f8dcSMark Johnston write_lopacket(fd, packet1);
3615211f8dcSMark Johnston get_ipstat(&new);
3625211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toolong);
3635211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3645211f8dcSMark Johnston
3655211f8dcSMark Johnston get_ipstat(&old);
3665211f8dcSMark Johnston write_lopacket(fd, packet2);
3675211f8dcSMark Johnston get_ipstat(&new);
3685211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toolong);
3695211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3705211f8dcSMark Johnston
3715211f8dcSMark Johnston error = close(fd);
3725211f8dcSMark Johnston ATF_REQUIRE(error == 0);
3735211f8dcSMark Johnston free_lopacket(packet1);
3745211f8dcSMark Johnston free_lopacket(packet2);
3755211f8dcSMark Johnston }
3765211f8dcSMark Johnston
ATF_TP_ADD_TCS(tp)3775211f8dcSMark Johnston ATF_TP_ADD_TCS(tp)
3785211f8dcSMark Johnston {
3795211f8dcSMark Johnston ATF_TP_ADD_TC(tp, ip_reass__multiple_last_fragments);
3805211f8dcSMark Johnston ATF_TP_ADD_TC(tp, ip_reass__zero_length_fragment);
3815211f8dcSMark Johnston ATF_TP_ADD_TC(tp, ip_reass__large_fragment);
3825211f8dcSMark Johnston
3835211f8dcSMark Johnston return (atf_no_error());
3845211f8dcSMark Johnston }
385