Commit b3ce0325 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

vlan: Change vlan_dev_set_vlan_flag() to handle multiple flags at once

Change vlan_dev_set_vlan_flag() to handle multiple flags at once and
rename to vlan_dev_change_flags(). This allows to to use it from the
netlink interface, which in turn allows to handle necessary adjustments
when changing flags centrally.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eca9ebac
...@@ -591,9 +591,9 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -591,9 +591,9 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
err = -EPERM; err = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
break; break;
err = vlan_dev_set_vlan_flag(dev, err = vlan_dev_change_flags(dev,
args.u.flag, args.vlan_qos ? args.u.flag : 0,
args.vlan_qos); args.u.flag);
break; break;
case SET_VLAN_NAME_TYPE_CMD: case SET_VLAN_NAME_TYPE_CMD:
......
...@@ -28,8 +28,7 @@ void vlan_dev_set_ingress_priority(const struct net_device *dev, ...@@ -28,8 +28,7 @@ void vlan_dev_set_ingress_priority(const struct net_device *dev,
u32 skb_prio, short vlan_prio); u32 skb_prio, short vlan_prio);
int vlan_dev_set_egress_priority(const struct net_device *dev, int vlan_dev_set_egress_priority(const struct net_device *dev,
u32 skb_prio, short vlan_prio); u32 skb_prio, short vlan_prio);
int vlan_dev_set_vlan_flag(const struct net_device *dev, int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
u32 flag, short flag_val);
void vlan_dev_get_realdev_name(const struct net_device *dev, char *result); void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result); void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result);
......
...@@ -507,18 +507,16 @@ int vlan_dev_set_egress_priority(const struct net_device *dev, ...@@ -507,18 +507,16 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
} }
/* Flags are defined in the vlan_flags enum in include/linux/if_vlan.h file. */ /* Flags are defined in the vlan_flags enum in include/linux/if_vlan.h file. */
int vlan_dev_set_vlan_flag(const struct net_device *dev, int vlan_dev_change_flags(const struct net_device *dev, u32 flags, u32 mask)
u32 flag, short flag_val)
{ {
/* verify flag is supported */ struct vlan_dev_info *vlan = vlan_dev_info(dev);
if (flag == VLAN_FLAG_REORDER_HDR) { u32 old_flags = vlan->flags;
if (flag_val)
vlan_dev_info(dev)->flags |= VLAN_FLAG_REORDER_HDR; if (mask & ~VLAN_FLAG_REORDER_HDR)
else
vlan_dev_info(dev)->flags &= ~VLAN_FLAG_REORDER_HDR;
return 0;
}
return -EINVAL; return -EINVAL;
vlan->flags = (old_flags & ~mask) | (flags & mask);
return 0;
} }
void vlan_dev_get_realdev_name(const struct net_device *dev, char *result) void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
......
...@@ -75,7 +75,6 @@ static int vlan_validate(struct nlattr *tb[], struct nlattr *data[]) ...@@ -75,7 +75,6 @@ static int vlan_validate(struct nlattr *tb[], struct nlattr *data[])
static int vlan_changelink(struct net_device *dev, static int vlan_changelink(struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[]) struct nlattr *tb[], struct nlattr *data[])
{ {
struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct ifla_vlan_flags *flags; struct ifla_vlan_flags *flags;
struct ifla_vlan_qos_mapping *m; struct ifla_vlan_qos_mapping *m;
struct nlattr *attr; struct nlattr *attr;
...@@ -83,8 +82,7 @@ static int vlan_changelink(struct net_device *dev, ...@@ -83,8 +82,7 @@ static int vlan_changelink(struct net_device *dev,
if (data[IFLA_VLAN_FLAGS]) { if (data[IFLA_VLAN_FLAGS]) {
flags = nla_data(data[IFLA_VLAN_FLAGS]); flags = nla_data(data[IFLA_VLAN_FLAGS]);
vlan->flags = (vlan->flags & ~flags->mask) | vlan_dev_change_flags(dev, flags->flags, flags->mask);
(flags->flags & flags->mask);
} }
if (data[IFLA_VLAN_INGRESS_QOS]) { if (data[IFLA_VLAN_INGRESS_QOS]) {
nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) { nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment