From: Thomas F Herbert <thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Pravin Shelar <pshelar-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
Cc: "dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org"
<dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org>,
netdev <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
therbert-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH net-next V15 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes
Date: Thu, 15 Oct 2015 08:50:27 -0400 [thread overview]
Message-ID: <561FA113.6050304@gmail.com> (raw)
In-Reply-To: <CALnjE+rFgnRZ0awed1eox62zEeFKaCXoAucv6wS4MVBFK_RLRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 10/13/15 2:14 PM, Pravin Shelar wrote:
> On Tue, Oct 13, 2015 at 10:39 AM, Thomas F Herbert
> <thomasfherbert@gmail.com> wrote:
>> Pravin,
>>
>> Thanks for the review.
>>
>>
>> On 10/13/15 7:47 AM, Pravin Shelar wrote:
>>> On Sat, Oct 10, 2015 at 4:40 PM, Thomas F Herbert
>>> <thomasfherbert@gmail.com> wrote:
>>>> Add support for 802.1ad including the ability to push and pop double
>>>> tagged vlans. Add support for 802.1ad to netlink parsing and flow
>>>> conversion. Uses double nested encap attributes to represent double
>>>> tagged vlan. Inner TPID encoded along with ctci in nested attributes.
>>>>
>>>> Signed-off-by: Thomas F Herbert<thomasfherbert@gmail.com>
>>>> ---
>>>> net/openvswitch/actions.c | 6 +-
>>>> net/openvswitch/flow.c | 92 +++++++++++++++++++----
>>>> net/openvswitch/flow.h | 11 ++-
>>>> net/openvswitch/flow_netlink.c | 166
>>>> +++++++++++++++++++++++++++++++++++++----
>>>> net/openvswitch/vport-netdev.c | 4 +-
>>>> 5 files changed, 245 insertions(+), 34 deletions(-)
>>>>
>>> ...
>>>
> ...
>
>>> I see lot of duplicate code here. How about code below:
>>>
>>> struct qtag_prefix {
>>> __be16 eth_type; /* ETH_P_8021Q or ETH_P_8021AD */
>>> __be16 tci;
>>> };
>>>
>>> /* Return < 0 on memory error
>>> * Return == 0 on non vlan or incomplete packet packet
>>> * Return > 0 on successfully parsing vlan tag.
>>> */
>>> static int parse_vlan_tag(__be16 vlan_proto, struct sk_buff *skb,
>>> struct vlan_tag *cvlan)
>>> {
>>> if (likely(!eth_type_vlan(skb->vlan_proto)))
>>> return 0;
>>>
>>> if (unlikely(skb->len < sizeof(struct qtag_prefix) +
>>> sizeof(__be16))) {
>>> vlan->tci = 0;
>>> return 0;
>>> }
>>>
>>> if (unlikely(!pskb_may_pull(skb, sizeof(struct qtag_prefix) +
>>> sizeof(__be16))))
>>> return -ENOMEM;
>>>
>>> qp = (struct qtag_prefix *)skb->data;
>>> key->eth.cvlan.tci = qp->tci | htons(VLAN_TAG_PRESENT);
>>> key->eth.cvlan.tpid = qp->eth_type;
>>>
>>> __skb_pull(skb, sizeof(struct qtag_prefix));
>>> return 1;
>>> }
>> This makes for cleaner code and certainly better for maintainability so I
>> have just implemented it for this next revision. However, note that with
>> this change, we incur the overhead of an additional function call for single
>> tagged vlan packets.
>>
> If there is any performance issue we can fix the code later.
>
>>> static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
>>> {
>>> struct qtag_prefix *qp = (struct qtag_prefix *)skb->data;
> ...
>
>>>> + u64 mask_v_attrs = 0;
>>>> +
>>>> + err = parse_flow_mask_nlattrs(*nla, a, &mask_v_attrs,
>>>> log);
>>>> + if (err)
>>>> + return err;
>>>> +
>>>> + if (mask_v_attrs & 1 << OVS_KEY_ATTR_ENCAP) {
>>>> + if (!*ie_valid) {
>>>> + OVS_NLERR(log, "Encap mask attribute is
>>>> set for non-CVLAN frame.");
>>>> + err = -EINVAL;
>>>> + return err;
>>>> + }
>>>> + encap = a[OVS_KEY_ATTR_ENCAP];
>>>> +
>>>> + err = cust_vlan_from_nlattrs(match, a, is_mask,
>>>> log);
>>>> + if (err)
>>>> + return err;
>>>> + *nla = encap;
>>>> +
>>> There is no checking for ATTR_VLAN or ATTR_ETHERTYPE. This can result
>>> in null pointer deference in cust_vlan_from_nlattrs().
>> The original vlan code does not check for these attribs in the masked case.
>> It does check for them in the non-masked case and then sets a boolean and
>> checks it in the masked case. I do the same thing for the inner vlan. I
>> check for the attributes in the non-masked case and set a boolean and check
>> the boolean in the masked case. Why is this not sufficient?
> Original code is checking for attributes before referencing them. For
> example in function ovs_nla_get_match() before extracting eth_type,
> it does check a[OVS_KEY_ATTR_ETHERTYPE]. But If you spot bug in
> current code please send fix for net tree.
> Regarding the Boolean, it is for presence of inner vlan for key
> attribute, mask attribute still could be missing vlan attribute.
> For vlan mask, we can keep check sanity check as outer vlan. It means
> eth_type must be specified and should be 0xffff, and tci mask is
> optional and by default initialized to 0xffff.
You are correct. I was thinking of something else. I had this but must
have lost it one of the patch revisions. Fixed it in V16.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
next prev parent reply other threads:[~2015-10-15 12:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 23:40 [PATCH net-next V15 0/3] openvswitch: Add support for 802.1ad Thomas F Herbert
[not found] ` <1444520433-1958-1-git-send-email-thomasfherbert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-10 23:40 ` [PATCH net-next V15 1/3] openvswitch: 802.1ad uapi changes Thomas F Herbert
2015-10-10 23:40 ` [PATCH net-next V15 3/3] 802.1AD: Flow handling, actions, vlan parsing and netlink attributes Thomas F Herbert
2015-10-13 6:47 ` Pravin Shelar
[not found] ` <CALnjE+qdqBrzZ_p6RCHLr63tSWTKPnTWhQuWsJ8dvAmq-bf9rQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-13 17:39 ` Thomas F Herbert
2015-10-13 18:14 ` Pravin Shelar
[not found] ` <CALnjE+rFgnRZ0awed1eox62zEeFKaCXoAucv6wS4MVBFK_RLRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-15 12:50 ` Thomas F Herbert [this message]
2015-10-10 23:40 ` [PATCH net-next V15 2/3] Check for vlan ethernet types for 8021.q or 802.1ad Thomas F Herbert
2015-10-12 13:52 ` Sergei Shtylyov
2015-10-13 2:58 ` [PATCH net-next V15 0/3] openvswitch: Add support for 802.1ad David Miller
2015-10-13 6:48 ` Pravin Shelar
[not found] ` <20151012.195841.292062617131376194.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-10-13 8:47 ` Thomas F Herbert
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=561FA113.6050304@gmail.com \
--to=thomasfherbert-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pshelar-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org \
--cc=therbert-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.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).