[libvirt] [PATCH] Remove MAX_TAP_ID, take 3

Aron Griffis aron.griffis at hp.com
Thu Jul 30 02:56:48 UTC 2009


Matthias Bolte wrote:  [Wed Jul 29 2009, 08:58:18PM EDT]
> 2009/7/29 Daniel Veillard <veillard at redhat.com>:
> > On Wed, Jul 29, 2009 at 08:05:37PM +0200, Daniel Veillard wrote:
> >> On Wed, Jul 29, 2009 at 12:52:30PM -0400, Aron Griffis wrote:
> >> > This is a resend of take 2 to fix formatting problems in the
> >> > patch.  No other changes.
> >> >
> >> > As far as I can tell, there's no reason to format the device
> >> > string in brAddTap().  Delegate the job to TUNSETIFF, thereby
> >> > removing the loop and the MAX_TAP_ID artificial limit.  This
> >> > patch allows me to get 421 guests running before hitting other
> >> > limits.
> >>
> >>   haha ! that one worked :-)
> >>
> >> I will review and apply, thanks !
> >
> >  Actually just looking at brAddTap() after patching makes it clear,
> > and based on Mark and Dan feedback great !
> >  Applied and commited to git, thanks !
> >
> > Daniel
> 
> This patch breaks -Werror, because GCC is unhappy with the initializer
> for ifreq.
> 
> The follow change makes GCC happy again:
> 
> diff --git a/src/bridge.c b/src/bridge.c
> index ec37192..6480a35 100644
> --- a/src/bridge.c
> +++ b/src/bridge.c
> @@ -465,7 +465,7 @@ brAddTap(brControl *ctl,
>           int *tapfd)
>  {
>      int fd, len;
> -    struct ifreq ifr = {0};
> +    struct ifreq ifr = {{{0}}, {{0, {0}}}};
> 
>      if (!ctl || !ctl->fd || !bridge || !ifname)
>          return EINVAL;

Ugh, sorry about that.  And it looked so neat and clean to me.  ;-)

Maybe instead of the nested curlies, we should revert to memset
as it was doing previously:

diff --git a/src/bridge.c b/src/bridge.c
index ec37192..58e480e 100644
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -465,7 +465,7 @@ brAddTap(brControl *ctl,
          int *tapfd)
 {
     int fd, len;
-    struct ifreq ifr = {0};
+    struct ifreq ifr;
 
     if (!ctl || !ctl->fd || !bridge || !ifname)
         return EINVAL;
@@ -473,6 +473,8 @@ brAddTap(brControl *ctl,
     if ((fd = open("/dev/net/tun", O_RDWR)) < 0)
       return errno;
 
+    memset(&ifr, 0, sizeof(ifr));
+
     ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
 
 #ifdef IFF_VNET_HDR




More information about the libvir-list mailing list