int bytes, pipefd[2];
char *token, *saveptr = NULL;
char buffer[MAX_BUFFER_SIZE];
+ char netdev_link[IFNAMSIZ+1];
if (netdev->type != LXC_NET_VETH) {
ERROR("nic type %d not support for unprivileged use",
// Call lxc-user-nic pid type bridge
char pidstr[20];
- char *args[] = {LXC_USERNIC_PATH, pidstr, "veth", netdev->link, netdev->name, NULL };
+ if (netdev->link) {
+ strncpy(netdev_link, netdev->link, IFNAMSIZ);
+ } else {
+ strncpy(netdev_link, "none", IFNAMSIZ);
+ }
+ char *args[] = {LXC_USERNIC_PATH, pidstr, "veth", netdev_link, netdev->name, NULL };
snprintf(pidstr, 19, "%lu", (unsigned long) pid);
pidstr[19] = '\0';
execvp(args[0], args);
int ret;
struct stat sb;
+ if (strcmp(nic, "none") == 0)
+ return true;
ret = snprintf(path, MAXPATHLEN, "/sys/class/net/%s", nic);
if (ret < 0 || ret >= MAXPATHLEN) // should never happen!
return false;
return false;
}
- /* copy the bridge's mtu to both ends */
- mtu = get_mtu(br);
- if (mtu != -1) {
- if (lxc_netdev_set_mtu(veth1buf, mtu) < 0 ||
- lxc_netdev_set_mtu(veth2buf, mtu) < 0) {
- fprintf(stderr, "Failed setting mtu\n");
- goto out_del;
+ if (strcmp(br, "none") != 0) {
+ /* copy the bridge's mtu to both ends */
+ mtu = get_mtu(br);
+ if (mtu != -1) {
+ if (lxc_netdev_set_mtu(veth1buf, mtu) < 0 ||
+ lxc_netdev_set_mtu(veth2buf, mtu) < 0) {
+ fprintf(stderr, "Failed setting mtu\n");
+ goto out_del;
+ }
}
- }
- /* attach veth1 to bridge */
- if (lxc_bridge_attach(br, veth1buf) < 0) {
- fprintf(stderr, "Error attaching %s to %s\n", veth1buf, br);
- goto out_del;
+ /* attach veth1 to bridge */
+ if (lxc_bridge_attach(br, veth1buf) < 0) {
+ fprintf(stderr, "Error attaching %s to %s\n", veth1buf, br);
+ goto out_del;
+ }
}
/* pass veth2 to target netns */