From: Jiri Pirko <jiri@resnulli.us>
To: Pravin Shelar <pshelar@nicira.com>
Cc: netdev <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Tom Herbert <therbert@google.com>,
Eric Dumazet <edumazet@google.com>,
Willem de Bruijn <willemb@google.com>,
Daniel Borkmann <dborkman@redhat.com>,
mst@redhat.com, fw@strlen.de, Paul.Durrant@citrix.com,
Thomas Graf <tgraf@suug.ch>, Cong Wang <cwang@twopensource.com>
Subject: Re: [patch net-next v3 5/9] vlan: introduce *vlan_hwaccel_push_inside helpers
Date: Wed, 19 Nov 2014 09:38:47 +0100 [thread overview]
Message-ID: <20141119083847.GA1926@nanopsycho.orion> (raw)
In-Reply-To: <CALnjE+qp2SiKPFaRQDWcBxR-kiryfnsttT902iUnTi7=DZT6JQ@mail.gmail.com>
Wed, Nov 19, 2014 at 09:05:34AM CET, pshelar@nicira.com wrote:
>On Tue, Nov 18, 2014 at 1:37 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>> Use them to push skb->vlan_tci into the payload and avoid code
>> duplication.
>>
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>> ---
>> drivers/net/vxlan.c | 22 ++++++----------------
>> include/linux/if_vlan.h | 34 ++++++++++++++++++++++++++++++++++
>> net/core/dev.c | 8 ++------
>> net/core/netpoll.c | 4 +---
>> net/ipv4/geneve.c | 11 +++--------
>> net/openvswitch/datapath.c | 6 +-----
>> net/openvswitch/vport-gre.c | 12 ++++--------
>> 7 files changed, 51 insertions(+), 46 deletions(-)
>>
>> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
>> index bb8fbab..64d45fa 100644
>> --- a/drivers/net/vxlan.c
>> +++ b/drivers/net/vxlan.c
>> @@ -1599,14 +1599,9 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
>> if (unlikely(err))
>> return err;
>>
>> - if (vlan_tx_tag_present(skb)) {
>> - skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
>> - vlan_tx_tag_get(skb));
>> - if (WARN_ON(!skb))
>> - return -ENOMEM;
>> -
>> - skb->vlan_tci = 0;
>> - }
>> + skb = vlan_hwaccel_push_inside(skb);
>> + if (WARN_ON(!skb))
>> + return -ENOMEM;
>>
>> vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
>> vxh->vx_flags = htonl(VXLAN_FLAGS);
>> @@ -1643,14 +1638,9 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
>> if (unlikely(err))
>> return err;
>>
>> - if (vlan_tx_tag_present(skb)) {
>> - skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
>> - vlan_tx_tag_get(skb));
>> - if (WARN_ON(!skb))
>> - return -ENOMEM;
>> -
>> - skb->vlan_tci = 0;
>> - }
>> + skb = vlan_hwaccel_push_inside(skb);
>> + if (WARN_ON(!skb))
>> + return -ENOMEM;
>>
>> vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
>> vxh->vx_flags = htonl(VXLAN_FLAGS);
>> diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
>> index 46e4a15..291e670 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
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 3611e60..ac48362 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -2644,12 +2644,8 @@ static struct sk_buff *validate_xmit_vlan(struct sk_buff *skb,
>> netdev_features_t features)
>> {
>> if (vlan_tx_tag_present(skb) &&
>> - !vlan_hw_offload_capable(features, skb->vlan_proto)) {
>> - skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
>> - vlan_tx_tag_get(skb));
>> - if (skb)
>> - skb->vlan_tci = 0;
>> - }
>> + !vlan_hw_offload_capable(features, skb->vlan_proto))
>> + skb = __vlan_hwaccel_push_inside(skb);
>> return skb;
>> }
>>
>> diff --git a/net/core/netpoll.c b/net/core/netpoll.c
>> index 65d3723..e0ad5d1 100644
>> --- a/net/core/netpoll.c
>> +++ b/net/core/netpoll.c
>> @@ -79,8 +79,7 @@ static int netpoll_start_xmit(struct sk_buff *skb, struct net_device *dev,
>>
>> if (vlan_tx_tag_present(skb) &&
>> !vlan_hw_offload_capable(features, skb->vlan_proto)) {
>> - skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
>> - vlan_tx_tag_get(skb));
>> + skb = __vlan_hwaccel_push_inside(skb);
>> if (unlikely(!skb)) {
>> /* This is actually a packet drop, but we
>> * don't want the code that calls this
>> @@ -88,7 +87,6 @@ static int netpoll_start_xmit(struct sk_buff *skb, struct net_device *dev,
>> */
>> goto out;
>> }
>> - skb->vlan_tci = 0;
>> }
>>
>> status = netdev_start_xmit(skb, dev, txq, false);
>> diff --git a/net/ipv4/geneve.c b/net/ipv4/geneve.c
>> index fd430a6..a457232 100644
>> --- a/net/ipv4/geneve.c
>> +++ b/net/ipv4/geneve.c
>> @@ -131,14 +131,9 @@ int geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt,
>> if (unlikely(err))
>> return err;
>>
>> - if (vlan_tx_tag_present(skb)) {
>> - skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
>> - vlan_tx_tag_get(skb));
>> - if (unlikely(!skb)
>> - return -ENOMEM;
>> -
>> - skb->vlan_tci = 0;
>> - }
>> + skb = vlan_hwaccel_push_inside(skb);
>> + if (unlikely(!skb))
>> + return -ENOMEM;
>>
>> gnvh = (struct genevehdr *)__skb_push(skb, sizeof(*gnvh) + opt_len);
>> geneve_build_header(gnvh, tun_flags, vni, opt_len, opt);
>> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
>> index c63e60e..0cb9d4f 100644
>> --- a/net/openvswitch/datapath.c
>> +++ b/net/openvswitch/datapath.c
>> @@ -425,12 +425,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
>> if (!nskb)
>> return -ENOMEM;
>>
>> - nskb = vlan_insert_tag_set_proto(nskb, nskb->vlan_proto,
>> - vlan_tx_tag_get(nskb));
>> - if (!nskb)
>> - return -ENOMEM;
>> + nskb = __vlan_hwaccel_push_inside(nskb);
>>
>> - nskb->vlan_tci = 0;
>
>Need to check for returned nskb for NULL case.
Oops, Fixed. Thanks.
>
>> skb = nskb;
>> }
>>
>> diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c
>> index 777cd8c..6b69df5 100644
>> --- a/net/openvswitch/vport-gre.c
>> +++ b/net/openvswitch/vport-gre.c
>> @@ -175,14 +175,10 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
>> goto err_free_rt;
>> }
>>
>> - if (vlan_tx_tag_present(skb)) {
>> - skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
>> - vlan_tx_tag_get(skb));
>> - if (unlikely(!skb) {
>> - err = -ENOMEM;
>> - goto err_free_rt;
>> - }
>> - skb->vlan_tci = 0;
>> + skb = vlan_hwaccel_push_inside(skb);
>> + if (unlikely(!skb)) {
>> + err = -ENOMEM;
>> + goto err_free_rt;
>> }
>>
>> /* Push Tunnel header. */
>> --
>> 1.9.3
>>
next prev parent reply other threads:[~2014-11-19 8:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-18 21:37 [patch net-next v3 0/9] sched: introduce vlan action Jiri Pirko
2014-11-18 21:37 ` [patch net-next v3 1/9] openvswitch: actions: use skb_postpull_rcsum when possible Jiri Pirko
2014-11-18 21:37 ` [patch net-next v3 2/9] vlan: make __vlan_hwaccel_put_tag return void Jiri Pirko
2014-11-19 8:05 ` Pravin Shelar
2014-11-18 21:37 ` [patch net-next v3 3/9] vlan: kill vlan_put_tag helper Jiri Pirko
2014-11-18 21:37 ` [patch net-next v3 4/9] vlan: rename __vlan_put_tag to vlan_insert_tag_set_proto Jiri Pirko
2014-11-19 8:05 ` Pravin Shelar
2014-11-18 21:37 ` [patch net-next v3 5/9] vlan: introduce *vlan_hwaccel_push_inside helpers Jiri Pirko
2014-11-19 8:05 ` Pravin Shelar
2014-11-19 8:38 ` Jiri Pirko [this message]
2014-11-18 21:37 ` [patch net-next v3 6/9] vlan: introduce __vlan_insert_tag helper which does not free skb Jiri Pirko
2014-11-19 8:05 ` Pravin Shelar
2014-11-18 21:37 ` [patch net-next v3 7/9] net: move make_writable helper into common code Jiri Pirko
2014-11-18 21:37 ` [patch net-next v3 8/9] net: move vlan pop/push functions " Jiri Pirko
2014-11-19 8:06 ` Pravin Shelar
2014-11-19 10:03 ` Jiri Pirko
2014-11-19 13:03 ` Jiri Benc
2014-11-19 20:32 ` Pravin Shelar
2014-11-18 21:37 ` [patch net-next v3 9/9] sched: introduce vlan action Jiri Pirko
2014-11-18 21:39 ` [patch iproute2 v3] tc: add support for vlan tc action Jiri Pirko
2014-11-18 21:54 ` [patch net-next v3 0/9] sched: introduce vlan action Or Gerlitz
2014-11-18 22:04 ` Jiri Pirko
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=20141119083847.GA1926@nanopsycho.orion \
--to=jiri@resnulli.us \
--cc=Paul.Durrant@citrix.com \
--cc=cwang@twopensource.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=jhs@mojatatu.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pshelar@nicira.com \
--cc=tgraf@suug.ch \
--cc=therbert@google.com \
--cc=willemb@google.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).