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

Function rt_setup_new_rs

freebsd/netinet/tcp_ratelimit.c:511–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511static struct tcp_rate_set *
512rt_setup_new_rs(struct ifnet *ifp, int *error)
513{
514 struct tcp_rate_set *rs;
515 const uint64_t *rate_table_act;
516 uint64_t lentim, res;
517 size_t sz;
518 uint32_t hash_type;
519 int i;
520 struct if_ratelimit_query_results rl;
521 struct sysctl_oid *rl_sysctl_root;
522 /*
523 * We expect to enter with the
524 * mutex locked.
525 */
526
527 if (ifp->if_ratelimit_query == NULL) {
528 /*
529 * We can do nothing if we cannot
530 * get a query back from the driver.
531 */
532 printf("Warning:No query functions for %s:%d-- failed\n",
533 ifp->if_dname, ifp->if_dunit);
534 return (NULL);
535 }
536 rs = malloc(sizeof(struct tcp_rate_set), M_TCPPACE, M_NOWAIT | M_ZERO);
537 if (rs == NULL) {
538 if (error)
539 *error = ENOMEM;
540 printf("Warning:No memory for malloc of tcp_rate_set\n");
541 return (NULL);
542 }
543 memset(&rl, 0, sizeof(rl));
544 rl.flags = RT_NOSUPPORT;
545 ifp->if_ratelimit_query(ifp, &rl);
546 if (rl.flags & RT_IS_UNUSABLE) {
547 /*
548 * The interface does not really support
549 * the rate-limiting.
550 */
551 memset(rs, 0, sizeof(struct tcp_rate_set));
552 rs->rs_ifp = ifp;
553 rs->rs_if_dunit = ifp->if_dunit;
554 rs->rs_flags = RS_INTF_NO_SUP;
555 rs->rs_disable = 1;
556 rs_number_alive++;
557 sysctl_ctx_init(&rs->sysctl_ctx);
558 rl_sysctl_root = SYSCTL_ADD_NODE(&rs->sysctl_ctx,
559 SYSCTL_STATIC_CHILDREN(_net_inet_tcp_rl),
560 OID_AUTO,
561 rs->rs_ifp->if_xname,
562 CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
563 "");
564 rl_add_syctl_entries(rl_sysctl_root, rs);
565 mtx_lock(&rs_mtx);
566 CK_LIST_INSERT_HEAD(&int_rs, rs, next);
567 mtx_unlock(&rs_mtx);
568 return (rs);

Callers 1

tcp_rl_ifnet_linkFunction · 0.85

Calls 10

mallocFunction · 0.85
memsetFunction · 0.85
sysctl_ctx_initFunction · 0.85
rl_add_syctl_entriesFunction · 0.85
populate_canned_tableFunction · 0.85
rl_attach_txrtlmtFunction · 0.85
printfFunction · 0.50
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected