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

Function pf_commit_altq

freebsd/netpfil/pf/pf_ioctl.c:695–752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695static int
696pf_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}

Callers 3

pf_altq_ifnet_eventFunction · 0.85
pfioctlFunction · 0.85
shutdown_pfFunction · 0.85

Calls 7

altq_pfattachFunction · 0.85
pf_enable_altqFunction · 0.85
pf_disable_altqFunction · 0.85
altq_pfdetachFunction · 0.85
altq_removeFunction · 0.85
pf_qid_unrefFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected