[ovs-dev] [PATCH 07/11] lib/packets: Remove the unused l7 setting for ICMP.

Jarno Rajahalme jarno.rajahalme at nsn.com
Mon Feb 11 14:46:23 UTC 2013


Remove the setting of l7 pointer for ICMP packets, as it is not being used.
Clarify the role of l7 pointer in determining whether a whole UDP or TCP
header has been received.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme at nsn.com>
---
 lib/flow.c    |   11 ++++-------
 lib/packets.c |   44 ++++++++++++++++++++++++--------------------
 2 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 525fb71..3960013 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -348,7 +348,7 @@ invalid:
  *    - packet->l4 to just past the IPv4 header, if one is present and has a
  *      correct length, and otherwise NULL.
  *
- *    - packet->l7 to just past the TCP or UDP or ICMP header, if one is
+ *    - packet->l7 to just past the TCP or UDP header, if one is
  *      present and has a correct length, and otherwise NULL.
  */
 void
@@ -385,7 +385,7 @@ flow_extract(struct ofpbuf *packet, uint32_t skb_priority, uint32_t skb_mark,
  *    - packet->l4 to just past the IPv4 header, if one is present and has a
  *      correct length, and otherwise NULL.
  *
- *    - packet->l7 to just past the TCP or UDP or ICMP header, if one is
+ *    - packet->l7 to just past the TCP or UDP header, if one is
  *      present and has a correct length, and otherwise NULL.
  */
 void
@@ -437,7 +437,7 @@ flow_extract_l2_onwards(struct ofpbuf *packet, struct flow *flow)
  *    - packet->l4 to just past the IPv4 header, if one is present and has a
  *      correct length, and otherwise NULL.
  *
- *    - packet->l7 to just past the TCP or UDP or ICMP header, if one is
+ *    - packet->l7 to just past the TCP or UDP header, if one is
  *      present and has a correct length, and otherwise NULL.
  */
 void
@@ -478,7 +478,6 @@ flow_extract_l3_onwards(struct ofpbuf *packet, struct flow *flow,
                     if (icmp) {
                         flow->tp_src = htons(icmp->icmp_type);
                         flow->tp_dst = htons(icmp->icmp_code);
-                        packet->l7 = b.data;
                     }
                 }
             }
@@ -494,9 +493,7 @@ flow_extract_l3_onwards(struct ofpbuf *packet, struct flow *flow,
         } else if (flow->nw_proto == IPPROTO_UDP) {
             parse_udp(packet, &b, flow);
         } else if (flow->nw_proto == IPPROTO_ICMPV6) {
-            if (parse_icmpv6(&b, flow)) {
-                packet->l7 = b.data;
-            }
+            parse_icmpv6(&b, flow);
         }
     } else if (dl_type == htons(ETH_TYPE_ARP) ||
                dl_type == htons(ETH_TYPE_RARP)) {
diff --git a/lib/packets.c b/lib/packets.c
index a39cddf..629939c 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -631,17 +631,19 @@ packet_set_ipv4_addr(struct ofpbuf *packet, ovs_be32 *addr, ovs_be32 new_addr)
 {
     struct ip_header *nh = packet->l3;
 
-    if (nh->ip_proto == IPPROTO_TCP && packet->l7) {
-        struct tcp_header *th = packet->l4;
-
-        th->tcp_csum = recalc_csum32(th->tcp_csum, *addr, new_addr);
-    } else if (nh->ip_proto == IPPROTO_UDP && packet->l7) {
-        struct udp_header *uh = packet->l4;
-
-        if (uh->udp_csum) {
-            uh->udp_csum = recalc_csum32(uh->udp_csum, *addr, new_addr);
-            if (!uh->udp_csum) {
-                uh->udp_csum = htons(0xffff);
+    if (packet->l7) {
+        if (nh->ip_proto == IPPROTO_TCP) {
+            struct tcp_header *th = packet->l4;
+
+            th->tcp_csum = recalc_csum32(th->tcp_csum, *addr, new_addr);
+        } else if (nh->ip_proto == IPPROTO_UDP) {
+            struct udp_header *uh = packet->l4;
+
+            if (uh->udp_csum) {
+                uh->udp_csum = recalc_csum32(uh->udp_csum, *addr, new_addr);
+                if (!uh->udp_csum) {
+                    uh->udp_csum = htons(0xffff);
+                }
             }
         }
     }
@@ -737,17 +739,19 @@ static void
 packet_update_csum128(struct ofpbuf *packet, uint8_t proto,
                      ovs_be32 addr[4], const ovs_be32 new_addr[4])
 {
-    if (proto == IPPROTO_TCP && packet->l7) {
-        struct tcp_header *th = packet->l4;
+    if (packet->l7) {
+        if (proto == IPPROTO_TCP) {
+            struct tcp_header *th = packet->l4;
 
-        th->tcp_csum = recalc_csum128(th->tcp_csum, addr, new_addr);
-    } else if (proto == IPPROTO_UDP && packet->l7) {
-        struct udp_header *uh = packet->l4;
+            th->tcp_csum = recalc_csum128(th->tcp_csum, addr, new_addr);
+        } else if (proto == IPPROTO_UDP) {
+            struct udp_header *uh = packet->l4;
 
-        if (uh->udp_csum) {
-            uh->udp_csum = recalc_csum128(uh->udp_csum, addr, new_addr);
-            if (!uh->udp_csum) {
-                uh->udp_csum = htons(0xffff);
+            if (uh->udp_csum) {
+                uh->udp_csum = recalc_csum128(uh->udp_csum, addr, new_addr);
+                if (!uh->udp_csum) {
+                    uh->udp_csum = htons(0xffff);
+                }
             }
         }
     }
-- 
1.7.10.4




More information about the dev mailing list