From c587b35a3cbb9722e35ffa652614cd5a76ab97d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Chac=C3=B3n?= Date: Sun, 20 Mar 2022 17:53:27 -0600 Subject: [PATCH] Add support for CIDR subnets --- v1.1/LibreQoS.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/v1.1/LibreQoS.py b/v1.1/LibreQoS.py index 7086e6ae..0c93e267 100644 --- a/v1.1/LibreQoS.py +++ b/v1.1/LibreQoS.py @@ -204,8 +204,14 @@ def refreshShapers(): if device['ipv4']: parentString = str(major) + ':' flowIDstring = str(major) + ':' + str(minor) - print(tabs + ' ', end='') - shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + device['ipv4'] + ' --cpu ' + str(queue-1) + ' --classid ' + flowIDstring) + if '/' in device['ipv4']: + hosts = list(ipaddress.ip_network(device['ipv4']).hosts()) + for host in hosts: + print(tabs + ' ', end='') + shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + str(host) + ' --cpu ' + str(queue-1) + ' --classid ' + flowIDstring) + else: + print(tabs + ' ', end='') + shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + device['ipv4'] + ' --cpu ' + str(queue-1) + ' --classid ' + flowIDstring) device['qdisc'] = flowIDstring if device['hostname'] not in devicesShaped: devicesShaped.append(device['hostname'])