]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
macvlan/macvtap: support 'passthru' mode
authorSridhar Samudrala <sri@us.ibm.com>
Thu, 17 Mar 2011 00:01:58 +0000 (17:01 -0700)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Thu, 17 Mar 2011 00:01:58 +0000 (17:01 -0700)
Add support for 'passthru' mode when creating a macvlan/macvtap device
which allows takeover of the underlying device and passing it to a KVM
guest using virtio with macvtap backend.

Only one macvlan device is allowed in passthru mode and it inherits
the mac address from the underlying device and sets it in promiscuous
mode to receive and forward all the packets.

Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
ip/iplink_macvlan.c
ip/iplink_macvtap.c

index a3c78bd806caf5b7f695b274406703096f6761a5..15022aa9cced2cf0bd0cdf972b00c82a7752ad25 100644 (file)
 static void explain(void)
 {
        fprintf(stderr,
-               "Usage: ... macvlan mode { private | vepa | bridge }\n"
+               "Usage: ... macvlan mode { private | vepa | bridge | passthru }\n"
        );
 }
 
 static int mode_arg(void)
 {
         fprintf(stderr, "Error: argument of \"mode\" must be \"private\", "
-               "\"vepa\" or \"bridge\"\n");
+               "\"vepa\", \"bridge\" or \"passthru\" \n");
         return -1;
 }
 
@@ -48,6 +48,8 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
                                mode = MACVLAN_MODE_VEPA;
                        else if (strcmp(*argv, "bridge") == 0)
                                mode = MACVLAN_MODE_BRIDGE;
+                       else if (strcmp(*argv, "passthru") == 0)
+                               mode = MACVLAN_MODE_PASSTHRU;
                        else
                                return mode_arg();
 
@@ -82,6 +84,7 @@ static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
                  mode == MACVLAN_MODE_PRIVATE ? "private"
                : mode == MACVLAN_MODE_VEPA    ? "vepa"
                : mode == MACVLAN_MODE_BRIDGE  ? "bridge"
+               : mode == MACVLAN_MODE_PASSTHRU  ? "passthru"
                :                                "unknown");
 }
 
index 35199b1cf093f68226a05a1806c83823df5b1d6c..07aed4e609aa70349969d7d544b9188aedd27586 100644 (file)
 static void explain(void)
 {
        fprintf(stderr,
-               "Usage: ... macvtap mode { private | vepa | bridge }\n"
+               "Usage: ... macvtap mode { private | vepa | bridge | passthru }\n"
        );
 }
 
 static int mode_arg(void)
 {
         fprintf(stderr, "Error: argument of \"mode\" must be \"private\", "
-               "\"vepa\" or \"bridge\"\n");
+               "\"vepa\", \"bridge\" or \"passthru\" \n");
         return -1;
 }
 
@@ -45,6 +45,8 @@ static int macvtap_parse_opt(struct link_util *lu, int argc, char **argv,
                                mode = MACVLAN_MODE_VEPA;
                        else if (strcmp(*argv, "bridge") == 0)
                                mode = MACVLAN_MODE_BRIDGE;
+                       else if (strcmp(*argv, "passthru") == 0)
+                               mode = MACVLAN_MODE_PASSTHRU;
                        else
                                return mode_arg();
 
@@ -79,6 +81,7 @@ static void macvtap_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
                  mode == MACVLAN_MODE_PRIVATE ? "private"
                : mode == MACVLAN_MODE_VEPA    ? "vepa"
                : mode == MACVLAN_MODE_BRIDGE  ? "bridge"
+               : mode == MACVLAN_MODE_PASSTHRU  ? "passthru"
                :                                "unknown");
 }