summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2012-10-23 10:29:31 +0000
committerglebius <glebius@FreeBSD.org>2012-10-23 10:29:31 +0000
commite4588fbb85bd0666ca8a968aaa2ec629cec2991f (patch)
tree7e4d610c873d26f59c77183cdd9bfb3b95d9993a /sys/netinet
parentfea857f2a843cb039f3757ef79ba28b083d7a0c3 (diff)
downloadFreeBSD-src-e4588fbb85bd0666ca8a968aaa2ec629cec2991f.zip
FreeBSD-src-e4588fbb85bd0666ca8a968aaa2ec629cec2991f.tar.gz
Simplify ip_stripoptions() reducing number of intermediate
variables.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_options.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c
index 5083f6f..df32027 100644
--- a/sys/netinet/ip_options.c
+++ b/sys/netinet/ip_options.c
@@ -458,20 +458,18 @@ ip_srcroute(struct mbuf *m0)
void
ip_stripoptions(struct mbuf *m)
{
- int i;
struct ip *ip = mtod(m, struct ip *);
- caddr_t opts;
int olen;
- olen = (ip->ip_hl << 2) - sizeof (struct ip);
- opts = (caddr_t)(ip + 1);
- i = m->m_len - (sizeof (struct ip) + olen);
- bcopy(opts + olen, opts, (unsigned)i);
+ olen = (ip->ip_hl << 2) - sizeof(struct ip);
m->m_len -= olen;
if (m->m_flags & M_PKTHDR)
m->m_pkthdr.len -= olen;
ip->ip_len = htons(ntohs(ip->ip_len) - olen);
ip->ip_hl = sizeof(struct ip) >> 2;
+
+ bcopy((char *)ip + sizeof(struct ip) + olen, (ip + 1),
+ (size_t )(m->m_len - sizeof(struct ip)));
}
/*
OpenPOWER on IntegriCloud