| 693 | } |
| 694 | |
| 695 | static int |
| 696 | pf_commit_altq(u_int32_t ticket) |
| 697 | { |
| 698 | struct pf_altqqueue *old_altqs, *old_altq_ifs; |
| 699 | struct pf_altq *altq, *tmp; |
| 700 | int err, error = 0; |
| 701 | |
| 702 | PF_RULES_WASSERT(); |
| 703 | |
| 704 | if (!V_altqs_inactive_open || ticket != V_ticket_altqs_inactive) |
| 705 | return (EBUSY); |
| 706 | |
| 707 | /* swap altqs, keep the old. */ |
| 708 | old_altqs = V_pf_altqs_active; |
| 709 | old_altq_ifs = V_pf_altq_ifs_active; |
| 710 | V_pf_altqs_active = V_pf_altqs_inactive; |
| 711 | V_pf_altq_ifs_active = V_pf_altq_ifs_inactive; |
| 712 | V_pf_altqs_inactive = old_altqs; |
| 713 | V_pf_altq_ifs_inactive = old_altq_ifs; |
| 714 | V_ticket_altqs_active = V_ticket_altqs_inactive; |
| 715 | |
| 716 | /* Attach new disciplines */ |
| 717 | TAILQ_FOREACH(altq, V_pf_altq_ifs_active, entries) { |
| 718 | if ((altq->local_flags & PFALTQ_FLAG_IF_REMOVED) == 0) { |
| 719 | /* attach the discipline */ |
| 720 | error = altq_pfattach(altq); |
| 721 | if (error == 0 && V_pf_altq_running) |
| 722 | error = pf_enable_altq(altq); |
| 723 | if (error != 0) |
| 724 | return (error); |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | /* Purge the old altq lists */ |
| 729 | TAILQ_FOREACH_SAFE(altq, V_pf_altq_ifs_inactive, entries, tmp) { |
| 730 | if ((altq->local_flags & PFALTQ_FLAG_IF_REMOVED) == 0) { |
| 731 | /* detach and destroy the discipline */ |
| 732 | if (V_pf_altq_running) |
| 733 | error = pf_disable_altq(altq); |
| 734 | err = altq_pfdetach(altq); |
| 735 | if (err != 0 && error == 0) |
| 736 | error = err; |
| 737 | err = altq_remove(altq); |
| 738 | if (err != 0 && error == 0) |
| 739 | error = err; |
| 740 | } |
| 741 | free(altq, M_PFALTQ); |
| 742 | } |
| 743 | TAILQ_INIT(V_pf_altq_ifs_inactive); |
| 744 | TAILQ_FOREACH_SAFE(altq, V_pf_altqs_inactive, entries, tmp) { |
| 745 | pf_qid_unref(altq->qid); |
| 746 | free(altq, M_PFALTQ); |
| 747 | } |
| 748 | TAILQ_INIT(V_pf_altqs_inactive); |
| 749 | |
| 750 | V_altqs_inactive_open = 0; |
| 751 | return (error); |
| 752 | } |
no test coverage detected