MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ff_hook_socket

Function ff_hook_socket

adapter/syscall/ff_hook_syscall.c:336–384  ·  view source on GitHub ↗

* APP need set type |= SOCK_FSTACK */

Source from the content-addressed store, hash-verified

334 * APP need set type |= SOCK_FSTACK
335 */
336int
337ff_hook_socket(int domain, int type, int protocol)
338{
339 ERR_LOG("ff_hook_socket, domain:%d, type:%d, protocol:%d\n", domain, type, protocol);
340 if (unlikely(fstack_territory(domain, type, protocol) == 0)) {
341 return ff_linux_socket(domain, type, protocol);
342 }
343
344 if (unlikely(type & SOCK_KERNEL) && !(type & SOCK_FSTACK)) {
345 type &= ~SOCK_KERNEL;
346 return ff_linux_socket(domain, type, protocol);
347 }
348
349 if (unlikely(inited == 0)) {
350 if (ff_adapter_init() < 0) {
351 return ff_linux_socket(domain, type, protocol);
352 }
353 }
354#ifdef FF_MULTI_SC
355 else {
356 if (ff_adapter_init() < 0) {
357 ERR_LOG("FF_MUTLI_SC ff_adapter_init failed\n");
358 return -1;
359 }
360 }
361#endif
362
363 type &= ~SOCK_FSTACK;
364
365 DEFINE_REQ_ARGS(socket);
366
367 args->domain = domain;
368 args->type = type;
369 args->protocol = protocol;
370
371 SYSCALL(FF_SO_SOCKET, args);
372
373#ifdef FF_MULTI_SC
374 scs[worker_id - 1].fd = ret;
375#endif
376
377 if (ret >= 0) {
378 ret = convert_fstack_fd(ret);
379 }
380
381 ERR_LOG("ff_hook_socket return fd:%d\n", ret);
382
383 RETURN();
384}
385
386int
387ff_hook_bind(int fd, const struct sockaddr *addr,

Callers

nothing calls this directly

Calls 4

ff_linux_socketFunction · 0.85
ff_adapter_initFunction · 0.85
fstack_territoryFunction · 0.70
convert_fstack_fdFunction · 0.70

Tested by

no test coverage detected