[ovs-dev] [PATCH 03/16] packet: packet_get_tcp_flags: use flow's innermost dl_type

Simon Horman horms at verge.net.au
Wed Feb 6 13:53:54 UTC 2013


Use the innermost dl_type when decoding L3 and L4 data from a packet.

Signed-off-by: Simon Horman <horms at verge.net.au>

---

v2.18
* Update to use dl_type_is_ip_any() wrapper.
  I am reluctant to update is_ip_any() to use flow_innermost_dl_type(flow)
  as I am not convinced that this is correct for all users of is_ip_any().
  Furthermore, the dl_type_is_ip_any() seems to be useful in subsequent
  patches in the MPLS series.

v2.12 - v2.17
* Use flow_innermost_dl_type helper

v2.11
* First post
---
 lib/packets.c |    4 +++-
 lib/packets.h |    9 +++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/packets.c b/lib/packets.c
index 424f7ac..a39cddf 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -887,7 +887,9 @@ packet_set_udp_port(struct ofpbuf *packet, ovs_be16 src, ovs_be16 dst)
 uint8_t
 packet_get_tcp_flags(const struct ofpbuf *packet, const struct flow *flow)
 {
-    if (is_ip_any(flow) && flow->nw_proto == IPPROTO_TCP && packet->l7) {
+    ovs_be16 dl_type = flow_innermost_dl_type(flow);
+    if (dl_type_is_ip_any(dl_type) &&
+        flow->nw_proto == IPPROTO_TCP && packet->l7) {
         const struct tcp_header *tcp = packet->l4;
         return TCP_FLAGS(tcp->tcp_ctl);
     } else {
diff --git a/lib/packets.h b/lib/packets.h
index 973f3e8..0f97fe6 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -548,10 +548,15 @@ static inline bool ipv6_mask_is_exact(const struct in6_addr *mask) {
     return ipv6_addr_equals(mask, &in6addr_exact);
 }
 
+static inline bool dl_type_is_ip_any(ovs_be16 dl_type)
+{
+    return dl_type == htons(ETH_TYPE_IP)
+        || dl_type == htons(ETH_TYPE_IPV6);
+}
+
 static inline bool is_ip_any(const struct flow *flow)
 {
-    return flow->dl_type == htons(ETH_TYPE_IP)
-        || flow->dl_type == htons(ETH_TYPE_IPV6);
+    return dl_type_is_ip_any(flow->dl_type);
 }
 
 void format_ipv6_addr(char *addr_str, const struct in6_addr *addr);
-- 
1.7.10.4




More information about the dev mailing list