* Create or lookup a domainset based on the key held in 'domain'. */
| 553 | * Create or lookup a domainset based on the key held in 'domain'. |
| 554 | */ |
| 555 | struct domainset * |
| 556 | domainset_create(const struct domainset *domain) |
| 557 | { |
| 558 | struct domainset *ndomain; |
| 559 | |
| 560 | /* |
| 561 | * Validate the policy. It must specify a useable policy number with |
| 562 | * only valid domains. Preferred must include the preferred domain |
| 563 | * in the mask. |
| 564 | */ |
| 565 | if (domain->ds_policy <= DOMAINSET_POLICY_INVALID || |
| 566 | domain->ds_policy > DOMAINSET_POLICY_MAX) |
| 567 | return (NULL); |
| 568 | if (domain->ds_policy == DOMAINSET_POLICY_PREFER && |
| 569 | !DOMAINSET_ISSET(domain->ds_prefer, &domain->ds_mask)) |
| 570 | return (NULL); |
| 571 | if (!DOMAINSET_SUBSET(&domainset0.ds_mask, &domain->ds_mask)) |
| 572 | return (NULL); |
| 573 | ndomain = uma_zalloc(domainset_zone, M_WAITOK | M_ZERO); |
| 574 | domainset_copy(domain, ndomain); |
| 575 | return _domainset_create(ndomain, NULL); |
| 576 | } |
| 577 | |
| 578 | /* |
| 579 | * Update thread domainset pointers. |
no test coverage detected