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
a1ae535a
Unverified
Commit
a1ae535a
authored
Sep 03, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: user send()/recv()
Also move all functions to network.{c,h}. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
d0fbc7ba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
78 deletions
+75
-78
conf.c
src/lxc/conf.c
+0
-37
network.c
src/lxc/network.c
+73
-4
network.h
src/lxc/network.h
+2
-0
start.c
src/lxc/start.c
+0
-37
No files found.
src/lxc/conf.c
View file @
a1ae535a
...
...
@@ -3106,43 +3106,6 @@ static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
return
ret
;
}
static
int
lxc_network_send_name_and_ifindex_to_parent
(
struct
lxc_handler
*
handler
)
{
struct
lxc_list
*
iterator
,
*
network
;
int
data_sock
=
handler
->
data_sock
[
0
];
if
(
!
handler
->
am_root
)
return
0
;
network
=
&
handler
->
conf
->
network
;
lxc_list_for_each
(
iterator
,
network
)
{
int
ret
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
/* Send network device name in the child's namespace to parent. */
ret
=
lxc_abstract_unix_send_credential
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
);
if
(
ret
<
0
)
goto
on_error
;
/* Send network device ifindex in the child's namespace to
* parent.
*/
ret
=
lxc_abstract_unix_send_credential
(
data_sock
,
&
netdev
->
ifindex
,
sizeof
(
netdev
->
ifindex
));
if
(
ret
<
0
)
goto
on_error
;
}
TRACE
(
"Sent network device names and ifindeces to parent"
);
return
0
;
on_error:
close
(
handler
->
data_sock
[
0
]);
close
(
handler
->
data_sock
[
1
]);
return
-
1
;
}
int
lxc_setup
(
struct
lxc_handler
*
handler
)
{
const
char
*
name
=
handler
->
name
;
...
...
src/lxc/network.c
View file @
a1ae535a
...
...
@@ -3009,8 +3009,7 @@ int lxc_network_send_veth_names_to_child(struct lxc_handler *handler)
if
(
netdev
->
type
!=
LXC_NET_VETH
)
continue
;
ret
=
lxc_abstract_unix_send_credential
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
);
ret
=
send
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
,
0
);
if
(
ret
<
0
)
{
close
(
handler
->
data_sock
[
0
]);
close
(
handler
->
data_sock
[
1
]);
...
...
@@ -3040,8 +3039,7 @@ int lxc_network_recv_veth_names_from_parent(struct lxc_handler *handler)
if
(
netdev
->
type
!=
LXC_NET_VETH
)
continue
;
ret
=
lxc_abstract_unix_rcv_credential
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
);
ret
=
recv
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
,
0
);
if
(
ret
<
0
)
{
close
(
handler
->
data_sock
[
0
]);
close
(
handler
->
data_sock
[
1
]);
...
...
@@ -3054,3 +3052,74 @@ int lxc_network_recv_veth_names_from_parent(struct lxc_handler *handler)
return
0
;
}
int
lxc_network_send_name_and_ifindex_to_parent
(
struct
lxc_handler
*
handler
)
{
struct
lxc_list
*
iterator
,
*
network
;
int
data_sock
=
handler
->
data_sock
[
0
];
if
(
!
handler
->
am_root
)
return
0
;
network
=
&
handler
->
conf
->
network
;
lxc_list_for_each
(
iterator
,
network
)
{
int
ret
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
/* Send network device name in the child's namespace to parent. */
ret
=
send
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
,
0
);
if
(
ret
<
0
)
goto
on_error
;
/* Send network device ifindex in the child's namespace to
* parent.
*/
ret
=
send
(
data_sock
,
&
netdev
->
ifindex
,
sizeof
(
netdev
->
ifindex
),
0
);
if
(
ret
<
0
)
goto
on_error
;
}
TRACE
(
"Sent network device names and ifindeces to parent"
);
return
0
;
on_error:
close
(
handler
->
data_sock
[
0
]);
close
(
handler
->
data_sock
[
1
]);
return
-
1
;
}
int
lxc_network_recv_name_and_ifindex_from_child
(
struct
lxc_handler
*
handler
)
{
struct
lxc_list
*
iterator
,
*
network
;
int
data_sock
=
handler
->
data_sock
[
1
];
if
(
!
handler
->
am_root
)
return
0
;
network
=
&
handler
->
conf
->
network
;
lxc_list_for_each
(
iterator
,
network
)
{
int
ret
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
/* Receive network device name in the child's namespace to
* parent.
*/
ret
=
recv
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
,
0
);
if
(
ret
<
0
)
goto
on_error
;
/* Receive network device ifindex in the child's namespace to
* parent.
*/
ret
=
recv
(
data_sock
,
&
netdev
->
ifindex
,
sizeof
(
netdev
->
ifindex
),
0
);
if
(
ret
<
0
)
goto
on_error
;
}
return
0
;
on_error:
close
(
handler
->
data_sock
[
0
]);
close
(
handler
->
data_sock
[
1
]);
return
-
1
;
}
src/lxc/network.h
View file @
a1ae535a
...
...
@@ -277,5 +277,7 @@ extern int lxc_setup_network_in_child_namespaces(const struct lxc_conf *conf,
struct
lxc_list
*
network
);
extern
int
lxc_network_send_veth_names_to_child
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_recv_veth_names_from_parent
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_send_name_and_ifindex_to_parent
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_recv_name_and_ifindex_from_child
(
struct
lxc_handler
*
handler
);
#endif
/* __LXC_NETWORK_H */
src/lxc/start.c
View file @
a1ae535a
...
...
@@ -1057,43 +1057,6 @@ out_error:
return
-
1
;
}
static
int
lxc_network_recv_name_and_ifindex_from_child
(
struct
lxc_handler
*
handler
)
{
struct
lxc_list
*
iterator
,
*
network
;
int
data_sock
=
handler
->
data_sock
[
1
];
if
(
!
handler
->
am_root
)
return
0
;
network
=
&
handler
->
conf
->
network
;
lxc_list_for_each
(
iterator
,
network
)
{
int
ret
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
/* Receive network device name in the child's namespace to
* parent.
*/
ret
=
lxc_abstract_unix_rcv_credential
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
);
if
(
ret
<
0
)
goto
on_error
;
/* Receive network device ifindex in the child's namespace to
* parent.
*/
ret
=
lxc_abstract_unix_rcv_credential
(
data_sock
,
&
netdev
->
ifindex
,
sizeof
(
netdev
->
ifindex
));
if
(
ret
<
0
)
goto
on_error
;
}
return
0
;
on_error:
close
(
handler
->
data_sock
[
0
]);
close
(
handler
->
data_sock
[
1
]);
return
-
1
;
}
static
int
lxc_recv_ttys_from_child
(
struct
lxc_handler
*
handler
)
{
int
i
;
...
...
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