| 622 | } |
| 623 | |
| 624 | static void |
| 625 | pfxrtr_add(struct nd_prefix *pr, struct nd_defrouter *dr) |
| 626 | { |
| 627 | struct nd_pfxrouter *new; |
| 628 | bool update; |
| 629 | |
| 630 | ND6_UNLOCK_ASSERT(); |
| 631 | |
| 632 | ND6_RLOCK(); |
| 633 | if (pfxrtr_lookup(pr, dr) != NULL) { |
| 634 | ND6_RUNLOCK(); |
| 635 | return; |
| 636 | } |
| 637 | ND6_RUNLOCK(); |
| 638 | |
| 639 | new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO); |
| 640 | if (new == NULL) |
| 641 | return; |
| 642 | defrouter_ref(dr); |
| 643 | new->router = dr; |
| 644 | |
| 645 | ND6_WLOCK(); |
| 646 | if (pfxrtr_lookup(pr, dr) == NULL) { |
| 647 | LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry); |
| 648 | update = true; |
| 649 | } else { |
| 650 | /* We lost a race to add the reference. */ |
| 651 | defrouter_rele(dr); |
| 652 | free(new, M_IP6NDP); |
| 653 | update = false; |
| 654 | } |
| 655 | ND6_WUNLOCK(); |
| 656 | |
| 657 | if (update) |
| 658 | pfxlist_onlink_check(); |
| 659 | } |
| 660 | |
| 661 | static void |
| 662 | pfxrtr_del(struct nd_pfxrouter *pfr) |
no test coverage detected