Hi,

Instead of stripping the IP options manually in icmp_reflect(),
just call ip_stripoptions().  Remove an unneeded parameter and
adjust the ip length in ip_stripoptions().  From FreeBSD.

ok?

bluhm

Index: netinet/ip_icmp.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.109
diff -u -p -u -p -r1.109 ip_icmp.c
--- netinet/ip_icmp.c   11 Nov 2013 09:15:34 -0000      1.109
+++ netinet/ip_icmp.c   16 Nov 2013 13:36:35 -0000
@@ -807,18 +807,7 @@ icmp_reflect(struct mbuf *m, struct mbuf
                                printf("%d\n", opts->m_len);
 #endif
                }
-               /*
-                * Now strip out original options by copying rest of first
-                * mbuf's data back, and adjust the IP length.
-                */
-               ip->ip_len = htons(ntohs(ip->ip_len) - optlen);
-               ip->ip_hl = sizeof(struct ip) >> 2;
-               m->m_len -= optlen;
-               if (m->m_flags & M_PKTHDR)
-                       m->m_pkthdr.len -= optlen;
-               optlen += sizeof(struct ip);
-               bcopy((caddr_t)ip + optlen, (caddr_t)(ip + 1),
-                   m->m_len - sizeof(struct ip));
+               ip_stripoptions(m);
        }
        m->m_flags &= ~(M_BCAST|M_MCAST);
        if (op)
Index: netinet/ip_input.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.220
diff -u -p -u -p -r1.220 ip_input.c
--- netinet/ip_input.c  11 Nov 2013 09:15:34 -0000      1.220
+++ netinet/ip_input.c  16 Nov 2013 13:27:47 -0000
@@ -1336,14 +1336,10 @@ ip_srcroute(struct mbuf *m0)
 }
 
 /*
- * Strip out IP options, at higher
- * level protocol in the kernel.
- * Second argument is buffer to which options
- * will be moved, and return value is their length.
- * XXX should be deleted; last arg currently ignored.
+ * Strip out IP options, at higher level protocol in the kernel.
  */
 void
-ip_stripoptions(struct mbuf *m, struct mbuf *mopt)
+ip_stripoptions(struct mbuf *m)
 {
        int i;
        struct ip *ip = mtod(m, struct ip *);
@@ -1358,6 +1354,7 @@ ip_stripoptions(struct mbuf *m, struct m
        if (m->m_flags & M_PKTHDR)
                m->m_pkthdr.len -= olen;
        ip->ip_hl = sizeof(struct ip) >> 2;
+       ip->ip_len = htons(ntohs(ip->ip_len) - olen);
 }
 
 int inetctlerrmap[PRC_NCMDS] = {
Index: netinet/ip_var.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.48
diff -u -p -u -p -r1.48 ip_var.h
--- netinet/ip_var.h    24 Oct 2013 11:17:36 -0000      1.48
+++ netinet/ip_var.h    16 Nov 2013 13:18:01 -0000
@@ -200,7 +200,7 @@ int  ip_setmoptions(int, struct ip_mopti
 void    ip_slowtimo(void);
 struct mbuf *
         ip_srcroute(struct mbuf *);
-void    ip_stripoptions(struct mbuf *, struct mbuf *);
+void    ip_stripoptions(struct mbuf *);
 int     ip_sysctl(int *, u_int, void *, size_t *, void *, size_t);
 void    ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *,
            struct mbuf *);

Reply via email to