*BSD News Article 71185


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!news-res.gsl.net!news.gsl.net!uwm.edu!math.ohio-state.edu!jussieu.fr!rain.fr!wanadoo.fr!usenet
From: pyk@sv.vtcom.fr (Pierre-Yves Kerembellec)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: FreeBSD 2.1.0 broadcast problem/bug : does it ring a bell ?
Date: Tue, 11 Jun 1996 15:55:09 GMT
Organization: Solutions Vocales
Lines: 49
Message-ID: <4pk4vh$1db@cyan.wanadoo.fr>
Reply-To: pyk@sv.vtcom.fr
NNTP-Posting-Host: iap3.wanadoo.fr
X-Newsreader: Forte Free Agent 1.0.82

Hi !

I think there may be a bug in the FreeBSD 2.1.0 INET network layers (no
problem on 2.0.5). I tried to execute this small program which broadcasts
one UDP datagram on port UDP 9090 :

----------------------------------------------------------------------------
int main()
{
 int    fSocket,bOption=1,nSize;
 struct sockaddr_in tSocket;
 char   sBuffer[256];

 if ((fSocket = socket(AF_INET,SOCK_DGRAM,0))<0)
    {perror("socket"); exit(1);}
 if (setsockopt(fSocket,SOL_SOCKET,SO_BROADCAST,&bOption,sizeof(bOption))<0)
    {perror("setsockopt"); exit(2);}
 memset(&tSocket,0,sizeof(tSocket));
 tSocket.sin_port         = htons(9090);
 tSocket.sin_family       = AF_INET;
 tSocket.sin_addr.s_addr  = INADDR_BROADCAST;
 strcpy(sBuffer,"Hello world");
 if (sendto(fSocket,sBuffer,strlen(sBuffer),0,(struct sockaddr *)&tSocket,sizeof(tSocket)))<0)

    {perror("sendto"); exit(3);}
 for(;;);
}
----------------------------------------------------------------------------

Then I used tcpdump to see the resulting local network activity on this 
particular port : on 2.05, I get an Ethernet broadcast, but on 2.1.0, the
packet is directly sent to the default gateway ! (the dst ether address is
my router MAC address !)
The fact is that the dst IP address is 255.255.255.255, instead of 
(255.255.255.255 & my_interface_network_address), so the routing code
in the kernel send the packet to the default gateway, since the dst address
does not match any of the directly connected networks ...

Any clue ?

Pierre-Yves

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Pierre-Yves KEREMBELLEC         Phone # +33 1 46 12 67 50
Solutions Vocales               Fax   # +33 1 46 12 67 00
40, rue Gabriel Crie            E-mail  pyk@sv.vtcom.fr
92245 Malakoff Cedex, France    WEBMaster / FTPMaster
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=