From: Ian Jackson <ian.jackson@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Joshua Perrett <jperrett256@gmail.com>,
George Dunlap <george.dunlap@citrix.com>
Subject: Re: [PATCH] libxl: made vm mac address assignment deterministic
Date: Thu, 6 Sep 2018 17:18:08 +0100 [thread overview]
Message-ID: <23441.21312.528088.442952@mariner.uk.xensource.com> (raw)
In-Reply-To: <20180906155141.sds22dfzywbglovl@zion.uk.xensource.com>
Wei Liu writes ("Re: [PATCH] libxl: made vm mac address assignment deterministic"):
> On Wed, Sep 05, 2018 at 12:25:55PM +0000, Joshua Perrett wrote:
> > Uses MD5 on the host mac address, vm name and vif index to generate the
> > last three bytes of the vm mac address (for each vm).
There is no such thing as "the" host mac address. The host might
have several. However, generally there is a specific interface that
will be used for this guest, depending on the vif connection mode. In
bridge mode, for example, there is the mac address of the bridge. I
think you should make sure to use the right interface.
I think you need to add something to the documentation. You should
mention that this approach is only deterministic *on the same host*
(so in setups where the guest might be started on multiple hosts, with
networked storage, it won't work) and only *with the same physical
nic* (so swapping out the physical nic will change all the guests'
addresses).
> > MD5 code is originally from the public domain (written by Colin Plumb in
> > 1993), files found in xen/tools/blktap2/drivers/.
You are duplicating these files within the Xen tree. That's pretty
ugly. Can we not do this a better way ?
> > +static int libxl__get_host_mac(libxl__gc *gc, unsigned char *buf)
> > +{
> > + int rc = ERROR_FAIL;
>
> Having a blank line makes things a bit clearer.
>
> > + #ifdef __linux__
> > + struct ifaddrs *iface_list;
Can we not have #ifdefs here please ? The Linux-specific part should
go in libxl_linux.c.
> > + memcpy(&value, s->sll_addr, 6);
>
> Please use sizeof(s->sll_addr) instead of 6.
Err, are you sure ? Let me quote the proposed code:
> > + if (s->sll_halen == 6) {
> > + uint64_t value = 0;
> > + memcpy(&value, s->sll_addr, 6);
This is very strange. How can it possibly be right to overwrite the
first 6 bytes of value ? That does a different thing on big-endian
and little-endian machines. (
Also why are we not checking sll_hatype ?
> > + if (value > largest) {
> > + memcpy(buf, s->sll_addr, 6);
> > + largest = value;
> > + rc = 0;
>
> Interesting algorithm, but I don't know anything better at the moment.
> :)
There is some reason for choosing the lexically largest address, IIRC.
But the reason should be in a comment in the code. (ISTR reading
something about this in the Debian bridge-interfaces(5) manpage.)
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-09-06 16:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 12:25 [PATCH] libxl: made vm mac address assignment deterministic Joshua Perrett
2018-09-06 15:51 ` Wei Liu
2018-09-06 16:18 ` Ian Jackson [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-09-12 9:54 Marcus Granado
2018-09-12 10:52 ` George Dunlap
2018-08-30 15:18 Joshua Perrett
2018-08-31 17:05 ` Wei Liu
2018-08-29 16:34 Joshua Perrett
2018-08-30 8:27 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23441.21312.528088.442952@mariner.uk.xensource.com \
--to=ian.jackson@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jperrett256@gmail.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).