diff options
author | Jiri Pirko <jiri@resnulli.us> | 2014-11-19 14:04:59 +0100 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2015-04-27 16:48:34 -0400 |
commit | a67e2e88342accd49587d9bad72f6dabd7673f7c (patch) | |
tree | 00749cb39b448bc725224e0a1f11d5d45fc1a2cf /include | |
parent | d329729a26406301996d4ae63b3d7d489bd2f361 (diff) | |
download | lwn-a67e2e88342accd49587d9bad72f6dabd7673f7c.tar.gz lwn-a67e2e88342accd49587d9bad72f6dabd7673f7c.zip |
vlan: introduce *vlan_hwaccel_push_inside helpers
[ Upstream commit 5968250c868ceee680aa77395b24e6ddcae17d36 ]
Use them to push skb->vlan_tci into the payload and avoid code
duplication.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/if_vlan.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 309a06042d0b..3a3c4fadcc64 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -341,6 +341,40 @@ static inline struct sk_buff *vlan_insert_tag_set_proto(struct sk_buff *skb, return skb; } +/* + * __vlan_hwaccel_push_inside - pushes vlan tag to the payload + * @skb: skbuff to tag + * + * Pushes the VLAN tag from @skb->vlan_tci inside to the payload. + * + * Following the skb_unshare() example, in case of error, the calling function + * doesn't have to worry about freeing the original skb. + */ +static inline struct sk_buff *__vlan_hwaccel_push_inside(struct sk_buff *skb) +{ + skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto, + vlan_tx_tag_get(skb)); + if (likely(skb)) + skb->vlan_tci = 0; + return skb; +} +/* + * vlan_hwaccel_push_inside - pushes vlan tag to the payload + * @skb: skbuff to tag + * + * Checks is tag is present in @skb->vlan_tci and if it is, it pushes the + * VLAN tag from @skb->vlan_tci inside to the payload. + * + * Following the skb_unshare() example, in case of error, the calling function + * doesn't have to worry about freeing the original skb. + */ +static inline struct sk_buff *vlan_hwaccel_push_inside(struct sk_buff *skb) +{ + if (vlan_tx_tag_present(skb)) + skb = __vlan_hwaccel_push_inside(skb); + return skb; +} + /** * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting * @skb: skbuff to tag |