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
cb0dc11b
Unverified
Commit
cb0dc11b
authored
Aug 23, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: log cleanup thread pid for openswitch
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
dae8c253
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
34 deletions
+48
-34
network.c
src/lxc/network.c
+48
-34
No files found.
src/lxc/network.c
View file @
cb0dc11b
...
@@ -20,35 +20,36 @@
...
@@ -20,35 +20,36 @@
* License along with this library; if not, write to the Free Software
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#define _GNU_SOURCE
#include "config.h"
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdio.h>
#undef _GNU_SOURCe
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/inotify.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <netinet/in.h>
#include <linux/netlink.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/rtnetlink.h>
#include <linux/sockios.h>
#include <linux/sockios.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <netinet/in.h>
#include <sys/inotify.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "nl.h"
#include "network.h"
#include "conf.h"
#include "conf.h"
#include "log.h"
#include "network.h"
#include "nl.h"
#include "utils.h"
#include "utils.h"
#if HAVE_IFADDRS_H
#if HAVE_IFADDRS_H
...
@@ -58,37 +59,38 @@
...
@@ -58,37 +59,38 @@
#endif
#endif
#ifndef IFLA_LINKMODE
#ifndef IFLA_LINKMODE
#
define IFLA_LINKMODE 17
#define IFLA_LINKMODE 17
#endif
#endif
#ifndef IFLA_LINKINFO
#ifndef IFLA_LINKINFO
#
define IFLA_LINKINFO 18
#define IFLA_LINKINFO 18
#endif
#endif
#ifndef IFLA_NET_NS_PID
#ifndef IFLA_NET_NS_PID
#
define IFLA_NET_NS_PID 19
#define IFLA_NET_NS_PID 19
#endif
#endif
#ifndef IFLA_INFO_KIND
#ifndef IFLA_INFO_KIND
#
define IFLA_INFO_KIND 1
#define IFLA_INFO_KIND 1
#endif
#endif
#ifndef IFLA_VLAN_ID
#ifndef IFLA_VLAN_ID
#
define IFLA_VLAN_ID 1
#define IFLA_VLAN_ID 1
#endif
#endif
#ifndef IFLA_INFO_DATA
#ifndef IFLA_INFO_DATA
#
define IFLA_INFO_DATA 2
#define IFLA_INFO_DATA 2
#endif
#endif
#ifndef VETH_INFO_PEER
#ifndef VETH_INFO_PEER
#
define VETH_INFO_PEER 1
#define VETH_INFO_PEER 1
#endif
#endif
#ifndef IFLA_MACVLAN_MODE
#ifndef IFLA_MACVLAN_MODE
#
define IFLA_MACVLAN_MODE 1
#define IFLA_MACVLAN_MODE 1
#endif
#endif
lxc_log_define
(
lxc_network
,
lxc
);
int
lxc_netdev_move_by_index
(
int
ifindex
,
pid_t
pid
,
const
char
*
ifname
)
int
lxc_netdev_move_by_index
(
int
ifindex
,
pid_t
pid
,
const
char
*
ifname
)
{
{
...
@@ -1404,18 +1406,30 @@ static bool is_ovs_bridge(const char *bridge)
...
@@ -1404,18 +1406,30 @@ static bool is_ovs_bridge(const char *bridge)
return
false
;
return
false
;
}
}
/*
/* Called from a background thread - when nic goes away, remove it from the
* Called from a background thread - when nic goes away, remove
* bridge.
* it from the bridge
*/
*/
static
void
ovs_cleanup_nic
(
const
char
*
lxcpath
,
const
char
*
name
,
const
char
*
bridge
,
const
char
*
nic
)
static
void
ovs_cleanup_nic
(
const
char
*
lxcpath
,
const
char
*
name
,
const
char
*
bridge
,
const
char
*
nic
)
{
{
if
(
lxc_check_inherited
(
NULL
,
true
,
&
(
int
){
-
1
},
1
)
<
0
)
int
ret
;
ret
=
lxc_check_inherited
(
NULL
,
true
,
&
(
int
){
-
1
},
1
);
if
(
ret
<
0
)
return
;
return
;
if
(
lxc_wait
(
name
,
"STOPPED"
,
-
1
,
lxcpath
)
<
0
)
TRACE
(
"Registering cleanup thread to remove nic
\"
%s
\"
from "
"openvswitch bridge
\"
%s
\"
"
,
nic
,
bridge
);
ret
=
lxc_wait
(
name
,
"STOPPED"
,
-
1
,
lxcpath
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to register cleanup thread to remove nic
\"
%s
\"
"
"from openvswitch bridge
\"
%s
\"
"
,
nic
,
bridge
);
return
;
return
;
}
execlp
(
"ovs-vsctl"
,
"ovs-vsctl"
,
"del-port"
,
bridge
,
nic
,
(
char
*
)
NULL
);
execlp
(
"ovs-vsctl"
,
"ovs-vsctl"
,
"del-port"
,
bridge
,
nic
,
(
char
*
)
NULL
);
exit
(
1
);
/* not reached */
exit
(
EXIT_FAILURE
);
}
}
static
int
attach_to_ovs_bridge
(
const
char
*
lxcpath
,
const
char
*
name
,
const
char
*
bridge
,
const
char
*
nic
)
static
int
attach_to_ovs_bridge
(
const
char
*
lxcpath
,
const
char
*
name
,
const
char
*
bridge
,
const
char
*
nic
)
...
...
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