Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Fix an XXX of mine, be clearer about what we're ...



details:   https://anonhg.NetBSD.org/src/rev/f3c89bbadf87
branches:  trunk
changeset: 323066:f3c89bbadf87
user:      maxv <maxv%NetBSD.org@localhost>
date:      Tue May 29 17:21:57 2018 +0000

description:
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.

diffstat:

 sys/netinet/ip_output.c |  17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diffs (49 lines):

diff -r bd39d4022c80 -r f3c89bbadf87 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Tue May 29 16:53:56 2018 +0000
+++ b/sys/netinet/ip_output.c   Tue May 29 17:21:57 2018 +0000
@@ -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 @@
        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 @@
                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



Home | Main Index | Thread Index | Old Index