summaryrefslogtreecommitdiff
path: root/include/openflow/openflow-1.4.h
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2015-08-28 14:55:11 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2015-08-28 14:55:11 -0700
commit74ff3298c8806bb09d0c7e40a25b889ab7564769 (patch)
treeeb79e22f9460a0699825569a14710e393ee3358d /include/openflow/openflow-1.4.h
parentd8ef07e70995e56005e3bc55b86cdb7d0e2066e5 (diff)
downloadopenvswitch-74ff3298c8806bb09d0c7e40a25b889ab7564769.tar.gz
userspace: Define and use struct eth_addr.
Define struct eth_addr and use it instead of a uint8_t array for all ethernet addresses in OVS userspace. The struct is always the right size, and it can be assigned without an explicit memcpy, which makes code more readable. "struct eth_addr" is a good type name for this as many utility functions are already named accordingly. struct eth_addr can be accessed as bytes as well as ovs_be16's, which makes the struct 16-bit aligned. All use seems to be 16-bit aligned, so some algorithms on the ethernet addresses can be made a bit more efficient making use of this fact. As the struct fits into a register (in 64-bit systems) we pass it by value when possible. This patch also changes the few uses of Linux specific ETH_ALEN to OVS's own ETH_ADDR_LEN, and removes the OFP_ETH_ALEN, as it is no longer needed. This work stemmed from a desire to make all struct flow members assignable for unrelated exploration purposes. However, I think this might be a nice code readability improvement by itself. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Diffstat (limited to 'include/openflow/openflow-1.4.h')
-rw-r--r--include/openflow/openflow-1.4.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/openflow/openflow-1.4.h b/include/openflow/openflow-1.4.h
index 37eef4a42..1ed4e392a 100644
--- a/include/openflow/openflow-1.4.h
+++ b/include/openflow/openflow-1.4.h
@@ -72,7 +72,7 @@ struct ofp14_port {
ovs_be32 port_no;
ovs_be16 length;
uint8_t pad[2];
- uint8_t hw_addr[OFP_ETH_ALEN];
+ struct eth_addr hw_addr;
uint8_t pad2[2]; /* Align to 64 bits. */
char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
@@ -106,7 +106,7 @@ OFP_ASSERT(sizeof(struct ofp14_port_mod_prop_ethernet) == 8);
struct ofp14_port_mod {
ovs_be32 port_no;
uint8_t pad[4];
- uint8_t hw_addr[OFP_ETH_ALEN];
+ struct eth_addr hw_addr;
uint8_t pad2[2];
ovs_be32 config; /* Bitmap of OFPPC_* flags. */
ovs_be32 mask; /* Bitmap of OFPPC_* flags to be changed. */