From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shmulik Ladkani Subject: [PATCH v3 net-next 2/4] net/sched: act_mirred: Refactor detection whether dev needs xmit at mac header Date: Thu, 29 Sep 2016 14:03:30 +0300 Message-ID: <1475147012-15538-3-git-send-email-shmulik.ladkani@gmail.com> References: <1475147012-15538-1-git-send-email-shmulik.ladkani@gmail.com> Cc: Jamal Hadi Salim , WANG Cong , Eric Dumazet , Daniel Borkmann , netdev@vger.kernel.org, Shmulik Ladkani To: David Miller Return-path: Received: from mail-wm0-f67.google.com ([74.125.82.67]:33299 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750700AbcI2LEF (ORCPT ); Thu, 29 Sep 2016 07:04:05 -0400 Received: by mail-wm0-f67.google.com with SMTP id w84so10130393wmg.0 for ; Thu, 29 Sep 2016 04:04:04 -0700 (PDT) In-Reply-To: <1475147012-15538-1-git-send-email-shmulik.ladkani@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Move detection logic that tests whether device expects skb data to point at mac_header upon xmit into a function. Signed-off-by: Shmulik Ladkani --- net/sched/act_mirred.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 16e17a887b..69dcce8c75 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -54,6 +54,20 @@ static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = { static int mirred_net_id; static struct tc_action_ops act_mirred_ops; +static bool dev_is_mac_header_xmit(const struct net_device *dev) +{ + switch (dev->type) { + case ARPHRD_TUNNEL: + case ARPHRD_TUNNEL6: + case ARPHRD_SIT: + case ARPHRD_IPGRE: + case ARPHRD_VOID: + case ARPHRD_NONE: + return false; + } + return true; +} + static int tcf_mirred_init(struct net *net, struct nlattr *nla, struct nlattr *est, struct tc_action **a, int ovr, int bind) @@ -96,19 +110,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, tcf_hash_release(*a, bind); return -ENODEV; } - switch (dev->type) { - case ARPHRD_TUNNEL: - case ARPHRD_TUNNEL6: - case ARPHRD_SIT: - case ARPHRD_IPGRE: - case ARPHRD_VOID: - case ARPHRD_NONE: - mac_header_xmit = false; - break; - default: - mac_header_xmit = true; - break; - } + mac_header_xmit = dev_is_mac_header_xmit(dev); } else { dev = NULL; } -- 2.7.4