diff options
author | 2013-11-17 10:07:32 +0000 | |
---|---|---|
committer | 2013-11-17 10:07:32 +0000 | |
commit | 1a3a8af285ac6e7a7f4d33215c300d18d990d288 (patch) | |
tree | be043265c933dad4c5dfb510bbad1f1117699e56 | |
parent | speeling (diff) | |
download | wireguard-openbsd-1a3a8af285ac6e7a7f4d33215c300d18d990d288.tar.xz wireguard-openbsd-1a3a8af285ac6e7a7f4d33215c300d18d990d288.zip |
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 deraadt@ henninh@ lteo@
-rw-r--r-- | sys/netinet/ip_icmp.c | 15 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 11 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 4 |
3 files changed, 8 insertions, 22 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 531d83fcd70..5ea912e2f31 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.109 2013/11/11 09:15:34 mpi Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.110 2013/11/17 10:07:32 bluhm Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -807,18 +807,7 @@ icmp_reflect(struct mbuf *m, struct mbuf **op, struct in_ifaddr *ia) 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) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index ff285013500..ce269563fc4 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.220 2013/11/11 09:15:34 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.221 2013/11/17 10:07:32 bluhm Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -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 mbuf *mopt) 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] = { diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 469164b20a8..b667012f96c 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.48 2013/10/24 11:17:36 deraadt Exp $ */ +/* $OpenBSD: ip_var.h,v 1.49 2013/11/17 10:07:32 bluhm Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -200,7 +200,7 @@ int ip_setmoptions(int, struct ip_moptions **, struct mbuf *, u_int); 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 *); |