@@ -47,44 +47,59 @@ static int vlan_validate(struct nlattr *tb[], struct nlattr *data[],
47
47
int err ;
48
48
49
49
if (tb [IFLA_ADDRESS ]) {
50
- if (nla_len (tb [IFLA_ADDRESS ]) != ETH_ALEN )
50
+ if (nla_len (tb [IFLA_ADDRESS ]) != ETH_ALEN ) {
51
+ NL_SET_ERR_MSG_MOD (extack , "Invalid link address" );
51
52
return - EINVAL ;
52
- if (!is_valid_ether_addr (nla_data (tb [IFLA_ADDRESS ])))
53
+ }
54
+ if (!is_valid_ether_addr (nla_data (tb [IFLA_ADDRESS ]))) {
55
+ NL_SET_ERR_MSG_MOD (extack , "Invalid link address" );
53
56
return - EADDRNOTAVAIL ;
57
+ }
54
58
}
55
59
56
- if (!data )
60
+ if (!data ) {
61
+ NL_SET_ERR_MSG_MOD (extack , "VLAN properties not specified" );
57
62
return - EINVAL ;
63
+ }
58
64
59
65
if (data [IFLA_VLAN_PROTOCOL ]) {
60
66
switch (nla_get_be16 (data [IFLA_VLAN_PROTOCOL ])) {
61
67
case htons (ETH_P_8021Q ):
62
68
case htons (ETH_P_8021AD ):
63
69
break ;
64
70
default :
71
+ NL_SET_ERR_MSG_MOD (extack , "Invalid VLAN protocol" );
65
72
return - EPROTONOSUPPORT ;
66
73
}
67
74
}
68
75
69
76
if (data [IFLA_VLAN_ID ]) {
70
77
id = nla_get_u16 (data [IFLA_VLAN_ID ]);
71
- if (id >= VLAN_VID_MASK )
78
+ if (id >= VLAN_VID_MASK ) {
79
+ NL_SET_ERR_MSG_MOD (extack , "Invalid VLAN id" );
72
80
return - ERANGE ;
81
+ }
73
82
}
74
83
if (data [IFLA_VLAN_FLAGS ]) {
75
84
flags = nla_data (data [IFLA_VLAN_FLAGS ]);
76
85
if ((flags -> flags & flags -> mask ) &
77
86
~(VLAN_FLAG_REORDER_HDR | VLAN_FLAG_GVRP |
78
- VLAN_FLAG_LOOSE_BINDING | VLAN_FLAG_MVRP ))
87
+ VLAN_FLAG_LOOSE_BINDING | VLAN_FLAG_MVRP )) {
88
+ NL_SET_ERR_MSG_MOD (extack , "Invalid VLAN flags" );
79
89
return - EINVAL ;
90
+ }
80
91
}
81
92
82
93
err = vlan_validate_qos_map (data [IFLA_VLAN_INGRESS_QOS ]);
83
- if (err < 0 )
94
+ if (err < 0 ) {
95
+ NL_SET_ERR_MSG_MOD (extack , "Invalid ingress QOS map" );
84
96
return err ;
97
+ }
85
98
err = vlan_validate_qos_map (data [IFLA_VLAN_EGRESS_QOS ]);
86
- if (err < 0 )
99
+ if (err < 0 ) {
100
+ NL_SET_ERR_MSG_MOD (extack , "Invalid egress QOS map" );
87
101
return err ;
102
+ }
88
103
return 0 ;
89
104
}
90
105
@@ -126,14 +141,21 @@ static int vlan_newlink(struct net *src_net, struct net_device *dev,
126
141
__be16 proto ;
127
142
int err ;
128
143
129
- if (!data [IFLA_VLAN_ID ])
144
+ if (!data [IFLA_VLAN_ID ]) {
145
+ NL_SET_ERR_MSG_MOD (extack , "VLAN id not specified" );
130
146
return - EINVAL ;
147
+ }
131
148
132
- if (!tb [IFLA_LINK ])
149
+ if (!tb [IFLA_LINK ]) {
150
+ NL_SET_ERR_MSG_MOD (extack , "link not specified" );
133
151
return - EINVAL ;
152
+ }
153
+
134
154
real_dev = __dev_get_by_index (src_net , nla_get_u32 (tb [IFLA_LINK ]));
135
- if (!real_dev )
155
+ if (!real_dev ) {
156
+ NL_SET_ERR_MSG_MOD (extack , "link does not exist" );
136
157
return - ENODEV ;
158
+ }
137
159
138
160
if (data [IFLA_VLAN_PROTOCOL ])
139
161
proto = nla_get_be16 (data [IFLA_VLAN_PROTOCOL ]);
@@ -146,7 +168,8 @@ static int vlan_newlink(struct net *src_net, struct net_device *dev,
146
168
dev -> priv_flags |= (real_dev -> priv_flags & IFF_XMIT_DST_RELEASE );
147
169
vlan -> flags = VLAN_FLAG_REORDER_HDR ;
148
170
149
- err = vlan_check_real_dev (real_dev , vlan -> vlan_proto , vlan -> vlan_id );
171
+ err = vlan_check_real_dev (real_dev , vlan -> vlan_proto , vlan -> vlan_id ,
172
+ extack );
150
173
if (err < 0 )
151
174
return err ;
152
175
0 commit comments