Commit 1b7d4743 by Daniel Lezcano Committed by Daniel Lezcano

Simplify broadcast computation

David Ward reported this computation could be written in a simpler way. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 955f4ce6
...@@ -423,8 +423,9 @@ static int config_network_ipv4(const char *key, char *value, ...@@ -423,8 +423,9 @@ static int config_network_ipv4(const char *key, char *value,
* prefix and address * prefix and address
*/ */
if (!bcast) { if (!bcast) {
int mask = htonl(INADDR_BROADCAST << (32 - inetdev->prefix)); inetdev->bcast.s_addr = inetdev->addr.s_addr;
inetdev->bcast.s_addr = (inetdev->addr.s_addr & mask) | ~mask; inetdev->bcast.s_addr |=
htonl(INADDR_BROADCAST >> inetdev->prefix);
} }
lxc_list_add(&netdev->ipv4, list); lxc_list_add(&netdev->ipv4, list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment