Re: [PATCH 1/2] save duid to lease file



On Wed, 2013-02-13 at 11:16 -0500, Gene Czarcinski wrote:
> On 02/13/2013 10:43 AM, Dan Williams wrote:
> > On Wed, 2013-02-13 at 03:01 -0500, Gene Czarcinski wrote:
> >> get_duid() got a default-duid from the lease file, from
> >> one of the system files, or from the machine-id but did
> >> not save it back to the lease file so that dhclient
> >> could use it.
> >> Signed-off-by: Gene Czarcinski <gene czarc net>
> > Instead of writing it when getting it, we should actually write it when
> > we're about to execute dhclient for IPv6.  So something like this
> > instead?  Good catch though, thanks for looking into this.
> >
> > Dan
> Works for me.  Once I turned on logging level=debug and realized that 
> the DUID had the correct value but that it was never saved, the answer 
> was obvious.
> 
> I believe you will find the other patch equally interesting.  There was 
> no way to get duid-UUID with uuid_parse().

Yeah, I'd looked at the code for libuuid already.  I saw that it was
ignoring '-' already, which obviously machine-id doesn't have, but I
mentally passed over the strlen() == 36 parts.  I've got that patch and
a cleanup in my tree waiting on some testing and then I'll push.

Thanks!
Dan

> Gene
> 
> >
> > diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c
> > index d9f5135..c43ecf5 100644
> > --- a/src/dhcp-manager/nm-dhcp-dhclient.c
> > +++ b/src/dhcp-manager/nm-dhcp-dhclient.c
> > @@ -455,8 +455,9 @@ dhclient_start (NMDHCPClient *client,
> >          GError *error = NULL;
> >          const char *iface, *uuid, *system_bus_address;
> >          char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL;
> > -       gboolean ipv6;
> > +       gboolean ipv6, success;
> >          guint log_domain;
> > +       char *escaped;
> >   
> >          g_return_val_if_fail (priv->pid_file == NULL, -1);
> >   
> > @@ -497,6 +498,20 @@ dhclient_start (NMDHCPClient *client,
> >                  return -1;
> >          }
> >   
> > +       /* Save the DUID to the leasefile dhclient will actually use */
> > +       if (ipv6) {
> > +               escaped = nm_dhcp_dhclient_escape_duid (duid);
> > +               success = nm_dhcp_dhclient_save_duid (priv->lease_file, escaped, &error);
> > +               g_free (escaped);
> > +               if (!success) {
> > +                       nm_log_warn (log_domain, "(%s): failed to save DUID to %s: (%d) %s.",
> > +                                    iface, priv->lease_file,
> > +                                    error ? error->code : -1,
> > +                                    error && error->message ? error->message : "(unknown)");
> > +                       return -1;
> > +               }
> > +       }
> > +
> >          argv = g_ptr_array_new ();
> >          g_ptr_array_add (argv, (gpointer) priv->path);
> >   
> >
> >
> >
> 
> _______________________________________________
> networkmanager-list mailing list
> networkmanager-list gnome org
> https://mail.gnome.org/mailman/listinfo/networkmanager-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]