Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
9d036caa
Unverified
Commit
9d036caa
authored
Sep 13, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: minor tweaks
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
938980ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
network.c
src/lxc/network.c
+19
-10
No files found.
src/lxc/network.c
View file @
9d036caa
...
...
@@ -3171,6 +3171,7 @@ int addattr(struct nlmsghdr *n, size_t maxlen, int type, const void *data, size_
int
len
=
RTA_LENGTH
(
alen
);
struct
rtattr
*
rta
;
errno
=
EMSGSIZE
;
if
(
NLMSG_ALIGN
(
n
->
nlmsg_len
)
+
RTA_ALIGN
(
len
)
>
maxlen
)
return
-
1
;
...
...
@@ -3204,8 +3205,8 @@ int lxc_netns_set_nsid(int fd)
struct
nlmsghdr
*
hdr
;
struct
rtgenmsg
*
msg
;
int
saved_errno
;
__s32
ns_id
=
-
1
;
__u32
netns_fd
=
fd
;
const
__s32
ns_id
=
-
1
;
const
__u32
netns_fd
=
fd
;
ret
=
netlink_open
(
&
nlh
,
NETLINK_ROUTE
);
if
(
ret
<
0
)
...
...
@@ -3222,17 +3223,22 @@ int lxc_netns_set_nsid(int fd)
hdr
->
nlmsg_seq
=
RTM_NEWNSID
;
msg
->
rtgen_family
=
AF_UNSPEC
;
addattr
(
hdr
,
1024
,
__LXC_NETNSA_FD
,
&
netns_fd
,
sizeof
(
netns_fd
));
addattr
(
hdr
,
1024
,
__LXC_NETNSA_NSID
,
&
ns_id
,
sizeof
(
ns_id
));
ret
=
addattr
(
hdr
,
1024
,
__LXC_NETNSA_FD
,
&
netns_fd
,
sizeof
(
netns_fd
));
if
(
ret
<
0
)
goto
on_error
;
ret
=
addattr
(
hdr
,
1024
,
__LXC_NETNSA_NSID
,
&
ns_id
,
sizeof
(
ns_id
));
if
(
ret
<
0
)
goto
on_error
;
ret
=
__netlink_transaction
(
&
nlh
,
hdr
,
hdr
);
on_error:
saved_errno
=
errno
;
netlink_close
(
&
nlh
);
errno
=
saved_errno
;
if
(
ret
<
0
)
return
-
1
;
return
0
;
return
ret
;
}
static
int
parse_rtattr
(
struct
rtattr
*
tb
[],
int
max
,
struct
rtattr
*
rta
,
int
len
)
...
...
@@ -3267,7 +3273,8 @@ int lxc_netns_get_nsid(int fd)
int
ret
;
ssize_t
len
;
char
buf
[
NLMSG_ALIGN
(
sizeof
(
struct
nlmsghdr
))
+
NLMSG_ALIGN
(
sizeof
(
struct
rtgenmsg
))
+
NLMSG_ALIGN
(
1024
)];
NLMSG_ALIGN
(
sizeof
(
struct
rtgenmsg
))
+
NLMSG_ALIGN
(
1024
)];
struct
rtattr
*
tb
[
__LXC_NETNSA_MAX
+
1
];
struct
nl_handler
nlh
;
struct
nlmsghdr
*
hdr
;
...
...
@@ -3290,15 +3297,17 @@ int lxc_netns_get_nsid(int fd)
hdr
->
nlmsg_seq
=
RTM_GETNSID
;
msg
->
rtgen_family
=
AF_UNSPEC
;
addattr
(
hdr
,
1024
,
__LXC_NETNSA_FD
,
&
netns_fd
,
sizeof
(
netns_fd
));
ret
=
addattr
(
hdr
,
1024
,
__LXC_NETNSA_FD
,
&
netns_fd
,
sizeof
(
netns_fd
));
if
(
ret
==
0
)
ret
=
__netlink_transaction
(
&
nlh
,
hdr
,
hdr
);
ret
=
__netlink_transaction
(
&
nlh
,
hdr
,
hdr
);
saved_errno
=
errno
;
netlink_close
(
&
nlh
);
errno
=
saved_errno
;
if
(
ret
<
0
)
return
-
1
;
errno
=
EINVAL
;
msg
=
NLMSG_DATA
(
hdr
);
len
=
hdr
->
nlmsg_len
-
NLMSG_SPACE
(
sizeof
(
*
msg
));
if
(
len
<
0
)
...
...
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