netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amine Kherbouche <amine.kherbouche@6wind.com>
To: David Lamparter <equinox@diac24.net>, netdev@vger.kernel.org
Cc: roopa@cumulusnetworks.com
Subject: Re: [PATCH 4/6] mpls: VPLS support
Date: Mon, 21 Aug 2017 17:14:46 +0200	[thread overview]
Message-ID: <4cf89536-2d14-e2aa-cad9-bd13976d6fb3@6wind.com> (raw)
In-Reply-To: <20170816170202.456851-5-equinox@diac24.net>


> new file mode 100644
> index 000000000000..28ac810da6e9
> --- /dev/null
> +++ b/net/mpls/vpls.c
> @@ -0,0 +1,469 @@
> +/*
> + *  net/mpls/vpls.c
> + *
> + *  Copyright (C) 2016 David Lamparter
> + *
> + */
> +
> +#include <linux/netdevice.h>
> +#include <linux/slab.h>
> +#include <linux/ethtool.h>
> +#include <linux/etherdevice.h>
> +#include <linux/u64_stats_sync.h>
> +#include <linux/mpls.h>
> +
> +#include <net/rtnetlink.h>
> +#include <net/dst.h>
> +#include <net/xfrm.h>
> +#include <net/mpls.h>
> +#include <linux/module.h>
> +#include <net/dst_metadata.h>
> +#include <net/ip_tunnels.h>

some headers are not needed.


> +
> +static netdev_tx_t vpls_xmit(struct sk_buff *skb, struct net_device *dev)
> +{
> +	int err = -EINVAL, ok_count = 0;
> +	struct vpls_priv *priv = netdev_priv(dev);
> +	struct vpls_info *vi;
> +	struct pcpu_sw_netstats *stats;
> +	size_t len = skb->len;
> +
> +	rcu_read_lock();
> +	vi = skb_vpls_info(skb);
> +
> +	skb_orphan(skb);
> +	skb_forward_csum(skb);
> +
> +	if (vi) {
> +		err = vpls_xmit_wire(skb, dev, priv, vi->pw_label);
> +		if (err)
> +			goto out_err;
> +	} else {

the rcu_read_lock() is just needed for the else statement right ?

> +		struct sk_buff *cloned;
> +		struct vpls_wirelist *wl;
> +		size_t i;
> +
> +		wl = rcu_dereference(priv->wires);
> +		if (wl->count == 0) {
> +			dev->stats.tx_carrier_errors++;
> +			goto out_err;
> +		}
> +
> +		for (i = 0; i < wl->count; i++) {
> +			cloned = skb_clone(skb, GFP_KERNEL);
> +			if (vpls_xmit_wire(cloned, dev, priv, wl->wires[i]))
> +				consume_skb(cloned);
> +			else
> +				ok_count++;
> +		}
> +		if (!ok_count)
> +			goto out_err;
> +
> +		consume_skb(skb);
> +	}
> +
> +	stats = this_cpu_ptr(dev->tstats);
> +	u64_stats_update_begin(&stats->syncp);
> +	stats->tx_packets++;
> +	stats->tx_bytes += len;
> +	u64_stats_update_end(&stats->syncp);
> +
> +	rcu_read_unlock();
> +	return 0;
> +}


> +int vpls_rcv(struct sk_buff *skb, struct net_device *in_dev,
> +	     struct packet_type *pt, struct mpls_route *rt,
> +	     struct mpls_shim_hdr *hdr, struct net_device *orig_dev)
> +{
> +	struct net_device *dev = rt->rt_vpls_dev;
> +	struct mpls_entry_decoded dec;
> +	struct metadata_dst *md_dst;
> +	struct pcpu_sw_netstats *stats;
> +
> +	if (!dev)
> +		goto drop_nodev;
> +

we can get dec.bos from mpls stack as a function param, no need to 
decode the mpls header again.

> +	dec = mpls_entry_decode(hdr);
> +	if (!dec.bos) {
> +		dev->stats.rx_frame_errors++;
> +		goto drop;
> +	}
> +
> +	skb_pull(skb, sizeof(*hdr));
> +
> +	if (unlikely(!pskb_may_pull(skb, ETH_HLEN))) {
> +		dev->stats.rx_length_errors++;
> +		goto drop;
> +	}



> +static const struct net_device_ops vpls_netdev_ops = {
> +	.ndo_init		= vpls_dev_init,
> +	.ndo_open		= vpls_open,
> +	.ndo_stop		= vpls_close,
> +	.ndo_start_xmit		= vpls_xmit,
> +	.ndo_change_mtu		= vpls_change_mtu,
> +	.ndo_get_stats64	= ip_tunnel_get_stats64,
> +	.ndo_set_rx_mode	= vpls_set_multicast_list,
> +	.ndo_set_mac_address	= eth_mac_addr,
> +	.ndo_features_check	= passthru_features_check,
> +};

can you add .ndo_get_stats64 function ?


>

  reply	other threads:[~2017-08-21 15:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16 17:01 [RFC net-next] VPLS support David Lamparter
2017-08-16 17:01 ` [PATCH 1/6] bridge: learn dst metadata in FDB David Lamparter
2017-08-16 20:38   ` Nikolay Aleksandrov
2017-08-17 11:03     ` David Lamparter
2017-08-17 11:39       ` Nikolay Aleksandrov
2017-08-17 11:51         ` Nikolay Aleksandrov
2017-08-17 12:10           ` David Lamparter
2017-08-17 12:19             ` Nikolay Aleksandrov
2017-08-17 12:20             ` David Lamparter
2017-08-17 12:45         ` David Lamparter
2017-08-17 13:04           ` Nikolay Aleksandrov
2017-08-17 16:16     ` David Lamparter
2017-08-16 17:01 ` [PATCH 2/6] mpls: split forwarding path on rx/tx boundary David Lamparter
2017-08-19 17:10   ` kbuild test robot
2017-08-19 17:42   ` kbuild test robot
2017-08-16 17:01 ` [PATCH 3/6] mpls: add VPLS entry points David Lamparter
2017-08-19 18:27   ` kbuild test robot
2017-08-21 14:01   ` Amine Kherbouche
2017-08-21 15:55     ` David Lamparter
2017-08-21 16:13       ` Amine Kherbouche
2017-08-16 17:02 ` [PATCH 4/6] mpls: VPLS support David Lamparter
2017-08-21 15:14   ` Amine Kherbouche [this message]
2017-08-21 16:18     ` David Lamparter
2017-08-21 16:11   ` Amine Kherbouche
2017-08-16 17:02 ` [PATCH 5/6] bridge: add VPLS pseudowire info in fdb dump David Lamparter
2017-08-16 17:02 ` [PATCH 6/6] mpls: pseudowire control word support David Lamparter

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=4cf89536-2d14-e2aa-cad9-bd13976d6fb3@6wind.com \
    --to=amine.kherbouche@6wind.com \
    --cc=equinox@diac24.net \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.com \
    /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).