mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +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:
@@ -107,8 +107,8 @@ struct flow {
|
||||
uint8_t pad1[6]; /* Pad to 64 bits. */
|
||||
|
||||
/* L2, Order the same as in the Ethernet header! (64-bit aligned) */
|
||||
uint8_t dl_dst[ETH_ADDR_LEN]; /* Ethernet destination address. */
|
||||
uint8_t dl_src[ETH_ADDR_LEN]; /* Ethernet source address. */
|
||||
struct eth_addr dl_dst; /* Ethernet destination address. */
|
||||
struct eth_addr dl_src; /* Ethernet source address. */
|
||||
ovs_be16 dl_type; /* Ethernet frame type. */
|
||||
ovs_be16 vlan_tci; /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */
|
||||
ovs_be32 mpls_lse[ROUND_UP(FLOW_MAX_MPLS_LABELS, 2)]; /* MPLS label stack
|
||||
@@ -124,8 +124,8 @@ struct flow {
|
||||
uint8_t nw_ttl; /* IP TTL/Hop Limit. */
|
||||
uint8_t nw_proto; /* IP protocol or low 8 bits of ARP opcode. */
|
||||
struct in6_addr nd_target; /* IPv6 neighbor discovery (ND) target. */
|
||||
uint8_t arp_sha[ETH_ADDR_LEN]; /* ARP/ND source hardware address. */
|
||||
uint8_t arp_tha[ETH_ADDR_LEN]; /* ARP/ND target hardware address. */
|
||||
struct eth_addr arp_sha; /* ARP/ND source hardware address. */
|
||||
struct eth_addr arp_tha; /* ARP/ND target hardware address. */
|
||||
ovs_be16 tcp_flags; /* TCP flags. With L3 to avoid matching L4. */
|
||||
ovs_be16 pad2; /* Pad to 64 bits. */
|
||||
|
||||
|
Reference in New Issue
Block a user