| 264 | |
| 265 | |
| 266 | int fix_bond_socket_list(struct socket_id *list) |
| 267 | { |
| 268 | struct socket_id *sid; |
| 269 | struct socket_id *next_sid; |
| 270 | struct socket_bond_elem *be; |
| 271 | struct socket_info_full *sif = NULL; |
| 272 | struct socket_info_full *orig_sif; |
| 273 | struct socket_info_ref *ref; |
| 274 | const struct socket_info *bond_si; |
| 275 | str bond_spec, host; |
| 276 | int port, proto, found_any; |
| 277 | |
| 278 | for (sid = list; sid; sid = next_sid) { |
| 279 | |
| 280 | next_sid = sid->next; |
| 281 | |
| 282 | if (sid->proto!=PROTO_BOND) { |
| 283 | LM_BUG("non-bond socket found in the list\n"); |
| 284 | goto error; |
| 285 | } |
| 286 | |
| 287 | sif = new_sock_info(sid, NULL); |
| 288 | if (!sif) { |
| 289 | LM_ERR("failed to build socket info for bond <%s>\n", sid->name); |
| 290 | goto error; |
| 291 | } |
| 292 | |
| 293 | for (be = sid->bond_list; be; be = be->next) { |
| 294 | bond_spec.s = be->name; |
| 295 | bond_spec.len = strlen(be->name); |
| 296 | found_any = 0; |
| 297 | if (parse_phostport(bond_spec.s, bond_spec.len, &host.s, &host.len, |
| 298 | &port, &proto) != 0) { |
| 299 | LM_WARN("failed to parse bond member <%s> for bond <%s>\n", |
| 300 | be->name, sid->name); |
| 301 | continue; |
| 302 | } |
| 303 | |
| 304 | bond_si = grep_internal_sock_info(&host, (unsigned short)port, |
| 305 | (unsigned short)proto); |
| 306 | if (bond_si) { |
| 307 | found_any = 1; |
| 308 | ref = pkg_malloc(sizeof(*ref)); |
| 309 | if (!ref) { |
| 310 | LM_ERR("pkg memory allocation failed while building " |
| 311 | "bond <%s>\n", sid->name); |
| 312 | goto error; |
| 313 | } |
| 314 | ref->si = bond_si; |
| 315 | ref->next = sif->socket_info.bond_sis; |
| 316 | sif->socket_info.bond_sis = ref; |
| 317 | |
| 318 | LM_DBG("bond socket [%.*s] including real socket [%.*s]\n", |
| 319 | sif->socket_info.name.len, sif->socket_info.name.s, |
| 320 | bond_si->sock_str.len, bond_si->sock_str.s); |
| 321 | continue; |
| 322 | } |
| 323 |
no test coverage detected