| 715 | } |
| 716 | |
| 717 | void |
| 718 | sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr, |
| 719 | uint32_t ifn_index, const char *if_name) |
| 720 | { |
| 721 | struct sctp_vrf *vrf; |
| 722 | struct sctp_ifa *sctp_ifap = NULL; |
| 723 | |
| 724 | SCTP_IPI_ADDR_WLOCK(); |
| 725 | vrf = sctp_find_vrf(vrf_id); |
| 726 | if (vrf == NULL) { |
| 727 | SCTPDBG(SCTP_DEBUG_PCB4, "Can't find vrf_id 0x%x\n", vrf_id); |
| 728 | goto out_now; |
| 729 | } |
| 730 | |
| 731 | #ifdef SCTP_DEBUG |
| 732 | SCTPDBG(SCTP_DEBUG_PCB4, "vrf_id 0x%x: deleting address:", vrf_id); |
| 733 | SCTPDBG_ADDR(SCTP_DEBUG_PCB4, addr); |
| 734 | #endif |
| 735 | sctp_ifap = sctp_find_ifa_by_addr(addr, vrf->vrf_id, SCTP_ADDR_LOCKED); |
| 736 | if (sctp_ifap) { |
| 737 | /* Validate the delete */ |
| 738 | if (sctp_ifap->ifn_p) { |
| 739 | int valid = 0; |
| 740 | |
| 741 | /*- |
| 742 | * The name has priority over the ifn_index |
| 743 | * if its given. |
| 744 | */ |
| 745 | if (if_name) { |
| 746 | if (strncmp(if_name, sctp_ifap->ifn_p->ifn_name, SCTP_IFNAMSIZ) == 0) { |
| 747 | /* They match its a correct delete */ |
| 748 | valid = 1; |
| 749 | } |
| 750 | } |
| 751 | if (!valid) { |
| 752 | /* last ditch check ifn_index */ |
| 753 | if (ifn_index == sctp_ifap->ifn_p->ifn_index) { |
| 754 | valid = 1; |
| 755 | } |
| 756 | } |
| 757 | if (!valid) { |
| 758 | SCTPDBG(SCTP_DEBUG_PCB4, "ifn:%d ifname:%s does not match addresses\n", |
| 759 | ifn_index, ((if_name == NULL) ? "NULL" : if_name)); |
| 760 | SCTPDBG(SCTP_DEBUG_PCB4, "ifn:%d ifname:%s - ignoring delete\n", |
| 761 | sctp_ifap->ifn_p->ifn_index, sctp_ifap->ifn_p->ifn_name); |
| 762 | SCTP_IPI_ADDR_WUNLOCK(); |
| 763 | return; |
| 764 | } |
| 765 | } |
| 766 | SCTPDBG(SCTP_DEBUG_PCB4, "Deleting ifa %p\n", (void *)sctp_ifap); |
| 767 | sctp_ifap->localifa_flags &= SCTP_ADDR_VALID; |
| 768 | /* |
| 769 | * We don't set the flag. This means that the structure will |
| 770 | * hang around in EP's that have bound specific to it until |
| 771 | * they close. This gives us TCP like behavior if someone |
| 772 | * removes an address (or for that matter adds it right |
| 773 | * back). |
| 774 | */ |
no test coverage detected