From 4fb81152933d5498e598b2437c57ca410a804038 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 24 Nov 2021 15:50:04 +0100 Subject: [PATCH] net_qdisc_nfs_low: Add script Add script net_qdisc_nfs_low. usage: /usr/sbin/net_qdisc_nfs_low { start | stop | restart | status } Called with "start", this script installs a traffic shaping queueing discipline and filters on the default network interface, which gives nfs traffic, in which the current system is the client, a lower priority than other traffic. --- install.sh | 1 + net_qdisc_nfs_low/net_qdisc_nfs_low | 44 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 net_qdisc_nfs_low/net_qdisc_nfs_low diff --git a/install.sh b/install.sh index 5bc75be..0d1ccad 100755 --- a/install.sh +++ b/install.sh @@ -230,6 +230,7 @@ install_data prun/pman.1 "$DESTDIR$usr_mandir/m install_exec crashkernel/startup-crashmemory "$DESTDIR$usr_sbindir/startup-crashmemory" install_data crashkernel/startup-crashmemory.service "$DESTDIR$systemdunitdir/startup-crashmemory.service" install_exec mxsnoop/mxsnoop.sh "$DESTDIR$usr_sbindir/mxsnoop.sh" +install_exec net_qdisc_nfs_low/net_qdisc_nfs_low "$DESTDIR$usr_sbindir/net_qdisc_nfs_low" postinstall exit diff --git a/net_qdisc_nfs_low/net_qdisc_nfs_low b/net_qdisc_nfs_low/net_qdisc_nfs_low new file mode 100755 index 0000000..828d0b1 --- /dev/null +++ b/net_qdisc_nfs_low/net_qdisc_nfs_low @@ -0,0 +1,44 @@ +#! /bin/bash + +. /etc/local/mxhost.conf + +case "$1" in + start) + tc qdisc add dev $MX_NETDEV root handle 10: prio + tc qdisc add dev $MX_NETDEV parent 10:1 handle 20: sfq # band 0 highest priority + tc qdisc add dev $MX_NETDEV parent 10:2 handle 30: sfq # band 2 + tc qdisc add dev $MX_NETDEV parent 10:3 handle 40: sfq # band 3 + + tc filter add dev $MX_NETDEV parent 10: handle 100: protocol ip prio 4 u32 divisor 1 + tc filter add dev $MX_NETDEV parent 10: handle 100:0:1 protocol ip prio 4 u32 ht 100: match tcp dst 2049 FFFF flowid 10:2 + + # The "root filter list is always 800:0. + # "match ip firstfrag" compiles to "match 00002000/00003fff at 4" which + # includes the "more fragments" flag, so only initial fragments of a + # fragmented packet would be selected, not single fragments of an + # unfragmented packet. So use "match u32 00000000 00001fff at 4" to + # make sure, this is a initial segment and has a tcp header. + + tc filter add dev $MX_NETDEV parent 10: handle 800:0:1 protocol ip prio 4 u32 ht 800: \ + match ip protocol 06 ff \ + match u32 00000000 00001fff at 4 \ + offset at 0 mask 0f00 shift 6 \ + link 100: + tc filter add dev $MX_NETDEV parent 10: handle 800:0:2 protocol ip prio 4 u32 ht 800: match u32 0 0 flowid 10:1 + ;; + stop) + tc filter delete dev $MX_NETDEV + tc qdisc delete dev $MX_NETDEV root + ;; + restart) + $0 stop + $0 start + ;; + status) + tc -s qdisc show dev $MX_NETDEV + tc -s filter show dev $MX_NETDEV + ;; + *) + echo "usage: $0 { start | stop | restart | status }" >&2 + exit 1 +esac