aboutsummaryrefslogtreecommitdiffstats
path: root/net/dcb/dcbnl.c
diff options
context:
space:
mode:
authorShmulik Ravid <shmulikr@broadcom.com>2011-01-03 03:04:59 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-03 15:12:11 -0500
commit7f891cf1fc0d5d5c5b359caec77e5383e1d55986 (patch)
tree58efa7cd0579cef739d04200eebc09cf3facbf6a /net/dcb/dcbnl.c
parent87e609760b5304ef0c0c53cf4d0b29fde9812e1b (diff)
dcbnl: more informed return values for new dcbnl routines
More accurate return values for the following (new) dcbnl routines: dcbnl_getdcbx() dcbnl_setdcbx() dcbnl_getfeatcfg() dcbnl_setfeatcfg() Signed-off-by: Shmulik Ravid <shmulikr@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dcb/dcbnl.c')
-rw-r--r--net/dcb/dcbnl.c81
1 files changed, 37 insertions, 44 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index ff3c12d2cd7..9399af56571 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1286,10 +1286,10 @@ nlmsg_failure:
1286static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb, 1286static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb,
1287 u32 pid, u32 seq, u16 flags) 1287 u32 pid, u32 seq, u16 flags)
1288{ 1288{
1289 int ret = -EINVAL; 1289 int ret;
1290 1290
1291 if (!netdev->dcbnl_ops->getdcbx) 1291 if (!netdev->dcbnl_ops->getdcbx)
1292 return ret; 1292 return -EOPNOTSUPP;
1293 1293
1294 ret = dcbnl_reply(netdev->dcbnl_ops->getdcbx(netdev), RTM_GETDCB, 1294 ret = dcbnl_reply(netdev->dcbnl_ops->getdcbx(netdev), RTM_GETDCB,
1295 DCB_CMD_GDCBX, DCB_ATTR_DCBX, pid, seq, flags); 1295 DCB_CMD_GDCBX, DCB_ATTR_DCBX, pid, seq, flags);
@@ -1300,11 +1300,14 @@ static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb,
1300static int dcbnl_setdcbx(struct net_device *netdev, struct nlattr **tb, 1300static int dcbnl_setdcbx(struct net_device *netdev, struct nlattr **tb,
1301 u32 pid, u32 seq, u16 flags) 1301 u32 pid, u32 seq, u16 flags)
1302{ 1302{
1303 int ret = -EINVAL; 1303 int ret;
1304 u8 value; 1304 u8 value;
1305 1305
1306 if (!tb[DCB_ATTR_DCBX] || !netdev->dcbnl_ops->setdcbx) 1306 if (!netdev->dcbnl_ops->setdcbx)
1307 return ret; 1307 return -EOPNOTSUPP;
1308
1309 if (!tb[DCB_ATTR_DCBX])
1310 return -EINVAL;
1308 1311
1309 value = nla_get_u8(tb[DCB_ATTR_DCBX]); 1312 value = nla_get_u8(tb[DCB_ATTR_DCBX]);
1310 1313
@@ -1323,23 +1326,23 @@ static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlattr **tb,
1323 struct dcbmsg *dcb; 1326 struct dcbmsg *dcb;
1324 struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1], *nest; 1327 struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1], *nest;
1325 u8 value; 1328 u8 value;
1326 int ret = -EINVAL; 1329 int ret, i;
1327 int i;
1328 int getall = 0; 1330 int getall = 0;
1329 1331
1330 if (!tb[DCB_ATTR_FEATCFG] || !netdev->dcbnl_ops->getfeatcfg) 1332 if (!netdev->dcbnl_ops->getfeatcfg)
1331 return ret; 1333 return -EOPNOTSUPP;
1334
1335 if (!tb[DCB_ATTR_FEATCFG])
1336 return -EINVAL;
1332 1337
1333 ret = nla_parse_nested(data, DCB_FEATCFG_ATTR_MAX, tb[DCB_ATTR_FEATCFG], 1338 ret = nla_parse_nested(data, DCB_FEATCFG_ATTR_MAX, tb[DCB_ATTR_FEATCFG],
1334 dcbnl_featcfg_nest); 1339 dcbnl_featcfg_nest);
1335 if (ret) { 1340 if (ret)
1336 ret = -EINVAL;
1337 goto err_out; 1341 goto err_out;
1338 }
1339 1342
1340 dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1343 dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1341 if (!dcbnl_skb) { 1344 if (!dcbnl_skb) {
1342 ret = -EINVAL; 1345 ret = -ENOBUFS;
1343 goto err_out; 1346 goto err_out;
1344 } 1347 }
1345 1348
@@ -1351,8 +1354,8 @@ static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlattr **tb,
1351 1354
1352 nest = nla_nest_start(dcbnl_skb, DCB_ATTR_FEATCFG); 1355 nest = nla_nest_start(dcbnl_skb, DCB_ATTR_FEATCFG);
1353 if (!nest) { 1356 if (!nest) {
1354 ret = -EINVAL; 1357 ret = -EMSGSIZE;
1355 goto err; 1358 goto nla_put_failure;
1356 } 1359 }
1357 1360
1358 if (data[DCB_FEATCFG_ATTR_ALL]) 1361 if (data[DCB_FEATCFG_ATTR_ALL])
@@ -1363,30 +1366,22 @@ static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlattr **tb,
1363 continue; 1366 continue;
1364 1367
1365 ret = netdev->dcbnl_ops->getfeatcfg(netdev, i, &value); 1368 ret = netdev->dcbnl_ops->getfeatcfg(netdev, i, &value);
1366 if (!ret) { 1369 if (!ret)
1367 ret = nla_put_u8(dcbnl_skb, i, value); 1370 ret = nla_put_u8(dcbnl_skb, i, value);
1368 1371
1369 if (ret) { 1372 if (ret) {
1370 nla_nest_cancel(dcbnl_skb, nest); 1373 nla_nest_cancel(dcbnl_skb, nest);
1371 ret = -EINVAL; 1374 goto nla_put_failure;
1372 goto err; 1375 }
1373 }
1374 } else
1375 goto err;
1376 } 1376 }
1377 nla_nest_end(dcbnl_skb, nest); 1377 nla_nest_end(dcbnl_skb, nest);
1378 1378
1379 nlmsg_end(dcbnl_skb, nlh); 1379 nlmsg_end(dcbnl_skb, nlh);
1380 1380
1381 ret = rtnl_unicast(dcbnl_skb, &init_net, pid); 1381 return rtnl_unicast(dcbnl_skb, &init_net, pid);
1382 if (ret) { 1382nla_put_failure:
1383 ret = -EINVAL; 1383 nlmsg_cancel(dcbnl_skb, nlh);
1384 goto err_out;
1385 }
1386
1387 return 0;
1388nlmsg_failure: 1384nlmsg_failure:
1389err:
1390 kfree_skb(dcbnl_skb); 1385 kfree_skb(dcbnl_skb);
1391err_out: 1386err_out:
1392 return ret; 1387 return ret;
@@ -1396,20 +1391,20 @@ static int dcbnl_setfeatcfg(struct net_device *netdev, struct nlattr **tb,
1396 u32 pid, u32 seq, u16 flags) 1391 u32 pid, u32 seq, u16 flags)
1397{ 1392{
1398 struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1]; 1393 struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1];
1399 int ret = -EINVAL; 1394 int ret, i;
1400 u8 value; 1395 u8 value;
1401 int i;
1402 1396
1403 if (!tb[DCB_ATTR_FEATCFG] || !netdev->dcbnl_ops->setfeatcfg) 1397 if (!netdev->dcbnl_ops->setfeatcfg)
1404 return ret; 1398 return -ENOTSUPP;
1399
1400 if (!tb[DCB_ATTR_FEATCFG])
1401 return -EINVAL;
1405 1402
1406 ret = nla_parse_nested(data, DCB_FEATCFG_ATTR_MAX, tb[DCB_ATTR_FEATCFG], 1403 ret = nla_parse_nested(data, DCB_FEATCFG_ATTR_MAX, tb[DCB_ATTR_FEATCFG],
1407 dcbnl_featcfg_nest); 1404 dcbnl_featcfg_nest);
1408 1405
1409 if (ret) { 1406 if (ret)
1410 ret = -EINVAL;
1411 goto err; 1407 goto err;
1412 }
1413 1408
1414 for (i = DCB_FEATCFG_ATTR_ALL+1; i <= DCB_FEATCFG_ATTR_MAX; i++) { 1409 for (i = DCB_FEATCFG_ATTR_ALL+1; i <= DCB_FEATCFG_ATTR_MAX; i++) {
1415 if (data[i] == NULL) 1410 if (data[i] == NULL)
@@ -1420,14 +1415,12 @@ static int dcbnl_setfeatcfg(struct net_device *netdev, struct nlattr **tb,
1420 ret = netdev->dcbnl_ops->setfeatcfg(netdev, i, value); 1415 ret = netdev->dcbnl_ops->setfeatcfg(netdev, i, value);
1421 1416
1422 if (ret) 1417 if (ret)
1423 goto operr; 1418 goto err;
1424 } 1419 }
1425
1426operr:
1427 ret = dcbnl_reply(!!ret, RTM_SETDCB, DCB_CMD_SFEATCFG,
1428 DCB_ATTR_FEATCFG, pid, seq, flags);
1429
1430err: 1420err:
1421 dcbnl_reply(ret, RTM_SETDCB, DCB_CMD_SFEATCFG, DCB_ATTR_FEATCFG,
1422 pid, seq, flags);
1423
1431 return ret; 1424 return ret;
1432} 1425}
1433 1426