| 471 | } |
| 472 | |
| 473 | struct sctp_ifa * |
| 474 | sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index, |
| 475 | uint32_t ifn_type, const char *if_name, void *ifa, |
| 476 | struct sockaddr *addr, uint32_t ifa_flags, |
| 477 | int dynamic_add) |
| 478 | { |
| 479 | struct sctp_vrf *vrf; |
| 480 | struct sctp_ifn *sctp_ifnp, *new_sctp_ifnp; |
| 481 | struct sctp_ifa *sctp_ifap, *new_sctp_ifap; |
| 482 | struct sctp_ifalist *hash_addr_head; |
| 483 | struct sctp_ifnlist *hash_ifn_head; |
| 484 | uint32_t hash_of_addr; |
| 485 | int new_ifn_af = 0; |
| 486 | |
| 487 | #ifdef SCTP_DEBUG |
| 488 | SCTPDBG(SCTP_DEBUG_PCB4, "vrf_id 0x%x: adding address: ", vrf_id); |
| 489 | SCTPDBG_ADDR(SCTP_DEBUG_PCB4, addr); |
| 490 | #endif |
| 491 | SCTP_MALLOC(new_sctp_ifnp, struct sctp_ifn *, |
| 492 | sizeof(struct sctp_ifn), SCTP_M_IFN); |
| 493 | if (new_sctp_ifnp == NULL) { |
| 494 | #ifdef INVARIANTS |
| 495 | panic("No memory for IFN"); |
| 496 | #endif |
| 497 | return (NULL); |
| 498 | } |
| 499 | SCTP_MALLOC(new_sctp_ifap, struct sctp_ifa *, sizeof(struct sctp_ifa), SCTP_M_IFA); |
| 500 | if (new_sctp_ifap == NULL) { |
| 501 | #ifdef INVARIANTS |
| 502 | panic("No memory for IFA"); |
| 503 | #endif |
| 504 | SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); |
| 505 | return (NULL); |
| 506 | } |
| 507 | |
| 508 | SCTP_IPI_ADDR_WLOCK(); |
| 509 | sctp_ifnp = sctp_find_ifn(ifn, ifn_index); |
| 510 | if (sctp_ifnp) { |
| 511 | vrf = sctp_ifnp->vrf; |
| 512 | } else { |
| 513 | vrf = sctp_find_vrf(vrf_id); |
| 514 | if (vrf == NULL) { |
| 515 | vrf = sctp_allocate_vrf(vrf_id); |
| 516 | if (vrf == NULL) { |
| 517 | SCTP_IPI_ADDR_WUNLOCK(); |
| 518 | SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN); |
| 519 | SCTP_FREE(new_sctp_ifap, SCTP_M_IFA); |
| 520 | return (NULL); |
| 521 | } |
| 522 | } |
| 523 | } |
| 524 | if (sctp_ifnp == NULL) { |
| 525 | /* |
| 526 | * build one and add it, can't hold lock until after malloc |
| 527 | * done though. |
| 528 | */ |
| 529 | sctp_ifnp = new_sctp_ifnp; |
| 530 | new_sctp_ifnp = NULL; |
no test coverage detected