ofp-util: Drop unneeded null pointer tests.
[openvswitch] / lib / flow.c
index 7ef0e5b6319c5fbacb93674d46d7455b43b75ad5..f4446c93a4005e6e49306892e83a71328b2b3fad 100644 (file)
@@ -180,7 +180,7 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
                 || (nexthdr == IPPROTO_DSTOPTS)) {
             /* These headers, while different, have the fields we care about
              * in the same location and with the same interpretation. */
-            const struct ip6_ext *ext_hdr = (struct ip6_ext *)packet->data;
+            const struct ip6_ext *ext_hdr = packet->data;
             nexthdr = ext_hdr->ip6e_nxt;
             if (!ofpbuf_try_pull(packet, (ext_hdr->ip6e_len + 1) * 8)) {
                 return EINVAL;
@@ -190,13 +190,13 @@ parse_ipv6(struct ofpbuf *packet, struct flow *flow)
              * we care about are in the same location as the generic
              * option header--only the header length is calculated
              * differently. */
-            const struct ip6_ext *ext_hdr = (struct ip6_ext *)packet->data;
+            const struct ip6_ext *ext_hdr = packet->data;
             nexthdr = ext_hdr->ip6e_nxt;
             if (!ofpbuf_try_pull(packet, (ext_hdr->ip6e_len + 2) * 4)) {
                return EINVAL;
             }
         } else if (nexthdr == IPPROTO_FRAGMENT) {
-            const struct ip6_frag *frag_hdr = (struct ip6_frag *)packet->data;
+            const struct ip6_frag *frag_hdr = packet->data;
 
             nexthdr = frag_hdr->ip6f_nxt;
             if (!ofpbuf_try_pull(packet, sizeof *frag_hdr)) {
@@ -497,14 +497,8 @@ flow_get_metadata(const struct flow *flow, struct flow_metadata *fmd)
     BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
 
     fmd->tun_id = flow->tun_id;
-    fmd->tun_id_mask = htonll(UINT64_MAX);
-
     fmd->metadata = flow->metadata;
-    fmd->metadata_mask = htonll(UINT64_MAX);
-
     memcpy(fmd->regs, flow->regs, sizeof fmd->regs);
-    memset(fmd->reg_masks, 0xff, sizeof fmd->reg_masks);
-
     fmd->in_port = flow->in_port;
 }
 
@@ -1066,6 +1060,7 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
                 b->l4 = icmp = ofpbuf_put_zeros(b, sizeof *icmp);
                 icmp->icmp_type = ntohs(flow->tp_src);
                 icmp->icmp_code = ntohs(flow->tp_dst);
+                icmp->icmp_csum = csum(icmp, ICMP_HEADER_LEN);
             }
         }