OpenWrt Forum Archive

Topic: Ethernet Port Priority

The content of this topic has been archived on 30 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I previously had Sveasoft firmware installed on my WRT54Gv2, and it featured QoS configs for Layer 2 based QoS.  That is to say, one could configure packet priority based on which switch port frames came in from.  I believe I recall that this was allegedly implemented in hardware, rather than being sent up to the host for CPU processing of TCP headers & so forth, and therefore allegedly offered significant improvements in jitter performance.

A little googling around seems to indicate that the magic phrase may be "Ethernet Port Priority".

Am I completely mistaken about this, or is this functionality built into the WRT54G chips?  If so, can it be configured in OpenWRT, and how?

TIA

That is possible with the help of VLANs and iptables/tc.

First you must to separate your LAN ports to different VLANs - otherwise you can't tell which LAN port the traffic is coming from. Then you'll have a bunch of new VLAN interfaces (e.g., eth0.1, eth0.2 and so on) instead of the original LAN interface (eth0 in this case). This can be done using /etc/config/network, vconfig and ifconfig.

iptables is capable of MARK'ing packets based on the interface where they're coming from. (You can also match different ports, source/dest addresses, application layer stuff (with layer7 module) just to mention a few.)

For example you can set (internal) priority of 1 to TCP packets that are coming from eth0.2, and prio 2 for eth0.3 packets:

iptables -t mangle -A PREROUTING -i eth0.2 -p tcp -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i eth0.3 -p tcp -j MARK --set-mark 2

Then you can use tc to filter packets to different QoS classes using those priority marks:
(note that you must have your QoS rules set up before filtering... see LARTC below)

...
tc filter add dev $WAN_IF parent X:Y protocol ip prio 1 handle 1 fw classid Z:AA
tc filter add dev $WAN_IF parent X:Y protocol ip prio 2 handle 2 fw classid Z:BB
...

Internet is full of manuals and guides for iptables and there's also lots of material about tc and Linux specific and generic traffic shaping (that's what you are doing here).

Good but a bit old guide is Linux Advanced Routing & Traffic Control HOWTO (http://lartc.org/). Nice site about iptables is at http://www.linuxtopia.org/Linux_Firewal … index.html .

HTH

--
kurkku

The discussion might have continued from here.