forked from ccp-project/ccp-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccp_kernel_load
executable file
·55 lines (42 loc) · 1.23 KB
/
ccp_kernel_load
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
module="ccp"
device="ccpkp"
mode="664"
usage() {
echo "usage: sudo ./ccp_kernel_load ipc=[0|1]"
echo " netlink : ipc=0"
echo " char-dev : ipc=1"
}
if [ "$EUID" -ne 0 ]; then
echo "error: must run as root"
usage
exit 1
fi
if [ "$#" -ne 1 ]; then
usage
exit 1
fi
make IPC=$(echo $1 | awk -F'=' '{print $NF}') || exit
# invoke insmod with all arguments we got
# and use a pathname, as insmod doesn't look in . by default
/sbin/insmod ./$module.ko || ((dmesg | tail) && exit 1)
# only need the following for char-dev
if [ "$1" = "ipc=1" ];
then
# Group: since distributions do it differently, look for wheel or use staff
if grep -q '^staff:' /etc/group; then
group="staff"
else
group="wheel"
fi
# retrieve major number
major=$(awk "\$2==\"$device\" {print \$1; exit}" /proc/devices)
# Remove stale nodes and replace them, then give gid and perms
# Usually the script is shorter, it's scull that has several devices in it.
rm -f /dev/${device}
mknod /dev/${device} c $major 0
chgrp $group /dev/${device}
chmod $mode /dev/${device}
fi
ALLOWED=$(sudo cat /proc/sys/net/ipv4/tcp_allowed_congestion_control)
echo "${ALLOWED} ccp" | sudo tee /proc/sys/net/ipv4/tcp_allowed_congestion_control