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.7 retrieving revision 1.245.2.3 diff -u -p -r1.218.2.7 -r1.245.2.3 --- src/sys/netinet/ip_input.c 2007/12/07 17:34:29 1.218.2.7 +++ src/sys/netinet/ip_input.c 2007/06/08 14:17:46 1.245.2.3 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.218.2.7 2007/12/07 17:34:29 yamt Exp $ */ +/* $NetBSD: ip_input.c,v 1.245.2.3 2007/06/08 14:17:46 ad 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.7 2007/12/07 17:34:29 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.245.2.3 2007/06/08 14:17:46 ad 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); } } @@ -903,7 +904,9 @@ ours: */ IPQ_LOCK(); hash = IPREASS_HASH(ip->ip_src.s_addr, ip->ip_id); - LIST_FOREACH(fp, &ipq[hash], ipq_q) { + /* XXX LIST_FOREACH(fp, &ipq[hash], ipq_q) */ + for (fp = LIST_FIRST(&ipq[hash]); fp != NULL; + fp = LIST_NEXT(fp, ipq_q)) { if (ip->ip_id == fp->ipq_id && in_hosteq(ip->ip_src, fp->ipq_src) && in_hosteq(ip->ip_dst, fp->ipq_dst) && @@ -1012,6 +1015,7 @@ found: /* XXX error stat??? */ error = EINVAL; DPRINTF(("ip_input: no SP, packet discarded\n"));/*XXX*/ + goto bad; } splx(s); if (error) @@ -1775,16 +1779,39 @@ 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] = { - [PRC_MSGSIZE] = EMSGSIZE, - [PRC_HOSTDEAD] = EHOSTDOWN, - [PRC_HOSTUNREACH] = EHOSTUNREACH, - [PRC_UNREACH_NET] = EHOSTUNREACH, - [PRC_UNREACH_HOST] = EHOSTUNREACH, - [PRC_UNREACH_PROTOCOL] = ECONNREFUSED, - [PRC_UNREACH_PORT] = ECONNREFUSED, - [PRC_UNREACH_SRCFAIL] = EHOSTUNREACH, - [PRC_PARAMPROB] = ENOPROTOOPT, + 0, 0, 0, 0, + 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH, + EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED, + EMSGSIZE, EHOSTUNREACH, 0, 0, + 0, 0, 0, 0, + ENOPROTOOPT }; /* @@ -1868,7 +1895,7 @@ ip_forward(struct mbuf *m, int srcrt) */ if (rt->rt_ifp == m->m_pkthdr.rcvif && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 && - !in_nullhost(satocsin(rt_getkey(rt))->sin_addr) && + !in_nullhost(satosin(rt_key(rt))->sin_addr) && ipsendredirects && !srcrt) { if (rt->rt_ifa && (ip->ip_src.s_addr & ifatoia(rt->rt_ifa)->ia_subnetmask) == @@ -2054,12 +2081,13 @@ 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); - *mp = sbcreatecontrol(&sdl, sdl.sdl_len, IP_RECVIF, IPPROTO_IP); + sdl.sdl_len = offsetof(struct sockaddr_dl, sdl_data[0]); + sdl.sdl_family = AF_LINK; + sdl.sdl_index = m->m_pkthdr.rcvif ? + m->m_pkthdr.rcvif->if_index : 0; + sdl.sdl_nlen = sdl.sdl_alen = sdl.sdl_slen = 0; + *mp = sbcreatecontrol((void *) &sdl, sdl.sdl_len, + IP_RECVIF, IPPROTO_IP); if (*mp) mp = &(*mp)->m_next; }