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
75b074ee
Unverified
Commit
75b074ee
authored
Jul 03, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: simplify instantiate_phys()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
83530dba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
network.c
src/lxc/network.c
+16
-9
No files found.
src/lxc/network.c
View file @
75b074ee
...
@@ -652,7 +652,8 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -652,7 +652,8 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
return
-
1
;
return
-
1
;
}
}
/* Note that we're retrieving the container's ifindex in the host's
/*
* Note that we're retrieving the container's ifindex in the host's
* network namespace because we need it to move the device from the
* network namespace because we need it to move the device from the
* host's network namespace to the container's network namespace later
* host's network namespace to the container's network namespace later
* on.
* on.
...
@@ -665,12 +666,16 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -665,12 +666,16 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
return
-
1
;
return
-
1
;
}
}
/* Store the ifindex of the host's network device in the host's
/*
* Store the ifindex of the host's network device in the host's
* namespace.
* namespace.
*/
*/
netdev
->
priv
.
phys_attr
.
ifindex
=
netdev
->
ifindex
;
netdev
->
priv
.
phys_attr
.
ifindex
=
netdev
->
ifindex
;
/* Get original device MTU setting and store for restoration after container shutdown. */
/*
* Get original device MTU setting and store for restoration after
* container shutdown.
*/
mtu_orig
=
netdev_get_mtu
(
netdev
->
ifindex
);
mtu_orig
=
netdev_get_mtu
(
netdev
->
ifindex
);
if
(
mtu_orig
<
0
)
{
if
(
mtu_orig
<
0
)
{
SYSERROR
(
"Failed to get original mtu for interface
\"
%s
\"
"
,
netdev
->
link
);
SYSERROR
(
"Failed to get original mtu for interface
\"
%s
\"
"
,
netdev
->
link
);
...
@@ -683,14 +688,16 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -683,14 +688,16 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
err
=
lxc_safe_uint
(
netdev
->
mtu
,
&
mtu
);
err
=
lxc_safe_uint
(
netdev
->
mtu
,
&
mtu
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
errno
=
-
err
;
errno
=
-
err
;
SYSERROR
(
"Failed to parse mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
netdev
->
link
);
SYSERROR
(
"Failed to parse mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
netdev
->
link
);
return
-
1
;
return
-
1
;
}
}
err
=
lxc_netdev_set_mtu
(
netdev
->
link
,
mtu
);
err
=
lxc_netdev_set_mtu
(
netdev
->
link
,
mtu
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
errno
=
-
err
;
errno
=
-
err
;
SYSERROR
(
"Failed to set mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
netdev
->
link
);
SYSERROR
(
"Failed to set mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
netdev
->
link
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -702,15 +709,15 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -702,15 +709,15 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
NULL
,
NULL
,
};
};
err
=
run_script_argv
(
handler
->
name
,
err
=
run_script_argv
(
handler
->
name
,
handler
->
conf
->
hooks_version
,
handler
->
conf
->
hooks_version
,
"net"
,
"net"
,
netdev
->
upscript
,
"up"
,
argv
);
netdev
->
upscript
,
"up"
,
argv
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
return
-
1
;
return
-
1
;
}
}
}
}
DEBUG
(
"Instantiated phys
\"
%s
\"
with ifindex is
\"
%d
\"
"
,
netdev
->
link
,
netdev
->
ifindex
);
DEBUG
(
"Instantiated phys
\"
%s
\"
with ifindex is
\"
%d
\"
"
,
netdev
->
link
,
netdev
->
ifindex
);
return
0
;
return
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