Message ID | 1371476111-4449-3-git-send-email-akong@redhat.com |
---|---|
State | New |
Headers | show |
On Mon, Jun 17, 2013 at 09:35:11PM +0800, Amos Kong wrote: > Currently we only support to allocate 0xff mac-addresses, > if we start guest by pci-bridge/multiple-func, the macaddr > are not enough. > > This patch extends the mac-address space to 0xffffffff > > 52:54:00:00:00:00 ~ 52:54:ff:ff:ff:ff > > Signed-off-by: Amos Kong <akong@redhat.com> And then there's even more chance a user error (forgot to specify mac) will lead to broken LANs because of collisions. Why is it that whoever wants >256 NICs can't just specify the addresses explicitly? > --- > net/net.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/net/net.c b/net/net.c > index f019da4..78bb080 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -153,10 +153,12 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr) > realloc_mac: > macaddr->a[0] = 0x52; > macaddr->a[1] = 0x54; > - macaddr->a[2] = 0x00; > - macaddr->a[3] = 0x12; > - macaddr->a[4] = 0x34; > - macaddr->a[5] = 0x56 + index++; > + macaddr->a[2] = 0x00 + ((0x120000 + 0x3400 + 0x56 + index) >> 24 & 0xff); > + macaddr->a[3] = 0x12 + ((0x3400 + 0x56 + index) >> 16 & 0xff); > + macaddr->a[4] = 0x34 + ((0x56 + index) >> 8 & 0xff); > + macaddr->a[5] = 0x56 + (index & 0xff); > + > + index++; > > QTAILQ_FOREACH(nc, &net_clients, next) { > peer = nc->peer; > -- > 1.8.1.4
On Mon, Jun 17, 2013 at 05:04:03PM +0300, Michael S. Tsirkin wrote: > On Mon, Jun 17, 2013 at 09:35:11PM +0800, Amos Kong wrote: > > Currently we only support to allocate 0xff mac-addresses, > > if we start guest by pci-bridge/multiple-func, the macaddr > > are not enough. > > > > This patch extends the mac-address space to 0xffffffff > > > > 52:54:00:00:00:00 ~ 52:54:ff:ff:ff:ff > > > > Signed-off-by: Amos Kong <akong@redhat.com> > > > And then there's even more chance a user error > (forgot to specify mac) will lead to broken > LANs because of collisions. > > Why is it that whoever wants >256 NICs can't just > specify the addresses explicitly? We should lead user to use assigned mac, those two patches are just considered for the lazy users ;)
On Tue, Jun 18, 2013 at 09:51:44AM +0800, Amos Kong wrote: > On Mon, Jun 17, 2013 at 05:04:03PM +0300, Michael S. Tsirkin wrote: > > On Mon, Jun 17, 2013 at 09:35:11PM +0800, Amos Kong wrote: > > > Currently we only support to allocate 0xff mac-addresses, > > > if we start guest by pci-bridge/multiple-func, the macaddr > > > are not enough. > > > > > > This patch extends the mac-address space to 0xffffffff > > > > > > 52:54:00:00:00:00 ~ 52:54:ff:ff:ff:ff > > > > > > Signed-off-by: Amos Kong <akong@redhat.com> > > > > > > And then there's even more chance a user error > > (forgot to specify mac) will lead to broken > > LANs because of collisions. > > > > Why is it that whoever wants >256 NICs can't just > > specify the addresses explicitly? > > We should lead user to use assigned mac, those two patches > are just considered for the lazy users ;) Let's just fail address allocation once the low byte overflows. If you want >256 NICs, specify MAC addresses. > > -- > Amos.
diff --git a/net/net.c b/net/net.c index f019da4..78bb080 100644 --- a/net/net.c +++ b/net/net.c @@ -153,10 +153,12 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr) realloc_mac: macaddr->a[0] = 0x52; macaddr->a[1] = 0x54; - macaddr->a[2] = 0x00; - macaddr->a[3] = 0x12; - macaddr->a[4] = 0x34; - macaddr->a[5] = 0x56 + index++; + macaddr->a[2] = 0x00 + ((0x120000 + 0x3400 + 0x56 + index) >> 24 & 0xff); + macaddr->a[3] = 0x12 + ((0x3400 + 0x56 + index) >> 16 & 0xff); + macaddr->a[4] = 0x34 + ((0x56 + index) >> 8 & 0xff); + macaddr->a[5] = 0x56 + (index & 0xff); + + index++; QTAILQ_FOREACH(nc, &net_clients, next) { peer = nc->peer;
Currently we only support to allocate 0xff mac-addresses, if we start guest by pci-bridge/multiple-func, the macaddr are not enough. This patch extends the mac-address space to 0xffffffff 52:54:00:00:00:00 ~ 52:54:ff:ff:ff:ff Signed-off-by: Amos Kong <akong@redhat.com> --- net/net.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)