From owner-freebsd-net@FreeBSD.ORG Tue Jul 15 10:06:57 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EBA5437B401 for ; Tue, 15 Jul 2003 10:06:56 -0700 (PDT) Received: from hole.shrew.net (cs24354-246.austin.rr.com [24.243.54.246]) by mx1.FreeBSD.org (Postfix) with ESMTP id 117FA43F75 for ; Tue, 15 Jul 2003 10:06:56 -0700 (PDT) (envelope-from mgrooms@shrew.net) Received: from mail.shrew.net (localhost.shrew.net [127.0.0.1]) by hole.shrew.net (8.12.9/8.12.9) with SMTP id h6FH9UOW055742; Tue, 15 Jul 2003 17:09:35 GMT (envelope-from mgrooms@shrew.net) Message-Id: <200307151709.h6FH9UOW055742@hole.shrew.net> Received: from 65.118.63.254 (auth. user mgrooms@mail.shrew.net) by mail.shrew.net with HTTP; Tue, 15 Jul 2003 17:09:30 +0000 To: "Wes Peters" , "Chuck Swiger" Date: Tue, 15 Jul 2003 17:09:30 +0000 X-Mailer: IlohaMail/0.8.8 (On: mail.shrew.net) In-Reply-To: <200307111407.04591.wes@softweyr.com> From: "Matthew Grooms" Bounce-To: "Matthew Grooms" Errors-To: "Matthew Grooms" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable cc: "freebsd-net@freebsd.org" Subject: Re: broadcast udp packets ... X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jul 2003 17:06:57 -0000 Hmmm, >What we observed on our embedded system is the packet gets sent on all >attached interfaces, with dest IP 255.255.255.255, and a src IP of the >local address that has the default route. If there isn't a default >route, sending to 255.255.255.255 fails with "no route to host." > Maybe I am confused. When I use a udp socket bound to an interface, packets that are generated from that socket get thier dest address translated to a network specific broadcast address. Do I understad you correctly when you say that you can generate packets destined to 255.255.255.255? Am I doing somthing different then you are? ... int test_sock =3D socket( PF_INET, SOCK_DGRAM, 0 ); if( test_sock =3D=3D -1 ) return -1; struct ifreq ifr; memset( &ifr, 0, sizeof( struct ifreq ) ); strcpy( ifr.ifr_name, config.get_service_iface() ); if( ioctl( test_sock, SIOCGIFADDR, &ifr ) =3D=3D -1 ) return -1; uint32_t value =3D 1; if( setsockopt( test_sock, SOL_SOCKET, SO_BROADCAST, (char*) &value, sizeof( uint32_t ) ) =3D=3D -1 return -1; struct sockaddr_in serv_addr; memset( &serv_addr, 0, sizeof( struct sockaddr_in ) ); memcpy( &serv_addr, &ifr.ifr_addr, sizeof( struct sockaddr_in ) ); serv_addr.sin_family =3D AF_INET; serv_addr.sin_port =3D htons( config.get_service_port() ); if( bind( test_sock, ( struct sockaddr * ) &serv_addr, sizeof( struct sockaddr_in ) ) =3D=3D - 1) return -1; struct sockaddr_in bcast_addr; memset( &bcast_addr, 0, sizeof( struct sockaddr_in ) ); bcast_addr.sin_family =3D AF_INET; bcast_addr.sin_addr.s_addr =3D 0xffffffff; bcast_addr.sin_port =3D htons( 100 ); char test_buff[] =3D { "TEST123TEST123" }; if( sendto( test_sock, test_buff, sizeof( test_buff ), 0, ( const struct sockaddr * ) &bcast_addr, sizeof( const struct sockaddr_in ) ) =3D=3D -1 ) printf( "failed to generate broadcast packet( %d bytes )\n", sizeof( test_buff ) ); else printf( "broadcast packet generated ( %d bytes )\n", sizeof( test_buff ) ); >This is bogus, so I propose to change it to a special case, where >packets sent to 255.255.255.255 will be sent on each attached >interface, with src IP of the interface "primary" address. When you say attached, do you mean the socket is bound to the ip address of that interface or do you mean all configured interfaces on that host? Should this be affected by the MSG_DONTROUTE flag? It would seem that if you were requesting the packet be routed, that it would be emmitted on all network interfaces. If the MSG_DONTROUTE were passed, that the packet would only be generated on the interface the socket is bound to. Then again, maybe I don't understand the scope of your proposal from down here in userland. Im not a kernel hacker :( >sound reasonable? Should it work without a default route? (I think it >should, the special case of the all-call broadcast shouldn't even go >into rtalloc.) > >I hope to have a working prototype done, on either -STABLE or -CURRENT, >this weekend. If testers like the behavior, I'll commit to CURRENT and >MFC on a normal timeline; we'll want this fixed here before 5.2. > -Matthew