All of lore.kernel.org
 help / color / mirror / Atom feed
From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
To: Vladislav Yasevich <vyasevich@gmail.com>, netdev@vger.kernel.org
Cc: stephen@networkplumber.org, bridge@lists.linux-foundation.org,
	Vladislav Yasevich <vyasevic@redhat.com>
Subject: Re: [Bridge] [PATCH v2 net 1/3] bridge: Add a default_pvid sysfs attribute
Date: Wed, 01 Oct 2014 15:45:56 +0900	[thread overview]
Message-ID: <542BA324.7010603@lab.ntt.co.jp> (raw)
In-Reply-To: <1412105462-340-2-git-send-email-vyasevic@redhat.com>

On 2014/10/01 4:31, Vladislav Yasevich wrote:
> This patch allows the user to set and retrieve default_pvid
> value.  A new value can only be stored when vlan filtering
> is disabled.
> 
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> ---
...
> +int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val)
> +{
> +	u16 pvid = val;
> +	int err = 0;
> +
> +	if (!pvid || pvid >= VLAN_VID_MASK)
> +		return -EINVAL;

This seems to accept a large value as a valid value.
For example, ((1 << 16) + 10) will be handled as 10.
How about using "val" for this check?

> +
> +	if (!rtnl_trylock())
> +		return restart_syscall();
> +
> +	if (pvid == br->default_pvid)
> +		goto unlock;
> +
> +	/* Only allow default pvid change when filtering is disabled */
> +	if (br->vlan_enabled) {
> +		err = -EPERM;

Additional log message might help users know why it was rejected.

Thanks,
Toshiaki Makita


WARNING: multiple messages have this Message-ID (diff)
From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
To: Vladislav Yasevich <vyasevich@gmail.com>, netdev@vger.kernel.org
Cc: stephen@networkplumber.org, bridge@lists.linux-foundation.org,
	Vladislav Yasevich <vyasevic@redhat.com>
Subject: Re: [PATCH v2 net 1/3] bridge: Add a default_pvid sysfs attribute
Date: Wed, 01 Oct 2014 15:45:56 +0900	[thread overview]
Message-ID: <542BA324.7010603@lab.ntt.co.jp> (raw)
In-Reply-To: <1412105462-340-2-git-send-email-vyasevic@redhat.com>

On 2014/10/01 4:31, Vladislav Yasevich wrote:
> This patch allows the user to set and retrieve default_pvid
> value.  A new value can only be stored when vlan filtering
> is disabled.
> 
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> ---
...
> +int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val)
> +{
> +	u16 pvid = val;
> +	int err = 0;
> +
> +	if (!pvid || pvid >= VLAN_VID_MASK)
> +		return -EINVAL;

This seems to accept a large value as a valid value.
For example, ((1 << 16) + 10) will be handled as 10.
How about using "val" for this check?

> +
> +	if (!rtnl_trylock())
> +		return restart_syscall();
> +
> +	if (pvid == br->default_pvid)
> +		goto unlock;
> +
> +	/* Only allow default pvid change when filtering is disabled */
> +	if (br->vlan_enabled) {
> +		err = -EPERM;

Additional log message might help users know why it was rejected.

Thanks,
Toshiaki Makita

  reply	other threads:[~2014-10-01  6:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30 19:30 [Bridge] [PATCH v2 net 0/3] bridge: Add vlan filtering support for default pvid Vladislav Yasevich
2014-09-30 19:30 ` Vladislav Yasevich
2014-09-30 19:31 ` [Bridge] [PATCH v2 net 1/3] bridge: Add a default_pvid sysfs attribute Vladislav Yasevich
2014-09-30 19:31   ` Vladislav Yasevich
2014-10-01  6:45   ` Toshiaki Makita [this message]
2014-10-01  6:45     ` Toshiaki Makita
2014-09-30 19:31 ` [Bridge] [PATCH v2 net 2/3] bridge: Simplify pvid checks Vladislav Yasevich
2014-09-30 19:31   ` Vladislav Yasevich
2014-10-01  6:50   ` [Bridge] " Toshiaki Makita
2014-10-01  6:50     ` Toshiaki Makita
2014-09-30 19:31 ` [Bridge] [PATCH v2 net 3/3] bridge: Add filtering support for default_pvid Vladislav Yasevich
2014-09-30 19:31   ` Vladislav Yasevich
2014-10-01  6:54   ` [Bridge] " Toshiaki Makita
2014-10-01  6:54     ` Toshiaki Makita
2014-09-30 21:07 ` [Bridge] [PATCH v2 net 0/3] bridge: Add vlan filtering support for default pvid David Miller
2014-09-30 21:07   ` David Miller
2014-09-30 23:16   ` [Bridge] " Vlad Yasevich
2014-09-30 23:16     ` Vlad Yasevich
2014-10-02  1:53 ` [Bridge] " David Miller
2014-10-02  1:53   ` David Miller

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=542BA324.7010603@lab.ntt.co.jp \
    --to=makita.toshiaki@lab.ntt.co.jp \
    --cc=bridge@lists.linux-foundation.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=vyasevic@redhat.com \
    --cc=vyasevich@gmail.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.