* 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. */
| 536 | * Returns 0 on success and fills in operation metadata into @rc. |
| 537 | */ |
| 538 | int |
| 539 | rib_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. |
no test coverage detected