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

Function rib_add_route

freebsd/net/route/route_ctl.c:538–568  ·  view source on GitHub ↗

* Adds route defined by @info into 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. */

Source from the content-addressed store, hash-verified

536 * Returns 0 on success and fills in operation metadata into @rc.
537 */
538int
539rib_add_route(uint32_t fibnum, struct rt_addrinfo *info,
540 struct rib_cmd_info *rc)
541{
542 struct rib_head *rnh;
543 int error;
544
545 NET_EPOCH_ASSERT();
546
547 rnh = get_rnh(fibnum, info);
548 if (rnh == NULL)
549 return (EAFNOSUPPORT);
550
551 /*
552 * Check consistency between RTF_HOST flag and netmask
553 * existence.
554 */
555 if (info->rti_flags & RTF_HOST)
556 info->rti_info[RTAX_NETMASK] = NULL;
557 else if (info->rti_info[RTAX_NETMASK] == NULL)
558 return (EINVAL);
559
560 bzero(rc, sizeof(struct rib_cmd_info));
561 rc->rc_cmd = RTM_ADD;
562
563 error = add_route(rnh, info, rc);
564 if (error == 0)
565 rib_notify(rnh, RIB_NOTIFY_DELAYED, rc);
566
567 return (error);
568}
569
570/*
571 * Creates rtentry and nexthop based on @info data.

Callers 1

rib_actionFunction · 0.85

Calls 4

get_rnhFunction · 0.85
bzeroFunction · 0.85
add_routeFunction · 0.85
rib_notifyFunction · 0.85

Tested by

no test coverage detected