From patchwork Fri Oct 11 02:35:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 282514 X-Patchwork-Delegate: davem@davemloft.net 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 EAECF2C00B3 for ; Fri, 11 Oct 2013 13:35:59 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753276Ab3JKCf4 (ORCPT ); Thu, 10 Oct 2013 22:35:56 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:33800 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752235Ab3JKCfz (ORCPT ); Thu, 10 Oct 2013 22:35:55 -0400 Received: by mail-pa0-f48.google.com with SMTP id bj1so3610331pad.7 for ; Thu, 10 Oct 2013 19:35:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=Ui4vxjgh/0zPQYZHNgkHd6B6H9Q34qBwFeKNZcEG8Sw=; b=kaA/QCSgJ8jSMhcZzCmulsQVCBO9PvxxzaBoUIK8tENa9NFdsYFm5evGgPbaSwsU7+ lU95qbVjSb/t7p7pAfZ/uqLJZgYQywtzIHcih68LSAzcEHQS4Trkp+iTr4vhg/NLKSki SiZEh7ywzg7Hu0W2OFc3gwH0jCaGhwYi1PS7saW2HjeM8Qm6S1D1gjvJZEF+s08I4cCR Ps++x9WcK8+z0bzWHuny2+nuDFWoYT9ZGbk4k8z5DFYPC67I2igha3Q6Hhx5SrIIBHT+ xs3TOZj3Sn3ie3OVUPtYO9vw/+48b9Stmzyh6AVP3kdU8edmiCKRcV1h6UPvnHj8+iSf SUrg== X-Gm-Message-State: ALoCoQn3BdjZvHATJQjSRoOcbf1FTG9uzDuSErsnpaKINK+AkJuR5nxn07eVVfv/RTJlQn/PLuOb X-Received: by 10.68.25.170 with SMTP id d10mr17605151pbg.78.1381458955058; Thu, 10 Oct 2013 19:35:55 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id a6sm9694554pbr.17.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Oct 2013 19:35:54 -0700 (PDT) Date: Thu, 10 Oct 2013 19:35:51 -0700 From: Stephen Hemminger To: Felix Fietkau Cc: netdev@vger.kernel.org Subject: Re: [PATCH net] bridge: allow receiption on disabled port Message-ID: <20131010193551.462fc1f8@nehalam.linuxnetplumber.net> In-Reply-To: <52571481.5010907@openwrt.org> References: <1381409570-1892-1-git-send-email-nbd@openwrt.org> <20131010133646.1bdd42c1@nehalam.linuxnetplumber.net> <52571481.5010907@openwrt.org> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is what I was thinking would be better. Don't want these packets leaking into PRE_ROUTEING chain or have any chance to get flooded out other ports. Compile tested only... I could use another goto instead but that becomes spaghetti and never like to jump back into a block. --- 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 --- a/net/bridge/br_input.c 2013-10-06 14:48:24.946450042 -0700 +++ b/net/bridge/br_input.c 2013-10-10 19:32:14.227926344 -0700 @@ -152,6 +152,16 @@ static int br_handle_local_finish(struct return 0; /* process further */ } +/* Deliver packet to local host only */ +static rx_handler_result_t br_local_only(struct sk_buff *skb) +{ + if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, + NULL, br_handle_local_finish)) + return RX_HANDLER_CONSUMED; /* consumed by filter */ + else + return RX_HANDLER_PASS; /* continue processing */ +} + /* * Return NULL if skb is handled * note: already called with rcu_read_lock @@ -206,18 +216,20 @@ rx_handler_result_t br_handle_frame(stru goto forward; } - /* Deliver packet to local host only */ - if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, - NULL, br_handle_local_finish)) { - return RX_HANDLER_CONSUMED; /* consumed by filter */ - } else { - *pskb = skb; - return RX_HANDLER_PASS; /* continue processing */ - } + *pskb = skb; + return br_local_only(skb); } forward: switch (p->state) { + case BR_STATE_DISABLED: + if (!ether_addr_equal(p->br->dev->dev_addr, dest)) + goto drop; + + skb->pkt_type = PACKET_HOST; + *pskb = skb; + return br_local_only(skb); + case BR_STATE_FORWARDING: rhook = rcu_dereference(br_should_route_hook); if (rhook) {