Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.218.2.6 retrieving revision 1.251 diff -u -p -r1.218.2.6 -r1.251 --- src/sys/netinet/ip_input.c 2007/11/15 11:45:07 1.218.2.6 +++ src/sys/netinet/ip_input.c 2007/08/10 22:46:16 1.251 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.218.2.6 2007/11/15 11:45:07 yamt Exp $ */ +/* $NetBSD: ip_input.c,v 1.251 2007/08/10 22:46:16 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -98,7 +98,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.218.2.6 2007/11/15 11:45:07 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.251 2007/08/10 22:46:16 dyoung Exp $"); #include "opt_inet.h" #include "opt_gateway.h" @@ -469,6 +469,7 @@ ipintr(void) splx(s); if (m == 0) return; + MCLAIM(m, &ip_rx_mowner); ip_input(m); } } @@ -1012,6 +1013,7 @@ found: /* XXX error stat??? */ error = EINVAL; DPRINTF(("ip_input: no SP, packet discarded\n"));/*XXX*/ + goto bad; } splx(s); if (error) @@ -1775,6 +1777,32 @@ ip_srcroute(void) return (m); } +/* + * 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. + */ +void +ip_stripoptions(struct mbuf *m, struct mbuf *mopt) +{ + int i; + struct ip *ip = mtod(m, struct ip *); + void *opts; + int olen; + + olen = (ip->ip_hl << 2) - sizeof (struct ip); + opts = (void *)(ip + 1); + i = m->m_len - (sizeof (struct ip) + olen); + memmove(opts, (char *)opts + olen, (unsigned)i); + 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; +} + const int inetctlerrmap[PRC_NCMDS] = { 0, 0, 0, 0, 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH, @@ -2051,11 +2079,8 @@ ip_savecontrol(struct inpcb *inp, struct if (inp->inp_flags & INP_RECVIF) { struct sockaddr_dl sdl; - sockaddr_dl_init(&sdl, sizeof(sdl), - (m->m_pkthdr.rcvif != NULL) - ? m->m_pkthdr.rcvif->if_index - : 0, - 0, NULL, 0, NULL, 0); + sockaddr_dl_init(&sdl, (m->m_pkthdr.rcvif != NULL) ? + m->m_pkthdr.rcvif->if_index : 0, 0, NULL, 0, NULL, 0); *mp = sbcreatecontrol(&sdl, sdl.sdl_len, IP_RECVIF, IPPROTO_IP); if (*mp) mp = &(*mp)->m_next;