Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
3789f6d1
Commit
3789f6d1
authored
Jul 27, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server-side routing functions; plus some fixes
parent
25722083
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
src/netns/iproute.py
src/netns/iproute.py
+10
-7
src/netns/protocol.py
src/netns/protocol.py
+12
-5
No files found.
src/netns/iproute.py
View file @
3789f6d1
...
...
@@ -576,27 +576,30 @@ def get_all_route_data():
device = ifdata[match.group(4)]
if prefix == 'default' or re.search(r'/0$', prefix):
prefix = None
ret.append((tipe, prefix, nexthop, device))
prefix_len = 0
else:
prefix, foo, prefix_len = prefix.partition('/')
ret.append((tipe, prefix, int(prefix_len), nexthop, device))
return ret
def get_route_data():
# filter out non-unicast routes
return [x for x in get_all_route_data() if x[0] == 'unicast']
def del_route(tipe, prefix, nexthop, device):
_add_del_route('del', tipe, prefix, nexthop, device)
def del_route(tipe, prefix,
prefix_len,
nexthop, device):
_add_del_route('del', tipe, prefix,
prefix_len,
nexthop, device)
def add_route(tipe, prefix, nexthop, device):
_add_del_route('add', tipe, prefix, nexthop, device)
def add_route(tipe, prefix,
prefix_len,
nexthop, device):
_add_del_route('add', tipe, prefix,
prefix_len,
nexthop, device)
def _add_del_route(action, tipe, prefix, nexthop, device):
def _add_del_route(action, tipe, prefix,
prefix_len,
nexthop, device):
cmd = ['ip', 'route', action]
if device:
device = _get_if_name(device)
if tipe and tipe != 'unicast':
cmd += [tipe]
if prefix:
cmd += [
prefix
]
cmd += [
"
%
s
/%
d
" % (prefix, prefix_len)
]
else:
cmd += ['default']
if nexthop:
...
...
src/netns/protocol.py
View file @
3789f6d1
...
...
@@ -37,8 +37,8 @@ _proto_commands = {
},
"ROUT"
:
{
"LIST"
:
(
""
,
""
),
"ADD"
:
(
"sisi"
,
""
),
"DEL"
:
(
"sisi"
,
""
)
"ADD"
:
(
"s
s
isi"
,
""
),
"DEL"
:
(
"s
s
isi"
,
""
)
},
"PROC"
:
{
"CRTE"
:
(
"b"
,
"b*"
),
...
...
@@ -374,9 +374,16 @@ class Server(object):
netns
.
iproute
.
del_addr
(
ifnr
,
a
)
self
.
reply
(
200
,
"Done."
)
# def do_ROUT_LIST(self, cmdname):
# def do_ROUT_ADD(self, cmdname, prefix, prefixlen, nexthop, ifnr):
# def do_ROUT_DEL(self, cmdname, prefix, prefixlen, nexthop, ifnr):
def
do_ROUT_LIST
(
self
,
cmdname
):
netns
.
iproute
.
get_route_data
()
self
.
reply
(
200
,
[
"# Routing data follows."
]
+
yaml
.
dump
(
addrdata
).
split
(
"
\
n
"
))
def
do_ROUT_ADD
(
self
,
cmdname
,
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
):
netns
.
iproute
.
add_route
(
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
)
def
do_ROUT_DEL
(
self
,
cmdname
,
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
):
netns
.
iproute
.
del_route
(
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
)
# ============================================================================
#
...
...
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