@@ -85,18 +85,18 @@ static void setup_loopback(struct __test_metadata *const _metadata)
8585 clear_ambient_cap (_metadata , CAP_NET_ADMIN );
8686}
8787
88+ static bool prot_is_tcp (const struct protocol_variant * const prot )
89+ {
90+ return (prot -> domain == AF_INET || prot -> domain == AF_INET6 ) &&
91+ prot -> type == SOCK_STREAM &&
92+ (prot -> protocol == IPPROTO_TCP || prot -> protocol == IPPROTO_IP );
93+ }
94+
8895static bool is_restricted (const struct protocol_variant * const prot ,
8996 const enum sandbox_type sandbox )
9097{
91- switch (prot -> domain ) {
92- case AF_INET :
93- case AF_INET6 :
94- switch (prot -> type ) {
95- case SOCK_STREAM :
96- return sandbox == TCP_SANDBOX ;
97- }
98- break ;
99- }
98+ if (sandbox == TCP_SANDBOX )
99+ return prot_is_tcp (prot );
100100 return false;
101101}
102102
@@ -105,7 +105,7 @@ static int socket_variant(const struct service_fixture *const srv)
105105 int ret ;
106106
107107 ret = socket (srv -> protocol .domain , srv -> protocol .type | SOCK_CLOEXEC ,
108- 0 );
108+ srv -> protocol . protocol );
109109 if (ret < 0 )
110110 return - errno ;
111111 return ret ;
@@ -290,22 +290,70 @@ FIXTURE_TEARDOWN(protocol)
290290}
291291
292292/* clang-format off */
293- FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv4_tcp ) {
293+ FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv4_tcp1 ) {
294294 /* clang-format on */
295295 .sandbox = NO_SANDBOX ,
296296 .prot = {
297297 .domain = AF_INET ,
298298 .type = SOCK_STREAM ,
299+ /* IPPROTO_IP == 0 */
300+ .protocol = IPPROTO_IP ,
299301 },
300302};
301303
302304/* clang-format off */
303- FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv6_tcp ) {
305+ FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv4_tcp2 ) {
306+ /* clang-format on */
307+ .sandbox = NO_SANDBOX ,
308+ .prot = {
309+ .domain = AF_INET ,
310+ .type = SOCK_STREAM ,
311+ .protocol = IPPROTO_TCP ,
312+ },
313+ };
314+
315+ /* clang-format off */
316+ FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv4_mptcp ) {
317+ /* clang-format on */
318+ .sandbox = NO_SANDBOX ,
319+ .prot = {
320+ .domain = AF_INET ,
321+ .type = SOCK_STREAM ,
322+ .protocol = IPPROTO_MPTCP ,
323+ },
324+ };
325+
326+ /* clang-format off */
327+ FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv6_tcp1 ) {
328+ /* clang-format on */
329+ .sandbox = NO_SANDBOX ,
330+ .prot = {
331+ .domain = AF_INET6 ,
332+ .type = SOCK_STREAM ,
333+ /* IPPROTO_IP == 0 */
334+ .protocol = IPPROTO_IP ,
335+ },
336+ };
337+
338+ /* clang-format off */
339+ FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv6_tcp2 ) {
304340 /* clang-format on */
305341 .sandbox = NO_SANDBOX ,
306342 .prot = {
307343 .domain = AF_INET6 ,
308344 .type = SOCK_STREAM ,
345+ .protocol = IPPROTO_TCP ,
346+ },
347+ };
348+
349+ /* clang-format off */
350+ FIXTURE_VARIANT_ADD (protocol , no_sandbox_with_ipv6_mptcp ) {
351+ /* clang-format on */
352+ .sandbox = NO_SANDBOX ,
353+ .prot = {
354+ .domain = AF_INET6 ,
355+ .type = SOCK_STREAM ,
356+ .protocol = IPPROTO_MPTCP ,
309357 },
310358};
311359
@@ -350,22 +398,70 @@ FIXTURE_VARIANT_ADD(protocol, no_sandbox_with_unix_datagram) {
350398};
351399
352400/* clang-format off */
353- FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv4_tcp ) {
401+ FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv4_tcp1 ) {
402+ /* clang-format on */
403+ .sandbox = TCP_SANDBOX ,
404+ .prot = {
405+ .domain = AF_INET ,
406+ .type = SOCK_STREAM ,
407+ /* IPPROTO_IP == 0 */
408+ .protocol = IPPROTO_IP ,
409+ },
410+ };
411+
412+ /* clang-format off */
413+ FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv4_tcp2 ) {
414+ /* clang-format on */
415+ .sandbox = TCP_SANDBOX ,
416+ .prot = {
417+ .domain = AF_INET ,
418+ .type = SOCK_STREAM ,
419+ .protocol = IPPROTO_TCP ,
420+ },
421+ };
422+
423+ /* clang-format off */
424+ FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv4_mptcp ) {
354425 /* clang-format on */
355426 .sandbox = TCP_SANDBOX ,
356427 .prot = {
357428 .domain = AF_INET ,
358429 .type = SOCK_STREAM ,
430+ .protocol = IPPROTO_MPTCP ,
431+ },
432+ };
433+
434+ /* clang-format off */
435+ FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv6_tcp1 ) {
436+ /* clang-format on */
437+ .sandbox = TCP_SANDBOX ,
438+ .prot = {
439+ .domain = AF_INET6 ,
440+ .type = SOCK_STREAM ,
441+ /* IPPROTO_IP == 0 */
442+ .protocol = IPPROTO_IP ,
443+ },
444+ };
445+
446+ /* clang-format off */
447+ FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv6_tcp2 ) {
448+ /* clang-format on */
449+ .sandbox = TCP_SANDBOX ,
450+ .prot = {
451+ .domain = AF_INET6 ,
452+ .type = SOCK_STREAM ,
453+ .protocol = IPPROTO_TCP ,
359454 },
360455};
361456
362457/* clang-format off */
363- FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv6_tcp ) {
458+ FIXTURE_VARIANT_ADD (protocol , tcp_sandbox_with_ipv6_mptcp ) {
364459 /* clang-format on */
365460 .sandbox = TCP_SANDBOX ,
366461 .prot = {
367462 .domain = AF_INET6 ,
368463 .type = SOCK_STREAM ,
464+ .protocol = IPPROTO_MPTCP ,
369465 },
370466};
371467
0 commit comments