diff options
author | Andy Zhou <azhou@nicira.com> | 2013-08-22 15:12:57 -0400 |
---|---|---|
committer | Jesse Gross <jesse@nicira.com> | 2013-08-26 17:03:14 -0400 |
commit | 02237373b1c61a09a4db329545e39cffc48910d5 (patch) | |
tree | 47c876a301fbf432aa5b25e988aa7c217d9c724a /net/openvswitch | |
parent | a175a723301a8a4a9fedf9ce5b8ca586e7a97b40 (diff) |
openvswitch: Rename key_len to key_end
Key_end is a better name describing the ending boundary than key_len.
Rename those variables to make it less confusing.
Signed-off-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'net/openvswitch')
-rw-r--r-- | net/openvswitch/flow.c | 31 | ||||
-rw-r--r-- | net/openvswitch/flow.h | 2 |
2 files changed, 17 insertions, 16 deletions
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index 2b4785590b56..80bcb96467a5 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c | |||
@@ -997,10 +997,11 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key) | |||
997 | return 0; | 997 | return 0; |
998 | } | 998 | } |
999 | 999 | ||
1000 | static u32 ovs_flow_hash(const struct sw_flow_key *key, int key_start, int key_len) | 1000 | static u32 ovs_flow_hash(const struct sw_flow_key *key, int key_start, |
1001 | int key_end) | ||
1001 | { | 1002 | { |
1002 | return jhash2((u32 *)((u8 *)key + key_start), | 1003 | return jhash2((u32 *)((u8 *)key + key_start), |
1003 | DIV_ROUND_UP(key_len - key_start, sizeof(u32)), 0); | 1004 | DIV_ROUND_UP(key_end - key_start, sizeof(u32)), 0); |
1004 | } | 1005 | } |
1005 | 1006 | ||
1006 | static int flow_key_start(const struct sw_flow_key *key) | 1007 | static int flow_key_start(const struct sw_flow_key *key) |
@@ -1012,31 +1013,31 @@ static int flow_key_start(const struct sw_flow_key *key) | |||
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | static bool __cmp_key(const struct sw_flow_key *key1, | 1015 | static bool __cmp_key(const struct sw_flow_key *key1, |
1015 | const struct sw_flow_key *key2, int key_start, int key_len) | 1016 | const struct sw_flow_key *key2, int key_start, int key_end) |
1016 | { | 1017 | { |
1017 | return !memcmp((u8 *)key1 + key_start, | 1018 | return !memcmp((u8 *)key1 + key_start, |
1018 | (u8 *)key2 + key_start, (key_len - key_start)); | 1019 | (u8 *)key2 + key_start, (key_end - key_start)); |
1019 | } | 1020 | } |
1020 | 1021 | ||
1021 | static bool __flow_cmp_key(const struct sw_flow *flow, | 1022 | static bool __flow_cmp_key(const struct sw_flow *flow, |
1022 | const struct sw_flow_key *key, int key_start, int key_len) | 1023 | const struct sw_flow_key *key, int key_start, int key_end) |
1023 | { | 1024 | { |
1024 | return __cmp_key(&flow->key, key, key_start, key_len); | 1025 | return __cmp_key(&flow->key, key, key_start, key_end); |
1025 | } | 1026 | } |
1026 | 1027 | ||
1027 | static bool __flow_cmp_unmasked_key(const struct sw_flow *flow, | 1028 | static bool __flow_cmp_unmasked_key(const struct sw_flow *flow, |
1028 | const struct sw_flow_key *key, int key_start, int key_len) | 1029 | const struct sw_flow_key *key, int key_start, int key_end) |
1029 | { | 1030 | { |
1030 | return __cmp_key(&flow->unmasked_key, key, key_start, key_len); | 1031 | return __cmp_key(&flow->unmasked_key, key, key_start, key_end); |
1031 | } | 1032 | } |
1032 | 1033 | ||
1033 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, | 1034 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, |
1034 | const struct sw_flow_key *key, int key_len) | 1035 | const struct sw_flow_key *key, int key_end) |
1035 | { | 1036 | { |
1036 | int key_start; | 1037 | int key_start; |
1037 | key_start = flow_key_start(key); | 1038 | key_start = flow_key_start(key); |
1038 | 1039 | ||
1039 | return __flow_cmp_unmasked_key(flow, key, key_start, key_len); | 1040 | return __flow_cmp_unmasked_key(flow, key, key_start, key_end); |
1040 | 1041 | ||
1041 | } | 1042 | } |
1042 | 1043 | ||
@@ -1044,11 +1045,11 @@ struct sw_flow *ovs_flow_lookup_unmasked_key(struct flow_table *table, | |||
1044 | struct sw_flow_match *match) | 1045 | struct sw_flow_match *match) |
1045 | { | 1046 | { |
1046 | struct sw_flow_key *unmasked = match->key; | 1047 | struct sw_flow_key *unmasked = match->key; |
1047 | int key_len = match->range.end; | 1048 | int key_end = match->range.end; |
1048 | struct sw_flow *flow; | 1049 | struct sw_flow *flow; |
1049 | 1050 | ||
1050 | flow = ovs_flow_lookup(table, unmasked); | 1051 | flow = ovs_flow_lookup(table, unmasked); |
1051 | if (flow && (!ovs_flow_cmp_unmasked_key(flow, unmasked, key_len))) | 1052 | if (flow && (!ovs_flow_cmp_unmasked_key(flow, unmasked, key_end))) |
1052 | flow = NULL; | 1053 | flow = NULL; |
1053 | 1054 | ||
1054 | return flow; | 1055 | return flow; |
@@ -1061,16 +1062,16 @@ static struct sw_flow *ovs_masked_flow_lookup(struct flow_table *table, | |||
1061 | struct sw_flow *flow; | 1062 | struct sw_flow *flow; |
1062 | struct hlist_head *head; | 1063 | struct hlist_head *head; |
1063 | int key_start = mask->range.start; | 1064 | int key_start = mask->range.start; |
1064 | int key_len = mask->range.end; | 1065 | int key_end = mask->range.end; |
1065 | u32 hash; | 1066 | u32 hash; |
1066 | struct sw_flow_key masked_key; | 1067 | struct sw_flow_key masked_key; |
1067 | 1068 | ||
1068 | ovs_flow_key_mask(&masked_key, flow_key, mask); | 1069 | ovs_flow_key_mask(&masked_key, flow_key, mask); |
1069 | hash = ovs_flow_hash(&masked_key, key_start, key_len); | 1070 | hash = ovs_flow_hash(&masked_key, key_start, key_end); |
1070 | head = find_bucket(table, hash); | 1071 | head = find_bucket(table, hash); |
1071 | hlist_for_each_entry_rcu(flow, head, hash_node[table->node_ver]) { | 1072 | hlist_for_each_entry_rcu(flow, head, hash_node[table->node_ver]) { |
1072 | if (flow->mask == mask && | 1073 | if (flow->mask == mask && |
1073 | __flow_cmp_key(flow, &masked_key, key_start, key_len)) | 1074 | __flow_cmp_key(flow, &masked_key, key_start, key_end)) |
1074 | return flow; | 1075 | return flow; |
1075 | } | 1076 | } |
1076 | return NULL; | 1077 | return NULL; |
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index d08dcf78dbf3..e79305184b79 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h | |||
@@ -243,7 +243,7 @@ int ovs_ipv4_tun_to_nlattr(struct sk_buff *skb, | |||
243 | const struct ovs_key_ipv4_tunnel *output); | 243 | const struct ovs_key_ipv4_tunnel *output); |
244 | 244 | ||
245 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, | 245 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, |
246 | const struct sw_flow_key *key, int key_len); | 246 | const struct sw_flow_key *key, int key_end); |
247 | 247 | ||
248 | struct sw_flow_mask { | 248 | struct sw_flow_mask { |
249 | int ref_count; | 249 | int ref_count; |