From patchwork Thu Oct 28 23:10:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sridhar Samudrala X-Patchwork-Id: 69515 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1C897B70DE for ; Fri, 29 Oct 2010 10:11:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758952Ab0J1XLB (ORCPT ); Thu, 28 Oct 2010 19:11:01 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:54326 "EHLO e3.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752702Ab0J1XK7 (ORCPT ); Thu, 28 Oct 2010 19:10:59 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o9SMrxbf024272; Thu, 28 Oct 2010 18:53:59 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9SNAwMN1982628; Thu, 28 Oct 2010 19:10:58 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o9SNAvT5022538; Thu, 28 Oct 2010 19:10:57 -0400 Received: from [9.47.24.19] (sridhar.beaverton.ibm.com [9.47.24.19]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o9SNAuTT022495; Thu, 28 Oct 2010 19:10:56 -0400 Subject: [PATCH iproute2] macvlan/macvtap: support 'passthru' mode From: Sridhar Samudrala To: Arnd Bergmann , Stephen Hemminger , "Michael S. Tsirkin" , Patrick McHardy Cc: netdev , "kvm@vger.kernel.org" Date: Thu, 28 Oct 2010 16:10:55 -0700 Message-Id: <1288307455.30131.83.camel@sridhar.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 ----------------------------------------------------------------------- --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/if_link.h b/include/linux/if_link.h index f5bb2dc..23de79e 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h @@ -230,6 +230,7 @@ enum macvlan_mode { MACVLAN_MODE_PRIVATE = 1, /* don't talk to other macvlans */ MACVLAN_MODE_VEPA = 2, /* talk to other ports through ext bridge */ MACVLAN_MODE_BRIDGE = 4, /* talk to bridge ports directly */ + MACVLAN_MODE_PASSTHRU = 8, /* take over the underlying device */ }; /* SR-IOV virtual function management section */ diff --git a/ip/iplink_macvlan.c b/ip/iplink_macvlan.c index a3c78bd..15022aa 100644 --- a/ip/iplink_macvlan.c +++ b/ip/iplink_macvlan.c @@ -23,14 +23,14 @@ 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"); } diff --git a/ip/iplink_macvtap.c b/ip/iplink_macvtap.c index 35199b1..5665b6d 100644 --- a/ip/iplink_macvtap.c +++ b/ip/iplink_macvtap.c @@ -20,14 +20,14 @@ 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"); }