Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
emulab
emulab-stable
Commits
cdd73465
Commit
cdd73465
authored
Aug 10, 2007
by
David Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If no lilo, but grub, adjust grub config file to boot a linkdelay kernel
if possible.
parent
b3bc5c12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
13 deletions
+89
-13
tmcd/linux/delaysetup
tmcd/linux/delaysetup
+89
-13
No files found.
tmcd/linux/delaysetup
View file @
cdd73465
...
@@ -75,8 +75,8 @@ my $KERNELJAIL = "jail";
...
@@ -75,8 +75,8 @@ my $KERNELJAIL = "jail";
my
$KERNELLDELAY
=
"
linkdelay
";
my
$KERNELLDELAY
=
"
linkdelay
";
my
$TMDELMAP
=
TMDELMAP
;
# Really comes from libloc.
my
$TMDELMAP
=
TMDELMAP
;
# Really comes from libloc.
my
$TC
=
"
/
usr/local/
sbin/tc
";
# This is the working version!
my
$TC
=
"
/sbin/tc
";
# This is the working version!
my
$IPTABLES
=
"
/
usr/local/
sbin/iptables
";
# This is the working version!
my
$IPTABLES
=
"
/sbin/iptables
";
# This is the working version!
# This should never happen!
# This should never happen!
if
(
REMOTE
()
||
MFS
())
{
if
(
REMOTE
()
||
MFS
())
{
...
@@ -222,8 +222,8 @@ sub LinkDelaySetup()
...
@@ -222,8 +222,8 @@ sub LinkDelaySetup()
#
#
# NB: Linux doesn't support floats either, and wants usecs.
# NB: Linux doesn't support floats either, and wants usecs.
#
#
$delay
=
int
(
$delay
+
0.5
)
*
1000
;
#
$delay = int($delay + 0.5) * 1000;
$rdelay
=
int
(
$rdelay
+
0.5
)
*
1000
;
#
$rdelay = int($rdelay + 0.5) * 1000;
#
#
# Sweet! 'k' as in "kbit" means 1024, not 1000, to tc.
# Sweet! 'k' as in "kbit" means 1024, not 1000, to tc.
...
@@ -278,13 +278,10 @@ sub LinkDelaySetup()
...
@@ -278,13 +278,10 @@ sub LinkDelaySetup()
print
DEL
"
ifconfig
$iface
txqueuelen
$queue
\n
";
print
DEL
"
ifconfig
$iface
txqueuelen
$queue
\n
";
print
DEL
"
$TC
qdisc add dev
$iface
handle
$pipeno
root
";
print
DEL
"
$TC
qdisc add dev
$iface
handle
$pipeno
root
";
print
DEL
"
plr
$plr
\n
";
print
DEL
"
netem loss
${plr}
% delay
${delay}
ms
\n
";
print
DEL
"
$TC
qdisc add dev
$iface
handle
"
.
(
$pipeno
+
10
)
.
"
";
print
DEL
"
$TC
qdisc add dev
$iface
handle
"
.
(
$pipeno
+
10
)
.
"
";
print
DEL
"
parent
${pipeno}
:1 delay usecs
$delay
\n
";
print
DEL
"
parent
"
.
(
$pipeno
)
.
"
:1 htb default 1
\n
";
print
DEL
"
$TC
qdisc add dev
$iface
handle
"
.
(
$pipeno
+
20
)
.
"
";
print
DEL
"
parent
"
.
(
$pipeno
+
10
)
.
"
:1 htb default 1
\n
";
if
(
$bandw
!=
0
)
{
if
(
$bandw
!=
0
)
{
print
DEL
"
$TC
class add dev
$iface
classid
"
.
(
$pipeno
+
20
)
.
"
:1
";
print
DEL
"
$TC
class add dev
$iface
classid
"
.
(
$pipeno
+
20
)
.
"
:1
";
...
@@ -391,10 +388,89 @@ sub checkkernel($)
...
@@ -391,10 +388,89 @@ sub checkkernel($)
# XXX only works for linkdelay right now
# XXX only works for linkdelay right now
return
if
(
$kernel
ne
$KERNELLDELAY
);
return
if
(
$kernel
ne
$KERNELLDELAY
);
my
$lilocmd
=
"
/sbin/lilo -D
$kernel
";
if
(
!
(
$kernvers
=~
/$kernel/i
))
{
if
(
system
(
$lilocmd
))
{
print
STDERR
"
Error ($?) running '
$lilocmd
'
\n
";
# XXX only works for linkdelay right now
return
1
;
return
if
(
$kernel
ne
$KERNELLDELAY
);
# check if we have lilo or grub:
my
$islilo
=
0
;
if
(
-
e
"
/etc/lilo.conf
"
&&
-
x
"
/sbin/lilo
")
{
$islilo
=
1
;
}
elsif
(
-
e
"
/boot/grub/grub.conf
"
||
-
e
"
/boot/grub/menu.lst
")
{
$isgrub
=
1
;
}
else
{
print
STDERR
"
Error: neither grub nor lilo seems to be
"
.
"
installed!
\n
";
return
1
;
}
if
(
$islilo
)
{
my
$lilocmd
=
"
/sbin/lilo -D
$kernel
";
if
(
system
(
$lilocmd
))
{
print
STDERR
"
Error ($?) running '
$lilocmd
'
\n
";
return
1
;
}
}
elsif
(
$isgrub
)
{
# we could have had both grub and lilo detected, but if lilo
# was installed, we just blew away the first sector, so fixing up
# grub becomes rather pointless.
my
$file
=
"
/boot/grub/grub.conf
";
if
(
!
(
-
e
$file
))
{
$file
=
"
/boot/grub/menu.lst
";
if
(
!
(
-
e
$file
))
{
print
STDERR
"
Error: could not find any grub
"
.
"
conf files!
\n
";
return
1
;
}
}
my
@lines
;
open
(
FD
,
$file
)
or
die
"
could not open
$file
!
";
@lines
=
<
FD
>
;
close
(
FD
);
my
$i
=
0
;
my
$found
=
0
;
foreach
my
$line
(
@lines
)
{
if
(
$line
=~
/^\s*Title\s+/i
)
{
if
(
$line
=~
/$kernel/i
)
{
$found
=
1
;
last
;
}
++
$i
;
}
}
if
(
!
$found
)
{
print
STDERR
"
Error: could not find a linkdelay kernel
"
.
"
in
$file
!
\n
";
return
1
;
}
my
$idx
=
$i
;
$found
=
0
;
for
(
$i
=
0
;
$i
<
scalar
(
@lines
);
++
$i
)
{
if
(
$lines
[
$i
]
=~
/\s*default\s*=\s*(\d+)/i
)
{
$lines
[
$i
]
=
"
default=
$idx
\n
";
$found
=
1
;
# note that we don't just quit -- there could be more.
}
}
if
(
!
$found
)
{
@lines
=
("
default=
$idx
\n
",
@lines
);
}
# rewrite it.
open
(
FD
,"
>
$file
")
or
die
"
could not open
$file
!
";
foreach
my
$line
(
@lines
)
{
print
FD
$line
;
}
}
}
system
("
sync
");
system
("
sync
");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment