From patchwork Tue Sep 13 12:33:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 669317 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sYPHQ4cphz9s9x for ; Tue, 13 Sep 2016 22:33:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=rA2n+jRe; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 06F5FB920FB; Tue, 13 Sep 2016 14:33:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Tue, 13 Sep 2016 14:33:49 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 98453B920EF for ; Tue, 13 Sep 2016 14:33:46 +0200 (CEST) X-policyd-weight: using cached result; rate: -7 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Tue, 13 Sep 2016 14:33:45 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id b187so18071887wme.0 for ; Tue, 13 Sep 2016 05:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Oa7iaPsgzeexkZFsXTdjeZVq+vQusggPmpzpZ0OOmIY=; b=rA2n+jReDZ80WRAFX4fZcp3LSwFl7mOLp7JjSIYaaGaopFmG3asU9wYCnb7PoV7iR2 GDYvgGX8SH0sPiMzjGPGI3zQ3d6VAnrpWcIaM3IHf3/tCwfBOX9CUMcODRFF6RiazO6A 77VUOiveSdLy4zLJNXyp/GZfMgzILSuQFhvN8/fdMc0bFQKq4uGGQ00zLNpLvDHor+JR 0nIpzmuZ+uqhrM/QtoYok/CeEZw7pSLHsyJbusOKlii1e0zvqO0gsPwYhp/lFM4TToAp SY4e+q+xOUfRjOdPcQCq8/4LUPZQKe6A+yvpoOXxmdeH3kjtRgniDK3ZVs+rTwkFGFsu bkgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Oa7iaPsgzeexkZFsXTdjeZVq+vQusggPmpzpZ0OOmIY=; b=ZqMEls0INRjilMzeEZLd8loa6jOOfe5gqg/P+Y8qtjIHgBp8LOG3hChbVow8u1dcCC bQ5onR1vgU8OZU9DQQ3SHpi9KM6GozcsyX0VJZ97h5vbsjTffaZvNiEMc7bSAcg9+jQG aKPIAXyE2ywcXD4I1CVGZaJkuqHWzaNZDRibBO+xubSrvTPTrLVQXlQdKHSrFmtVhrpV vzgIVHKKc1kJr2VijVTjK031avuAjWCgX3oQlaf3/9Qr12lmGjcPwoujU5k5VWGzShrF FbDm0ZIOgq1nC7wdzJIz0Cfun0xXXJSeIYFJbafk2Rpb6MZKc/Yx/hbKdbTTLA+ihwJE d5xw== X-Gm-Message-State: AE9vXwNEQoLw5B98bpOJaogYpD+JHlU1UAhwta73Lo4uB/iWLTRACgUhgsAYpuyK1QeSdA== X-Received: by 10.28.210.5 with SMTP id j5mr492265wmg.67.1473770025261; Tue, 13 Sep 2016 05:33:45 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id yt4sm22715991wjc.48.2016.09.13.05.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 05:33:44 -0700 (PDT) From: Hans Dedecker To: lede-dev@lists.infradead.org, openwrt-devel@lists.openwrt.org Date: Tue, 13 Sep 2016 14:33:38 +0200 Message-Id: <1473770020-19533-1-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [OpenWrt-Devel] [PATCH netifd 1/3] bridge: Allow setting multicast_fast_leave_option X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Setting the multicast_fast_leave option of a bridge allows to control the forwarding of multicast traffic when an IGMP/MLD leave is received. In case multicast_leave_option is enabled and a leave is received the multicast membership will immediately be dropped on the bridge port while in the other case the multicast membership will time out in the bridge. This could be usefull in scenarios where explicit multicast membership host tracking is not supported in the upstream network. In this case the multicast stream is still flowing after a leave is received resulting into possible bandwidth saturation on the lan if a new stream is joined as multiple multicast streams are received. Signed-off-by: Hans Dedecker --- device.c | 9 +++++++++ device.h | 3 +++ system-linux.c | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/device.c b/device.c index fa3d00f..d45ce63 100644 --- a/device.c +++ b/device.c @@ -51,6 +51,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_DADTRANSMITS] = { .name = "dadtransmits", .type = BLOBMSG_TYPE_INT32 }, [DEV_ATTR_MULTICAST_TO_UNICAST] = { .name = "multicast_to_unicast", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_MULTICAST_ROUTER] = { .name = "multicast_router", .type = BLOBMSG_TYPE_INT32 }, + [DEV_ATTR_MULTICAST_FAST_LEAVE] = { .name = "multicast_fast_leave", . type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_MULTICAST] = { .name ="multicast", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_LEARNING] = { .name ="learning", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_UNICAST_FLOOD] = { .name ="unicast_flood", .type = BLOBMSG_TYPE_BOOL }, @@ -184,6 +185,7 @@ device_merge_settings(struct device *dev, struct device_settings *n) s->multicast : os->multicast; n->multicast_to_unicast = s->multicast_to_unicast; n->multicast_router = s->multicast_router; + n->multicast_fast_leave = s->multicast_fast_leave; n->learning = s->learning; n->unicast_flood = s->unicast_flood; n->flags = s->flags | os->flags | os->valid_flags; @@ -304,6 +306,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb) DPRINTF("Invalid value: %d - (Use 0: never, 1: learn, 2: always)\n", blobmsg_get_u32(cur)); } + if ((cur = tb[DEV_ATTR_MULTICAST_FAST_LEAVE])) { + s->multicast_fast_leave = blobmsg_get_bool(cur); + s->flags |= DEV_OPT_MULTICAST_FAST_LEAVE; + } + if ((cur = tb[DEV_ATTR_MULTICAST])) { s->multicast = blobmsg_get_bool(cur); s->flags |= DEV_OPT_MULTICAST; @@ -994,6 +1001,8 @@ device_dump_status(struct blob_buf *b, struct device *dev) blobmsg_add_u8(b, "multicast_to_unicast", st.multicast_to_unicast); if (st.flags & DEV_OPT_MULTICAST_ROUTER) blobmsg_add_u32(b, "multicast_router", st.multicast_router); + if (st.flags & DEV_OPT_MULTICAST_FAST_LEAVE) + blobmsg_add_u8(b, "multicast_fast_leave", st.multicast_fast_leave); if (st.flags & DEV_OPT_MULTICAST) blobmsg_add_u8(b, "multicast", st.multicast); if (st.flags & DEV_OPT_LEARNING) diff --git a/device.h b/device.h index e13e435..032a8e9 100644 --- a/device.h +++ b/device.h @@ -44,6 +44,7 @@ enum { DEV_ATTR_DADTRANSMITS, DEV_ATTR_MULTICAST_TO_UNICAST, DEV_ATTR_MULTICAST_ROUTER, + DEV_ATTR_MULTICAST_FAST_LEAVE, DEV_ATTR_MULTICAST, DEV_ATTR_LEARNING, DEV_ATTR_UNICAST_FLOOD, @@ -94,6 +95,7 @@ enum { DEV_OPT_LEARNING = (1 << 17), DEV_OPT_UNICAST_FLOOD = (1 << 18), DEV_OPT_NEIGHGCSTALETIME = (1 << 19), + DEV_OPT_MULTICAST_FAST_LEAVE = (1 << 20), }; /* events broadcasted to all users of a device */ @@ -156,6 +158,7 @@ struct device_settings { unsigned int dadtransmits; bool multicast_to_unicast; unsigned int multicast_router; + bool multicast_fast_leave; bool multicast; bool learning; bool unicast_flood; diff --git a/system-linux.c b/system-linux.c index d868c15..6e4a194 100644 --- a/system-linux.c +++ b/system-linux.c @@ -326,6 +326,11 @@ static void system_bridge_set_multicast_to_unicast(struct device *dev, const cha system_set_dev_sysctl("/sys/class/net/%s/brport/multicast_to_unicast", dev->ifname, val); } +static void system_bridge_set_multicast_fast_leave(struct device *dev, const char *val) +{ + system_set_dev_sysctl("/sys/class/net/%s/brport/multicast_fast_leave", dev->ifname, val); +} + static void system_bridge_set_hairpin_mode(struct device *dev, const char *val) { system_set_dev_sysctl("/sys/class/net/%s/brport/hairpin_mode", dev->ifname, val); @@ -680,6 +685,10 @@ int system_bridge_addif(struct device *bridge, struct device *dev) system_bridge_set_multicast_router(dev, buf, false); } + if (dev->settings.flags & DEV_OPT_MULTICAST_FAST_LEAVE && + dev->settings.multicast_fast_leave) + system_bridge_set_multicast_fast_leave(dev, "1"); + if (dev->settings.flags & DEV_OPT_LEARNING && !dev->settings.learning) system_bridge_set_learning(dev, "0");