* Sysctl handler to display the list of available CC algorithms. */
| 127 | * Sysctl handler to display the list of available CC algorithms. |
| 128 | */ |
| 129 | static int |
| 130 | cc_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 |
nothing calls this directly
no test coverage detected