php / php/php-src

ext/sockets/tests/bug63000.phpt fails when multicast disabled

Open
#11,662 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Category: Tests Extension: sockets Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

This test tries to set a multicast socket option,

$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, '0.0.0.0', 31057);

$so = socket_set_option($socket, IPPROTO_IP, MCAST_JOIN_GROUP, array(
    "group" => '224.0.0.251',
    "interface" => 0,
));
var_dump($so);

but even on Linux, the ability to do so is not guaranteed. For example, if you run the test in its own network namespace,

$ unshare -n sapi/cli/php ./run-tests.php ext/sockets/tests/bug63000.phpt

you'll get an error,

---- EXPECTED OUTPUT
bool(true)
---- ACTUAL OUTPUT
Warning: socket_set_option(): Unable to set socket option [19]: No such device in ...bug63000.php on line 5
bool(false)
---- FAILED

The reason is that multicast first has to be enabled on a "new" network interface. Specifically, both of the following seem necessary,

$ ifconfig lo multicast
$ route add -net 224.0.0.0 netmask 224.0.0.0 lo

before the test will work.

I'm not really sure what the best way around this is. A simpler test for basic multicast support in SKIPIF?

PHP Version

php-8.2.8

Operating System

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ext/sockets/tests/bug63000.phpt and run it through sapi/cli/php with run-tests.php, including the unshare -n case described in the issue. Review the existing test behavior and make its result appropriate when multicast is unavailable, while retaining coverage when multicast is supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
networking, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.