[ovs-dev,v5,6/7] Give the variables more meaningful names
diff mbox series

Message ID 20190911141005.1346-7-michalx.obrembski@intel.com
State New
Headers show
Series
  • dpdk: Add support for TSO
Related show

Commit Message

Michal Obrembski Sept. 11, 2019, 2:10 p.m. UTC
From: Artur Twardowski <arturx.twardowski@intel.com>

Replaced variable names "hlen", "ulen", "gnh" with longer ones to make
the code analysis easier. Additionally, UDP header len is no longer
accumulated into GENEVE header length, additions are used in the places
where the sum of both headers is used.

Signed-off-by: Artur Twardowski <arturx.twardowski@intel.com>
---
 lib/netdev-native-tnl.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

Patch
diff mbox series

diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 54ed0e9..d0ea3d5 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -837,8 +837,8 @@  netdev_geneve_pop_header(struct dp_packet *packet)
 {
     struct pkt_metadata *md = &packet->md;
     struct flow_tnl *tnl = &md->tunnel;
-    struct genevehdr *gnh;
-    unsigned int hlen, opts_len, ulen;
+    struct genevehdr *geneve_hdr;
+    unsigned int geneve_hdr_len, opts_len, udp_hdr_len;
 
     pkt_metadata_init_tnl(md);
     if (!dp_packet_may_pull(packet, packet->l4_ofs, GENEVE_BASE_HLEN)) {
@@ -847,40 +847,42 @@  netdev_geneve_pop_header(struct dp_packet *packet)
         goto err;
     }
 
-    gnh = udp_extract_tnl_md(packet, tnl, &ulen);
-    if (!gnh) {
+    geneve_hdr = udp_extract_tnl_md(packet, tnl, &udp_hdr_len);
+    if (!geneve_hdr) {
         goto err;
     }
 
-    opts_len = gnh->opt_len * 4;
-    hlen = ulen + GENEVE_BASE_HLEN + opts_len;
-    if (!dp_packet_may_pull(packet, packet->l4_ofs, hlen - ulen)) {
-        VLOG_WARN_RL(&err_rl, "geneve packet too small: header len=%u packet size=%u\n",
-                     hlen, dp_packet_size(packet));
+    opts_len = geneve_hdr->opt_len * 4;
+    geneve_hdr_len = GENEVE_BASE_HLEN + opts_len;
+    if (!dp_packet_may_pull(packet, udp_hdr_len, geneve_hdr_len)) {
+        VLOG_WARN_RL(&err_rl, "geneve packet too small: "
+                              "wanted headers=%u, but packet size=%u\n",
+                              geneve_hdr_len + udp_hdr_len,
+                              dp_packet_size(packet));
         goto err;
     }
 
-    if (gnh->ver != 0) {
-        VLOG_WARN_RL(&err_rl, "unknown geneve version: %"PRIu8"\n", gnh->ver);
+    if (geneve_hdr->ver != 0) {
+        VLOG_WARN_RL(&err_rl, "unknown geneve version: %"PRIu8"\n", geneve_hdr->ver);
         goto err;
     }
 
-    if (gnh->proto_type != htons(ETH_TYPE_TEB)) {
+    if (geneve_hdr->proto_type != htons(ETH_TYPE_TEB)) {
         VLOG_WARN_RL(&err_rl, "unknown geneve encapsulated protocol: %#x\n",
-                     ntohs(gnh->proto_type));
+                     ntohs(geneve_hdr->proto_type));
         goto err;
     }
 
-    tnl->flags |= gnh->oam ? FLOW_TNL_F_OAM : 0;
-    tnl->tun_id = htonll(ntohl(get_16aligned_be32(&gnh->vni)) >> 8);
+    tnl->flags |= geneve_hdr->oam ? FLOW_TNL_F_OAM : 0;
+    tnl->tun_id = htonll(ntohl(get_16aligned_be32(&geneve_hdr->vni)) >> 8);
     tnl->flags |= FLOW_TNL_F_KEY;
 
-    memcpy(tnl->metadata.opts.gnv, gnh->options, opts_len);
+    memcpy(tnl->metadata.opts.gnv, geneve_hdr->options, opts_len);
     tnl->metadata.present.len = opts_len;
     tnl->flags |= FLOW_TNL_F_UDPIF;
 
     packet->packet_type = htonl(PT_ETH);
-    dp_packet_reset_packet(packet, hlen);
+    dp_packet_reset_packet(packet, geneve_hdr_len + udp_hdr_len);
 
     return packet;
 err: