From: David Ahern <dsa@cumulusnetworks.com>
To: netdev@vger.kernel.org
Cc: David Ahern <dsa@cumulusnetworks.com>
Subject: [RFC PATCH net-next 3/3] net: Change VRF driver to use the new L3 RX handler
Date: Fri, 28 Aug 2015 17:34:23 -0700 [thread overview]
Message-ID: <1440808463-14526-4-git-send-email-dsa@cumulusnetworks.com> (raw)
In-Reply-To: <1440808463-14526-1-git-send-email-dsa@cumulusnetworks.com>
By registering an L3 handler the VRF driver's rx handler does not need
the L3 check. Once the skb->dev is switched to the VRF device the packet
is reinjected to the stack and starts anew. This is required for the
packet to get picked up at the packet socket level with the new
device and continue up the stack hitting netfilter hooks as well.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
drivers/net/vrf.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index e7094fbd7568..3aa1a7db830c 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -88,16 +88,6 @@ static struct dst_ops vrf_dst_ops = {
.default_advmss = vrf_default_advmss,
};
-static bool is_ip_rx_frame(struct sk_buff *skb)
-{
- switch (skb->protocol) {
- case htons(ETH_P_IP):
- case htons(ETH_P_IPV6):
- return true;
- }
- return false;
-}
-
static void vrf_tx_error(struct net_device *vrf_dev, struct sk_buff *skb)
{
vrf_dev->stats.tx_errors++;
@@ -108,21 +98,19 @@ static void vrf_tx_error(struct net_device *vrf_dev, struct sk_buff *skb)
static rx_handler_result_t vrf_handle_frame(struct sk_buff **pskb)
{
struct sk_buff *skb = *pskb;
+ struct net_device *dev = vrf_master_get_rcu(skb->dev);
+ struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
- if (is_ip_rx_frame(skb)) {
- struct net_device *dev = vrf_master_get_rcu(skb->dev);
- struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
+ u64_stats_update_begin(&dstats->syncp);
+ dstats->rx_pkts++;
+ dstats->rx_bytes += skb->len;
+ u64_stats_update_end(&dstats->syncp);
- u64_stats_update_begin(&dstats->syncp);
- dstats->rx_pkts++;
- dstats->rx_bytes += skb->len;
- u64_stats_update_end(&dstats->syncp);
+ skb->dev = dev;
- skb->dev = dev;
+ netif_receive_skb(skb);
- return RX_HANDLER_ANOTHER;
- }
- return RX_HANDLER_PASS;
+ return RX_HANDLER_CONSUMED;
}
static struct rtnl_link_stats64 *vrf_get_stats64(struct net_device *dev,
@@ -405,7 +393,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
vrf_ptr->tb_id = vrf->tb_id;
/* register the packet handler for slave ports */
- ret = netdev_rx_handler_register(port_dev, vrf_handle_frame, dev);
+ ret = netdev_l3_rx_handler_register(port_dev, vrf_handle_frame, dev);
if (ret) {
netdev_err(port_dev,
"Device %s failed to register rx_handler\n",
--
1.9.1
next prev parent reply other threads:[~2015-08-29 0:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-29 0:34 [RFC PATCH net-next 0/3] L3 RX handler David Ahern
2015-08-29 0:34 ` [RFC PATCH net-next 1/3] net: Introduce L3 RX Handler David Ahern
2015-08-29 0:34 ` [RFC PATCH net-next 2/3] net: Add L3 Rx handler to IPv4 processing David Ahern
2015-08-29 0:34 ` David Ahern [this message]
2015-08-29 1:31 ` [RFC PATCH net-next 0/3] L3 RX handler Eric Dumazet
2015-08-29 5:14 ` David Miller
2015-08-29 15:20 ` David Ahern
2015-08-29 18:02 ` Tom Herbert
2015-08-31 3:59 ` David Ahern
2015-08-29 5:14 ` David Miller
2015-08-29 15:05 ` David Ahern
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=1440808463-14526-4-git-send-email-dsa@cumulusnetworks.com \
--to=dsa@cumulusnetworks.com \
--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).