[lxc-devel] [PATCH] fix broadcast compution
David Ward
david.ward at ll.mit.edu
Sat Feb 12 15:17:25 UTC 2011
Daniel,
On 02/06/2010 03:29 PM, Daniel Lezcano wrote:
>diff --git a/src/lxc/confile.c b/src/lxc/confile.c
>index 4d81ac6..7c72752 100644
>--- a/src/lxc/confile.c
>+++ b/src/lxc/confile.c
>@@ -423,9 +423,8 @@ static int config_network_ipv4(const char *key, char *value,
> * prefix and address
> */
> if (!bcast) {
>- inetdev->bcast.s_addr =
>- htonl(INADDR_BROADCAST<< (32 - inetdev->prefix));
>- inetdev->bcast.s_addr&= inetdev->addr.s_addr;
>+ int mask = htonl(INADDR_BROADCAST<< (32 - inetdev->prefix));
>+ inetdev->bcast.s_addr = (inetdev->addr.s_addr& mask) | ~mask;
> }
>
> lxc_list_add(&netdev->ipv4, list);
The following would be a lot simpler:
inetdev->bcast.s_addr = inetdev->addr.s_addr;
inetdev->bcast.s_addr |= htonl(INADDR_BROADCAST>> inetdev->prefix);
David
More information about the lxc-devel
mailing list