* APP need set type |= SOCK_FSTACK */
| 334 | * APP need set type |= SOCK_FSTACK |
| 335 | */ |
| 336 | int |
| 337 | ff_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 | |
| 386 | int |
| 387 | ff_hook_bind(int fd, const struct sockaddr *addr, |
nothing calls this directly
no test coverage detected