* Removes route defined by @info from the kernel table specified by @fibnum and * sa_family in @info->rti_info[RTAX_DST]. * * Returns 0 on success and fills in operation metadata into @rc. */
| 727 | * Returns 0 on success and fills in operation metadata into @rc. |
| 728 | */ |
| 729 | int |
| 730 | rib_del_route(uint32_t fibnum, struct rt_addrinfo *info, struct rib_cmd_info *rc) |
| 731 | { |
| 732 | struct rib_head *rnh; |
| 733 | struct sockaddr *dst_orig, *netmask; |
| 734 | struct sockaddr_storage mdst; |
| 735 | int error; |
| 736 | |
| 737 | NET_EPOCH_ASSERT(); |
| 738 | |
| 739 | rnh = get_rnh(fibnum, info); |
| 740 | if (rnh == NULL) |
| 741 | return (EAFNOSUPPORT); |
| 742 | |
| 743 | bzero(rc, sizeof(struct rib_cmd_info)); |
| 744 | rc->rc_cmd = RTM_DELETE; |
| 745 | |
| 746 | dst_orig = info->rti_info[RTAX_DST]; |
| 747 | netmask = info->rti_info[RTAX_NETMASK]; |
| 748 | |
| 749 | if (netmask != NULL) { |
| 750 | /* Ensure @dst is always properly masked */ |
| 751 | if (dst_orig->sa_len > sizeof(mdst)) |
| 752 | return (EINVAL); |
| 753 | rt_maskedcopy(dst_orig, (struct sockaddr *)&mdst, netmask); |
| 754 | info->rti_info[RTAX_DST] = (struct sockaddr *)&mdst; |
| 755 | } |
| 756 | error = del_route(rnh, info, rc); |
| 757 | info->rti_info[RTAX_DST] = dst_orig; |
| 758 | |
| 759 | return (error); |
| 760 | } |
| 761 | |
| 762 | /* |
| 763 | * Conditionally unlinks rtentry matching data inside @info from @rnh. |
no test coverage detected