Skip to content

Commit

Permalink
Better handling of ifb0 (#93)
Browse files Browse the repository at this point in the history
* Better handling of ifb0

* fix

* fix
  • Loading branch information
soulgalore authored Aug 26, 2024
1 parent 7288e5e commit 7edc3af
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/tc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ async function getDefaultInterface() {
async function moduleProbe() {
try {
await sudo('modprobe', 'ifb');
// eslint-disable-next-line no-empty
} catch {}
}
async function setupifb0() {
try {
// Check if ifb0 exist
await sudo('ip', 'link', 'show', 'ifb0');
} catch {
// we are probably in a Docker env
// let us hope that the host is Linux
try {
await sudo('ip', 'link', 'add', 'ifb0', 'type', 'ifb');
} catch {
// If we already setup ifb in a previous run, this will fail
}
// Add the interface
await sudo('ip', 'link', 'add', 'ifb0', 'type', 'ifb');
}

// Bring the interface up
await sudo('ip', 'link', 'set', 'ifb0', 'up');
}

async function setup(defaultInterface) {
await sudo('ip', 'link', 'set', 'dev', 'ifb0', 'up');
await sudo('tc', 'qdisc', 'add', 'dev', defaultInterface, 'ingress');
await sudo(
'tc',
Expand Down Expand Up @@ -145,6 +149,7 @@ export async function start(up, down, rtt = 0, packetLoss = 0) {

const indexFace = await getDefaultInterface();
await moduleProbe();
await setupifb0();
await setup(indexFace);
await setLimits(up, down, halfWayRTT, packetLoss, indexFace);
}
Expand Down

0 comments on commit 7edc3af

Please sign in to comment.