Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/route_ctl.c
Show First 20 Lines • Show All 583 Lines • ▼ Show 20 Lines | create_rtentry(struct rib_head *rnh, struct rt_addrinfo *info, | ||||
if (dst->sa_len > sizeof(((struct rtentry *)NULL)->rt_dstb)) | if (dst->sa_len > sizeof(((struct rtentry *)NULL)->rt_dstb)) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (info->rti_ifa == NULL) { | if (info->rti_ifa == NULL) { | ||||
error = rt_getifa_fib(info, rnh->rib_fibnum); | error = rt_getifa_fib(info, rnh->rib_fibnum); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} else { | |||||
ifa_ref(info->rti_ifa); | |||||
} | } | ||||
error = nhop_create_from_info(rnh, info, &nh); | error = nhop_create_from_info(rnh, info, &nh); | ||||
ifa_free(info->rti_ifa); | |||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
rt = uma_zalloc(V_rtzone, M_NOWAIT | M_ZERO); | rt = uma_zalloc(V_rtzone, M_NOWAIT | M_ZERO); | ||||
if (rt == NULL) { | if (rt == NULL) { | ||||
nhop_free(nh); | nhop_free(nh); | ||||
return (ENOBUFS); | return (ENOBUFS); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | rib_change_route(uint32_t fibnum, struct rt_addrinfo *info, | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
change_nhop(struct rib_head *rnh, struct rt_addrinfo *info, | change_nhop(struct rib_head *rnh, struct rt_addrinfo *info, | ||||
struct nhop_object *nh_orig, struct nhop_object **nh_new) | struct nhop_object *nh_orig, struct nhop_object **nh_new) | ||||
{ | { | ||||
int free_ifa = 0; | |||||
int error; | int error; | ||||
/* | /* | ||||
* New gateway could require new ifaddr, ifp; | * New gateway could require new ifaddr, ifp; | ||||
* flags may also be different; ifp may be specified | * flags may also be different; ifp may be specified | ||||
* by ll sockaddr when protocol address is ambiguous | * by ll sockaddr when protocol address is ambiguous | ||||
*/ | */ | ||||
if (((nh_orig->nh_flags & NHF_GATEWAY) && | if (((nh_orig->nh_flags & NHF_GATEWAY) && | ||||
info->rti_info[RTAX_GATEWAY] != NULL) || | info->rti_info[RTAX_GATEWAY] != NULL) || | ||||
info->rti_info[RTAX_IFP] != NULL || | info->rti_info[RTAX_IFP] != NULL || | ||||
(info->rti_info[RTAX_IFA] != NULL && | (info->rti_info[RTAX_IFA] != NULL && | ||||
!sa_equal(info->rti_info[RTAX_IFA], nh_orig->nh_ifa->ifa_addr))) { | !sa_equal(info->rti_info[RTAX_IFA], nh_orig->nh_ifa->ifa_addr))) { | ||||
error = rt_getifa_fib(info, rnh->rib_fibnum); | error = rt_getifa_fib(info, rnh->rib_fibnum); | ||||
if (info->rti_ifa != NULL) | |||||
free_ifa = 1; | |||||
if (error != 0) { | if (error != 0) { | ||||
if (free_ifa) { | |||||
ifa_free(info->rti_ifa); | |||||
info->rti_ifa = NULL; | info->rti_ifa = NULL; | ||||
} | |||||
return (error); | return (error); | ||||
} | } | ||||
} | } | ||||
error = nhop_create_from_nhop(rnh, nh_orig, info, nh_new); | error = nhop_create_from_nhop(rnh, nh_orig, info, nh_new); | ||||
if (free_ifa) { | |||||
ifa_free(info->rti_ifa); | |||||
info->rti_ifa = NULL; | info->rti_ifa = NULL; | ||||
} | |||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef ROUTE_MPATH | #ifdef ROUTE_MPATH | ||||
static int | static int | ||||
change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info, | change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info, | ||||
struct route_nhop_data *rnd_orig, struct rib_cmd_info *rc) | struct route_nhop_data *rnd_orig, struct rib_cmd_info *rc) | ||||
▲ Show 20 Lines • Show All 547 Lines • Show Last 20 Lines |