summaryrefslogtreecommitdiff
path: root/lib/netdev-provider.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 /lib/netdev-provider.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 'lib/netdev-provider.h')
-rw-r--r--lib/netdev-provider.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index aab63b770..a33bb3b3a 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -337,15 +337,13 @@ struct netdev_class {
void (*send_wait)(struct netdev *netdev, int qid);
/* Sets 'netdev''s Ethernet address to 'mac' */
- int (*set_etheraddr)(struct netdev *netdev,
- const uint8_t mac[ETH_ADDR_LEN]);
+ int (*set_etheraddr)(struct netdev *netdev, const struct eth_addr mac);
/* Retrieves 'netdev''s Ethernet address into 'mac'.
*
* This address will be advertised as 'netdev''s MAC address through the
* OpenFlow protocol, among other uses. */
- int (*get_etheraddr)(const struct netdev *netdev,
- uint8_t mac[ETH_ADDR_LEN]);
+ int (*get_etheraddr)(const struct netdev *netdev, struct eth_addr *mac);
/* Retrieves 'netdev''s MTU into '*mtup'.
*
@@ -683,7 +681,7 @@ struct netdev_class {
* This function may be set to null if it would always return EOPNOTSUPP
* anyhow. */
int (*arp_lookup)(const struct netdev *netdev, ovs_be32 ip,
- uint8_t mac[ETH_ADDR_LEN]);
+ struct eth_addr *mac);
/* Retrieves the current set of flags on 'netdev' into '*old_flags'. Then,
* turns off the flags that are set to 1 in 'off' and turns on the flags