@@ -2287,13 +2287,15 @@ rstp_send_bpdu_cb(struct dp_packet *pkt, void *ofport_, void *ofproto_)
struct ofproto_dpif *ofproto = ofproto_;
struct ofport_dpif *ofport = ofport_;
struct eth_header *eth = dp_packet_eth(pkt);
+ struct eth_addr mac;
- netdev_get_etheraddr(ofport->up.netdev, ð->eth_src);
- if (eth_addr_is_zero(eth->eth_src)) {
+ netdev_get_etheraddr(ofport->up.netdev, &mac);
+ if (eth_addr_is_zero(mac)) {
VLOG_WARN_RL(&rl, "%s port %d: cannot send RSTP BPDU on a port which "
"does not have a configured source MAC address.",
ofproto->up.name, ofp_to_u16(ofport->up.ofp_port));
} else {
+ eth->eth_src = mac;
ofproto_dpif_send_packet(ofport, false, pkt);
}
dp_packet_delete(pkt);
@@ -2312,12 +2314,14 @@ send_bpdu_cb(struct dp_packet *pkt, int port_num, void *ofproto_)
ofproto->up.name, port_num);
} else {
struct eth_header *eth = dp_packet_eth(pkt);
+ struct eth_addr mac;
- netdev_get_etheraddr(ofport->up.netdev, ð->eth_src);
- if (eth_addr_is_zero(eth->eth_src)) {
+ netdev_get_etheraddr(ofport->up.netdev, &mac);
+ if (eth_addr_is_zero(mac)) {
VLOG_WARN_RL(&rl, "%s: cannot send BPDU on port %d "
"with unknown MAC", ofproto->up.name, port_num);
} else {
+ eth->eth_src = mac;
ofproto_dpif_send_packet(ofport, false, pkt);
}
}
Clang 4.0 complains: ../ofproto/ofproto-dpif.c:2291:46: error: taking address of packed member 'eth_src' of class or structure 'eth_header' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] netdev_get_etheraddr(ofport->up.netdev, ð->eth_src); ^~~~~~~~~~~~ ../ofproto/ofproto-dpif.c:2316:50: error: taking address of packed member 'eth_src' of class or structure 'eth_header' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] netdev_get_etheraddr(ofport->up.netdev, ð->eth_src); Ethernet source addresses are 48 bits offset into the Ethernet header, so taking a pointer for this is not guaranteed to be valid on all architectures. Fix this by retrieving the mac address to the local stack and copying it into the header. Signed-off-by: Joe Stringer <joe@ovn.org> --- ofproto/ofproto-dpif.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)