summaryrefslogtreecommitdiff
path: root/include/openflow/openflow-1.1.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.1.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.1.h')
-rw-r--r--include/openflow/openflow-1.1.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/include/openflow/openflow-1.1.h b/include/openflow/openflow-1.1.h
index b5a73101b..5b4ba2b91 100644
--- a/include/openflow/openflow-1.1.h
+++ b/include/openflow/openflow-1.1.h
@@ -110,7 +110,7 @@ enum ofp11_port_features {
struct ofp11_port {
ovs_be32 port_no;
uint8_t pad[4];
- 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 */
@@ -133,11 +133,10 @@ OFP_ASSERT(sizeof(struct ofp11_port) == 64);
struct ofp11_port_mod {
ovs_be32 port_no;
uint8_t pad[4];
- uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
- configurable. This is used to
- sanity-check the request, so it must
- be the same as returned in an
- ofp11_port struct. */
+ struct eth_addr hw_addr; /* The hardware address is not configurable. This
+ is used to sanity-check the request, so it must
+ be the same as returned in an ofp11_port
+ struct. */
uint8_t pad2[2]; /* Pad to 64 bits. */
ovs_be32 config; /* Bitmap of OFPPC_* flags. */
ovs_be32 mask; /* Bitmap of OFPPC_* flags to be changed. */
@@ -194,10 +193,10 @@ struct ofp11_match {
struct ofp11_match_header omh;
ovs_be32 in_port; /* Input switch port. */
ovs_be32 wildcards; /* Wildcard fields. */
- uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
- uint8_t dl_src_mask[OFP_ETH_ALEN]; /* Ethernet source address mask. */
- uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
- uint8_t dl_dst_mask[OFP_ETH_ALEN]; /* Ethernet destination address mask. */
+ struct eth_addr dl_src; /* Ethernet source address. */
+ struct eth_addr dl_src_mask; /* Ethernet source address mask. */
+ struct eth_addr dl_dst; /* Ethernet destination address. */
+ struct eth_addr dl_dst_mask; /* Ethernet destination address mask. */
ovs_be16 dl_vlan; /* Input VLAN id. */
uint8_t dl_vlan_pcp; /* Input VLAN priority. */
uint8_t pad1[1]; /* Align to 32-bits */