From nobody@FreeBSD.org  Mon Jun 26 10:39:06 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 186C116A400
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 26 Jun 2006 10:39:06 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D5113444A8
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 26 Jun 2006 10:39:05 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k5QAd5of024757
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 26 Jun 2006 10:39:05 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k5QAd5jB024756;
	Mon, 26 Jun 2006 10:39:05 GMT
	(envelope-from nobody)
Message-Id: <200606261039.k5QAd5jB024756@www.freebsd.org>
Date: Mon, 26 Jun 2006 10:39:05 GMT
From: Colin Petrie <cpetrie@xcalibre.co.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: enabling net.inet.ip.fastforwarding breaks rfc2644
X-Send-Pr-Version: www-2.3

>Number:         99484
>Category:       kern
>Synopsis:       enabling net.inet.ip.fastforwarding breaks rfc2644
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 26 10:40:28 GMT 2006
>Closed-Date:    Mon Sep 25 15:34:17 GMT 2006
>Last-Modified:  Mon Sep 25 15:34:17 GMT 2006
>Originator:     Colin Petrie
>Release:        6.1-RELEASE
>Organization:
>Environment:
FreeBSD xxxxxxxx 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Mon May 15 12:15:49 BST 2006     root@xxxxxxxx:/usr/src/sys/i386/compile/ROUTER  i386

>Description:
When net.inet.ip.fastforwarding=1, FreeBSD 6.1-RELEASE will forward packets to network prefix broadcast addresses. This is in violation of RFC2644 (Changing the Default for Directed Broadcasts in Routers)

(while ping'ing 217.8.240.255)

# sysctl net.inet.ip.fastforwarding=1
# tcpdump -qnei vlan200 ether broadcast and icmp
11:28:37.473427 00:30:48:84:ff:b1 > ff:ff:ff:ff:ff:ff, IPv4, length 154: 217.133.19.77 > 217.8.240.255: ICMP echo request, id 3408, seq 0, length 120
11:28:38.569223 00:30:48:84:ff:b1 > ff:ff:ff:ff:ff:ff, IPv4, length 154: 217.133.19.77 > 217.8.240.255: ICMP echo request, id 3408, seq 0, length 120

# sysctl net.inet.ip.fastforwarding=0
# tcpdump -qnei vlan200 ether broadcast and icmp

(no packets returned)


>How-To-Repeat:
sysctl net.inet.ip.fastforwarding=1

Then ping the broadcast address on a LAN from a host on a different subnet
>Fix:
sysctl net.inet.ip.fastforwarding=0
>Release-Note:
>Audit-Trail:

From: Colin Petrie <cpetrie@xcalibre.co.uk>
To: bug-followup@FreeBSD.org,  cpetrie@xcalibre.co.uk
Cc:  
Subject: Re: kern/99484: enabling net.inet.ip.fastforwarding breaks rfc2644
Date: Tue, 27 Jun 2006 11:46:17 +0100

 Hi,
 
 The following patch appears to resolve the problem but I thought a bit 
 of peer review would be nice. Anyone see any problems with this patch?
 
 Cheers
 Colin
 
 
 *** ip_fastfwd.c        Tue Jun 27 11:29:01 2006
 --- ip_fastfwd.c.new    Tue Jun 27 11:30:18 2006
 *************** ip_fastforward(struct mbuf *m)
 *** 162,167 ****
 --- 162,168 ----
          u_short sum, ip_len;
          int error = 0;
          int hlen, mtu;
 +       int isbroadcast;
    #ifdef IPFIREWALL_FORWARD
          struct m_tag *fwd_tag;
    #endif
 *************** ip_fastforward(struct mbuf *m)
 *** 275,280 ****
 --- 276,282 ----
                  goto drop;
          }
 
 +
    #ifdef ALTQ
          /*
           * Is packet dropped by traffic conditioner?
 *************** passin:
 *** 421,426 ****
 --- 423,439 ----
           */
          if (ro.ro_rt->rt_flags & RTF_BLACKHOLE)
                  goto drop;
 +
 +         /*
 +          * Is packet a directed network broadcast packet?
 +          */
 +         isbroadcast = in_broadcast(dst->sin_addr, ifp);
 +         if (isbroadcast) {
 +               printf("ip_fastfwd: dropping directed broadcast - to %s\n",
 +                       inet_ntoa(dst->sin_addr));
 +                 ipstat.ips_badaddr++;
 +                 goto drop;
 +         }
 
          /*
           * Step 5: outgoing firewall packet processing
Responsible-Changed-From-To: freebsd-bugs->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Mon Sep 25 13:30:03 UTC 2006 
Responsible-Changed-Why:  
I can reproduce this on 7-CURRENT 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99484 
State-Changed-From-To: open->closed 
State-Changed-By: bms 
State-Changed-When: Mon Sep 25 15:33:57 UTC 2006 
State-Changed-Why:  
Functional duplicate of kern/98799 (same path, same behaviour, same functions) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99484 
>Unformatted:
