Merge tag 'vmwgfx-fixes-4.3-151001' of git://people.freedesktop.org/~thomash/linux...
[firefly-linux-kernel-4.4.55.git] / net / bridge / br_netlink.c
index 4d74a0639c4ccd040b6371665e6a74f8dca6f800..ea748c93a07f1dcd988cc18130d629d6a3556d98 100644 (file)
@@ -16,7 +16,6 @@
 #include <net/rtnetlink.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
-#include <net/switchdev.h>
 #include <uapi/linux/if_bridge.h>
 
 #include "br_private.h"
@@ -166,8 +165,6 @@ static int br_fill_ifvlaninfo_range(struct sk_buff *skb, u16 vid_start,
                            sizeof(vinfo), &vinfo))
                        goto nla_put_failure;
 
-               vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN;
-
                vinfo.vid = vid_end;
                vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END;
                if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO,
@@ -675,6 +672,21 @@ static int br_validate(struct nlattr *tb[], struct nlattr *data[])
                        return -EADDRNOTAVAIL;
        }
 
+       if (!data)
+               return 0;
+
+#ifdef CONFIG_BRIDGE_VLAN_FILTERING
+       if (data[IFLA_BR_VLAN_PROTOCOL]) {
+               switch (nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL])) {
+               case htons(ETH_P_8021Q):
+               case htons(ETH_P_8021AD):
+                       break;
+               default:
+                       return -EPROTONOSUPPORT;
+               }
+       }
+#endif
+
        return 0;
 }
 
@@ -730,6 +742,8 @@ static const struct nla_policy br_policy[IFLA_BR_MAX + 1] = {
        [IFLA_BR_AGEING_TIME] = { .type = NLA_U32 },
        [IFLA_BR_STP_STATE] = { .type = NLA_U32 },
        [IFLA_BR_PRIORITY] = { .type = NLA_U16 },
+       [IFLA_BR_VLAN_FILTERING] = { .type = NLA_U8 },
+       [IFLA_BR_VLAN_PROTOCOL] = { .type = NLA_U16 },
 };
 
 static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
@@ -777,6 +791,24 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
                br_stp_set_bridge_priority(br, priority);
        }
 
+       if (data[IFLA_BR_VLAN_FILTERING]) {
+               u8 vlan_filter = nla_get_u8(data[IFLA_BR_VLAN_FILTERING]);
+
+               err = __br_vlan_filter_toggle(br, vlan_filter);
+               if (err)
+                       return err;
+       }
+
+#ifdef CONFIG_BRIDGE_VLAN_FILTERING
+       if (data[IFLA_BR_VLAN_PROTOCOL]) {
+               __be16 vlan_proto = nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL]);
+
+               err = __br_vlan_set_proto(br, vlan_proto);
+               if (err)
+                       return err;
+       }
+#endif
+
        return 0;
 }
 
@@ -788,6 +820,10 @@ static size_t br_get_size(const struct net_device *brdev)
               nla_total_size(sizeof(u32)) +    /* IFLA_BR_AGEING_TIME */
               nla_total_size(sizeof(u32)) +    /* IFLA_BR_STP_STATE */
               nla_total_size(sizeof(u16)) +    /* IFLA_BR_PRIORITY */
+              nla_total_size(sizeof(u8)) +     /* IFLA_BR_VLAN_FILTERING */
+#ifdef CONFIG_BRIDGE_VLAN_FILTERING
+              nla_total_size(sizeof(__be16)) + /* IFLA_BR_VLAN_PROTOCOL */
+#endif
               0;
 }
 
@@ -800,14 +836,21 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
        u32 ageing_time = jiffies_to_clock_t(br->ageing_time);
        u32 stp_enabled = br->stp_enabled;
        u16 priority = (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1];
+       u8 vlan_enabled = br_vlan_enabled(br);
 
        if (nla_put_u32(skb, IFLA_BR_FORWARD_DELAY, forward_delay) ||
            nla_put_u32(skb, IFLA_BR_HELLO_TIME, hello_time) ||
            nla_put_u32(skb, IFLA_BR_MAX_AGE, age_time) ||
            nla_put_u32(skb, IFLA_BR_AGEING_TIME, ageing_time) ||
            nla_put_u32(skb, IFLA_BR_STP_STATE, stp_enabled) ||
-           nla_put_u16(skb, IFLA_BR_PRIORITY, priority))
+           nla_put_u16(skb, IFLA_BR_PRIORITY, priority) ||
+           nla_put_u8(skb, IFLA_BR_VLAN_FILTERING, vlan_enabled))
+               return -EMSGSIZE;
+
+#ifdef CONFIG_BRIDGE_VLAN_FILTERING
+       if (nla_put_be16(skb, IFLA_BR_VLAN_PROTOCOL, br->vlan_proto))
                return -EMSGSIZE;
+#endif
 
        return 0;
 }
@@ -839,7 +882,7 @@ struct rtnl_link_ops br_link_ops __read_mostly = {
        .kind                   = "bridge",
        .priv_size              = sizeof(struct net_bridge),
        .setup                  = br_dev_setup,
-       .maxtype                = IFLA_BRPORT_MAX,
+       .maxtype                = IFLA_BR_MAX,
        .policy                 = br_policy,
        .validate               = br_validate,
        .newlink                = br_dev_newlink,