@@ -47,44 +47,59 @@ static int vlan_validate(struct nlattr *tb[], struct nlattr *data[],
4747 int err ;
4848
4949 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" );
5152 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" );
5356 return - EADDRNOTAVAIL ;
57+ }
5458 }
5559
56- if (!data )
60+ if (!data ) {
61+ NL_SET_ERR_MSG_MOD (extack , "VLAN properties not specified" );
5762 return - EINVAL ;
63+ }
5864
5965 if (data [IFLA_VLAN_PROTOCOL ]) {
6066 switch (nla_get_be16 (data [IFLA_VLAN_PROTOCOL ])) {
6167 case htons (ETH_P_8021Q ):
6268 case htons (ETH_P_8021AD ):
6369 break ;
6470 default :
71+ NL_SET_ERR_MSG_MOD (extack , "Invalid VLAN protocol" );
6572 return - EPROTONOSUPPORT ;
6673 }
6774 }
6875
6976 if (data [IFLA_VLAN_ID ]) {
7077 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" );
7280 return - ERANGE ;
81+ }
7382 }
7483 if (data [IFLA_VLAN_FLAGS ]) {
7584 flags = nla_data (data [IFLA_VLAN_FLAGS ]);
7685 if ((flags -> flags & flags -> mask ) &
7786 ~(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" );
7989 return - EINVAL ;
90+ }
8091 }
8192
8293 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" );
8496 return err ;
97+ }
8598 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" );
87101 return err ;
102+ }
88103 return 0 ;
89104}
90105
@@ -126,14 +141,21 @@ static int vlan_newlink(struct net *src_net, struct net_device *dev,
126141 __be16 proto ;
127142 int err ;
128143
129- if (!data [IFLA_VLAN_ID ])
144+ if (!data [IFLA_VLAN_ID ]) {
145+ NL_SET_ERR_MSG_MOD (extack , "VLAN id not specified" );
130146 return - EINVAL ;
147+ }
131148
132- if (!tb [IFLA_LINK ])
149+ if (!tb [IFLA_LINK ]) {
150+ NL_SET_ERR_MSG_MOD (extack , "link not specified" );
133151 return - EINVAL ;
152+ }
153+
134154 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" );
136157 return - ENODEV ;
158+ }
137159
138160 if (data [IFLA_VLAN_PROTOCOL ])
139161 proto = nla_get_be16 (data [IFLA_VLAN_PROTOCOL ]);
@@ -146,7 +168,8 @@ static int vlan_newlink(struct net *src_net, struct net_device *dev,
146168 dev -> priv_flags |= (real_dev -> priv_flags & IFF_XMIT_DST_RELEASE );
147169 vlan -> flags = VLAN_FLAG_REORDER_HDR ;
148170
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 );
150173 if (err < 0 )
151174 return err ;
152175
0 commit comments