Skip to content

Commit 6edeb94

Browse files
committed
ext/sockets: UDP_SEGMENT support.
UDP segmentation offload is an optimisation attempt by sending multiple large enough datagrams over UDP which reduces syscalls as by default, they have to be broke down in small UDP packets, it is better if the hardware supports it, other handed down to the software implementation.
1 parent 13e0fb9 commit 6edeb94

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

ext/sockets/sockets.c

+16
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,22 @@ PHP_FUNCTION(socket_set_option)
23002300
}
23012301
#endif
23022302

2303+
#if defined(UDP_SEGMENT)
2304+
case UDP_SEGMENT: {
2305+
ov = zval_get_long(arg4);
2306+
2307+
// UDP segmentation offload maximum size or 0 to disable it
2308+
if (ov < 0 || ov > USHRT_MAX) {
2309+
zend_argument_value_error(4, "must be of between 0 and %u", USHRT_MAX);
2310+
RETURN_FALSE;
2311+
}
2312+
2313+
optlen = sizeof(ov);
2314+
opt_ptr = &ov;
2315+
break;
2316+
}
2317+
#endif
2318+
23032319
default:
23042320
default_case:
23052321
ov = zval_get_long(arg4);

ext/sockets/sockets.stub.php

+8
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,14 @@
20222022
const ETH_P_ALL = UNKNOWN;
20232023
#endif
20242024

2025+
#ifdef UDP_SEGMENT
2026+
/**
2027+
* @var int
2028+
* @cvalue UDP_SEGMENT
2029+
*/
2030+
const UDP_SEGMENT = UNKNOWN;
2031+
#endif
2032+
20252033
/**
20262034
* @strict-properties
20272035
* @not-serializable

ext/sockets/sockets_arginfo.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)