summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrell Ball <dlu998@gmail.com>2018-01-09 15:44:57 -0800
committerBen Pfaff <blp@ovn.org>2018-01-10 09:24:58 -0800
commitc8b1ad49da68227a86da432a4adc29d5855b6cdd (patch)
treef20c76b05227f2b79bd6a4c232c2455a417e73ab
parentdec0dbbc8a422d682cdb051999386c8d27715d27 (diff)
downloadopenvswitch-c8b1ad49da68227a86da432a4adc29d5855b6cdd.tar.gz
conntrack: Reorder sanity checks in extract_l3_ipvx().
The functions extract_l3_ipv4 and extract_l3_ipv6 check for unsupported ip fragments and return early. The checks were after an assignment that would not be needed when early return happens. This is slightly inefficient, but mostly reads poorly. Hence, reorder the ip fragment checks before the assignments. Signed-off-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/conntrack.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/conntrack.c b/lib/conntrack.c
index 470f11334..c89ac43ad 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -1518,11 +1518,11 @@ extract_l3_ipv4(struct conn_key *key, const void *data, size_t size,
return false;
}
- *new_data = (char *) data + ip_len;
- }
+ if (IP_IS_FRAGMENT(ip->ip_frag_off)) {
+ return false;
+ }
- if (IP_IS_FRAGMENT(ip->ip_frag_off)) {
- return false;
+ *new_data = (char *) data + ip_len;
}
if (validate_checksum && csum(data, ip_len) != 0) {
@@ -1562,14 +1562,14 @@ extract_l3_ipv6(struct conn_key *key, const void *data, size_t size,
return false;
}
- if (new_data) {
- *new_data = data;
- }
-
if (nw_frag) {
return false;
}
+ if (new_data) {
+ *new_data = data;
+ }
+
key->src.addr.ipv6 = ip6->ip6_src;
key->dst.addr.ipv6 = ip6->ip6_dst;
key->nw_proto = nw_proto;