kern/85052: [patch] ip_fastforward.c mishandle broadcast packets

Dmitrij Tejblum tejblum at yandex-team.ru
Wed Aug 17 20:30:20 GMT 2005


>Number:         85052
>Category:       kern
>Synopsis:       [patch] ip_fastforward.c mishandle broadcast packets
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 17 20:30:18 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Dmitrij Tejblum
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
OOO Yandex
>Environment:

Network with several routers with fastforwarding enabled.

>Description:

Fastforwarding may forward broadcast packets under some circumstances. It
does not appear to be useful. Comments in this file suggest that it is not
intended. It looks like ip_forward() (in ip_input.c) does not forward packets
with M_BCAST.


>How-To-Repeat:

On a router with fastforwarding enabled:

ifconfig vlanNNN create
ifconfig vlanNNN vlandev em0 vlan NNN
ifconfig vlanNNN up #note: no IP address assigned

Now, suppose we have the network 10.20.30.0/24 in vlan NNN. Broadcast packet 
to 10.20.30.255, received by the router, will be forwarded to the vlan NNN
(via other routers). I.e. we have a loop. Moreover, since M_BCAST is not
cleared, the packet is forwarded as a broadcast, and it result in a
broadcast storm.

>Fix:

Index: ip_fastfwd.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_fastfwd.c,v
retrieving revision 1.17.2.7
diff -u -r1.17.2.7 ip_fastfwd.c
--- ip_fastfwd.c	31 Mar 2005 17:03:45 -0000	1.17.2.7
+++ ip_fastfwd.c	17 Aug 2005 10:41:21 -0000
@@ -157,8 +157,6 @@
 	struct mbuf *m0 = NULL;
 	struct route ro;
 	struct sockaddr_in *dst = NULL;
-	struct in_ifaddr *ia = NULL;
-	struct ifaddr *ifa = NULL;
 	struct ifnet *ifp;
 	struct in_addr odest, dest;
 	u_short sum, ip_len;
@@ -324,21 +322,10 @@
 		return 0;
 
 	/*
-	 * Or is it for a local IP broadcast address on this host?
+	 * No L2 broadcast or multicast.
 	 */
-	if ((m->m_flags & M_BCAST) &&
-	    (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST)) {
-	        TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrhead, ifa_link) {
-			if (ifa->ifa_addr->sa_family != AF_INET)
-				continue;
-			ia = ifatoia(ifa);
-			if (ia->ia_netbroadcast.s_addr == ip->ip_dst.s_addr)
-				return 0;
-			if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr ==
-			    ip->ip_dst.s_addr)
-				return 0;
-		}
-	}
+	if (m->m_flags & (M_BCAST|M_MCAST))
+		return 0;
 	ipstat.ips_total++;
 
 	/*


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list