Bug 224920

Summary: limited broadcast for Linux programs
Product: Base System Reporter: Henry Hu <henry.hu.sh>
Component: kernAssignee: freebsd-emulation (Nobody) <emulation>
Status: New ---    
Severity: Affects Only Me CC: emaste
Priority: ---    
Version: 11.1-STABLE   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 247219    

Description Henry Hu 2018-01-05 02:08:20 UTC
Limited broadcast, or sending to 255.255.255.255, is the behavior specified in RFC 947, which is deprecated (https://wiki.freebsd.org/NetworkRFCCompliance). As a result, FreeBSD does not support it (sending to 255.255.255.255 results in an ether address of the default gw), unless IP_ONESBCAST is specified.
However, for Linux programs, it seems to be still expected to work. Some programs send UDP packets to 255.255.255.255 to discover devices on local network. One such example is Canon's ScanGear MP program, which uses this way to discover local scanners.

Sample trace:

21:06:37.887917 b0:6e:bf:2a:e7:23 > 04:a1:51:15:5e:11, ethertype IPv4 (0x0800), length 166: 192.168.1.126.51201 > 255.255.255.255.161:  C="canon_admin" GetRequest(104)  .1.3.6.1.4.1.1602.1.3.1.13.0 .1.3.6.1.4.1.1602.1.2.1.8.1.3.1.1 .1.3.6.1.4.1.1602.1.1.1.1.0 .1.3.6.1.4.1.1602.1.1.1.10.0 .1.3.6.1.4.1.1602.1.3.1.12.0

Expected:

21:05:46.430205 b0:6e:bf:2a:e7:23 > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 166: 192.168.1.126.44951 > 255.255.255.255.161:  C="canon_admin" GetRequest(104)  .1.3.6.1.4.1.1602.1.3.1.13.0 .1.3.6.1.4.1.1602.1.2.1.8.1.3.1.1 .1.3.6.1.4.1.1602.1.1.1.1.0 .1.3.6.1.4.1.1602.1.1.1.10.0 .1.3.6.1.4.1.1602.1.3.1.12.0

Since FreeBSD does not support this, this program cannot discover any devices.
The discovery code is in some binary blob, which is unable to be changed. For a closer emulation of Linux behavior, I suggest that when running Linux programs, we send a broadcast packet to the interface of the default route.

A workaround is letting ipfw do a forward:

fwd 192.168.1.255 udp from me to 255.255.255.255