From owner-freebsd-net@FreeBSD.ORG Wed Apr 8 01:50:17 2015 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9D310F1B for ; Wed, 8 Apr 2015 01:50:17 +0000 (UTC) Received: from shell1.rawbw.com (shell1.rawbw.com [198.144.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 87057F33 for ; Wed, 8 Apr 2015 01:50:17 +0000 (UTC) Received: from yuri.doctorlan.com (c-50-184-63-128.hsd1.ca.comcast.net [50.184.63.128]) (authenticated bits=0) by shell1.rawbw.com (8.14.9/8.14.9) with ESMTP id t381oGUd080223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Tue, 7 Apr 2015 18:50:16 -0700 (PDT) (envelope-from yuri@rawbw.com) X-Authentication-Warning: shell1.rawbw.com: Host c-50-184-63-128.hsd1.ca.comcast.net [50.184.63.128] claimed to be yuri.doctorlan.com Message-ID: <55248957.60109@rawbw.com> Date: Tue, 07 Apr 2015 18:50:15 -0700 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: net@freebsd.org Subject: Socket bound to 0.0.0.0 never receives broadcasts with non-zero IP source address Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-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: Wed, 08 Apr 2015 01:50:17 -0000 I noticed that the socket bound to '0.0.0.0' only receives UDP broadcasts when they are sent from zero IP: 0.0.0.0->255.255.255.255. When the source IP is not zeros, but some valid IP on that network, socket never receives such broadcast. I compared two packets in wireshark as they arrive, and the only difference on Ether/IP/UDP level is source IP. Is there any reason why source IP address would influence the reception of the broadcast packets? I use this python3 program to create bound socket and listen: #!/usr/bin/env python3.4 import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.bind(('0.0.0.0', 67)) print("Waiting for broadcast") (data, flags, ancillary, addr) = sock.recvmsg(4096, 256) print("Received broadcast packet") I use dhclient to send broadcast packets. It sends with src=0.0.0.0 when no /var/db/dhclient.leases.* exists, and it always sends with src= when the previous lease exists. 10.1 STABLE Yuri