Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
106
Merge Requests
106
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
e69f3905
Commit
e69f3905
authored
Oct 20, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8350a952
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
software/ors-amarisoft/k/tapsplit
software/ors-amarisoft/k/tapsplit
+12
-1
No files found.
software/ors-amarisoft/k/tapsplit
View file @
e69f3905
...
...
@@ -5,6 +5,7 @@ import netifaces
import
netaddr
from
socket
import
AF_INET6
from
math
import
log2
,
ceil
from
os.path
import
exists
import
sys
import
subprocess
...
...
@@ -16,7 +17,7 @@ def main():
assert
n
>
0
,
n
# determine tap's address, network and owner
owner
=
readfile
(
'/sys/devices/virtual/net/%s/owner'
%
tap
)
.
strip
()
owner
=
readfile
(
sysnet
(
tap
,
'owner'
)
)
.
strip
()
addr
=
None
net
=
None
prefixlen
=
None
...
...
@@ -55,10 +56,20 @@ def main():
continue
# leave this range for original tap
subtap
=
'%s-%d'
%
(
tap
,
i
)
print
(
'-> %s %s'
%
(
subtap
,
subnet
))
if
exists
(
sysnet
(
subtap
)):
run
(
'ip'
,
'link'
,
'del'
,
subtap
)
run
(
'ip'
,
'tuntap'
,
'add'
,
'dev'
,
subtap
,
'mode'
,
'tap'
,
'user'
,
owner
)
run
(
'ip'
,
'link'
,
'set'
,
subtap
,
'up'
)
# sysnet returns path on /sys corresponding to given interface.
def
sysnet
(
ifname
,
subpath
=
None
):
path
=
'/sys/devices/virtual/net/%s'
%
ifname
if
subpath
is
not
None
:
path
+=
'/'
+
subpath
return
path
def
run
(
*
argv
):
print
(
'# %s'
%
' '
.
join
(
argv
))
subprocess
.
check_call
(
argv
)
...
...
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