Skip to content

Commit

Permalink
rc: retrieve MTU from instanced nvram for QOS quantum, and also handl…
Browse files Browse the repository at this point in the history
…e null values
  • Loading branch information
RMerl committed Nov 20, 2020
1 parent 3b3fa96 commit 80080e1
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions release/src/router/rc/qos.c
Expand Up @@ -1073,7 +1073,7 @@ static int start_tqos(void)
unsigned int rate;
unsigned int ceil;
unsigned int ibw, obw, bw;
unsigned int mtu;
int wan_mtu;
FILE *f;
int x;
int inuse;
Expand All @@ -1084,6 +1084,7 @@ static int start_tqos(void)
char *qsched;
int overhead = 0;
char overheadstr[sizeof("overhead 128 linklayer ethernet")];
char nvmtu[sizeof("wan0_mtu")];

// judge interface by get_wan_ifname
// add Qos iptable rules in mangle table,
Expand Down Expand Up @@ -1111,7 +1112,6 @@ static int start_tqos(void)
* the BW is set here for each class
*/

mtu = strtoul(nvram_safe_get("wan_mtu"), NULL, 10);
bw = obw;

#ifdef RTCONFIG_BCMARM
Expand Down Expand Up @@ -1144,6 +1144,11 @@ static int start_tqos(void)
const char *wan_ifname = get_wan_ifname(wan_primary_ifunit());
const char *lan_ifname = nvram_safe_get("lan_ifname");

snprintf(nvmtu, sizeof (nvmtu), "wan%d_mtu", wan_primary_ifunit());
wan_mtu = nvram_get_int(nvmtu);
if (wan_mtu == 0)
wan_mtu = 1500;

/* Upload (WAN egress) */
fprintf(f,
"#!/bin/sh\n"
Expand Down Expand Up @@ -1221,7 +1226,7 @@ static int start_tqos(void)
"\t$TQAUL parent 1:%d handle %d: $SCH\n"
"\t$TFAUL parent 1: prio %d protocol ip handle %d fw flowid 1:%d\n",
i, rate, ceil,
x, calc(bw, rate), s, burst_leaf, (i >= 6) ? 7 : (i + 1), mtu, overheadstr,
x, calc(bw, rate), s, burst_leaf, (i >= 6) ? 7 : (i + 1), wan_mtu, overheadstr,
x, x,
x, i + 1, x);
}
Expand Down Expand Up @@ -1322,7 +1327,7 @@ static int start_tqos(void)
"\t$TQADL parent 2:%d handle %d: $SCH\n"
"\t$TFADL parent 2: prio %d protocol ip handle %d fw flowid 2:%d\n",
i, rate,
x, calc(bw, rate), burst_leaf, (i >= 6) ? 7 : (i + 1), mtu, overheadstr,
x, calc(bw, rate), burst_leaf, (i >= 6) ? 7 : (i + 1), wan_mtu, overheadstr,
x, x,
x, i + 1, x);
}
Expand Down Expand Up @@ -1993,6 +1998,8 @@ static int start_GeForce_QoS(void)
char *qsched;
int overhead = 0;
char overheadstr[sizeof("overhead 128 linklayer ethernet")];
int wan_mtu;
char nvmtu[sizeof("wan0_mtu")];

_dprintf("[GeForce] start GeForceNow QoS ...\n");
ibw = strtoul(nvram_safe_get("qos_ibw"), NULL, 10);
Expand All @@ -2012,7 +2019,6 @@ static int start_GeForce_QoS(void)
if (ibw_re < 1024 && ibw_re != 0) ibw_re = 1024;
if (obw_re < 1024 && obw_re != 0) obw_re = 1024;

mtu = strtoul(nvram_safe_get("wan_mtu"), NULL, 10);
bw = obw;
#ifdef RTCONFIG_BCMARM
switch(nvram_get_int("qos_sched")){
Expand Down Expand Up @@ -2041,6 +2047,11 @@ static int start_GeForce_QoS(void)
else
strcpy(overheadstr, "");

snprintf(nvmtu, sizeof (nvmtu), "wan%d_mtu", wan_primary_ifunit());
wan_mtu = nvram_get_int(nvmtu);
if (wan_mtu == 0)
wan_mtu = 1500;

if ((f = fopen(qosfn, "w")) == NULL) return -2;
fprintf(f,
"#!/bin/sh\n"
Expand Down Expand Up @@ -2099,11 +2110,11 @@ static int start_GeForce_QoS(void)
"\n"
, ibw, overheadstr // 1:
, obw, overheadstr // 2:
, ibw_re, ibw, mtu, overheadstr // 1:10
, 0.20*ibw, ibw, mtu, overheadstr // 1:20
, 0.15*ibw, ibw, mtu, overheadstr // 1:30
, 0.10*ibw, ibw, mtu, overheadstr // 1:40
, 0.05*ibw, ibw, mtu, overheadstr // 1:50
, ibw_re, ibw, wan_mtu, overheadstr // 1:10
, 0.20*ibw, ibw, wan_mtu, overheadstr // 1:20
, 0.15*ibw, ibw, wan_mtu, overheadstr // 1:30
, 0.10*ibw, ibw, wan_mtu, overheadstr // 1:40
, 0.05*ibw, ibw, wan_mtu, overheadstr // 1:50
);

/* fixed ports */
Expand Down Expand Up @@ -2152,11 +2163,11 @@ static int start_GeForce_QoS(void)
"$TQAU parent 2:50 handle 50: $SCH\n"
"$TFAU parent 2: prio 5 protocol ip handle 50 fw flowid 2:50\n"
"\n"
, obw_re , obw, mtu, overheadstr // 2:10
, 0.20*obw, obw, mtu, overheadstr // 2:20
, 0.15*obw, obw, mtu, overheadstr // 2:30
, 0.10*obw, obw, mtu, overheadstr // 2:40
, 0.05*obw, obw, mtu, overheadstr // 2:50
, obw_re , obw, wan_mtu, overheadstr // 2:10
, 0.20*obw, obw, wan_mtu, overheadstr // 2:20
, 0.15*obw, obw, wan_mtu, overheadstr // 2:30
, 0.10*obw, obw, wan_mtu, overheadstr // 2:40
, 0.05*obw, obw, wan_mtu, overheadstr // 2:50
);

/* fixed ports */
Expand Down

0 comments on commit 80080e1

Please sign in to comment.