Bug #75721 [NEW]: MCAST_JOIN_GROUP is broken for FreeBSD
| From: | jonathan at tangential dot ca | Date: | Fri, 22 Dec 2017 01:17:32 +0000 |
| Subject: | Bug #75721 [NEW]: MCAST_JOIN_GROUP is broken for FreeBSD | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213236@lists.php.net to get a copy of this message | ||
From: jonathan at tangential dot ca
Operating system: FreeBSD 10.3
PHP version: 7.0.26
Package: Sockets related
Bug Type: Bug
Bug description:MCAST_JOIN_GROUP is broken for FreeBSD
Description:
------------
FreeBSD supports listening on/joining both IPv4 and IPv6 multicast
groups. However, it handles full RFC 3678 support (including IPv6) via a
different interface (setsourcefilter vs setsockopt).
In order to properly support multicast on FreeBSD (including IPv6
support), one would have to (conditionally) use setsourcefilter instead
of setsockopt (throughout much of ext/sockets/multicast.c).
Since I don't have the requirement or will to implement this with
FreeBSD's newer protocol agnostic sourcefilter APIs, I've chosen to take
the easy way out and just make it work with IPv4 only.
This bug report should likely be split into two bugs as I've only
addressed the IPv4 case for now.
I've included versions that correspond to my environment. However, this
is far more generally applicable.
This bug is the FreeBSD variant/equivalent of bug #63000 (which was for
macOS).
Please see the following FreeBSD documentation references (for details
on FreeBSD's multicast support):
https://www.freebsd.org/cgi/man.cgi?query=ip&apropos=0&sektion=4&manpath=FreeBSD+12-current&arch=default&format=html
https://www.freebsd.org/cgi/man.cgi?query=sourcefilter&sektion=3&apropos=0&manpath=FreeBSD+12-current
Test script:
---------------
<?php
// This just listens for MDNS traffic. You could optionally dispatch a
query if your test network doesn't have a bunch of MDNS traffic
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if (!socket_set_option($socket, IPPROTO_IP, MCAST_JOIN_GROUP,
array('group' => '224.0.0.251', 'interface' => 0))) {
echo socket_strerror(socket_last_error());
}
socket_set_option($socket, SOL_SOCKET, SO_REUSEPORT, 1);
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 10, 'usec'
=> 0]);
socket_bind($socket, '0.0.0.0', 5353);
// socket_sendto($socket, $data, strlen($data), 0, '224.0.0.251',
5353);
$response = socket_read($socket, 1024, PHP_BINARY_READ);
var_dump($response);
Expected result:
----------------
true (and actually seeing multicast packets destined for the requested
group address)
Actual result:
--------------
false (with a pass-through error message referencing code [22]/EINVAL)
--
Edit bug report at https://bugs.php.net/bug.php?id=75721&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75721&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75721&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75721&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75721&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75721&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75721&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75721&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75721&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75721&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75721&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75721&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75721&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75721&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75721&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75721&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75721&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75721&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75721&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75721&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75721&r=mysqlcfg