Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of ifb0 #93

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading