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

Function cc_list_available

freebsd/netinet/cc/cc.c:129–176  ·  view source on GitHub ↗

* Sysctl handler to display the list of available CC algorithms. */

Source from the content-addressed store, hash-verified

127 * Sysctl handler to display the list of available CC algorithms.
128 */
129static int
130cc_list_available(SYSCTL_HANDLER_ARGS)
131{
132 struct cc_algo *algo;
133 struct sbuf *s;
134 int err, first, nalgos;
135
136 err = nalgos = 0;
137 first = 1;
138
139 CC_LIST_RLOCK();
140 STAILQ_FOREACH(algo, &cc_list, entries) {
141 nalgos++;
142 }
143 CC_LIST_RUNLOCK();
144
145 s = sbuf_new(NULL, NULL, nalgos * TCP_CA_NAME_MAX, SBUF_FIXEDLEN);
146
147 if (s == NULL)
148 return (ENOMEM);
149
150 /*
151 * It is theoretically possible for the CC list to have grown in size
152 * since the call to sbuf_new() and therefore for the sbuf to be too
153 * small. If this were to happen (incredibly unlikely), the sbuf will
154 * reach an overflow condition, sbuf_printf() will return an error and
155 * the sysctl will fail gracefully.
156 */
157 CC_LIST_RLOCK();
158 STAILQ_FOREACH(algo, &cc_list, entries) {
159 err = sbuf_printf(s, first ? "%s" : ", %s", algo->name);
160 if (err) {
161 /* Sbuf overflow condition. */
162 err = EOVERFLOW;
163 break;
164 }
165 first = 0;
166 }
167 CC_LIST_RUNLOCK();
168
169 if (!err) {
170 sbuf_finish(s);
171 err = sysctl_handle_string(oidp, sbuf_data(s), 0, req);
172 }
173
174 sbuf_delete(s);
175 return (err);
176}
177
178/*
179 * Reset the default CC algo to NewReno for any netstack which is using the algo

Callers

nothing calls this directly

Calls 6

sbuf_newFunction · 0.85
sbuf_printfFunction · 0.85
sbuf_finishFunction · 0.85
sysctl_handle_stringFunction · 0.85
sbuf_dataFunction · 0.85
sbuf_deleteFunction · 0.85

Tested by

no test coverage detected