[ovs-dev] [runt-flows 7/8] datapath: Fix default value of skb transport_header.

Ben Pfaff blp at nicira.com
Fri Aug 27 19:42:23 UTC 2010


On Thu, Aug 26, 2010 at 03:03:20PM -0700, Jesse Gross wrote:
> On Fri, Aug 13, 2010 at 10:55 AM, Ben Pfaff <blp at nicira.com> wrote:
> > @@ -353,7 +364,7 @@ int flow_extract(struct sk_buff *skb, u16 in_port, struct odp_flow_key *key)
> >                        }
> >                }
> >        } else {
> > -               skb_reset_transport_header(skb);
> > +               skb->transport_header = skb->network_header;
> >        }
> 
> We never set the transport header if we have a valid ARP header.  I
> don't think it's necessary but then that makes me wonder why this is
> necessary.

You're right.  Some actions do care about it for IP, but nothing cares
about it in other cases, so I just dropped the "else".

Here's the new version:

--8<--------------------------cut here-------------------------->8--

From: Ben Pfaff <blp at nicira.com>
Date: Fri, 27 Aug 2010 12:41:00 -0700
Subject: [PATCH] datapath: Fix default value of skb transport_header.

This commit started out as simply better documenting flow_extract(),
but then I realized that nothing cares about transport_header in the
non-IP case, so don't bother with it at all.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 datapath/flow.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/datapath/flow.c b/datapath/flow.c
index 5f122bb..7d3bc04 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -224,6 +224,18 @@ static __be16 parse_ethertype(struct sk_buff *skb)
  *
  * Returns 0 if successful, otherwise a negative errno value.
  *
+ * Initializes @skb header pointers as follows:
+ *
+ *    - skb->mac_header: the Ethernet header.
+ *
+ *    - skb->network_header: just past the Ethernet header, or just past the
+ *      VLAN header, to the first byte of the Ethernet payload.
+ *
+ *    - skb->transport_header: If key->dl_type is ETH_P_IP on output, then just
+ *      past the IPv4 header, if one is present and of a correct length,
+ *      otherwise the same as skb->network_header.  For other key->dl_type
+ *      values it is left untouched.
+ *
  * Sets OVS_CB(skb)->is_frag to %true if @skb is an IPv4 fragment, otherwise to
  * %false.
  */
@@ -355,8 +367,6 @@ int flow_extract(struct sk_buff *skb, u16 in_port, struct odp_flow_key *key)
 				memcpy(&key->nw_dst, arp->ar_tip, sizeof(key->nw_dst));
 			}
 		}
-	} else {
-		skb_reset_transport_header(skb);
 	}
 	return 0;
 }
-- 
1.7.1





More information about the dev mailing list