From pwroot@jhome.DIALix.COM  Fri Jun 23 10:42:30 1995
Received: from jhome.DIALix.COM (jhome.DIALix.COM [192.203.228.69])
          by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id KAA18301
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Jun 1995 10:42:26 -0700
Received: (from root@localhost) by jhome.DIALix.COM (8.6.11/8.6.9) id BAA00998; Sat, 24 Jun 1995 01:42:16 +0800
Message-Id: <199506231742.BAA00998@jhome.DIALix.COM>
Date: Sat, 24 Jun 1995 01:42:16 +0800
From: peter@haywire.dialix.com
Reply-To: peter@haywire.dialix.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: net/if.c can possibly choose incorrect net i/face.
X-Send-Pr-Version: 3.2

>Number:         555
>Category:       kern
>Synopsis:       net/if.c can possibly choose incorrect net i/face.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 23 10:50:00 1995
>Closed-Date:    Tue Jun 27 22:31:15 PDT 1995
>Last-Modified:
>Originator:     Peter Wemm
>Release:        FreeBSD 2.0-BUILT-19950616 i386
>Organization:
DIALix Services
>Environment:

FreeBSD jhome.DIALix.COM 2.0-BUILT-19950616 FreeBSD 2.0-BUILT-19950616 #0: Fri Jun 16 22:36:04 WST 1995     pwroot@jhome.DIALix.COM:/usr/src/sys/compile/JHOME  i386

>Description:

Although the current code solves the original problem [a program
that attempts to broadcast to the local ethernet was causing the wrong
output interface to be selected, by mistakenly applying the netmask to the
local address of a point-to-point link], it still isn't quite correct.

This is possibly because of a typo in the patch that I sent in originally.

Although the current code does not appear to break anything as it stands,
this is not a guarantee that it wont ever.  Hence the low priority.

Additionally, the code does not examine interfaces that have no netmask set,
even though the netmask is meant to be meaningless for P2P interfaces.

>How-To-Repeat:

read the source

>Fix:
	
	

*** if.c.dist	Fri Jun 16 15:12:44 1995
--- if.c	Fri Jun 16 15:16:08 1995
***************
*** 238,247 ****
  			register char *cp, *cp2, *cp3;
  
! 			if (ifa->ifa_addr->sa_family != af || ifa->ifa_netmask == 0)
  				next: continue;
  			if (ifp->if_flags & IFF_POINTOPOINT) {
! 				if (equal(addr, ifa->ifa_addr))
   					return (ifa);
  			} else {
  				cp = addr_data;
  				cp2 = ifa->ifa_addr->sa_data;
--- 238,249 ----
  			register char *cp, *cp2, *cp3;
  
! 			if (ifa->ifa_addr->sa_family != af)
  				next: continue;
  			if (ifp->if_flags & IFF_POINTOPOINT) {
! 				if (equal(addr, ifa->ifa_dstaddr))
   					return (ifa);
  			} else {
+ 				if (ifa->ifa_netmask == 0)
+ 					continue;
  				cp = addr_data;
  				cp2 = ifa->ifa_addr->sa_data;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: davidg 
State-Changed-When: Tue Jun 27 22:31:15 PDT 1995 
State-Changed-Why:  
The suggested patch looks correct and was applied. 
>Unformatted:



