All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: iwd@lists.01.org
Subject: Re: [PATCH 7/9] netconfig: Move loading settings to new method, refactor
Date: Thu, 26 Aug 2021 00:17:23 +0200	[thread overview]
Message-ID: <CAOq732+DLLQqFcEzpJ+hZR1ucCXE8=iMdCU4xCproJhO96eKqw@mail.gmail.com> (raw)
In-Reply-To: <6b81dfe5-686e-5ad7-762a-1133d85a7de5@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4209 bytes --]

On Wed, 25 Aug 2021 at 15:53, Denis Kenzior <denkenz@gmail.com> wrote:
> On 8/23/21 9:14 AM, Andrew Zaborowski wrote:
> > Split loading settings out of network_configure into a new method,
> > network_load_settings.  Make sure both consistently handle errors by
> > printing messages and informing the caller.
> > ---
> >   src/netconfig.c | 157 +++++++++++++++++++++++++++++++-----------------
> >   src/netconfig.h |   5 +-
> >   src/p2p.c       |  12 +++-
> >   src/station.c   |  20 +++---
> >   4 files changed, 127 insertions(+), 67 deletions(-)
> >
>
>    CC       src/netconfig.o
> src/netconfig.c: In function ‘netconfig_get_static4_address’:
> src/netconfig.c:298:5: error: implicit declaration of function
> ‘util_netmask_from_prefix’ [-Werror=implicit-function-declaration]
>    298 |     util_netmask_from_prefix(prefix_len)) {
>        |     ^~~~~~~~~~~~~~~~~~~~~~~~
> src/netconfig.c:297:29: error: comparison of integer expressions of different
> signedness: ‘__uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare]
>    297 |   if (ntohl(in_addr.s_addr) !=
>        |                             ^~
> cc1: all warnings being treated as errors

Oops, apparently I added the #include in the wrong commit.

>
> <snip>
>
> > @@ -998,22 +997,22 @@ static int validate_dns_list(int family, char **dns_list)
> >       return n_valid;
> >   }
> >
> > -bool netconfig_configure(struct netconfig *netconfig,
> > +bool netconfig_load_settings(struct netconfig *netconfig,
> >                               const struct l_settings *active_settings,
> > -                             const uint8_t *mac_address,
> > -                             netconfig_notify_func_t notify, void *user_data)
> > +                             const uint8_t *mac_address)
> >   {
> >       char *mdns;
> > -     char hostname[HOST_NAME_MAX + 1];
> >       bool send_hostname;
> > +     bool enabled;
> >
> > +     l_strfreev(netconfig->dns4_overrides);
>
> ? shouldn't this be taken care of by netconfig_reset?

I thought we might have a future use case for calling
netconfig_load_settings() multiple times without netconfig_reset
between, but no strong motivation for that.

>  We generally don't like
> side-effects in our APIs.

I wouldn't call avoiding a leak a side effect ;)

>
> >       netconfig->dns4_overrides = l_settings_get_string_list(active_settings,
> >                                                       "IPv4", "DNS", ' ');
> >
> >       if (netconfig->dns4_overrides) {
> >               int r = validate_dns_list(AF_INET, netconfig->dns4_overrides);
> >
> > -             if (r <= 0) {
> > +             if (unlikely(r <= 0)) {
> >                       l_strfreev(netconfig->dns4_overrides);
> >                       netconfig->dns4_overrides = NULL;
> >               }
> > @@ -1022,13 +1021,14 @@ bool netconfig_configure(struct netconfig *netconfig,
> >                       l_error("netconfig: Empty IPv4.DNS entry, skipping...");
> >       }
> >
> > +     l_strfreev(netconfig->dns6_overrides);
>
> Same here?
>
> >       netconfig->dns6_overrides = l_settings_get_string_list(active_settings,
> >                                                       "IPv6", "DNS", ' ');
> >
> >       if (netconfig->dns6_overrides) {
> >               int r = validate_dns_list(AF_INET6, netconfig->dns6_overrides);
> >
> > -             if (r <= 0) {
> > +             if (unlikely(r <= 0)) {
> >                       l_strfreev(netconfig->dns6_overrides);
> >                       netconfig->dns6_overrides = NULL;
> >               }
> > @@ -1038,8 +1038,6 @@ bool netconfig_configure(struct netconfig *netconfig,
> >       }
> >
> >       netconfig->active_settings = active_settings;
>
> Do we even need active settings now?

So in this method I only removed the usage of the l_settings from
netconfig_configure() but not from other places (*_get_gateway(),
netconfig_set_domains()) which may be called asynchronously.  It's
something we could do separately if desired but my use case was only
for setting the value of netconfig->rtm_protocol early.

Best regards

  reply	other threads:[~2021-08-25 22:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 14:14 [PATCH 1/9] handshake: Add HANDSHAKE_EVENT_P2P_IP_REQUEST Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 2/9] ap: Implement P2P GO-side 4-way handshake IP Allocation Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 3/9] autotests: Test GO-side IP Allocation in testP2P Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 4/9] ap: Expire client's leases on disconnect Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 5/9] ie: Add FILS IP Address Assignment parsers and builders Andrew Zaborowski
2021-08-25 13:47   ` Denis Kenzior
2021-08-25 21:34     ` Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 6/9] ap: Support FILS IP Address Assignment IE Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 7/9] netconfig: Move loading settings to new method, refactor Andrew Zaborowski
2021-08-25 13:50   ` Denis Kenzior
2021-08-25 22:17     ` Andrew Zaborowski [this message]
2021-08-25 22:37       ` Denis Kenzior
2021-08-25 22:56         ` Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 8/9] netconfig: FILS IP assigment API Andrew Zaborowski
2021-08-23 14:14 ` [PATCH 9/9] station, netdev: Enable FILS IP Address Assignment Andrew Zaborowski

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='CAOq732+DLLQqFcEzpJ+hZR1ucCXE8=iMdCU4xCproJhO96eKqw@mail.gmail.com' \
    --to=andrew.zaborowski@intel.com \
    --cc=iwd@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.