Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
4e6b03d6
Commit
4e6b03d6
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Plain Diff
Merge pull request #188 from mininet/devel/fixlimits
Set sysctl limits when net starts
parents
a3879524
b635fd9e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mininet/util.py
+42
-3
42 additions, 3 deletions
mininet/util.py
util/install.sh
+0
-9
0 additions, 9 deletions
util/install.sh
with
42 additions
and
12 deletions
mininet/util.py
+
42
−
3
View file @
4e6b03d6
...
...
@@ -3,7 +3,7 @@
from
mininet.log
import
output
,
info
,
error
,
warn
from
time
import
sleep
from
resource
import
setrlimit
,
RLIMIT_NPROC
,
RLIMIT_NOFILE
from
resource
import
getrlimit
,
setrlimit
,
RLIMIT_NPROC
,
RLIMIT_NOFILE
from
select
import
poll
,
POLLIN
,
POLLHUP
from
subprocess
import
call
,
check_call
,
Popen
,
PIPE
,
STDOUT
import
re
...
...
@@ -355,11 +355,50 @@ def pmonitor(popens, timeoutms=500, readline=True,
yield
None
,
''
# Other stuff we use
def
sysctlTestAndSet
(
name
,
limit
):
"
Helper function to set sysctl limits
"
#convert non-directory names into directory names
if
'
/
'
not
in
name
:
name
=
'
/proc/sys/
'
+
name
.
replace
(
'
.
'
,
'
/
'
)
#read limit
f
=
open
(
name
,
'
r+
'
)
oldLimit
=
f
.
readline
()
if
type
(
limit
)
is
int
:
#compare integer limits before overriding
if
int
(
oldLimit
)
<
limit
:
f
.
write
(
"
%d
"
%
limit
)
else
:
#overwrite non-integer limits
f
.
write
(
limit
)
f
.
close
()
def
rlimitTestAndSet
(
name
,
limit
):
"
Helper function to set rlimits
"
soft
,
hard
=
getrlimit
(
name
)
if
soft
<
limit
:
hardLimit
=
hard
if
limit
<
hard
else
limit
setrlimit
(
name
,
(
limit
,
hardLimit
)
)
def
fixLimits
():
"
Fix ridiculously small resource limits.
"
setrlimit
(
RLIMIT_NPROC
,
(
8192
,
8192
)
)
setrlimit
(
RLIMIT_NOFILE
,
(
16384
,
16384
)
)
rlimitTestAndSet
(
RLIMIT_NPROC
,
8192
)
rlimitTestAndSet
(
RLIMIT_NOFILE
,
16384
)
#Increase open file limit
sysctlTestAndSet
(
'
fs.file-max
'
,
10000
)
#Increase network buffer space
sysctlTestAndSet
(
'
net.core.wmem_max
'
,
16777216
)
sysctlTestAndSet
(
'
net.core.rmem_max
'
,
16777216
)
sysctlTestAndSet
(
'
net.ipv4.tcp_rmem
'
,
'
10240 87380 16777216
'
)
sysctlTestAndSet
(
'
net.ipv4.tcp_wmem
'
,
'
10240 87380 16777216
'
)
sysctlTestAndSet
(
'
net.core.netdev_max_backlog
'
,
5000
)
#Increase arp cache size
sysctlTestAndSet
(
'
net.ipv4.neigh.default.gc_thresh1
'
,
4096
)
sysctlTestAndSet
(
'
net.ipv4.neigh.default.gc_thresh2
'
,
8192
)
sysctlTestAndSet
(
'
net.ipv4.neigh.default.gc_thresh3
'
,
16384
)
#Increase routing table size
sysctlTestAndSet
(
'
net.ipv4.route.max_size
'
,
32768
)
#Increase number of PTYs for nodes
sysctlTestAndSet
(
'
kernel.pty.max
'
,
20000
)
def
mountCgroups
():
"
Make sure cgroups file system is mounted
"
...
...
This diff is collapsed.
Click to expand it.
util/install.sh
+
0
−
9
View file @
4e6b03d6
...
...
@@ -144,15 +144,6 @@ function mn_deps {
python-setuptools cgroup-bin ethtool help2man
\
pyflakes pylint pep8
# Add sysctl parameters as noted in the INSTALL file to increase kernel
# limits to support larger setups:
if
!
grep
Mininet /etc/sysctl.conf
;
then
echo
"Adding Mininet sysctl settings"
sudo
su
-c
"cat
$MININET_DIR
/mininet/util/sysctl_addon >> /etc/sysctl.conf"
fi
# Load new sysctl settings:
sudo
sysctl
-p
echo
"Installing Mininet core"
pushd
$MININET_DIR
/mininet
sudo
make
install
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment