From: Pravin B Shelar <pshelar@nicira.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Pravin B Shelar <pshelar@nicira.com>
Subject: [PATCH net-next v4 04/11] net: Export xmit_recursion
Date: Wed, 16 Jul 2014 17:18:30 -0700 [thread overview]
Message-ID: <1405556310-1769-1-git-send-email-pshelar@nicira.com> (raw)
Next patch adds re-circulation action to OVS. This is recursive
action needs to be limited to safe number recursions to
avoid overflowing kernel stack space. This patch export
xmit_recursion so that OVS can increment and check the value
before executing recirc action.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
include/linux/netdevice.h | 3 +++
net/core/dev.c | 10 +++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3a320db..ca7a1ab 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1941,6 +1941,9 @@ static inline struct net_device *first_net_device_rcu(struct net *net)
return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
}
+#define NET_RECURSION_LIMIT 10
+DECLARE_PER_CPU(int, net_xmit_recursion);
+
int netdev_boot_setup_check(struct net_device *dev);
unsigned long netdev_boot_base(const char *prefix, int unit);
struct net_device *dev_getbyhwaddr_rcu(struct net *net, unsigned short type,
diff --git a/net/core/dev.c b/net/core/dev.c
index 6e2a2cd..7f36a4f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2804,8 +2804,8 @@ static void skb_update_prio(struct sk_buff *skb)
#define skb_update_prio(skb)
#endif
-static DEFINE_PER_CPU(int, xmit_recursion);
-#define RECURSION_LIMIT 10
+DEFINE_PER_CPU(int, net_xmit_recursion);
+EXPORT_SYMBOL_GPL(net_xmit_recursion);
/**
* dev_loopback_xmit - loop back @skb
@@ -2895,15 +2895,15 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
if (txq->xmit_lock_owner != cpu) {
- if (__this_cpu_read(xmit_recursion) > RECURSION_LIMIT)
+ if (__this_cpu_read(net_xmit_recursion) > NET_RECURSION_LIMIT)
goto recursion_alert;
HARD_TX_LOCK(dev, txq, cpu);
if (!netif_xmit_stopped(txq)) {
- __this_cpu_inc(xmit_recursion);
+ __this_cpu_inc(net_xmit_recursion);
rc = dev_hard_start_xmit(skb, dev, txq);
- __this_cpu_dec(xmit_recursion);
+ __this_cpu_dec(net_xmit_recursion);
if (dev_xmit_complete(rc)) {
HARD_TX_UNLOCK(dev, txq);
goto out;
--
1.9.3
reply other threads:[~2014-07-17 0:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405556310-1769-1-git-send-email-pshelar@nicira.com \
--to=pshelar@nicira.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).