/system script add name=set_pppoe_queues \
source={

:local mark-p2p p2p
:local mark-non-p2p other

/queue tree{
#
# First remove any invalid queues. This happens whenever a pppoe
# connection is dropped - even if the connection returns the queue is
# forever lost.
#
:foreach j in [find invalid=yes] do {
#
# MT Bug?: "disabled" entries are considered to be "invalid" and
# would be deleted here - this keeps any "disabled" entries
#
:if (![get $j disabled]=yes) do {
remove $j
}
}
}

/interface {
:foreach i in [find type="pppoe-in"] do {
:set ifacename ([get $i name])

# This will print the list of interfaces found (debugging)
# ut ($ifacename)

:set queuename ([ick $ifacename 1 ([:len $ifacename] - 1)])

# Print the queue name to the console (debugging)
# ut $queuename

/queue tree{
#
# Create a "master-queue". The parent is the virtual interface
# (pppoe) not the physical interface
:if ([:len [find name=($queuename . " all out")]] = 0) do {
add name=($queuename . " all out") parent=$ifacename \
queue=qtype_p2p priority=1 limit-at=50000 \
max-limit=400000
}

#
# MT Bug?: It is possible to add a sub-queue to a "disabled" parent
# queue, and the sub-queue is not made "invalid" despite the fact
# that the parent queue "does not exist" (ie is "invalid")
# This prevents adding queue to a disabled parent
:if (![get [find name=($queuename . " all out")] disabled]=yes) do {
# Create a "sub-queue" for p2p traffic. The parent is the
# "master-queue" for the virtual interface (pppoe)
:if ([:len [find name=($queuename . " p2p out")]] = 0) do {
add name=($queuename . " p2p out") \
parent=($queuename . "all out") \
packet-mark=$mark-p2p queue=qtype_p2p priority=8 \
limit-at=50000 max-limit=200000
}

# Create a "sub-queue" for non-p2p traffic. The parent is the
# "master-queue" for the virtual interface (pppoe)
:if ([:len [find name=($queuename . " non-p2p out")]] = 0) do {
add name=($queuename . " non-p2p out") \
parent=($queuename . "all out") \
packet-mark=$mark-non-p2p queue=qtype_non_p2p \
priority=1 limit-at=0 max-limit=0
}
# Depending on how you have set up packet marking in mangle you
# can create "sub-queues" here for any other type of traffic sent out # on this virtual interface (pppoe)
}
}
}
}
}


/ system scheduler add name=set_pppoe_queues \
on-event=set_pppoe_queues \
interval=15s \
comment="Sets up non-simple pppoe queues for QoS"




موضوعات مشابه: