* [PATCH net-next] vlan: allow changing VLAN id and protocol
@ 2015-03-08 18:06 Stephen Hemminger
2015-03-08 18:25 ` Jeff Kirsher
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2015-03-08 18:06 UTC (permalink / raw)
To: David Miller; +Cc: netdev
The VLAN netlink interface allows changing the ID and protocol of an existing
VLAN, but it was being ignored. Move the initialization of the proto and
id into the change function to fix that.
Example of the problem:
# modprobe dummy
# ip li set dev dummy0 up
# ip li add link dummy0 name dummy0.10 type vlan id 100
# ip li set dummy0.10 type vlan id 111
# ip -d li show dev dummy0.10
19: dummy0.10@dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT
link/ether be:d3:7c:7f:86:18 brd ff:ff:ff:ff:ff:ff
vlan id 100 <REORDER_HDR>
^^^ should be 111
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
--- a/net/8021q/vlan_netlink.c 2015-03-08 09:38:48.519551748 -0700
+++ b/net/8021q/vlan_netlink.c 2015-03-08 09:42:16.332512289 -0700
@@ -89,10 +89,30 @@ static int vlan_validate(struct nlattr *
static int vlan_changelink(struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[])
{
+ struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
struct ifla_vlan_flags *flags;
struct ifla_vlan_qos_mapping *m;
struct nlattr *attr;
- int rem;
+ __be16 proto;
+ int err, rem;
+ u16 id;
+
+ if (data[IFLA_VLAN_PROTOCOL])
+ proto = nla_get_be16(data[IFLA_VLAN_PROTOCOL]);
+ else
+ proto = htons(ETH_P_8021Q);
+
+ if (data[IFLA_VLAN_ID])
+ id = nla_get_u16(data[IFLA_VLAN_ID]);
+ else
+ id = vlan->vlan_id;
+
+ err = vlan_check_real_dev(vlan->real_dev, proto, id);
+ if (err < 0)
+ return err;
+
+ vlan->vlan_id = id;
+ vlan->vlan_proto = proto;
if (data[IFLA_VLAN_FLAGS]) {
flags = nla_data(data[IFLA_VLAN_FLAGS]);
@@ -118,7 +138,6 @@ static int vlan_newlink(struct net *src_
{
struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
struct net_device *real_dev;
- __be16 proto;
int err;
if (!data[IFLA_VLAN_ID])
@@ -130,20 +149,9 @@ static int vlan_newlink(struct net *src_
if (!real_dev)
return -ENODEV;
- if (data[IFLA_VLAN_PROTOCOL])
- proto = nla_get_be16(data[IFLA_VLAN_PROTOCOL]);
- else
- proto = htons(ETH_P_8021Q);
-
- vlan->vlan_proto = proto;
- vlan->vlan_id = nla_get_u16(data[IFLA_VLAN_ID]);
vlan->real_dev = real_dev;
vlan->flags = VLAN_FLAG_REORDER_HDR;
- err = vlan_check_real_dev(real_dev, vlan->vlan_proto, vlan->vlan_id);
- if (err < 0)
- return err;
-
if (!tb[IFLA_MTU])
dev->mtu = real_dev->mtu;
else if (dev->mtu > real_dev->mtu)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vlan: allow changing VLAN id and protocol
2015-03-08 18:06 [PATCH net-next] vlan: allow changing VLAN id and protocol Stephen Hemminger
@ 2015-03-08 18:25 ` Jeff Kirsher
2015-03-08 21:44 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Kirsher @ 2015-03-08 18:25 UTC (permalink / raw)
To: Stephen Hemminger, David Miller; +Cc: netdev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
On 03/08/2015 11:06 AM, Stephen Hemminger wrote:
>
> The VLAN netlink interface allows changing the ID and protocol of an existing
> VLAN, but it was being ignored. Move the initialization of the proto and
> id into the change function to fix that.
>
> Example of the problem:
> # modprobe dummy
> # ip li set dev dummy0 up
> # ip li add link dummy0 name dummy0.10 type vlan id 100
> # ip li set dummy0.10 type vlan id 111
> # ip -d li show dev dummy0.10
> 19: dummy0.10@dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT
> link/ether be:d3:7c:7f:86:18 brd ff:ff:ff:ff:ff:ff
> vlan id 100 <REORDER_HDR>
> ^^^ should be 111
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBCgAGBQJU/JQlAAoJEOVv75VaS+3OnY8P/2JXfEavZqtBzK2wSRxaJ5o0
PU8FVutYDQ/DFFixEFtIaMY+nVpuViRXmUfowUEbXI5VOeoqwxhC5ek1V4c1TeAl
1gac0oY0ynqFHuAkj2MCkTR32IuOoLEjphekeYbJsLoMY4lF6iCXlQiJ+fboethk
u10p10l4nE16gKCohLvrfW9TjXKF0SiRN70tqOWwwyrhL8YYL4ifE3AQbt3cStvw
wzKrraMueodhtG1SJqVPnr2Iui7LN1hwQFH+J6V0RPYc6hqenQewgP+s4TaWd/a0
9iur1uJXnXvHGihh7HHIuF8ARQhSwlNRMXIq1T87F/qZIpHuUOouMDBZrrgSyBjJ
QAM9gSL5Yd9HX91W1wxl00dvc00GdZFd+x9Zb7ROV42biiA1Yudua3TjzqEbwc61
JM5kR7GUiThqPcWmC+9YjYCbE1ciidepD3LxtjKBQdVIdDUiim0jLzUv1d45L3ne
hsGuB6F64M0iTEHxM8c8NhwYiOpnl6lqaKAHAyGhBKLLlGkAyuktIr8+eXImxTz8
xu7q/DdX/z9/l8rNiqZmM9dI7cOrsW3BgvMi+/bpcbwe8vwIdir/GUpQ0duapG8z
OiNt5Xqda18FsFUyLRe1iq1YbeRLpRt0c+guMMTqLaa1m4i2LwiEEnKF8Ofklk6q
vA4U4evsyN4ROSUjJbAe
=yuzw
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vlan: allow changing VLAN id and protocol
2015-03-08 18:25 ` Jeff Kirsher
@ 2015-03-08 21:44 ` Stephen Hemminger
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2015-03-08 21:44 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: David Miller, netdev
On Sun, 08 Mar 2015 11:25:42 -0700
Jeff Kirsher <tarbal@gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> On 03/08/2015 11:06 AM, Stephen Hemminger wrote:
> >
> > The VLAN netlink interface allows changing the ID and protocol of an existing
> > VLAN, but it was being ignored. Move the initialization of the proto and
> > id into the change function to fix that.
> >
> > Example of the problem:
> > # modprobe dummy
> > # ip li set dev dummy0 up
> > # ip li add link dummy0 name dummy0.10 type vlan id 100
> > # ip li set dummy0.10 type vlan id 111
> > # ip -d li show dev dummy0.10
> > 19: dummy0.10@dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT
> > link/ether be:d3:7c:7f:86:18 brd ff:ff:ff:ff:ff:ff
> > vlan id 100 <REORDER_HDR>
> > ^^^ should be 111
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Self-NAK
This needs more state work to handle the case of GARP and all the
filtering stuff. There be small dragons here.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-08 21:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-08 18:06 [PATCH net-next] vlan: allow changing VLAN id and protocol Stephen Hemminger
2015-03-08 18:25 ` Jeff Kirsher
2015-03-08 21:44 ` Stephen Hemminger
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).