netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huang Qijun <dknightjun@gmail.com>
To: davem@davemloft.net
Cc: kuba@kernel.org, ap420073@gmail.com, tglx@linutronix.de,
	gregkh@linuxfoundation.org, allison@lohutok.net,
	dknightjun@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] vlan: fix the bug that cannot create vlan4095
Date: Mon, 18 May 2020 13:27:55 +0800	[thread overview]
Message-ID: <20200518052755.27467-1-dknightjun@gmail.com> (raw)

According to the 8021q standard, the VLAN id range is 1 to 4095.
But in the register_vlan_device function, the range is 1 to 4094,
because ">= VLAN_VID_MASK" is used to determine whether the id
is illegal. This will prevent the creation of the vlan4095 interface:
    $ vconfig add sit0 4095
    vconfig: ioctl error for add: Numerical result out of range

To fix this error, this patch uses ">= VLAN_N_VID" instead to
determine if the id is illegal.

Signed-off-by: Huang Qijun <dknightjun@gmail.com>
---
 net/8021q/vlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index d4bcfd8f95bf..5de7861ddf64 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -219,7 +219,7 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
 	char name[IFNAMSIZ];
 	int err;
 
-	if (vlan_id >= VLAN_VID_MASK)
+	if (vlan_id >= VLAN_N_VID)
 		return -ERANGE;
 
 	err = vlan_check_real_dev(real_dev, htons(ETH_P_8021Q), vlan_id,
-- 
2.17.1


             reply	other threads:[~2020-05-18  5:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18  5:27 Huang Qijun [this message]
2020-05-18  7:01 ` [PATCH] vlan: fix the bug that cannot create vlan4095 Ido Schimmel

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=20200518052755.27467-1-dknightjun@gmail.com \
    --to=dknightjun@gmail.com \
    --cc=allison@lohutok.net \
    --cc=ap420073@gmail.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).