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

Function sctp_add_addr_to_vrf

freebsd/netinet/sctp_pcb.c:473–715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471}
472
473struct sctp_ifa *
474sctp_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;

Callers 2

sctp_init_ifns_for_vrfFunction · 0.85
sctp_addr_changeFunction · 0.85

Calls 13

sctp_find_ifnFunction · 0.85
sctp_find_vrfFunction · 0.85
sctp_allocate_vrfFunction · 0.85
memsetFunction · 0.85
sctp_find_ifa_by_addrFunction · 0.85
sctp_delete_ifnFunction · 0.85
sctp_remove_ifa_from_ifnFunction · 0.85
sctp_add_ifa_to_ifnFunction · 0.85
sctp_get_ifa_hash_valFunction · 0.85
sctp_del_addr_from_vrfFunction · 0.85
sctp_timer_startFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected