From patchwork Thu Aug 13 17:02:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischer, Anna" X-Patchwork-Id: 31344 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 1600AB6EDF for ; Fri, 14 Aug 2009 03:04:12 +1000 (EST) Received: by ozlabs.org (Postfix) id 07BB4DDD0B; Fri, 14 Aug 2009 03:04:12 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 48F7DDDD01 for ; Fri, 14 Aug 2009 03:04:11 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755063AbZHMRDM (ORCPT ); Thu, 13 Aug 2009 13:03:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755054AbZHMRDL (ORCPT ); Thu, 13 Aug 2009 13:03:11 -0400 Received: from g4t0016.houston.hp.com ([15.201.24.19]:33286 "EHLO g4t0016.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755034AbZHMRDJ convert rfc822-to-8bit (ORCPT ); Thu, 13 Aug 2009 13:03:09 -0400 Received: from G6W0641.americas.hpqcorp.net (g6w0641.atlanta.hp.com [16.230.34.77]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by g4t0016.houston.hp.com (Postfix) with ESMTPS id 6F45C144A4; Thu, 13 Aug 2009 17:03:10 +0000 (UTC) Received: from G5W0324.americas.hpqcorp.net (16.228.8.69) by G6W0641.americas.hpqcorp.net (16.230.34.77) with Microsoft SMTP Server (TLS) id 8.1.375.2; Thu, 13 Aug 2009 17:02:29 +0000 Received: from GVW1118EXC.americas.hpqcorp.net ([16.228.24.174]) by G5W0324.americas.hpqcorp.net ([16.228.8.69]) with mapi; Thu, 13 Aug 2009 17:02:29 +0000 From: "Fischer, Anna" To: Stephen Hemminger , "netdev@vger.kernel.org" CC: "Paul Congdon (UC Davis)" , "evb@yahoogroups.com" , "bridge@lists.linux-foundation.org" , "davem@davemloft.net" , "virtualization@lists.linux-foundation.org" , "kaber@trash.net" , Arnd Bergmann , "Dickson, Mike (ISS Software)" , "adobriyan@gmail.com" , "bridge@osdl.org" , "linux-kernel@vger.kernel.org" Date: Thu, 13 Aug 2009 17:02:24 +0000 Subject: [PATCH] bridge-utils: Add 'hairpin' port forwarding mode Thread-Topic: [PATCH] bridge-utils: Add 'hairpin' port forwarding mode Thread-Index: AcocN9Q1l+yORnIkSQO8TlcFn86Rkw== Message-ID: <0199E0D51A61344794750DC57738F58E6D6B0C70DC@GVW1118EXC.americas.hpqcorp.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds a 'hairpin' (also called 'reflective relay') mode port configuration to the Linux Ethernet bridge utilities. A bridge supporting hairpin forwarding mode can send frames back out through the port the frame was received on. Hairpin mode is required to support basic VEPA (Virtual Ethernet Port Aggregator) capabilities. You can find additional information on VEPA here: http://tech.groups.yahoo.com/group/evb/ http://www.ieee802.org/1/files/public/docs2009/new-hudson-vepa_seminar-20090514d.pdf http://www.internet2.edu/presentations/jt2009jul/20090719-congdon.pdf Hairpin forwarding requires support from the kernel. A further kernel patch 'net/bridge: Add 'hairpin' port forwarding mode' is provided for this. Signed-off-by: Paul Congdon Signed-off-by: Anna Fischer --- brctl/brctl_cmd.c | 38 ++++++++++++++++++++++++++++++++++++++ brctl/brctl_disp.c | 2 ++ libbridge/libbridge.h | 3 +++ libbridge/libbridge_devif.c | 24 ++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 0 deletions(-) -- 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/brctl/brctl_cmd.c b/brctl/brctl_cmd.c index c93dd55..d37e99c 100644 --- a/brctl/brctl_cmd.c +++ b/brctl/brctl_cmd.c @@ -395,6 +395,42 @@ static int br_cmd_showmacs(int argc, char *const* argv) return 0; } +static int br_cmd_hairpin(int argc, char *const* argv) +{ + int hairpin, err; + const char *brname = *++argv; + const char *ifname = *++argv; + const char *hpmode = *++argv; + + if (!strcmp(hpmode, "on") || !strcmp(hpmode, "yes") + || !strcmp(hpmode, "1")) + hairpin = 1; + else if (!strcmp(hpmode, "off") || !strcmp(hpmode, "no") + || !strcmp(hpmode, "0")) + hairpin = 0; + else { + fprintf(stderr, "expect on/off for argument\n"); + return 1; + } + if (if_nametoindex(ifname) == 0) { + fprintf(stderr, "interface %s does not exist!\n", + ifname); + return 1; + } else if (if_nametoindex(brname) == 0) { + fprintf(stderr, "bridge %s does not exist!\n", + brname); + return 1; + } + + err = br_set_hairpin_mode(brname, ifname, hairpin); + + if (err) { + fprintf(stderr, "can't set %s to hairpin on bridge %s: %s\n", + ifname, brname, strerror(err)); + } + return err != 0; +} + static const struct command commands[] = { { 1, "addbr", br_cmd_addbr, "\t\tadd bridge" }, { 1, "delbr", br_cmd_delbr, "\t\tdelete bridge" }, @@ -402,6 +438,8 @@ static const struct command commands[] = { " \tadd interface to bridge" }, { 2, "delif", br_cmd_delif, " \tdelete interface from bridge" }, + { 3, "hairpin", br_cmd_hairpin, + " {on|off}\tturn hairpin on/off" }, { 2, "setageing", br_cmd_setageing, "