11 #include <linux/kernel.h>
12 #include <linux/netdevice.h>
13 #include <linux/if_vlan.h>
14 #include <linux/module.h>
33 static inline int vlan_validate_qos_map(
struct nlattr *
attr)
47 if (nla_len(tb[IFLA_ADDRESS]) !=
ETH_ALEN)
49 if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
57 id = nla_get_u16(data[IFLA_VLAN_ID]);
62 flags = nla_data(data[IFLA_VLAN_FLAGS]);
86 if (data[IFLA_VLAN_FLAGS]) {
87 flags = nla_data(data[IFLA_VLAN_FLAGS]);
105 static int vlan_newlink(
struct net *src_net,
struct net_device *dev,
112 if (!data[IFLA_VLAN_ID])
121 vlan->
vlan_id = nla_get_u16(data[IFLA_VLAN_ID]);
131 else if (dev->
mtu > real_dev->
mtu)
134 err = vlan_changelink(dev, tb, data);
141 static inline size_t vlan_qos_map_size(
unsigned int n)
146 return nla_total_size(
sizeof(
struct nlattr)) +
150 static size_t vlan_get_size(
const struct net_device *dev)
154 return nla_total_size(2) +
156 vlan_qos_map_size(vlan->nr_ingress_mappings) +
157 vlan_qos_map_size(vlan->nr_egress_mappings);
170 goto nla_put_failure;
174 if (
nla_put(skb, IFLA_VLAN_FLAGS,
sizeof(
f), &
f))
175 goto nla_put_failure;
178 nest = nla_nest_start(skb, IFLA_VLAN_INGRESS_QOS);
180 goto nla_put_failure;
190 goto nla_put_failure;
192 nla_nest_end(skb, nest);
198 goto nla_put_failure;
210 goto nla_put_failure;
213 nla_nest_end(skb, nest);
224 .policy = vlan_policy,
227 .validate = vlan_validate,
228 .newlink = vlan_newlink,
229 .changelink = vlan_changelink,
231 .get_size = vlan_get_size,
232 .fill_info = vlan_fill_info,