@@ -21,19 +21,23 @@ async function getDefaultInterface() {
21
21
async function moduleProbe ( ) {
22
22
try {
23
23
await sudo ( 'modprobe' , 'ifb' ) ;
24
+ // eslint-disable-next-line no-empty
25
+ } catch { }
26
+ }
27
+ async function setupifb0 ( ) {
28
+ try {
29
+ // Check if ifb0 exist
30
+ await sudo ( 'ip' , 'link' , 'show' , 'ifb0' ) ;
24
31
} catch {
25
- // we are probably in a Docker env
26
- // let us hope that the host is Linux
27
- try {
28
- await sudo ( 'ip' , 'link' , 'add' , 'ifb0' , 'type' , 'ifb' ) ;
29
- } catch {
30
- // If we already setup ifb in a previous run, this will fail
31
- }
32
+ // Add the interface
33
+ await sudo ( 'ip' , 'link' , 'add' , 'ifb0' , 'type' , 'ifb' ) ;
32
34
}
35
+
36
+ // Bring the interface up
37
+ await sudo ( 'ip' , 'link' , 'set' , 'ifb0' , 'up' ) ;
33
38
}
34
39
35
40
async function setup ( defaultInterface ) {
36
- await sudo ( 'ip' , 'link' , 'set' , 'dev' , 'ifb0' , 'up' ) ;
37
41
await sudo ( 'tc' , 'qdisc' , 'add' , 'dev' , defaultInterface , 'ingress' ) ;
38
42
await sudo (
39
43
'tc' ,
@@ -145,6 +149,7 @@ export async function start(up, down, rtt = 0, packetLoss = 0) {
145
149
146
150
const indexFace = await getDefaultInterface ( ) ;
147
151
await moduleProbe ( ) ;
152
+ await setupifb0 ( ) ;
148
153
await setup ( indexFace ) ;
149
154
await setLimits ( up , down , halfWayRTT , packetLoss , indexFace ) ;
150
155
}
0 commit comments