From: Simon Horman <simon.horman@netronome.com>
To: netdev@vger.kernel.org, dev@openvswitch.org
Cc: Simon Horman <simon.horman@netronome.com>
Subject: [PATCH v9 net-next 1/7] net: add skb_vlan_deaccel helper
Date: Wed, 4 May 2016 16:36:27 +0900 [thread overview]
Message-ID: <1462347393-22354-2-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1462347393-22354-1-git-send-email-simon.horman@netronome.com>
This breaks out the bulk of skb_vlan_push into a separate helper.
This new helper moves any vlan tag present in metadata into packet data.
The existing skb_vlan_push uses this new helper and then pushes a new
vlan tag (into metadata).
The motivation is to allow deaccelerating VLAN tags without adding a new
one. This is in preparation for a push ethernet header support in Open
vSwitch.
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
v9 [Simon Horman]
* New patch
---
include/linux/skbuff.h | 1 +
net/core/skbuff.c | 50 ++++++++++++++++++++++++++++++++------------------
2 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c413c588a24f..fa504d28c7e4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2994,6 +2994,7 @@ int skb_vlan_pop(struct sk_buff *skb);
int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
struct sk_buff *pskb_extract(struct sk_buff *skb, int off, int to_copy,
gfp_t gfp);
+int skb_vlan_deaccel(struct sk_buff *skb);
static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len)
{
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7a1d48983f81..84a3f8cc4b0a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4516,30 +4516,44 @@ int skb_vlan_pop(struct sk_buff *skb)
}
EXPORT_SYMBOL(skb_vlan_pop);
-int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
+int skb_vlan_deaccel(struct sk_buff *skb)
{
- if (skb_vlan_tag_present(skb)) {
- unsigned int offset = skb->data - skb_mac_header(skb);
- int err;
+ unsigned int offset;
+ int err;
- /* __vlan_insert_tag expect skb->data pointing to mac header.
- * So change skb->data before calling it and change back to
- * original position later
- */
- __skb_push(skb, offset);
- err = __vlan_insert_tag(skb, skb->vlan_proto,
- skb_vlan_tag_get(skb));
- if (err) {
- __skb_pull(skb, offset);
- return err;
- }
+ if (!skb_vlan_tag_present(skb))
+ return 0;
- skb->protocol = skb->vlan_proto;
- skb->mac_len += VLAN_HLEN;
+ offset = skb->data - skb_mac_header(skb);
- skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
+ /* __vlan_insert_tag expect skb->data pointing to mac header.
+ * So change skb->data before calling it and change back to
+ * original position later
+ */
+ __skb_push(skb, offset);
+ err = __vlan_insert_tag(skb, skb->vlan_proto, skb_vlan_tag_get(skb));
+ if (err) {
__skb_pull(skb, offset);
+ return err;
}
+
+ skb->protocol = skb->vlan_proto;
+ skb->mac_len += VLAN_HLEN;
+
+ skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
+ __skb_pull(skb, offset);
+
+ return 0;
+}
+EXPORT_SYMBOL(skb_vlan_deaccel);
+
+int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
+{
+ int err;
+
+ err = skb_vlan_deaccel(skb);
+ if (err)
+ return err;
__vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
return 0;
}
--
2.7.0.rc3.207.g0ac5344
next prev parent reply other threads:[~2016-05-04 7:36 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-04 7:36 [PATCH v9 net-next 0/7] openvswitch: support for layer 3 encapsulated packets Simon Horman
2016-05-04 7:36 ` Simon Horman [this message]
2016-05-04 7:36 ` [PATCH v9 net-next 2/7] openvswitch: set skb protocol when receiving on internal device Simon Horman
2016-05-04 7:36 ` [PATCH v9 net-next 3/7] openvswitch: add support to push and pop mpls for layer3 packets Simon Horman
[not found] ` <1462347393-22354-4-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-05-05 17:35 ` pravin shelar
2016-05-06 4:33 ` Simon Horman
2016-05-04 7:36 ` [PATCH v9 net-next 4/7] openvswitch: add layer 3 flow/port support Simon Horman
[not found] ` <1462347393-22354-5-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-05-05 17:37 ` pravin shelar
2016-05-06 5:57 ` Simon Horman
2016-05-06 9:25 ` Jiri Benc
2016-05-09 8:04 ` Simon Horman
[not found] ` <20160509080420.GA4470-IxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-05-10 12:01 ` Jiri Benc
2016-05-11 1:50 ` Simon Horman
[not found] ` <20160511015009.GB24436-IxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-05-11 3:06 ` Simon Horman
2016-05-11 14:09 ` Jiri Benc
2016-05-11 22:46 ` Simon Horman
2016-05-17 14:43 ` Jiri Benc
2016-05-18 2:18 ` Simon Horman
2016-05-11 13:57 ` Jiri Benc
2016-05-06 9:35 ` Jiri Benc
2016-05-09 8:18 ` Simon Horman
2016-05-10 0:16 ` [ovs-dev] " Yang, Yi Y
[not found] ` <79BBBFE6CB6C9B488C1A45ACD284F51913CB6446-0J0gbvR4kTggGBtAFL8yw7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2016-05-10 12:07 ` Jiri Benc
2016-05-10 12:06 ` Jiri Benc
2016-05-11 3:28 ` Simon Horman
2016-05-11 14:10 ` Jiri Benc
2016-05-17 14:32 ` Jiri Benc
2016-05-20 5:29 ` Simon Horman
2016-05-20 8:00 ` Jiri Benc
2016-05-20 8:11 ` Simon Horman
2016-05-20 8:16 ` Simon Horman
[not found] ` <20160520081611.GB17561-IxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2016-05-20 8:39 ` Jiri Benc
2016-05-20 9:12 ` Simon Horman
2016-05-20 9:20 ` Jiri Benc
2016-05-20 10:14 ` Simon Horman
[not found] ` <1462347393-22354-1-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-05-04 7:36 ` [PATCH v9 net-next 5/7] openvswitch: add layer 3 support to ovs_packet_cmd_execute() Simon Horman
[not found] ` <1462347393-22354-6-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-05-17 14:51 ` Jiri Benc
2016-05-18 2:24 ` Simon Horman
2016-05-04 7:36 ` [PATCH v9 net-next 6/7] openvswitch: extend layer 3 support to cover non-IP packets Simon Horman
2016-05-04 7:36 ` [PATCH v9 net-next 7/7] openvswitch: use ipgre tunnel rather than gretap tunnel Simon Horman
[not found] ` <1462347393-22354-8-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2016-05-05 21:45 ` pravin shelar
2016-05-06 6:54 ` Simon Horman
2016-05-06 9:15 ` Jiri Benc
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=1462347393-22354-2-git-send-email-simon.horman@netronome.com \
--to=simon.horman@netronome.com \
--cc=dev@openvswitch.org \
--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).