From: Jiri Benc <jbenc@redhat.com>
To: netdev@vger.kernel.org
Cc: pravin shelar <pshelar@ovn.org>, Eric Garver <e@erig.me>
Subject: [PATCH net-next v3 5/6] openvswitch: remove unreachable code in vlan parsing
Date: Fri, 7 Oct 2016 18:07:40 +0200 [thread overview]
Message-ID: <7a7568c8ae611b3f963031c935f14b3d4ec36f2a.1475855896.git.jbenc@redhat.com> (raw)
In-Reply-To: <cover.1475855896.git.jbenc@redhat.com>
Now when the first vlan tag is always in skb->vlan_tci, drop code that
assumed it might not be the case.
This patch also removes the wrong likely() statement around
skb_vlan_tag_present introduced by 018c1dda5ff1 ("openvswitch: 802.1AD Flow
handling, actions, vlan parsing, netlink attributes"). This code is called
whenever flow key is being extracted from the packet, the packet may be as
likely vlan tagged as not.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
v3: unchanged
---
net/openvswitch/flow.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 14159ac19850..45e384167053 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -308,9 +308,7 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
/**
* Parse vlan tag from vlan header.
- * Returns ERROR on memory error.
- * Returns 0 if it encounters a non-vlan or incomplete packet.
- * Returns 1 after successfully parsing vlan tag.
+ * Returns ERROR on memory error, 0 otherwise.
*/
static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *key_vh)
{
@@ -331,34 +329,24 @@ static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *key_vh)
key_vh->tpid = vh->tpid;
__skb_pull(skb, sizeof(struct vlan_head));
- return 1;
+ return 0;
}
static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
{
- int res;
-
key->eth.vlan.tci = 0;
key->eth.vlan.tpid = 0;
key->eth.cvlan.tci = 0;
key->eth.cvlan.tpid = 0;
- if (likely(skb_vlan_tag_present(skb))) {
- key->eth.vlan.tci = htons(skb->vlan_tci);
- key->eth.vlan.tpid = skb->vlan_proto;
- } else {
- /* Parse outer vlan tag in the non-accelerated case. */
- res = parse_vlan_tag(skb, &key->eth.vlan);
- if (res <= 0)
- return res;
- }
+ if (!skb_vlan_tag_present(skb))
+ return 0;
- /* Parse inner vlan tag. */
- res = parse_vlan_tag(skb, &key->eth.cvlan);
- if (res <= 0)
- return res;
+ key->eth.vlan.tci = htons(skb->vlan_tci);
+ key->eth.vlan.tpid = skb->vlan_proto;
- return 0;
+ /* Parse inner vlan tag. */
+ return parse_vlan_tag(skb, &key->eth.cvlan);
}
static __be16 parse_ethertype(struct sk_buff *skb)
--
1.8.3.1
next prev parent reply other threads:[~2016-10-07 16:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 16:07 [PATCH net-next v3 0/6] openvswitch: make vlan handling consistent Jiri Benc
2016-10-07 16:07 ` [PATCH net-next v3 1/6] openvswitch: make skb modifiable in ovs_flow_key_extract* Jiri Benc
2016-10-07 16:07 ` [PATCH net-next v3 2/6] openvswitch: normalize vlan rx path Jiri Benc
2016-10-07 16:07 ` [PATCH net-next v3 3/6] openvswitch: add NETIF_F_HW_VLAN_STAG_TX to internal dev Jiri Benc
2016-10-07 16:07 ` [PATCH net-next v3 4/6] openvswitch: keep vlan tag accelerated on internal device Jiri Benc
2016-10-07 16:07 ` Jiri Benc [this message]
2016-10-07 16:07 ` [PATCH net-next v3 6/6] openvswitch: fix vlan subtraction from packet length Jiri Benc
2016-10-07 19:59 ` [PATCH net-next v3 0/6] openvswitch: make vlan handling consistent Pravin Shelar
2016-10-10 12:46 ` 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=7a7568c8ae611b3f963031c935f14b3d4ec36f2a.1475855896.git.jbenc@redhat.com \
--to=jbenc@redhat.com \
--cc=e@erig.me \
--cc=netdev@vger.kernel.org \
--cc=pshelar@ovn.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).