[systemd-commits] man/systemd-nspawn.xml src/nspawn

Lennart Poettering lennart at kemper.freedesktop.org
Thu Feb 20 19:03:44 PST 2014


 man/systemd-nspawn.xml |   18 +++++++++++-------
 src/nspawn/nspawn.c    |   11 +++++++++--
 2 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit 08af0da26935e827b58809ff1946e2f7d496e666
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Feb 21 04:02:12 2014 +0100

    nspawn: when adding a veth interface to a bridge, use the "vb-" rather than "ve-" interface name prefix
    
    This way we can recognize the interfaces later on to apply different
    host-side configuration to them.

diff --git a/man/systemd-nspawn.xml b/man/systemd-nspawn.xml
index 6518eb8..8f09c1b 100644
--- a/man/systemd-nspawn.xml
+++ b/man/systemd-nspawn.xml
@@ -321,13 +321,17 @@
                         <varlistentry>
                                 <term><option>--network-bridge=</option></term>
 
-                                <listitem><para>Adds the host side of the
-                                Ethernet link created with
-                                <option>--network-veth</option>
-                                to the specified bridge. Note that
-                                <option>--network-bridge</option>
+                                <listitem><para>Adds the host side of
+                                the Ethernet link created with
+                                <option>--network-veth</option> to the
+                                specified bridge. Note that
+                                <option>--network-bridge=</option>
                                 implies
-                                <option>--network-veth</option>.</para></listitem>
+                                <option>--network-veth</option>. If
+                                this option is used the host side of
+                                the Ethernet link will use the
+                                <literal>vb-</literal> prefix instead
+                                of <literal>ve-</literal>.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
@@ -466,7 +470,7 @@
                                 destination in the container. The
                                 <option>--bind-ro=</option> option
                                 creates read-only bind
-                                mount.</para></listitem>
+                                mounts.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 0a00903..2441758 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1302,7 +1302,7 @@ static int reset_audit_loginuid(void) {
         return 0;
 }
 
-static int setup_veth(pid_t pid, char iface_name[]) {
+static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ]) {
         _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
         _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
         int r;
@@ -1313,6 +1313,13 @@ static int setup_veth(pid_t pid, char iface_name[]) {
         if (!arg_network_veth)
                 return 0;
 
+        /* Use two different interface name prefixes depending whether
+         * we are in bridge mode or not. */
+        if (arg_network_bridge)
+                memcpy(iface_name, "vb-", 3);
+        else
+                memcpy(iface_name, "ve-", 3);
+
         strncpy(iface_name+3, arg_machine, IFNAMSIZ - 3);
 
         r = sd_rtnl_open(&rtnl, 0);
@@ -1587,7 +1594,7 @@ int main(int argc, char *argv[]) {
         int n_fd_passed;
         pid_t pid = 0;
         sigset_t mask;
-        char veth_name[IFNAMSIZ] = "ve-";
+        char veth_name[IFNAMSIZ];
 
         log_parse_environment();
         log_open();



More information about the systemd-commits mailing list