mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
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>
This commit is contained in:
14
lib/sflow.h
14
lib/sflow.h
@@ -12,6 +12,8 @@
|
||||
#include "windefs.h"
|
||||
#endif
|
||||
|
||||
#include "openvswitch/types.h"
|
||||
|
||||
typedef enum {
|
||||
SFL_DSCLASS_IFINDEX = 0,
|
||||
SFL_DSCLASS_VLAN = 1,
|
||||
@@ -81,8 +83,10 @@ typedef struct _SFLSampled_header {
|
||||
typedef struct _SFLSampled_ethernet {
|
||||
u_int32_t eth_len; /* The length of the MAC packet excluding
|
||||
lower layer encapsulations */
|
||||
u_int8_t src_mac[8]; /* 6 bytes + 2 pad */
|
||||
u_int8_t dst_mac[8];
|
||||
struct eth_addr src_mac; /* 6 bytes */
|
||||
u_int8_t pad1[2]; /* 2 pad */
|
||||
struct eth_addr dst_mac;
|
||||
u_int8_t pad2[2];
|
||||
u_int32_t eth_type;
|
||||
} SFLSampled_ethernet;
|
||||
|
||||
@@ -527,8 +531,10 @@ typedef union _SFLLACP_portState {
|
||||
} SFLLACP_portState;
|
||||
|
||||
typedef struct _SFLLACP_counters {
|
||||
uint8_t actorSystemID[8]; /* 6 bytes + 2 pad */
|
||||
uint8_t partnerSystemID[8]; /* 6 bytes + 2 pad */
|
||||
struct eth_addr actorSystemID; /* 6 bytes */
|
||||
uint8_t pad1[2];
|
||||
struct eth_addr partnerSystemID; /* 6 bytes */
|
||||
uint8_t pad2[2];
|
||||
uint32_t attachedAggID;
|
||||
SFLLACP_portState portState;
|
||||
uint32_t LACPDUsRx;
|
||||
|
||||
Reference in New Issue
Block a user