return 0;
}
-static int lxc_attach_remount_sys_proc(void)
+int lxc_attach_remount_sys_proc(void)
{
int ret;
lxc_attach_exec_t exec_function, void *exec_payload,
lxc_attach_options_t *options, pid_t *attached_process);
+extern int lxc_attach_remount_sys_proc(void);
+
#endif /* __LXC_ATTACH_H */
{
int ret;
pid_t pid, pid_outside;
+ __do_free char *physname = NULL;
/*
* TODO - if this is a physical device, then we need am_host_unpriv.
_exit(EXIT_FAILURE);
}
+ /* create new mount namespace for use with remounting /sys and is_wlan() below. */
+ ret = unshare(CLONE_NEWNS);
+ if (ret < 0) {
+ ERROR("Failed to unshare mount namespace");
+ _exit(EXIT_FAILURE);
+ }
+
+ /* set / recursively as private so that mount propagation doesn't affect us. */
+ if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0) < 0) {
+ ERROR("Failed to recursively set / as private in mount namespace");
+ _exit(EXIT_FAILURE);
+ }
+
ret = lxc_netdev_isup(ifname);
if (ret < 0) {
ERROR("Failed to determine whether network device \"%s\" is up", ifname);
}
}
- ret = lxc_netdev_move_by_name(ifname, pid_outside, dst_ifname);
+ /* remount /sys so is_wlan() can check if this device is a wlan device. */
+ lxc_attach_remount_sys_proc();
+ physname = is_wlan(ifname);
+ if (physname)
+ ret = lxc_netdev_move_wlan(physname, ifname, pid_outside, dst_ifname);
+ else
+ ret = lxc_netdev_move_by_name(ifname, pid_outside, dst_ifname);
+
/* -EINVAL means there is no netdev named as ifname. */
if (ret < 0) {
if (ret == -EINVAL)
* will be passed to lxc_netdev_move_wlan() which will free it when done.
*/
#define PHYSNAME "/sys/class/net/%s/phy80211/name"
-static char *is_wlan(const char *ifname)
+char *is_wlan(const char *ifname)
{
__do_free char *path = NULL;
int i, ret;
_exit(lxc_netdev_rename_by_name(old, new));
}
-static int lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid,
+int lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid,
const char *newname)
{
__do_free char *cmd = NULL;
extern int lxc_netns_get_nsid(__s32 fd);
extern int lxc_create_network(struct lxc_handler *handler);
+extern char *is_wlan(const char *ifname);
+extern int lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid,
+ const char *newname);
+
#endif /* __LXC_NETWORK_H */