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
647d0e01
Unverified
Commit
647d0e01
authored
Mar 26, 2021
by
Christian Brauner
Committed by
GitHub
Mar 26, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3731 from samboyles1/master
network: handle name collisions when returning interfaces to host
parents
627c766c
bb301db7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
network.c
src/lxc/network.c
+14
-1
network.h
src/lxc/network.h
+1
-0
No files found.
src/lxc/network.c
View file @
647d0e01
...
@@ -3612,6 +3612,10 @@ static bool lxc_delete_network_priv(struct lxc_handler *handler)
...
@@ -3612,6 +3612,10 @@ static bool lxc_delete_network_priv(struct lxc_handler *handler)
}
}
if
(
netdev
->
type
==
LXC_NET_PHYS
)
{
if
(
netdev
->
type
==
LXC_NET_PHYS
)
{
/* Physical interfaces are initially returned to the parent namespace
* with their transient name to avoid collisions
*/
netdev
->
ifindex
=
if_nametoindex
(
netdev
->
transient_name
);
ret
=
lxc_netdev_rename_by_index
(
netdev
->
ifindex
,
netdev
->
link
);
ret
=
lxc_netdev_rename_by_index
(
netdev
->
ifindex
,
netdev
->
link
);
if
(
ret
<
0
)
if
(
ret
<
0
)
WARN
(
"Failed to rename interface with index %d "
WARN
(
"Failed to rename interface with index %d "
...
@@ -3684,6 +3688,12 @@ clear_ifindices:
...
@@ -3684,6 +3688,12 @@ clear_ifindices:
netdev
->
priv
.
veth_attr
.
veth1
[
0
]
=
'\0'
;
netdev
->
priv
.
veth_attr
.
veth1
[
0
]
=
'\0'
;
netdev
->
priv
.
veth_attr
.
ifindex
=
0
;
netdev
->
priv
.
veth_attr
.
ifindex
=
0
;
}
}
/* Clear transient name */
if
(
!
is_empty_string
(
netdev
->
transient_name
))
{
netdev
->
transient_name
[
0
]
=
'\0'
;
}
}
}
return
true
;
return
true
;
...
@@ -3761,7 +3771,10 @@ int lxc_restore_phys_nics_to_netns(struct lxc_handler *handler)
...
@@ -3761,7 +3771,10 @@ int lxc_restore_phys_nics_to_netns(struct lxc_handler *handler)
continue
;
continue
;
}
}
ret
=
lxc_netdev_move_by_index_fd
(
netdev
->
ifindex
,
oldfd
,
netdev
->
link
);
/* Restore physical interfaces to host's network namespace with its transient name
* to avoid collisions with the host's other interfaces.
*/
ret
=
lxc_netdev_move_by_index_fd
(
netdev
->
ifindex
,
oldfd
,
netdev
->
transient_name
);
if
(
ret
<
0
)
if
(
ret
<
0
)
WARN
(
"Error moving network device
\"
%s
\"
back to network namespace"
,
ifname
);
WARN
(
"Error moving network device
\"
%s
\"
back to network namespace"
,
ifname
);
else
else
...
...
src/lxc/network.h
View file @
647d0e01
...
@@ -136,6 +136,7 @@ union netdev_p {
...
@@ -136,6 +136,7 @@ union netdev_p {
* @created_name : the name with which this interface got created before
* @created_name : the name with which this interface got created before
* being renamed to final_name.
* being renamed to final_name.
* Currenly only used for veth devices.
* Currenly only used for veth devices.
* @transient_name : temporary name to avoid namespace collisions
* @hwaddr : mac address
* @hwaddr : mac address
* @mtu : maximum transmission unit
* @mtu : maximum transmission unit
* @priv : information specific to the specificed network type
* @priv : information specific to the specificed network type
...
...
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