All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jiri@resnulli.us
Cc: netdev@vger.kernel.org, jakub.kicinski@netronome.com,
	sthemmin@microsoft.com, dsahern@gmail.com, mlxsw@mellanox.com
Subject: Re: [patch net-next 1/3] net: devlink: allow to change namespaces
Date: Mon, 29 Jul 2019 10:52:16 -0700 (PDT)	[thread overview]
Message-ID: <20190729.105216.2073541569967891866.davem@davemloft.net> (raw)
In-Reply-To: <20190727094459.26345-2-jiri@resnulli.us>

From: Jiri Pirko <jiri@resnulli.us>
Date: Sat, 27 Jul 2019 11:44:57 +0200

> +	if ((netns_pid_attr && (netns_fd_attr || netns_id_attr)) ||
> +	    (netns_fd_attr && (netns_pid_attr || netns_id_attr)) ||
> +	    (netns_id_attr && (netns_pid_attr || netns_fd_attr))) {
> +		NL_SET_ERR_MSG(info->extack, "multiple netns identifying attributes specified");
> +		return ERR_PTR(-EINVAL);
> +	}

How about:

	if (!!a + !!b + !!c > 1) {
	...

> +
> +	if (netns_pid_attr) {
> +		net = get_net_ns_by_pid(nla_get_u32(netns_pid_attr));
> +	} else if (netns_fd_attr) {
> +		net = get_net_ns_by_fd(nla_get_u32(netns_fd_attr));
> +	} else if (netns_id_attr) {
> +		net = get_net_ns_by_id(sock_net(skb->sk),
> +				       nla_get_u32(netns_id_attr));
> +		if (!net)
> +			net = ERR_PTR(-EINVAL);
> +	}
> +	if (IS_ERR(net)) {

I think this is going to be one of those cases where a compiler won't be able
to prove that 'net' is guaranteed to be initialized at this spot.  Please
rearrange this code somehow so that is unlikely to happen.

Thanks.

  reply	other threads:[~2019-07-29 17:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-27  9:44 [patch net-next 0/3] net: devlink: Finish network namespace support Jiri Pirko
2019-07-27  9:44 ` [patch net-next 1/3] net: devlink: allow to change namespaces Jiri Pirko
2019-07-29 17:52   ` David Miller [this message]
2019-07-30  6:05     ` Jiri Pirko
2019-07-27  9:44 ` [patch net-next 2/3] net: devlink: export devlink net set/get helpers Jiri Pirko
2019-07-27  9:44 ` [patch net-next 3/3] netdevsim: create devlink and netdev instances in namespace Jiri Pirko
2019-07-29 18:59   ` Jakub Kicinski
2019-07-30  6:06     ` Jiri Pirko
2019-07-30 17:14       ` Jakub Kicinski
2019-07-30 21:03         ` Jiri Pirko
2019-07-27 10:05 ` [patch iproute2 1/2] devlink: introduce cmdline option to switch to a different namespace Jiri Pirko
2019-07-27 10:12   ` Toke Høiland-Jørgensen
2019-07-27 10:21     ` Jiri Pirko
2019-07-27 10:25       ` Toke Høiland-Jørgensen
2019-07-29 20:21       ` David Ahern
2019-07-30  6:07         ` Jiri Pirko
2019-07-29 20:17   ` David Ahern
2019-07-27 10:05 ` [patch iproute2 2/2] devlink: add support for network namespace change Jiri Pirko
2019-07-29 20:17 ` [patch net-next 0/3] net: devlink: Finish network namespace support David Ahern
2019-07-30  6:08   ` Jiri Pirko
2019-07-31 21:50     ` David Ahern
2019-07-31 22:02       ` Jakub Kicinski
2019-07-31 22:07         ` David Ahern
2019-07-31 22:28           ` Jakub Kicinski
2019-07-31 22:31             ` David Ahern
2019-08-02  7:42               ` Jiri Pirko

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=20190729.105216.2073541569967891866.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@resnulli.us \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=sthemmin@microsoft.com \
    /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.