From owner-freebsd-net@freebsd.org Tue Apr 12 14:09:15 2016 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CB40B0C5F6 for ; Tue, 12 Apr 2016 14:09:15 +0000 (UTC) (envelope-from marieheleneka@gmail.com) Received: from mail-lf0-x236.google.com (mail-lf0-x236.google.com [IPv6:2a00:1450:4010:c07::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8F6AB1F1E; Tue, 12 Apr 2016 14:09:14 +0000 (UTC) (envelope-from marieheleneka@gmail.com) Received: by mail-lf0-x236.google.com with SMTP id j11so26898012lfb.1; Tue, 12 Apr 2016 07:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=onM1+frCJuZoeOM9KKmmiyvJPXdDc2LCGJrrsIOAAI8=; b=uGUMpA4eq+8FXkIF6SnLzpFZgWV320he4SiX+3JNPVWkuBrimNZ03oFQtJoa2DhJT6 PNi/uV+Uczan7zmU7dnUPo/WmmL6fgxTU8/TL0La3j/pbR3g8QD82cBt5N6N4/qZCv8f /vYFBmSqx+XQ3vdFneZ6rV4i4VsWnV3/XSe9tgcZ7BRZ0hnIo3yWcAy5yW3sBQ9BSE4E gp8UZo9ygmRmdFSqRPwzvPk00g2GyBi+O4jBCSHckmQkgsiHqswAlokgVqtM/t/y3OEs scYP69eJpHMytFfTvosAPP/lAO7BxauYNlRdyTgDfsw0XsA/uCDfKjIhEcFv+ZILEkt2 rUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=onM1+frCJuZoeOM9KKmmiyvJPXdDc2LCGJrrsIOAAI8=; b=P68bZuAGXj1Wl+aU+yVD5sJw+bcuwZs4jI5GcUBJgnX8pBBUpvpc/lYuOTlXX/2tDi GJ6Uqj+k62qNIkXP3FD1CdhRUsaDkXHCAy0oc3qrhbNnDrA5WCx+6Va1z4MC3qIfbu8m YtQR3lYpFHhZfCTLPjQLXDg43C3wqQWBn2AOh1/Uxmas+Oz/No+RpTTGdZK6s1zkKMqq t1woyKlxMq0V+ELoElycdpDyTDyFRSEIpKYOk6U33mrxN4nb9TO6VtzGK4dkYCkHPFK/ isusrSqz6/O6kU4wZL0WgcMBGDKfKB4w7KwjaDXnKqPw4oCFMvd65wkVpe7yBgQgBxRN BIiQ== X-Gm-Message-State: AOPr4FXdwlqIHnHq23d9/cM2G9kW2Mhjy+9CYTX+/m5mwO2Qvar1iyyhor6kQAZ9C78qmuDKLTGBb+kSLiZFmA== X-Received: by 10.25.150.147 with SMTP id y141mr1269429lfd.95.1460470152391; Tue, 12 Apr 2016 07:09:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marie Helene Kvello-Aune Date: Tue, 12 Apr 2016 14:09:02 +0000 Message-ID: Subject: Re: libifconfig: Initial code available, looking for feedback To: Kristof Provost Cc: freebsd-net@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2016 14:09:15 -0000 On Mon, Apr 11, 2016 at 10:31 PM Kristof Provost wrote: > > > On 09 Apr 2016, at 15:59, Marie Helene Kvello-Aune < > marieheleneka@gmail.com> wrote: > > I've just pushed an initial version of libifconfig to the github > > repository[2]. I would appreciate feedback, in particular on the API > design > > and usage, and especially on how it communicates error state to the > > application. > > > Awesome. This is important work. I can=E2=80=99t be the only one who=E2= =80=99s tired of > writing > ioctl() calls to set an IP address. > > Is it still your intention to re-implement/refactor/re-whatever ifconfig > to use this > library? It seems like it=E2=80=99d be both a good test-case and a good w= ay to > ensure > the library stays up to date, and grows new capabilities as features are > added > to the network stack. I'm actually converting ifconfig as I add features to the library. It's how I test that things seem to work. :) > > > Expect the API to break frequently/often for the time being, as it is > still > > in very early stages of development. > > I=E2=80=99ve had a quick look at the library so far, and have a few remar= ks. > > It might be better to have an explicit (opaque to the library user) handl= e > to contain both the error state (libifconfig_errstate) and the open > sockets (sdkeys). > This would go a long way in making the library thread-safe (because users > can now > rely on their error state not getting clobbered by another thread). > > Good idea. Adrian Chadd mentioned something like this off-list as well, and I still haven't quite decided how to implement it. I have considered looking into implementing this similar to how the global 'errno' variable is implemented, but I haven't actually researched how to do this yet. I'm currently leaning towards having a libifconfig_state_create() (or similarily named) method which retrieves an appropriate struct for the calling application to pass into the library methods. Both approaches should be thread friendly. > Bikeshedding: > - libifconfig_ seems quite long for a prefix. Perhaps libifc_ or lifc_ ? > - if (foo !=3D NULL) free(foo); can be safely written as free(foo); > > Yeah, I have been feeling the prefix is a bit long as well. libifc_ looks ok to me. > Regards, > Kristof Thanks for the feedback! Regards, Marie Helene Kvello-Aune marieheleneka@gmail.com