From patchwork Mon Feb 1 09:56:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 576439 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 DF1AA140328 for ; Mon, 1 Feb 2016 21:08:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=IsJMOzrB; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 9B84C28C64B; Mon, 1 Feb 2016 10:59:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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 version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 70B4C28C603 for ; Mon, 1 Feb 2016 10:58:23 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 1 Feb 2016 10:58:23 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id p63so8278456wmp.1 for ; Mon, 01 Feb 2016 01:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ve5uIR4xO2F/BY+qGasZIpc3ij9QglfGXPLBF9sXT9g=; b=IsJMOzrBc4AjeZrUr8j8956omma5j+agujdYP4CNgLAjVTc4T1RjKC5mCKY/foPNkT Ud7gfRQZYz8FvQh9X3XdpnjrMfbailWsdZZLbdIvistm3SMiI20c4TXCnm54f9whwaSG Cpc24jMPQP8y/1a3W4xCGAw/NsVXunVINE+UrRGXyeguQzitwKSItDJplE0N6SS2K9rU 5gbCqc/5B63EZ+s3aEEJ3aFBT0FOSeiVO4d1Szv0ijmeFI49Cji2Z4JU+dNmWYpZ2ZSV hZGDalX93hVOVZBRfvgpyXYqinzr4egI2tSQgHUzcrEWd7rsUH9xcR9OPB/dkFLA2DLF dvAw== 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:in-reply-to :references; bh=Ve5uIR4xO2F/BY+qGasZIpc3ij9QglfGXPLBF9sXT9g=; b=cbPNvTJfH8EtylJjPjAGd1gwPO9WSFNwG5CwLWMuVWYqu/85u566E9I9XH6oHR+Mqb 3jz/lCyrEJZWhoxyR4lu+ZQpEDvpMrqJY/LX7uT1DW5CfKFmgLxY2QJ5atwR5wD3WMAr VmMVv9quC3vt0ODHs+5+oky1vaw8xHBpJZPcOlroA+TEfcq1KeY14C0b0VUhD84xhz6z 7ZB7JEXIPnVxtKG45iRwNnbEXdNHuoQktWp3huaxP1SDMuGHpNQCCsZn/RrwimpWuU21 1dbB1YSuY8vZpq5vMtmtTWaA1NGqhvq0NhK9a5aXFGIcLcOELCM7h/+qeFFA7urnq1CR lccQ== X-Gm-Message-State: AG10YORojNFBPbua91Tiq50Oe5v7hBsKKFzoJdBZSDdZbBGv73AA2QlbNgezlQuqAZJUdw== X-Received: by 10.28.186.85 with SMTP id k82mr11493376wmf.77.1454320672390; Mon, 01 Feb 2016 01:57:52 -0800 (PST) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id m67sm8118759wma.10.2016.02.01.01.57.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 01:57:51 -0800 (PST) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Mon, 1 Feb 2016 10:56:29 +0100 Message-Id: <1454320590-20710-15-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454320590-20710-1-git-send-email-dedeckeh@gmail.com> References: <1454320590-20710-1-git-send-email-dedeckeh@gmail.com> Cc: Hans Dedecker , cyrus@openwrt.org, Nick Podolak Subject: [OpenWrt-Devel] [PATCH netifd 15/16] device: Support multicast config option X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Make multicast device flag configurable by extending device attributes with the multicast attribute Signed-off-by: Hans Dedecker Signed-off-by: Nick Podolak --- Based on a patch by Nick Podolak (https://lists.openwrt.org/pipermail/openwrt-devel/2015-October/036654.html) with some minor tweaks. Original patch did not get applied due to line wrapping issue (https://lists.openwrt.org/pipermail/openwrt-devel/2015-November/037336.html) device.c | 10 ++++++++++ device.h | 3 +++ system-linux.c | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/device.c b/device.c index 65183f3..3404fee 100644 --- a/device.c +++ b/device.c @@ -50,6 +50,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] = { .name ="multicast", .type = BLOBMSG_TYPE_BOOL }, }; const struct uci_blob_param_list device_attr_list = { @@ -172,6 +173,8 @@ device_merge_settings(struct device *dev, struct device_settings *n) s->neigh6reachabletime : os->neigh6reachabletime; n->dadtransmits = s->flags & DEV_OPT_DADTRANSMITS ? s->dadtransmits : os->dadtransmits; + n->multicast = s->flags & DEV_OPT_MULTICAST ? + s->multicast : os->multicast; n->multicast_to_unicast = s->multicast_to_unicast; n->multicast_router = s->multicast_router; n->flags = s->flags | os->flags | os->valid_flags; @@ -287,6 +290,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])) { + s->multicast = blobmsg_get_bool(cur); + s->flags |= DEV_OPT_MULTICAST; + } + device_set_disabled(dev, disabled); } @@ -922,6 +930,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) + blobmsg_add_u8(b, "multicast", st.multicast); } s = blobmsg_open_table(b, "statistics"); diff --git a/device.h b/device.h index a6c131a..ac77cfb 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, __DEV_ATTR_MAX, }; @@ -86,6 +87,7 @@ enum { DEV_OPT_DADTRANSMITS = (1 << 13), DEV_OPT_MULTICAST_TO_UNICAST = (1 << 14), DEV_OPT_MULTICAST_ROUTER = (1 << 15), + DEV_OPT_MULTICAST = (1 << 16), }; /* events broadcasted to all users of a device */ @@ -146,6 +148,7 @@ struct device_settings { unsigned int dadtransmits; bool multicast_to_unicast; unsigned int multicast_router; + bool multicast; }; /* diff --git a/system-linux.c b/system-linux.c index 9978ade..86e373c 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1089,6 +1089,9 @@ system_if_get_settings(struct device *dev, struct device_settings *s) if (ioctl(sock_ioctl, SIOCGIFFLAGS, &ifr) == 0) { s->promisc = ifr.ifr_flags & IFF_PROMISC; s->flags |= DEV_OPT_PROMISC; + + s->multicast = ifr.ifr_flags & IFF_MULTICAST; + s->flags |= DEV_OPT_MULTICAST; } if (!system_get_rpfilter(dev, buf, sizeof(buf))) { @@ -1219,6 +1222,11 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned snprintf(buf, sizeof(buf), "%d", s->dadtransmits); system_set_dadtransmits(dev, buf); } + if (s->flags & DEV_OPT_MULTICAST & apply_mask) { + if (system_if_flags(dev->ifname, s->multicast ? IFF_MULTICAST : 0, + !s->multicast ? IFF_MULTICAST : 0) < 0) + s->flags &= ~DEV_OPT_MULTICAST; + } system_if_apply_rps_xps(dev, s); }