Module Name: src
Committed By: maxv
Date: Tue May 29 17:21:57 UTC 2018
Modified Files:
src/sys/netinet: ip_output.c
Log Message:
Fix an XXX of mine, be clearer about what we're doing. Basically we want to
preserve the fragment offset and flags. That's necessary if the packet
we're fragmenting is itself a fragment.
To generate a diff of this commit:
cvs rdiff -u -r1.304 -r1.305 src/sys/netinet/ip_output.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.304 src/sys/netinet/ip_output.c:1.305
--- src/sys/netinet/ip_output.c:1.304 Sun Apr 29 11:51:08 2018
+++ src/sys/netinet/ip_output.c Tue May 29 17:21:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_output.c,v 1.304 2018/04/29 11:51:08 maxv Exp $ */
+/* $NetBSD: ip_output.c,v 1.305 2018/05/29 17:21:57 maxv Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.304 2018/04/29 11:51:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.305 2018/05/29 17:21:57 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -820,16 +820,14 @@ ip_fragment(struct mbuf *m, struct ifnet
int sw_csum = m->m_pkthdr.csum_flags;
int fragments = 0;
int error = 0;
- int ipoff;
- bool mff;
+ int ipoff, ipflg;
ip = mtod(m, struct ip *);
hlen = ip->ip_hl << 2;
- /* XXX: Why don't we remove IP_RF? */
- ipoff = ntohs(ip->ip_off) & ~IP_MF;
-
- mff = (ip->ip_off & htons(IP_MF)) != 0;
+ /* Preserve the offset and flags. */
+ ipoff = ntohs(ip->ip_off) & IP_OFFMASK;
+ ipflg = ntohs(ip->ip_off) & (IP_RF|IP_DF|IP_MF);
if (ifp != NULL)
sw_csum &= ~ifp->if_csum_flags_tx;
@@ -875,8 +873,7 @@ ip_fragment(struct mbuf *m, struct ifnet
m->m_len = mhlen;
mhip->ip_off = ((off - hlen) >> 3) + ipoff;
- if (mff)
- mhip->ip_off |= IP_MF;
+ mhip->ip_off |= ipflg;
if (off + len >= ntohs(ip->ip_len))
len = ntohs(ip->ip_len) - off;
else