aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-07-06 00:26:27 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-06 00:26:27 -0400
commitb3ce0325f2bf1bb737cb8fc7c349ce8fefdd9e40 (patch)
treef2925e18555561b528b781c535c96bdbc0c809a9 /net/8021q
parenteca9ebac651f774d8b10fce7c5d173c3c3d3394f (diff)
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: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q')
-rw-r--r--net/8021q/vlan.c6
-rw-r--r--net/8021q/vlan.h3
-rw-r--r--net/8021q/vlan_dev.c20
-rw-r--r--net/8021q/vlan_netlink.c4
4 files changed, 14 insertions, 19 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index ab2225da0ee2..b591bfca1ab2 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -591,9 +591,9 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
591 err = -EPERM; 591 err = -EPERM;
592 if (!capable(CAP_NET_ADMIN)) 592 if (!capable(CAP_NET_ADMIN))
593 break; 593 break;
594 err = vlan_dev_set_vlan_flag(dev, 594 err = vlan_dev_change_flags(dev,
595 args.u.flag, 595 args.vlan_qos ? args.u.flag : 0,
596 args.vlan_qos); 596 args.u.flag);
597 break; 597 break;
598 598
599 case SET_VLAN_NAME_TYPE_CMD: 599 case SET_VLAN_NAME_TYPE_CMD:
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 5229a72c7ea1..639e2544a804 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -28,8 +28,7 @@ void vlan_dev_set_ingress_priority(const struct net_device *dev,
28 u32 skb_prio, short vlan_prio); 28 u32 skb_prio, short vlan_prio);
29int vlan_dev_set_egress_priority(const struct net_device *dev, 29int vlan_dev_set_egress_priority(const struct net_device *dev,
30 u32 skb_prio, short vlan_prio); 30 u32 skb_prio, short vlan_prio);
31int vlan_dev_set_vlan_flag(const struct net_device *dev, 31int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
32 u32 flag, short flag_val);
33void vlan_dev_get_realdev_name(const struct net_device *dev, char *result); 32void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
34void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result); 33void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result);
35 34
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 5d055c242ed8..76c665cdab66 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -507,18 +507,16 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
507} 507}
508 508
509/* Flags are defined in the vlan_flags enum in include/linux/if_vlan.h file. */ 509/* Flags are defined in the vlan_flags enum in include/linux/if_vlan.h file. */
510int vlan_dev_set_vlan_flag(const struct net_device *dev, 510int vlan_dev_change_flags(const struct net_device *dev, u32 flags, u32 mask)
511 u32 flag, short flag_val)
512{ 511{
513 /* verify flag is supported */ 512 struct vlan_dev_info *vlan = vlan_dev_info(dev);
514 if (flag == VLAN_FLAG_REORDER_HDR) { 513 u32 old_flags = vlan->flags;
515 if (flag_val) 514
516 vlan_dev_info(dev)->flags |= VLAN_FLAG_REORDER_HDR; 515 if (mask & ~VLAN_FLAG_REORDER_HDR)
517 else 516 return -EINVAL;
518 vlan_dev_info(dev)->flags &= ~VLAN_FLAG_REORDER_HDR; 517
519 return 0; 518 vlan->flags = (old_flags & ~mask) | (flags & mask);
520 } 519 return 0;
521 return -EINVAL;
522} 520}
523 521
524void vlan_dev_get_realdev_name(const struct net_device *dev, char *result) 522void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index c93e69ec28ed..fd7cb195d53f 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -75,7 +75,6 @@ static int vlan_validate(struct nlattr *tb[], struct nlattr *data[])
75static int vlan_changelink(struct net_device *dev, 75static int vlan_changelink(struct net_device *dev,
76 struct nlattr *tb[], struct nlattr *data[]) 76 struct nlattr *tb[], struct nlattr *data[])
77{ 77{
78 struct vlan_dev_info *vlan = vlan_dev_info(dev);
79 struct ifla_vlan_flags *flags; 78 struct ifla_vlan_flags *flags;
80 struct ifla_vlan_qos_mapping *m; 79 struct ifla_vlan_qos_mapping *m;
81 struct nlattr *attr; 80 struct nlattr *attr;
@@ -83,8 +82,7 @@ static int vlan_changelink(struct net_device *dev,
83 82
84 if (data[IFLA_VLAN_FLAGS]) { 83 if (data[IFLA_VLAN_FLAGS]) {
85 flags = nla_data(data[IFLA_VLAN_FLAGS]); 84 flags = nla_data(data[IFLA_VLAN_FLAGS]);
86 vlan->flags = (vlan->flags & ~flags->mask) | 85 vlan_dev_change_flags(dev, flags->flags, flags->mask);
87 (flags->flags & flags->mask);
88 } 86 }
89 if (data[IFLA_VLAN_INGRESS_QOS]) { 87 if (data[IFLA_VLAN_INGRESS_QOS]) {
90 nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) { 88 nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) {