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
b693b385
Commit
b693b385
authored
Mar 07, 2011
by
Daniel Lezcano
Committed by
Daniel Lezcano
Mar 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename physical device to the original name
Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
edfb9a57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
35 deletions
+31
-35
conf.c
src/lxc/conf.c
+17
-9
network.c
src/lxc/network.c
+8
-8
network.h
src/lxc/network.h
+6
-18
No files found.
src/lxc/conf.c
View file @
b693b385
...
@@ -1218,7 +1218,7 @@ static int setup_netdev(struct lxc_netdev *netdev)
...
@@ -1218,7 +1218,7 @@ static int setup_netdev(struct lxc_netdev *netdev)
/* empty network namespace */
/* empty network namespace */
if
(
!
netdev
->
ifindex
)
{
if
(
!
netdev
->
ifindex
)
{
if
(
netdev
->
flags
&
IFF_UP
)
{
if
(
netdev
->
flags
&
IFF_UP
)
{
err
=
lxc_
device
_up
(
"lo"
);
err
=
lxc_
netdev
_up
(
"lo"
);
if
(
err
)
{
if
(
err
)
{
ERROR
(
"failed to set the loopback up : %s"
,
ERROR
(
"failed to set the loopback up : %s"
,
strerror
(
-
err
));
strerror
(
-
err
));
...
@@ -1284,7 +1284,7 @@ static int setup_netdev(struct lxc_netdev *netdev)
...
@@ -1284,7 +1284,7 @@ static int setup_netdev(struct lxc_netdev *netdev)
if
(
netdev
->
flags
&
IFF_UP
)
{
if
(
netdev
->
flags
&
IFF_UP
)
{
int
err
;
int
err
;
err
=
lxc_
device
_up
(
current_ifname
);
err
=
lxc_
netdev
_up
(
current_ifname
);
if
(
err
)
{
if
(
err
)
{
ERROR
(
"failed to set '%s' up : %s"
,
current_ifname
,
ERROR
(
"failed to set '%s' up : %s"
,
current_ifname
,
strerror
(
-
err
));
strerror
(
-
err
));
...
@@ -1292,7 +1292,7 @@ static int setup_netdev(struct lxc_netdev *netdev)
...
@@ -1292,7 +1292,7 @@ static int setup_netdev(struct lxc_netdev *netdev)
}
}
/* the network is up, make the loopback up too */
/* the network is up, make the loopback up too */
err
=
lxc_
device
_up
(
"lo"
);
err
=
lxc_
netdev
_up
(
"lo"
);
if
(
err
)
{
if
(
err
)
{
ERROR
(
"failed to set the loopback up : %s"
,
ERROR
(
"failed to set the loopback up : %s"
,
strerror
(
-
err
));
strerror
(
-
err
));
...
@@ -1381,9 +1381,9 @@ static int instanciate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -1381,9 +1381,9 @@ static int instanciate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
}
}
if
(
netdev
->
mtu
)
{
if
(
netdev
->
mtu
)
{
err
=
lxc_
device
_set_mtu
(
veth1
,
atoi
(
netdev
->
mtu
));
err
=
lxc_
netdev
_set_mtu
(
veth1
,
atoi
(
netdev
->
mtu
));
if
(
!
err
)
if
(
!
err
)
err
=
lxc_
device
_set_mtu
(
veth2
,
atoi
(
netdev
->
mtu
));
err
=
lxc_
netdev
_set_mtu
(
veth2
,
atoi
(
netdev
->
mtu
));
if
(
err
)
{
if
(
err
)
{
ERROR
(
"failed to set mtu '%s' for %s-%s : %s"
,
ERROR
(
"failed to set mtu '%s' for %s-%s : %s"
,
netdev
->
mtu
,
veth1
,
veth2
,
strerror
(
-
err
));
netdev
->
mtu
,
veth1
,
veth2
,
strerror
(
-
err
));
...
@@ -1406,7 +1406,7 @@ static int instanciate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -1406,7 +1406,7 @@ static int instanciate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
goto
out_delete
;
goto
out_delete
;
}
}
err
=
lxc_
device
_up
(
veth1
);
err
=
lxc_
netdev
_up
(
veth1
);
if
(
err
)
{
if
(
err
)
{
ERROR
(
"failed to set %s up : %s"
,
veth1
,
strerror
(
-
err
));
ERROR
(
"failed to set %s up : %s"
,
veth1
,
strerror
(
-
err
));
goto
out_delete
;
goto
out_delete
;
...
@@ -1578,8 +1578,16 @@ void lxc_delete_network(struct lxc_list *network)
...
@@ -1578,8 +1578,16 @@ void lxc_delete_network(struct lxc_list *network)
lxc_list_for_each
(
iterator
,
network
)
{
lxc_list_for_each
(
iterator
,
network
)
{
netdev
=
iterator
->
elem
;
netdev
=
iterator
->
elem
;
if
(
netdev
->
ifindex
>
0
&&
netdev
->
type
!=
LXC_NET_PHYS
)
if
(
netdev
->
ifindex
==
0
)
lxc_netdev_delete_by_index
(
netdev
->
ifindex
);
continue
;
/* Recent kernels already delete the virtual devices */
if
(
netdev
->
type
!=
LXC_NET_PHYS
)
continue
;
if
(
lxc_netdev_rename_by_index
(
netdev
->
ifindex
,
netdev
->
link
))
WARN
(
"failed to rename to the initial name the netdev '%s'"
,
netdev
->
link
);
}
}
}
}
...
@@ -1597,7 +1605,7 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
...
@@ -1597,7 +1605,7 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
if
(
!
netdev
->
ifindex
)
if
(
!
netdev
->
ifindex
)
continue
;
continue
;
err
=
lxc_
device_move
(
netdev
->
ifindex
,
pid
);
err
=
lxc_
netdev_move_by_index
(
netdev
->
ifindex
,
pid
);
if
(
err
)
{
if
(
err
)
{
ERROR
(
"failed to move '%s' to the container : %s"
,
ERROR
(
"failed to move '%s' to the container : %s"
,
netdev
->
link
,
strerror
(
-
err
));
netdev
->
link
,
strerror
(
-
err
));
...
...
src/lxc/network.c
View file @
b693b385
...
@@ -89,7 +89,7 @@ struct ip_req {
...
@@ -89,7 +89,7 @@ struct ip_req {
struct
ifaddrmsg
ifa
;
struct
ifaddrmsg
ifa
;
};
};
int
lxc_
device_move
(
int
ifindex
,
pid_t
pid
)
int
lxc_
netdev_move_by_index
(
int
ifindex
,
pid_t
pid
)
{
{
struct
nl_handler
nlh
;
struct
nl_handler
nlh
;
struct
nlmsg
*
nlmsg
=
NULL
;
struct
nlmsg
*
nlmsg
=
NULL
;
...
@@ -225,7 +225,7 @@ int lxc_netdev_rename_by_name(const char *oldname, const char *newname)
...
@@ -225,7 +225,7 @@ int lxc_netdev_rename_by_name(const char *oldname, const char *newname)
return
lxc_netdev_rename_by_index
(
index
,
newname
);
return
lxc_netdev_rename_by_index
(
index
,
newname
);
}
}
static
int
device
_set_flag
(
const
char
*
name
,
int
flag
)
static
int
netdev
_set_flag
(
const
char
*
name
,
int
flag
)
{
{
struct
nl_handler
nlh
;
struct
nl_handler
nlh
;
struct
nlmsg
*
nlmsg
=
NULL
,
*
answer
=
NULL
;
struct
nlmsg
*
nlmsg
=
NULL
,
*
answer
=
NULL
;
...
@@ -272,7 +272,7 @@ out:
...
@@ -272,7 +272,7 @@ out:
return
err
;
return
err
;
}
}
int
lxc_
device
_set_mtu
(
const
char
*
name
,
int
mtu
)
int
lxc_
netdev
_set_mtu
(
const
char
*
name
,
int
mtu
)
{
{
struct
nl_handler
nlh
;
struct
nl_handler
nlh
;
struct
nlmsg
*
nlmsg
=
NULL
,
*
answer
=
NULL
;
struct
nlmsg
*
nlmsg
=
NULL
,
*
answer
=
NULL
;
...
@@ -320,14 +320,14 @@ out:
...
@@ -320,14 +320,14 @@ out:
return
err
;
return
err
;
}
}
int
lxc_
device
_up
(
const
char
*
name
)
int
lxc_
netdev
_up
(
const
char
*
name
)
{
{
return
device
_set_flag
(
name
,
IFF_UP
);
return
netdev
_set_flag
(
name
,
IFF_UP
);
}
}
int
lxc_
device
_down
(
const
char
*
name
)
int
lxc_
netdev
_down
(
const
char
*
name
)
{
{
return
device
_set_flag
(
name
,
0
);
return
netdev
_set_flag
(
name
,
0
);
}
}
int
lxc_veth_create
(
const
char
*
name1
,
const
char
*
name2
)
int
lxc_veth_create
(
const
char
*
name1
,
const
char
*
name2
)
...
@@ -743,7 +743,7 @@ int lxc_ipv4_addr_add(int ifindex, struct in_addr *addr,
...
@@ -743,7 +743,7 @@ int lxc_ipv4_addr_add(int ifindex, struct in_addr *addr,
/*
/*
* There is a lxc_bridge_attach, but no need of a bridge detach
* There is a lxc_bridge_attach, but no need of a bridge detach
* as automatically done by kernel when
device
deleted.
* as automatically done by kernel when
a netdev is
deleted.
*/
*/
int
lxc_bridge_attach
(
const
char
*
bridge
,
const
char
*
ifname
)
int
lxc_bridge_attach
(
const
char
*
bridge
,
const
char
*
ifname
)
{
{
...
...
src/lxc/network.h
View file @
b693b385
...
@@ -31,7 +31,7 @@ extern int lxc_convert_mac(char *macaddr, struct sockaddr *sockaddr);
...
@@ -31,7 +31,7 @@ extern int lxc_convert_mac(char *macaddr, struct sockaddr *sockaddr);
/*
/*
* Move a device between namespaces
* Move a device between namespaces
*/
*/
extern
int
lxc_
device_move
(
int
ifindex
,
pid_t
pid
);
extern
int
lxc_
netdev_move_by_index
(
int
ifindex
,
pid_t
pid
);
/*
/*
* Delete a network device
* Delete a network device
...
@@ -46,33 +46,21 @@ extern int lxc_netdev_rename_by_name(const char *oldname, const char *newname);
...
@@ -46,33 +46,21 @@ extern int lxc_netdev_rename_by_name(const char *oldname, const char *newname);
extern
int
lxc_netdev_rename_by_index
(
int
ifindex
,
const
char
*
newname
);
extern
int
lxc_netdev_rename_by_index
(
int
ifindex
,
const
char
*
newname
);
/*
/*
* Set the device network up
* Set the device network up
or down
*/
*/
extern
int
lxc_device_up
(
const
char
*
name
);
extern
int
lxc_netdev_up
(
const
char
*
name
);
extern
int
lxc_netdev_down
(
const
char
*
name
);
/*
* Set the device network down
*/
extern
int
lxc_device_down
(
const
char
*
name
);
/*
/*
* Change the mtu size for the specified device
* Change the mtu size for the specified device
*/
*/
extern
int
lxc_
device
_set_mtu
(
const
char
*
name
,
int
mtu
);
extern
int
lxc_
netdev
_set_mtu
(
const
char
*
name
,
int
mtu
);
/*
/*
* Create a v
eth network device
* Create a v
irtual network devices
*/
*/
extern
int
lxc_veth_create
(
const
char
*
name1
,
const
char
*
name2
);
extern
int
lxc_veth_create
(
const
char
*
name1
,
const
char
*
name2
);
/*
* Create a macvlan network device
*/
extern
int
lxc_macvlan_create
(
const
char
*
master
,
const
char
*
name
,
int
mode
);
extern
int
lxc_macvlan_create
(
const
char
*
master
,
const
char
*
name
,
int
mode
);
/*
* Create a vlan network device
*/
extern
int
lxc_vlan_create
(
const
char
*
master
,
const
char
*
name
,
ushort
vid
);
extern
int
lxc_vlan_create
(
const
char
*
master
,
const
char
*
name
,
ushort
vid
);
/*
/*
...
...
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