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.1.1.1 retrieving revision 1.6 diff -u -p -r1.1.1.1 -r1.6 --- src/sys/netinet/ip_input.c 1993/03/21 09:45:37 1.1.1.1 +++ src/sys/netinet/ip_input.c 1994/01/08 21:21:47 1.6 @@ -30,30 +30,31 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ip_input.c 7.19 (Berkeley) 5/25/91 + * from: @(#)ip_input.c 7.19 (Berkeley) 5/25/91 + * $Id: ip_input.c,v 1.6 1994/01/08 21:21:47 mycroft Exp $ */ -#include "param.h" -#include "systm.h" -#include "malloc.h" -#include "mbuf.h" -#include "domain.h" -#include "protosw.h" -#include "socket.h" -#include "errno.h" -#include "time.h" -#include "kernel.h" - -#include "../net/if.h" -#include "../net/route.h" - -#include "in.h" -#include "in_systm.h" -#include "ip.h" -#include "in_pcb.h" -#include "in_var.h" -#include "ip_var.h" -#include "ip_icmp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include #ifndef IPFORWARDING #ifdef GATEWAY @@ -141,7 +142,13 @@ ipintr() register struct ipq *fp; register struct in_ifaddr *ia; int hlen, s; +#ifdef PARANOID + static int busy = 0; + if (busy) + panic("ipintr: called recursively\n"); + ++busy; +#endif next: /* * Get next datagram off input queue and get IP header @@ -150,8 +157,12 @@ next: s = splimp(); IF_DEQUEUE(&ipintrq, m); splx(s); - if (m == 0) + if (m == 0) { +#ifdef PARANOID + --busy; +#endif return; + } #ifdef DIAGNOSTIC if ((m->m_flags & M_PKTHDR) == 0) panic("ipintr no HDR"); @@ -256,6 +267,53 @@ next: goto ours; } } +#ifdef MULTICAST + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { + struct in_multi *inm; +#ifdef MROUTING + extern struct socket *ip_mrouter; + + if (ip_mrouter) { + /* + * If we are acting as a multicast router, all + * incoming multicast packets are passed to the + * kernel-level multicast forwarding function. + * The packet is returned (relatively) intact; if + * ip_mforward() returns a non-zero value, the packet + * must be discarded, else it may be accepted below. + * + * (The IP ident field is put in the same byte order + * as expected when ip_mforward() is called from + * ip_output().) + */ + ip->ip_id = htons(ip->ip_id); + if (ip_mforward(ip, m->m_pkthdr.rcvif, m) != 0) { + m_freem(m); + goto next; + } + ip->ip_id = ntohs(ip->ip_id); + + /* + * The process-level routing demon needs to receive + * all multicast IGMP packets, whether or not this + * host belongs to their destination groups. + */ + if (ip->ip_p == IPPROTO_IGMP) + goto ours; + } +#endif + /* + * See if we belong to the destination multicast group on the + * arrival interface. + */ + IN_LOOKUP_MULTI(ip->ip_dst, m->m_pkthdr.rcvif, inm); + if (inm == NULL) { + m_freem(m); + goto next; + } + goto ours; + } +#endif if (ip->ip_dst.s_addr == (u_long)INADDR_BROADCAST) goto ours; if (ip->ip_dst.s_addr == INADDR_ANY) @@ -818,7 +876,7 @@ ip_srcroute() if (m == 0) return ((struct mbuf *)0); -#define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt)) +#define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt)) /* length is (nhops+1)*sizeof(addr) + sizeof(nop + srcrt header) */ m->m_len = ip_nhops * sizeof(struct in_addr) + sizeof(struct in_addr) +