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
b9a5bb58
Commit
b9a5bb58
authored
Feb 25, 2010
by
Daniel Lezcano
Committed by
Daniel Lezcano
Feb 25, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete network devices by index
Add a function to delete the network device by its index. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
6a3111b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
network.c
src/lxc/network.c
+36
-0
network.h
src/lxc/network.h
+5
-0
No files found.
src/lxc/network.c
View file @
b9a5bb58
...
@@ -170,6 +170,42 @@ out:
...
@@ -170,6 +170,42 @@ out:
return
err
;
return
err
;
}
}
int
lxc_device_delete_index
(
int
ifindex
)
{
struct
nl_handler
nlh
;
struct
nlmsg
*
nlmsg
=
NULL
,
*
answer
=
NULL
;
struct
link_req
*
link_req
;
int
err
=
-
1
;
if
(
netlink_open
(
&
nlh
,
NETLINK_ROUTE
))
return
-
1
;
nlmsg
=
nlmsg_alloc
(
NLMSG_GOOD_SIZE
);
if
(
!
nlmsg
)
goto
out
;
answer
=
nlmsg_alloc
(
NLMSG_GOOD_SIZE
);
if
(
!
answer
)
goto
out
;
link_req
=
(
struct
link_req
*
)
nlmsg
;
link_req
->
ifinfomsg
.
ifi_family
=
AF_UNSPEC
;
link_req
->
ifinfomsg
.
ifi_index
=
ifindex
;
nlmsg
->
nlmsghdr
.
nlmsg_len
=
NLMSG_LENGTH
(
sizeof
(
struct
ifinfomsg
));
nlmsg
->
nlmsghdr
.
nlmsg_flags
=
NLM_F_ACK
|
NLM_F_REQUEST
;
nlmsg
->
nlmsghdr
.
nlmsg_type
=
RTM_DELLINK
;
if
(
netlink_transaction
(
&
nlh
,
nlmsg
,
answer
))
goto
out
;
err
=
0
;
out:
netlink_close
(
&
nlh
);
nlmsg_free
(
answer
);
nlmsg_free
(
nlmsg
);
return
err
;
}
static
int
device_set_flag
(
const
char
*
name
,
int
flag
)
static
int
device_set_flag
(
const
char
*
name
,
int
flag
)
{
{
struct
nl_handler
nlh
;
struct
nl_handler
nlh
;
...
...
src/lxc/network.h
View file @
b9a5bb58
...
@@ -39,6 +39,11 @@ extern int lxc_device_move(int ifindex, pid_t pid);
...
@@ -39,6 +39,11 @@ extern int lxc_device_move(int ifindex, pid_t pid);
extern
int
lxc_device_delete
(
const
char
*
name
);
extern
int
lxc_device_delete
(
const
char
*
name
);
/*
/*
* Delete a network device by the index
*/
extern
int
lxc_device_delete_index
(
int
ifindex
);
/*
* Set the device network up
* Set the device network up
*/
*/
extern
int
lxc_device_up
(
const
char
*
name
);
extern
int
lxc_device_up
(
const
char
*
name
);
...
...
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