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

Function rt_unlinkrte

freebsd/net/route/route_ctl.c:770–824  ·  view source on GitHub ↗

* Conditionally unlinks rtentry matching data inside @info from @rnh. * Returns 0 on success with operation result stored in @rc. * On error, returns: * ESRCH - if prefix was not found, * EADDRINUSE - if trying to delete higher priority route. * ENOENT - if supplied filter function returned 0 (not matched). */

Source from the content-addressed store, hash-verified

768 * ENOENT - if supplied filter function returned 0 (not matched).
769 */
770static int
771rt_unlinkrte(struct rib_head *rnh, struct rt_addrinfo *info, struct rib_cmd_info *rc)
772{
773 struct rtentry *rt;
774 struct nhop_object *nh;
775 struct radix_node *rn;
776 struct route_nhop_data rnd;
777 int error;
778
779 rt = lookup_prefix(rnh, info, &rnd);
780 if (rt == NULL)
781 return (ESRCH);
782
783 nh = rt->rt_nhop;
784#ifdef ROUTE_MPATH
785 if (NH_IS_NHGRP(nh)) {
786 error = del_route_mpath(rnh, info, rt,
787 (struct nhgrp_object *)nh, rc);
788 return (error);
789 }
790#endif
791 error = check_info_match_nhop(info, rt, nh);
792 if (error != 0)
793 return (error);
794
795 if (can_override_nhop(info, nh) < 0)
796 return (EADDRINUSE);
797
798 /*
799 * Remove the item from the tree and return it.
800 * Complain if it is not there and do no more processing.
801 */
802 rn = rnh->rnh_deladdr(info->rti_info[RTAX_DST],
803 info->rti_info[RTAX_NETMASK], &rnh->head);
804 if (rn == NULL)
805 return (ESRCH);
806
807 if (rn->rn_flags & (RNF_ACTIVE | RNF_ROOT))
808 panic ("rtrequest delete");
809
810 rt = RNTORT(rn);
811 rt->rte_flags &= ~RTF_UP;
812
813 /* Finalize notification */
814 rnh->rnh_gen++;
815 rnh->rnh_prefixes--;
816
817 rc->rc_cmd = RTM_DELETE;
818 rc->rc_rt = rt;
819 rc->rc_nh_old = rt->rt_nhop;
820 rc->rc_nh_weight = rt->rt_weight;
821 rib_notify(rnh, RIB_NOTIFY_IMMEDIATE, rc);
822
823 return (0);
824}
825
826static int
827del_route(struct rib_head *rnh, struct rt_addrinfo *info,

Callers 2

del_routeFunction · 0.85
rt_checkdelrouteFunction · 0.85

Calls 6

lookup_prefixFunction · 0.85
del_route_mpathFunction · 0.85
check_info_match_nhopFunction · 0.85
can_override_nhopFunction · 0.85
rib_notifyFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected