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;
635211f8dcSMark Johnston uint16_t *cksump;
645211f8dcSMark Johnston
655211f8dcSMark Johnston ip->ip_sum = 0;
665211f8dcSMark Johnston cksump = (uint16_t *)ip;
675211f8dcSMark Johnston for (cksum = 0, i = 0; i < sizeof(*ip) / sizeof(*cksump); cksump++, i++)
685211f8dcSMark Johnston cksum += ntohs(*cksump);
695211f8dcSMark Johnston cksum = (cksum >> 16) + (cksum & 0xffff);
705211f8dcSMark Johnston cksum = ~(cksum + (cksum >> 16));
715211f8dcSMark Johnston ip->ip_sum = htons((uint16_t)cksum);
725211f8dcSMark Johnston }
735211f8dcSMark Johnston
745211f8dcSMark Johnston static struct lopacket *
alloc_lopacket(in_addr_t dstaddr,size_t payloadlen)755211f8dcSMark Johnston alloc_lopacket(in_addr_t dstaddr, size_t payloadlen)
765211f8dcSMark Johnston {
775211f8dcSMark Johnston struct ip *ip;
785211f8dcSMark Johnston struct lopacket *packet;
795211f8dcSMark Johnston size_t pktlen;
805211f8dcSMark Johnston
815211f8dcSMark Johnston pktlen = sizeof(*packet) + payloadlen;
825211f8dcSMark Johnston packet = malloc(pktlen);
835211f8dcSMark Johnston ATF_REQUIRE(packet != NULL);
845211f8dcSMark Johnston
855211f8dcSMark Johnston memset(packet, 0, pktlen);
865211f8dcSMark Johnston packet->family = AF_INET;
875211f8dcSMark Johnston
885211f8dcSMark Johnston ip = &packet->hdr;
895211f8dcSMark Johnston ip->ip_hl = sizeof(struct ip) >> 2;
905211f8dcSMark Johnston ip->ip_v = 4;
915211f8dcSMark Johnston ip->ip_tos = 0;
925211f8dcSMark Johnston ip->ip_len = htons(sizeof(*ip) + payloadlen);
935211f8dcSMark Johnston ip->ip_id = 0;
945211f8dcSMark Johnston ip->ip_off = 0;
955211f8dcSMark Johnston ip->ip_ttl = 1;
965211f8dcSMark Johnston ip->ip_p = IPPROTO_IP;
975211f8dcSMark Johnston ip->ip_sum = 0;
985211f8dcSMark Johnston ip->ip_src.s_addr = dstaddr;
995211f8dcSMark Johnston ip->ip_dst.s_addr = dstaddr;
1005211f8dcSMark Johnston update_cksum(ip);
1015211f8dcSMark Johnston
1025211f8dcSMark Johnston return (packet);
1035211f8dcSMark Johnston }
1045211f8dcSMark Johnston
1055211f8dcSMark Johnston static void
free_lopacket(struct lopacket * packet)1065211f8dcSMark Johnston free_lopacket(struct lopacket *packet)
1075211f8dcSMark Johnston {
1085211f8dcSMark Johnston
1095211f8dcSMark Johnston free(packet);
1105211f8dcSMark Johnston }
1115211f8dcSMark Johnston
1125211f8dcSMark Johnston static void
write_lopacket(int bpffd,struct lopacket * packet)1135211f8dcSMark Johnston write_lopacket(int bpffd, struct lopacket *packet)
1145211f8dcSMark Johnston {
1155211f8dcSMark Johnston struct timespec ts;
1165211f8dcSMark Johnston ssize_t n;
1175211f8dcSMark Johnston size_t len;
1185211f8dcSMark Johnston
1195211f8dcSMark Johnston len = sizeof(packet->family) + ntohs(packet->hdr.ip_len);
1205211f8dcSMark Johnston n = write(bpffd, packet, len);
1215211f8dcSMark Johnston ATF_REQUIRE_MSG(n >= 0, "packet write failed: %s", strerror(errno));
1225211f8dcSMark Johnston ATF_REQUIRE_MSG((size_t)n == len, "wrote %zd bytes instead of %zu",
1235211f8dcSMark Johnston n, len);
1245211f8dcSMark Johnston
1255211f8dcSMark Johnston /*
1265211f8dcSMark Johnston * Loopback packets are dispatched asynchronously, give netisr some
1275211f8dcSMark Johnston * time.
1285211f8dcSMark Johnston */
1295211f8dcSMark Johnston ts.tv_sec = 0;
1305211f8dcSMark Johnston ts.tv_nsec = 5000000; /* 5ms */
1315211f8dcSMark Johnston (void)nanosleep(&ts, NULL);
1325211f8dcSMark Johnston }
1335211f8dcSMark Johnston
1345211f8dcSMark Johnston static int
open_lobpf(in_addr_t * addrp)1355211f8dcSMark Johnston open_lobpf(in_addr_t *addrp)
1365211f8dcSMark Johnston {
1375211f8dcSMark Johnston struct ifreq ifr;
1385211f8dcSMark Johnston struct ifaddrs *ifa, *ifap;
1395211f8dcSMark Johnston int error, fd;
1405211f8dcSMark Johnston
1415211f8dcSMark Johnston fd = open("/dev/bpf0", O_RDWR);
1425211f8dcSMark Johnston if (fd < 0 && errno == ENOENT)
1435211f8dcSMark Johnston atf_tc_skip("no BPF device available");
1445211f8dcSMark Johnston ATF_REQUIRE_MSG(fd >= 0, "open(/dev/bpf0): %s", strerror(errno));
1455211f8dcSMark Johnston
1465211f8dcSMark Johnston error = getifaddrs(&ifap);
1475211f8dcSMark Johnston ATF_REQUIRE(error == 0);
1485211f8dcSMark Johnston for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next)
1495211f8dcSMark Johnston if ((ifa->ifa_flags & IFF_LOOPBACK) != 0 &&
1505211f8dcSMark Johnston ifa->ifa_addr->sa_family == AF_INET)
1515211f8dcSMark Johnston break;
1525211f8dcSMark Johnston if (ifa == NULL)
1535211f8dcSMark Johnston atf_tc_skip("no loopback address found");
1545211f8dcSMark Johnston
1555211f8dcSMark Johnston memset(&ifr, 0, sizeof(ifr));
1565211f8dcSMark Johnston strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
1575211f8dcSMark Johnston error = ioctl(fd, BIOCSETIF, &ifr);
1585211f8dcSMark Johnston ATF_REQUIRE_MSG(error == 0, "ioctl(BIOCSETIF): %s", strerror(errno));
1595211f8dcSMark Johnston
1605211f8dcSMark Johnston *addrp = ((struct sockaddr_in *)(void *)ifa->ifa_addr)->sin_addr.s_addr;
1615211f8dcSMark Johnston
1625211f8dcSMark Johnston freeifaddrs(ifap);
1635211f8dcSMark Johnston
1645211f8dcSMark Johnston return (fd);
1655211f8dcSMark Johnston }
1665211f8dcSMark Johnston
1675211f8dcSMark Johnston static void
get_ipstat(struct ipstat * stat)1685211f8dcSMark Johnston get_ipstat(struct ipstat *stat)
1695211f8dcSMark Johnston {
1705211f8dcSMark Johnston size_t len;
1715211f8dcSMark Johnston int error;
1725211f8dcSMark Johnston
1735211f8dcSMark Johnston memset(stat, 0, sizeof(*stat));
1745211f8dcSMark Johnston len = sizeof(*stat);
1755211f8dcSMark Johnston error = sysctlbyname("net.inet.ip.stats", stat, &len, NULL, 0);
1765211f8dcSMark Johnston ATF_REQUIRE_MSG(error == 0, "sysctl(net.inet.ip.stats) failed: %s",
1775211f8dcSMark Johnston strerror(errno));
1785211f8dcSMark Johnston ATF_REQUIRE(len == sizeof(*stat));
1795211f8dcSMark Johnston }
1805211f8dcSMark Johnston
1815211f8dcSMark Johnston #define CHECK_IP_COUNTER(oldp, newp, counter) \
1825211f8dcSMark Johnston ATF_REQUIRE_MSG((oldp)->ips_ ## counter < (newp)->ips_ ## counter, \
1835211f8dcSMark Johnston "ips_" #counter " wasn't incremented (%ju vs. %ju)", \
1845211f8dcSMark Johnston (uintmax_t)old.ips_ ## counter, (uintmax_t)new.ips_## counter);
1855211f8dcSMark Johnston
1865211f8dcSMark Johnston /*
1875211f8dcSMark Johnston * Make sure a fragment with MF set doesn't come after the last fragment of a
1885211f8dcSMark Johnston * packet. Make sure that multiple fragments with MF clear have the same offset
1895211f8dcSMark Johnston * and length.
1905211f8dcSMark Johnston */
1915211f8dcSMark Johnston ATF_TC(ip_reass__multiple_last_fragments);
ATF_TC_HEAD(ip_reass__multiple_last_fragments,tc)1925211f8dcSMark Johnston ATF_TC_HEAD(ip_reass__multiple_last_fragments, tc)
1935211f8dcSMark Johnston {
1945211f8dcSMark Johnston atf_tc_set_md_var(tc, "require.user", "root");
1955211f8dcSMark Johnston }
ATF_TC_BODY(ip_reass__multiple_last_fragments,tc)1965211f8dcSMark Johnston ATF_TC_BODY(ip_reass__multiple_last_fragments, tc)
1975211f8dcSMark Johnston {
1985211f8dcSMark Johnston struct ipstat old, new;
1995211f8dcSMark Johnston struct ip *ip;
2005211f8dcSMark Johnston struct lopacket *packet1, *packet2, *packet3, *packet4;
2015211f8dcSMark Johnston in_addr_t addr;
2025211f8dcSMark Johnston int error, fd;
2035211f8dcSMark Johnston uint16_t ipid;
2045211f8dcSMark Johnston
2055211f8dcSMark Johnston fd = open_lobpf(&addr);
2065211f8dcSMark Johnston ipid = arc4random_uniform(UINT16_MAX + 1);
2075211f8dcSMark Johnston
2085211f8dcSMark Johnston packet1 = alloc_lopacket(addr, 16);
2095211f8dcSMark Johnston ip = &packet1->hdr;
2105211f8dcSMark Johnston ip->ip_id = ipid;
2115211f8dcSMark Johnston ip->ip_off = htons(0x10);
2125211f8dcSMark Johnston update_cksum(ip);
2135211f8dcSMark Johnston
2145211f8dcSMark Johnston packet2 = alloc_lopacket(addr, 16);
2155211f8dcSMark Johnston ip = &packet2->hdr;
2165211f8dcSMark Johnston ip->ip_id = ipid;
2175211f8dcSMark Johnston ip->ip_off = htons(0x20);
2185211f8dcSMark Johnston update_cksum(ip);
2195211f8dcSMark Johnston
2205211f8dcSMark Johnston packet3 = alloc_lopacket(addr, 16);
2215211f8dcSMark Johnston ip = &packet3->hdr;
2225211f8dcSMark Johnston ip->ip_id = ipid;
2235211f8dcSMark Johnston ip->ip_off = htons(0x8);
2245211f8dcSMark Johnston update_cksum(ip);
2255211f8dcSMark Johnston
2265211f8dcSMark Johnston packet4 = alloc_lopacket(addr, 32);
2275211f8dcSMark Johnston ip = &packet4->hdr;
2285211f8dcSMark Johnston ip->ip_id = ipid;
2295211f8dcSMark Johnston ip->ip_off = htons(0x10);
2305211f8dcSMark Johnston update_cksum(ip);
2315211f8dcSMark Johnston
2325211f8dcSMark Johnston write_lopacket(fd, packet1);
2335211f8dcSMark Johnston
2345211f8dcSMark Johnston /* packet2 comes after packet1. */
2355211f8dcSMark Johnston get_ipstat(&old);
2365211f8dcSMark Johnston write_lopacket(fd, packet2);
2375211f8dcSMark Johnston get_ipstat(&new);
2385211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2395211f8dcSMark Johnston
2405211f8dcSMark Johnston /* packet2 comes after packet1 and has MF set. */
2415211f8dcSMark Johnston packet2->hdr.ip_off = htons(IP_MF | 0x20);
2425211f8dcSMark Johnston update_cksum(&packet2->hdr);
2435211f8dcSMark Johnston get_ipstat(&old);
2445211f8dcSMark Johnston write_lopacket(fd, packet2);
2455211f8dcSMark Johnston get_ipstat(&new);
2465211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2475211f8dcSMark Johnston
2485211f8dcSMark Johnston /* packet3 comes before packet1 but overlaps. */
2495211f8dcSMark Johnston get_ipstat(&old);
2505211f8dcSMark Johnston write_lopacket(fd, packet3);
2515211f8dcSMark Johnston get_ipstat(&new);
2525211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2535211f8dcSMark Johnston
2545211f8dcSMark Johnston /* packet4 has the same offset as packet1 but is longer. */
2555211f8dcSMark Johnston get_ipstat(&old);
2565211f8dcSMark Johnston write_lopacket(fd, packet4);
2575211f8dcSMark Johnston get_ipstat(&new);
2585211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
2595211f8dcSMark Johnston
2605211f8dcSMark Johnston error = close(fd);
2615211f8dcSMark Johnston ATF_REQUIRE(error == 0);
2625211f8dcSMark Johnston free_lopacket(packet1);
2635211f8dcSMark Johnston free_lopacket(packet2);
2649ed1e4ecSMark Johnston free_lopacket(packet3);
2659ed1e4ecSMark Johnston free_lopacket(packet4);
2665211f8dcSMark Johnston }
2675211f8dcSMark Johnston
2685211f8dcSMark Johnston /*
2695211f8dcSMark Johnston * Make sure that we reject zero-length fragments.
2705211f8dcSMark Johnston */
2715211f8dcSMark Johnston ATF_TC(ip_reass__zero_length_fragment);
ATF_TC_HEAD(ip_reass__zero_length_fragment,tc)2725211f8dcSMark Johnston ATF_TC_HEAD(ip_reass__zero_length_fragment, tc)
2735211f8dcSMark Johnston {
2745211f8dcSMark Johnston atf_tc_set_md_var(tc, "require.user", "root");
2755211f8dcSMark Johnston }
ATF_TC_BODY(ip_reass__zero_length_fragment,tc)2765211f8dcSMark Johnston ATF_TC_BODY(ip_reass__zero_length_fragment, tc)
2775211f8dcSMark Johnston {
2785211f8dcSMark Johnston struct ipstat old, new;
2795211f8dcSMark Johnston struct ip *ip;
2805211f8dcSMark Johnston struct lopacket *packet1, *packet2;
2815211f8dcSMark Johnston in_addr_t addr;
2825211f8dcSMark Johnston int error, fd;
2835211f8dcSMark Johnston uint16_t ipid;
2845211f8dcSMark Johnston
2855211f8dcSMark Johnston fd = open_lobpf(&addr);
2865211f8dcSMark Johnston ipid = arc4random_uniform(UINT16_MAX + 1);
2875211f8dcSMark Johnston
2885211f8dcSMark Johnston /*
2895211f8dcSMark Johnston * Create two packets, one with MF set, one without.
2905211f8dcSMark Johnston */
2915211f8dcSMark Johnston packet1 = alloc_lopacket(addr, 0);
2925211f8dcSMark Johnston ip = &packet1->hdr;
2935211f8dcSMark Johnston ip->ip_id = ipid;
2945211f8dcSMark Johnston ip->ip_off = htons(IP_MF | 0x10);
2955211f8dcSMark Johnston update_cksum(ip);
2965211f8dcSMark Johnston
2975211f8dcSMark Johnston packet2 = alloc_lopacket(addr, 0);
2985211f8dcSMark Johnston ip = &packet2->hdr;
2995211f8dcSMark Johnston ip->ip_id = ~ipid;
3005211f8dcSMark Johnston ip->ip_off = htons(0x10);
3015211f8dcSMark Johnston update_cksum(ip);
3025211f8dcSMark Johnston
3035211f8dcSMark Johnston get_ipstat(&old);
3045211f8dcSMark Johnston write_lopacket(fd, packet1);
3055211f8dcSMark Johnston get_ipstat(&new);
3065211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toosmall);
3075211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3085211f8dcSMark Johnston
3095211f8dcSMark Johnston get_ipstat(&old);
3105211f8dcSMark Johnston write_lopacket(fd, packet2);
3115211f8dcSMark Johnston get_ipstat(&new);
3125211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toosmall);
3135211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3145211f8dcSMark Johnston
3155211f8dcSMark Johnston error = close(fd);
3165211f8dcSMark Johnston ATF_REQUIRE(error == 0);
3175211f8dcSMark Johnston free_lopacket(packet1);
3185211f8dcSMark Johnston free_lopacket(packet2);
3195211f8dcSMark Johnston }
3205211f8dcSMark Johnston
3215211f8dcSMark Johnston ATF_TC(ip_reass__large_fragment);
ATF_TC_HEAD(ip_reass__large_fragment,tc)3225211f8dcSMark Johnston ATF_TC_HEAD(ip_reass__large_fragment, tc)
3235211f8dcSMark Johnston {
3245211f8dcSMark Johnston atf_tc_set_md_var(tc, "require.user", "root");
3255211f8dcSMark Johnston }
ATF_TC_BODY(ip_reass__large_fragment,tc)3265211f8dcSMark Johnston ATF_TC_BODY(ip_reass__large_fragment, tc)
3275211f8dcSMark Johnston {
3285211f8dcSMark Johnston struct ipstat old, new;
3295211f8dcSMark Johnston struct ip *ip;
3305211f8dcSMark Johnston struct lopacket *packet1, *packet2;
3315211f8dcSMark Johnston in_addr_t addr;
3325211f8dcSMark Johnston int error, fd;
3335211f8dcSMark Johnston uint16_t ipid;
3345211f8dcSMark Johnston
3355211f8dcSMark Johnston fd = open_lobpf(&addr);
3365211f8dcSMark Johnston ipid = arc4random_uniform(UINT16_MAX + 1);
3375211f8dcSMark Johnston
3385211f8dcSMark Johnston /*
3395211f8dcSMark Johnston * Create two packets, one with MF set, one without.
3405211f8dcSMark Johnston *
3415211f8dcSMark Johnston * 16 + (0x1fff << 3) > IP_MAXPACKET, so these should fail the check.
3425211f8dcSMark Johnston */
3435211f8dcSMark Johnston packet1 = alloc_lopacket(addr, 16);
3445211f8dcSMark Johnston ip = &packet1->hdr;
3455211f8dcSMark Johnston ip->ip_id = ipid;
3465211f8dcSMark Johnston ip->ip_off = htons(IP_MF | 0x1fff);
3475211f8dcSMark Johnston update_cksum(ip);
3485211f8dcSMark Johnston
3495211f8dcSMark Johnston packet2 = alloc_lopacket(addr, 16);
3505211f8dcSMark Johnston ip = &packet2->hdr;
3515211f8dcSMark Johnston ip->ip_id = ipid;
3525211f8dcSMark Johnston ip->ip_off = htons(0x1fff);
3535211f8dcSMark Johnston update_cksum(ip);
3545211f8dcSMark Johnston
3555211f8dcSMark Johnston get_ipstat(&old);
3565211f8dcSMark Johnston write_lopacket(fd, packet1);
3575211f8dcSMark Johnston get_ipstat(&new);
3585211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toolong);
3595211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3605211f8dcSMark Johnston
3615211f8dcSMark Johnston get_ipstat(&old);
3625211f8dcSMark Johnston write_lopacket(fd, packet2);
3635211f8dcSMark Johnston get_ipstat(&new);
3645211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, toolong);
3655211f8dcSMark Johnston CHECK_IP_COUNTER(&old, &new, fragdropped);
3665211f8dcSMark Johnston
3675211f8dcSMark Johnston error = close(fd);
3685211f8dcSMark Johnston ATF_REQUIRE(error == 0);
3695211f8dcSMark Johnston free_lopacket(packet1);
3705211f8dcSMark Johnston free_lopacket(packet2);
3715211f8dcSMark Johnston }
3725211f8dcSMark Johnston
ATF_TP_ADD_TCS(tp)3735211f8dcSMark Johnston ATF_TP_ADD_TCS(tp)
3745211f8dcSMark Johnston {
3755211f8dcSMark Johnston ATF_TP_ADD_TC(tp, ip_reass__multiple_last_fragments);
3765211f8dcSMark Johnston ATF_TP_ADD_TC(tp, ip_reass__zero_length_fragment);
3775211f8dcSMark Johnston ATF_TP_ADD_TC(tp, ip_reass__large_fragment);
3785211f8dcSMark Johnston
3795211f8dcSMark Johnston return (atf_no_error());
3805211f8dcSMark Johnston }
381