sd-dhcp-client: always set default broadcast hardware address when unspecified

The default value for InfiniBand is copied from dhcp-network.c.
This commit is contained in:
Yu Watanabe
2026-05-13 07:47:53 +09:00
parent eda10260a0
commit 304899fa57
3 changed files with 64 additions and 22 deletions
+28
View File
@@ -301,3 +301,31 @@ void ether_addr_mark_random(struct ether_addr *addr) {
addr->ether_addr_octet[0] &= 0xfe; /* clear multicast bit */
addr->ether_addr_octet[0] |= 0x02; /* set local assignment bit (IEEE802) */
}
int hw_addr_ensure_broadcast(struct hw_addr_data *bcast_addr, uint16_t arp_type) {
assert(bcast_addr);
if (!hw_addr_is_null(bcast_addr))
return 0;
switch (arp_type) {
case ARPHRD_ETHER:
*bcast_addr = (struct hw_addr_data) {
.length = ETH_ALEN,
.ether = {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }},
};
return 0;
case ARPHRD_INFINIBAND:
*bcast_addr = (struct hw_addr_data) {
.length = INFINIBAND_ALEN,
.infiniband = {
0x00, 0xff, 0xff, 0xff, 0xff, 0x12, 0x40, 0x1b,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff,
},
};
return 0;
default:
return -EAFNOSUPPORT;
}
}
+2
View File
@@ -106,3 +106,5 @@ extern const struct hash_ops ether_addr_hash_ops;
extern const struct hash_ops ether_addr_hash_ops_free;
void ether_addr_mark_random(struct ether_addr *addr);
int hw_addr_ensure_broadcast(struct hw_addr_data *bcast_addr, uint16_t arp_type);