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
9e195036
Unverified
Commit
9e195036
authored
May 10, 2019
by
Christian Brauner
Committed by
GitHub
May 10, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2985 from tomponline/tp-mtu
network: Adds mtu support for phys and macvlan types
parents
70aa3c7f
bc999107
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
13 deletions
+78
-13
api-extensions.md
doc/api-extensions.md
+5
-0
api_extensions.h
src/lxc/api_extensions.h
+1
-0
network.c
src/lxc/network.c
+71
-13
network.h
src/lxc/network.h
+1
-0
No files found.
doc/api-extensions.md
View file @
9e195036
...
@@ -91,3 +91,8 @@ This introduces the ability to specify `lxc.net.[i].ipv4.gateway` and/or
...
@@ -91,3 +91,8 @@ This introduces the ability to specify `lxc.net.[i].ipv4.gateway` and/or
`lxc.net.[i].ipv6.gateway`
with a value of
`dev`
which will cause the default gateway
`lxc.net.[i].ipv6.gateway`
with a value of
`dev`
which will cause the default gateway
inside the container to be created as a device route without destination gateway IP needed.
inside the container to be created as a device route without destination gateway IP needed.
This is primarily intended for use with layer 3 networking devices, such as IPVLAN.
This is primarily intended for use with layer 3 networking devices, such as IPVLAN.
## network\_phys\_macvlan\_mtu
This introduces the ability to specify a custom MTU for
`phys`
and
`macvlan`
devices using the
`lxc.net.[i].mtu`
property.
src/lxc/api_extensions.h
View file @
9e195036
...
@@ -48,6 +48,7 @@ static char *api_extensions[] = {
...
@@ -48,6 +48,7 @@ static char *api_extensions[] = {
"network_ipvlan"
,
"network_ipvlan"
,
"network_l2proxy"
,
"network_l2proxy"
,
"network_gateway_device_route"
,
"network_gateway_device_route"
,
"network_phys_macvlan_mtu"
,
};
};
static
size_t
nr_api_extensions
=
sizeof
(
api_extensions
)
/
sizeof
(
*
api_extensions
);
static
size_t
nr_api_extensions
=
sizeof
(
api_extensions
)
/
sizeof
(
*
api_extensions
);
...
...
src/lxc/network.c
View file @
9e195036
...
@@ -334,6 +334,7 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
...
@@ -334,6 +334,7 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
{
{
char
peerbuf
[
IFNAMSIZ
],
*
peer
;
char
peerbuf
[
IFNAMSIZ
],
*
peer
;
int
err
;
int
err
;
unsigned
int
mtu
=
0
;
if
(
netdev
->
link
[
0
]
==
'\0'
)
{
if
(
netdev
->
link
[
0
]
==
'\0'
)
{
ERROR
(
"No link for macvlan network device specified"
);
ERROR
(
"No link for macvlan network device specified"
);
...
@@ -363,6 +364,22 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
...
@@ -363,6 +364,22 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
goto
on_error
;
goto
on_error
;
}
}
if
(
netdev
->
mtu
)
{
err
=
lxc_safe_uint
(
netdev
->
mtu
,
&
mtu
);
if
(
err
<
0
)
{
errno
=
-
err
;
SYSERROR
(
"Failed to parse mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
peer
);
goto
on_error
;
}
err
=
lxc_netdev_set_mtu
(
peer
,
mtu
);
if
(
err
<
0
)
{
errno
=
-
err
;
SYSERROR
(
"Failed to set mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
peer
);
goto
on_error
;
}
}
if
(
netdev
->
upscript
)
{
if
(
netdev
->
upscript
)
{
char
*
argv
[]
=
{
char
*
argv
[]
=
{
"macvlan"
,
"macvlan"
,
...
@@ -606,7 +623,7 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -606,7 +623,7 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
}
}
}
}
DEBUG
(
"Instantiated vlan
\"
%s
\"
with ifindex is
\"
%d
\"
(vlan1000)
"
,
DEBUG
(
"Instantiated vlan
\"
%s
\"
with ifindex is
\"
%d
\"
"
,
peer
,
netdev
->
ifindex
);
peer
,
netdev
->
ifindex
);
return
0
;
return
0
;
...
@@ -618,12 +635,8 @@ on_error:
...
@@ -618,12 +635,8 @@ on_error:
static
int
instantiate_phys
(
struct
lxc_handler
*
handler
,
struct
lxc_netdev
*
netdev
)
static
int
instantiate_phys
(
struct
lxc_handler
*
handler
,
struct
lxc_netdev
*
netdev
)
{
{
int
ret
;
int
err
,
mtu_orig
=
0
;
char
*
argv
[]
=
{
unsigned
int
mtu
=
0
;
"phys"
,
netdev
->
link
,
NULL
,
};
if
(
netdev
->
link
[
0
]
==
'\0'
)
{
if
(
netdev
->
link
[
0
]
==
'\0'
)
{
ERROR
(
"No link for physical interface specified"
);
ERROR
(
"No link for physical interface specified"
);
...
@@ -648,13 +661,47 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -648,13 +661,47 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
*/
*/
netdev
->
priv
.
phys_attr
.
ifindex
=
netdev
->
ifindex
;
netdev
->
priv
.
phys_attr
.
ifindex
=
netdev
->
ifindex
;
if
(
!
netdev
->
upscript
)
/* Get original device MTU setting and store for restoration after container shutdown. */
return
0
;
mtu_orig
=
netdev_get_mtu
(
netdev
->
ifindex
);
if
(
mtu_orig
<
0
)
{
SYSERROR
(
"Failed to get original mtu for interface
\"
%s
\"
"
,
netdev
->
link
);
return
minus_one_set_errno
(
-
mtu_orig
);
}
ret
=
run_script_argv
(
handler
->
name
,
handler
->
conf
->
hooks_version
,
netdev
->
priv
.
phys_attr
.
mtu
=
mtu_orig
;
"net"
,
netdev
->
upscript
,
"up"
,
argv
);
if
(
ret
<
0
)
if
(
netdev
->
mtu
)
{
err
=
lxc_safe_uint
(
netdev
->
mtu
,
&
mtu
);
if
(
err
<
0
)
{
errno
=
-
err
;
SYSERROR
(
"Failed to parse mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
netdev
->
link
);
return
-
1
;
}
err
=
lxc_netdev_set_mtu
(
netdev
->
link
,
mtu
);
if
(
err
<
0
)
{
errno
=
-
err
;
SYSERROR
(
"Failed to set mtu
\"
%s
\"
for interface
\"
%s
\"
"
,
netdev
->
mtu
,
netdev
->
link
);
return
-
1
;
}
}
if
(
netdev
->
upscript
)
{
char
*
argv
[]
=
{
"phys"
,
netdev
->
link
,
NULL
,
};
err
=
run_script_argv
(
handler
->
name
,
handler
->
conf
->
hooks_version
,
"net"
,
netdev
->
upscript
,
"up"
,
argv
);
if
(
err
<
0
)
{
return
-
1
;
return
-
1
;
}
}
DEBUG
(
"Instantiated phys
\"
%s
\"
with ifindex is
\"
%d
\"
"
,
netdev
->
link
,
netdev
->
ifindex
);
return
0
;
return
0
;
}
}
...
@@ -3121,11 +3168,22 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
...
@@ -3121,11 +3168,22 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
WARN
(
"Failed to rename interface with index %d "
WARN
(
"Failed to rename interface with index %d "
"from
\"
%s
\"
to its initial name
\"
%s
\"
"
,
"from
\"
%s
\"
to its initial name
\"
%s
\"
"
,
netdev
->
ifindex
,
netdev
->
name
,
netdev
->
link
);
netdev
->
ifindex
,
netdev
->
name
,
netdev
->
link
);
else
else
{
TRACE
(
"Renamed interface with index %d from "
TRACE
(
"Renamed interface with index %d from "
"
\"
%s
\"
to its initial name
\"
%s
\"
"
,
"
\"
%s
\"
to its initial name
\"
%s
\"
"
,
netdev
->
ifindex
,
netdev
->
name
,
netdev
->
ifindex
,
netdev
->
name
,
netdev
->
link
);
netdev
->
link
);
/* Restore original MTU */
ret
=
lxc_netdev_set_mtu
(
netdev
->
link
,
netdev
->
priv
.
phys_attr
.
mtu
);
if
(
ret
<
0
)
{
WARN
(
"Failed to set interface
\"
%s
\"
to its initial mtu
\"
%d
\"
"
,
netdev
->
link
,
netdev
->
priv
.
phys_attr
.
mtu
);
}
else
{
TRACE
(
"Restored interface
\"
%s
\"
to its initial mtu
\"
%d
\"
"
,
netdev
->
link
,
netdev
->
priv
.
phys_attr
.
mtu
);
}
}
goto
clear_ifindices
;
goto
clear_ifindices
;
}
}
...
...
src/lxc/network.h
View file @
9e195036
...
@@ -122,6 +122,7 @@ struct ifla_ipvlan {
...
@@ -122,6 +122,7 @@ struct ifla_ipvlan {
*/
*/
struct
ifla_phys
{
struct
ifla_phys
{
int
ifindex
;
int
ifindex
;
int
mtu
;
};
};
union
netdev_p
{
union
netdev_p
{
...
...
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