mangle and Qos - pre vs post routing

Why would one mangle pre-routing vs post-routing for QOS?

I’ve seen it both ways but don’t know why.

I’m sure someone will post you a link of the packet flow diagram but it depends on that according to how you are routing the packets. Generally go for pre-routing although for a lot my applications I actually find the forward chain just as useful.

yea, I would see how that would be useful.

My question is how does one make that decision from pre/post routing decision, say on a CCR1036.

It is not very important. However note:

  • some mangle selection criteria can only be used pre-routing, some only post-routing
  • traffic from the router itself only passes pre/post-routing not forward.
  • there can only be a single packet mark on a packet, so when you want to use packet-marks
    both for routing decisions and for QoS, you need to apply the mark for QoS in post-routing

So what I normally do is:

  • set appropriate DSCP value in pre-routing in cases where the packets send with DSCP 00 by sender
    (select on some protocol/port/incoming interface)
  • set priority based on DSCP high 7 bits in post-routing
  • then set a packet mark based on priority (unfortunately this requires 8 rules)
  • use packet mark to select member of a queue tree.

In some cases I also use connection marking to tag connections as low-priority and then set the
DSCP accordingly for packets belonging to the connection. This can also be done post-routing,
befor the above “set priority”. Alternatively, priority can be modified after the “set priority” based
on the connection marks or on packet marks when you do not want to touch DSCP.

For routing decisions (and routing marks), wouldn’t you do that pre-routing?

Yes, and therefore do the QoS post-routing to avoid overwriting the mark.