From 32fdd7dd310912da6ffc244d1273b131afb6a944 Mon Sep 17 00:00:00 2001
From: Rahul <rahul.thakur@iopsys.eu>
Date: Mon, 8 Jun 2020 18:49:10 +0530
Subject: [PATCH] brcm63xx: targets panther and tiger updated

- remove fiber init script from panther, no longer needed
- add sleep to wanconf, it takes time to setup fiber uplink
- add firewall.qos script for panther and tiger. only 4 queues are
  available in downlink so in current form, firewall.qos causes
  network disruption by trying to map packets to non-existant queues.
---
 .../panther/base-files/etc/firewall.qos       | 37 +++++++++++++++++++
 .../panther/base-files/etc/init.d/fiber       | 15 --------
 .../panther/base-files/etc/init.d/wanconf     |  1 +
 .../tiger/base-files/etc/firewall.qos         | 37 +++++++++++++++++++
 4 files changed, 75 insertions(+), 15 deletions(-)
 create mode 100644 iopsys-brcm63xx-arm/panther/base-files/etc/firewall.qos
 delete mode 100755 iopsys-brcm63xx-arm/panther/base-files/etc/init.d/fiber
 create mode 100644 iopsys-brcm63xx-arm/tiger/base-files/etc/firewall.qos

diff --git a/iopsys-brcm63xx-arm/panther/base-files/etc/firewall.qos b/iopsys-brcm63xx-arm/panther/base-files/etc/firewall.qos
new file mode 100644
index 000000000..615d5bce0
--- /dev/null
+++ b/iopsys-brcm63xx-arm/panther/base-files/etc/firewall.qos
@@ -0,0 +1,37 @@
+#Queue Name=Priority
+q_def_queue=0
+q_normal=1
+q_medium=2
+q_highest=3
+
+# Local generated DNS traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p udp -m udp --dport 53 -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p udp -m udp --dport 53 -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# Local generated IGMP traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p 2 -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p 2 -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# Local generated DHCP traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p udp -m udp --dport 67:68 -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p udp -m udp --dport 67:68 -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# Local generated ICMP traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p icmp -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p icmp -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# LAN generated ICMP traffic goes to q_normal
+iptables -t mangle -D PREROUTING -p icmp -j MARK --set-xmark 0x$q_normal/0x$q_normal 2>/dev/null
+iptables -t mangle -A PREROUTING -p icmp -j MARK --set-xmark 0x$q_normal/0x$q_normal
+
+# Prioritize all traffic from a specific port
+#ebtables -t broute -D BROUTING -i eth3+ -j mark --mark-or 0x7 2>/dev/null
+#ebtables -t broute -A BROUTING -i eth3+ -j mark --mark-or 0x7
+
+# VLAN prio tag -> Queue prio
+for i in `seq 1 7`; do
+	ebtables -t broute -D BROUTING --skbvlan-prio $i -j mark --mark-or 0x$i 2>/dev/null
+	ebtables -t broute -A BROUTING --skbvlan-prio $i -j mark --mark-or 0x$i
+done
+
+# Rest goes to q_def_queue
diff --git a/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/fiber b/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/fiber
deleted file mode 100755
index 45a5068d0..000000000
--- a/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/fiber
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh /etc/rc.common
-
-START=60
-
-USE_PROCD=1
-
-start_service() {
-	wanconf
-}
-
-service_triggers()
-{
-        procd_add_reload_trigger network wireless
-}
-
diff --git a/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/wanconf b/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/wanconf
index 00d8bef49..07120eae5 100755
--- a/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/wanconf
+++ b/iopsys-brcm63xx-arm/panther/base-files/etc/init.d/wanconf
@@ -4,5 +4,6 @@ START=15
 
 boot() {
 	wanconf
+	sleep 5
 }
 
diff --git a/iopsys-brcm63xx-arm/tiger/base-files/etc/firewall.qos b/iopsys-brcm63xx-arm/tiger/base-files/etc/firewall.qos
new file mode 100644
index 000000000..615d5bce0
--- /dev/null
+++ b/iopsys-brcm63xx-arm/tiger/base-files/etc/firewall.qos
@@ -0,0 +1,37 @@
+#Queue Name=Priority
+q_def_queue=0
+q_normal=1
+q_medium=2
+q_highest=3
+
+# Local generated DNS traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p udp -m udp --dport 53 -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p udp -m udp --dport 53 -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# Local generated IGMP traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p 2 -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p 2 -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# Local generated DHCP traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p udp -m udp --dport 67:68 -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p udp -m udp --dport 67:68 -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# Local generated ICMP traffic goes to q_highest
+iptables -t mangle -D OUTPUT -p icmp -j MARK --set-xmark 0x$q_highest/0x$q_highest 2>/dev/null
+iptables -t mangle -A OUTPUT -p icmp -j MARK --set-xmark 0x$q_highest/0x$q_highest
+
+# LAN generated ICMP traffic goes to q_normal
+iptables -t mangle -D PREROUTING -p icmp -j MARK --set-xmark 0x$q_normal/0x$q_normal 2>/dev/null
+iptables -t mangle -A PREROUTING -p icmp -j MARK --set-xmark 0x$q_normal/0x$q_normal
+
+# Prioritize all traffic from a specific port
+#ebtables -t broute -D BROUTING -i eth3+ -j mark --mark-or 0x7 2>/dev/null
+#ebtables -t broute -A BROUTING -i eth3+ -j mark --mark-or 0x7
+
+# VLAN prio tag -> Queue prio
+for i in `seq 1 7`; do
+	ebtables -t broute -D BROUTING --skbvlan-prio $i -j mark --mark-or 0x$i 2>/dev/null
+	ebtables -t broute -A BROUTING --skbvlan-prio $i -j mark --mark-or 0x$i
+done
+
+# Rest goes to q_def_queue
-- 
GitLab