diff options
author | Thomas Graf <tgraf@suug.ch> | 2012-06-12 22:54:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-13 18:46:34 -0400 |
commit | 3d1f486952b750f1cca53cf22d4f769db5aba4f0 (patch) | |
tree | 8079cc97a2b15c35d3792307d3e9673486d6e812 /net/dcb | |
parent | ab6d470735682a6e1ba889a66f56eb1640242096 (diff) |
dcbnl: Return consistent error codes
EMSGSIZE - ran out of space while constructing message
EOPNOTSUPP - driver/hardware does not support operation
ENODEV - network device not found
EINVAL - invalid message
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dcb')
-rw-r--r-- | net/dcb/dcbnl.c | 273 |
1 files changed, 138 insertions, 135 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 4d9e0ef23d9f..5a5bc25b70d3 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c | |||
@@ -229,7 +229,7 @@ static int dcbnl_getstate(struct net_device *netdev, struct nlmsghdr *nlh, | |||
229 | { | 229 | { |
230 | /* if (!tb[DCB_ATTR_STATE] || !netdev->dcbnl_ops->getstate) */ | 230 | /* if (!tb[DCB_ATTR_STATE] || !netdev->dcbnl_ops->getstate) */ |
231 | if (!netdev->dcbnl_ops->getstate) | 231 | if (!netdev->dcbnl_ops->getstate) |
232 | return -EINVAL; | 232 | return -EOPNOTSUPP; |
233 | 233 | ||
234 | return nla_put_u8(skb, DCB_ATTR_STATE, | 234 | return nla_put_u8(skb, DCB_ATTR_STATE, |
235 | netdev->dcbnl_ops->getstate(netdev)); | 235 | netdev->dcbnl_ops->getstate(netdev)); |
@@ -240,22 +240,25 @@ static int dcbnl_getpfccfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
240 | { | 240 | { |
241 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1], *nest; | 241 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1], *nest; |
242 | u8 value; | 242 | u8 value; |
243 | int ret = -EINVAL; | 243 | int ret; |
244 | int i; | 244 | int i; |
245 | int getall = 0; | 245 | int getall = 0; |
246 | 246 | ||
247 | if (!tb[DCB_ATTR_PFC_CFG] || !netdev->dcbnl_ops->getpfccfg) | 247 | if (!tb[DCB_ATTR_PFC_CFG]) |
248 | return ret; | 248 | return -EINVAL; |
249 | |||
250 | if (!netdev->dcbnl_ops->getpfccfg) | ||
251 | return -EOPNOTSUPP; | ||
249 | 252 | ||
250 | ret = nla_parse_nested(data, DCB_PFC_UP_ATTR_MAX, | 253 | ret = nla_parse_nested(data, DCB_PFC_UP_ATTR_MAX, |
251 | tb[DCB_ATTR_PFC_CFG], | 254 | tb[DCB_ATTR_PFC_CFG], |
252 | dcbnl_pfc_up_nest); | 255 | dcbnl_pfc_up_nest); |
253 | if (ret) | 256 | if (ret) |
254 | goto err; | 257 | return ret; |
255 | 258 | ||
256 | nest = nla_nest_start(skb, DCB_ATTR_PFC_CFG); | 259 | nest = nla_nest_start(skb, DCB_ATTR_PFC_CFG); |
257 | if (!nest) | 260 | if (!nest) |
258 | goto err; | 261 | return -EMSGSIZE; |
259 | 262 | ||
260 | if (data[DCB_PFC_UP_ATTR_ALL]) | 263 | if (data[DCB_PFC_UP_ATTR_ALL]) |
261 | getall = 1; | 264 | getall = 1; |
@@ -269,14 +272,12 @@ static int dcbnl_getpfccfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
269 | ret = nla_put_u8(skb, i, value); | 272 | ret = nla_put_u8(skb, i, value); |
270 | if (ret) { | 273 | if (ret) { |
271 | nla_nest_cancel(skb, nest); | 274 | nla_nest_cancel(skb, nest); |
272 | goto err; | 275 | return ret; |
273 | } | 276 | } |
274 | } | 277 | } |
275 | nla_nest_end(skb, nest); | 278 | nla_nest_end(skb, nest); |
276 | 279 | ||
277 | return 0; | 280 | return 0; |
278 | err: | ||
279 | return -EINVAL; | ||
280 | } | 281 | } |
281 | 282 | ||
282 | static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlmsghdr *nlh, | 283 | static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlmsghdr *nlh, |
@@ -285,7 +286,7 @@ static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlmsghdr *nlh, | |||
285 | u8 perm_addr[MAX_ADDR_LEN]; | 286 | u8 perm_addr[MAX_ADDR_LEN]; |
286 | 287 | ||
287 | if (!netdev->dcbnl_ops->getpermhwaddr) | 288 | if (!netdev->dcbnl_ops->getpermhwaddr) |
288 | return -EINVAL; | 289 | return -EOPNOTSUPP; |
289 | 290 | ||
290 | netdev->dcbnl_ops->getpermhwaddr(netdev, perm_addr); | 291 | netdev->dcbnl_ops->getpermhwaddr(netdev, perm_addr); |
291 | 292 | ||
@@ -297,21 +298,24 @@ static int dcbnl_getcap(struct net_device *netdev, struct nlmsghdr *nlh, | |||
297 | { | 298 | { |
298 | struct nlattr *data[DCB_CAP_ATTR_MAX + 1], *nest; | 299 | struct nlattr *data[DCB_CAP_ATTR_MAX + 1], *nest; |
299 | u8 value; | 300 | u8 value; |
300 | int ret = -EINVAL; | 301 | int ret; |
301 | int i; | 302 | int i; |
302 | int getall = 0; | 303 | int getall = 0; |
303 | 304 | ||
304 | if (!tb[DCB_ATTR_CAP] || !netdev->dcbnl_ops->getcap) | 305 | if (!tb[DCB_ATTR_CAP]) |
305 | return ret; | 306 | return -EINVAL; |
307 | |||
308 | if (!netdev->dcbnl_ops->getcap) | ||
309 | return -EOPNOTSUPP; | ||
306 | 310 | ||
307 | ret = nla_parse_nested(data, DCB_CAP_ATTR_MAX, tb[DCB_ATTR_CAP], | 311 | ret = nla_parse_nested(data, DCB_CAP_ATTR_MAX, tb[DCB_ATTR_CAP], |
308 | dcbnl_cap_nest); | 312 | dcbnl_cap_nest); |
309 | if (ret) | 313 | if (ret) |
310 | goto err_out; | 314 | return ret; |
311 | 315 | ||
312 | nest = nla_nest_start(skb, DCB_ATTR_CAP); | 316 | nest = nla_nest_start(skb, DCB_ATTR_CAP); |
313 | if (!nest) | 317 | if (!nest) |
314 | goto err_out; | 318 | return -EMSGSIZE; |
315 | 319 | ||
316 | if (data[DCB_CAP_ATTR_ALL]) | 320 | if (data[DCB_CAP_ATTR_ALL]) |
317 | getall = 1; | 321 | getall = 1; |
@@ -324,15 +328,13 @@ static int dcbnl_getcap(struct net_device *netdev, struct nlmsghdr *nlh, | |||
324 | ret = nla_put_u8(skb, i, value); | 328 | ret = nla_put_u8(skb, i, value); |
325 | if (ret) { | 329 | if (ret) { |
326 | nla_nest_cancel(skb, nest); | 330 | nla_nest_cancel(skb, nest); |
327 | goto err_out; | 331 | return ret; |
328 | } | 332 | } |
329 | } | 333 | } |
330 | } | 334 | } |
331 | nla_nest_end(skb, nest); | 335 | nla_nest_end(skb, nest); |
332 | 336 | ||
333 | return 0; | 337 | return 0; |
334 | err_out: | ||
335 | return -EINVAL; | ||
336 | } | 338 | } |
337 | 339 | ||
338 | static int dcbnl_getnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, | 340 | static int dcbnl_getnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, |
@@ -340,25 +342,24 @@ static int dcbnl_getnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, | |||
340 | { | 342 | { |
341 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1], *nest; | 343 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1], *nest; |
342 | u8 value; | 344 | u8 value; |
343 | int ret = -EINVAL; | 345 | int ret; |
344 | int i; | 346 | int i; |
345 | int getall = 0; | 347 | int getall = 0; |
346 | 348 | ||
347 | if (!tb[DCB_ATTR_NUMTCS] || !netdev->dcbnl_ops->getnumtcs) | 349 | if (!tb[DCB_ATTR_NUMTCS]) |
348 | return ret; | 350 | return -EINVAL; |
351 | |||
352 | if (!netdev->dcbnl_ops->getnumtcs) | ||
353 | return -EOPNOTSUPP; | ||
349 | 354 | ||
350 | ret = nla_parse_nested(data, DCB_NUMTCS_ATTR_MAX, tb[DCB_ATTR_NUMTCS], | 355 | ret = nla_parse_nested(data, DCB_NUMTCS_ATTR_MAX, tb[DCB_ATTR_NUMTCS], |
351 | dcbnl_numtcs_nest); | 356 | dcbnl_numtcs_nest); |
352 | if (ret) { | 357 | if (ret) |
353 | ret = -EINVAL; | 358 | return ret; |
354 | goto err_out; | ||
355 | } | ||
356 | 359 | ||
357 | nest = nla_nest_start(skb, DCB_ATTR_NUMTCS); | 360 | nest = nla_nest_start(skb, DCB_ATTR_NUMTCS); |
358 | if (!nest) { | 361 | if (!nest) |
359 | ret = -EINVAL; | 362 | return -EMSGSIZE; |
360 | goto err_out; | ||
361 | } | ||
362 | 363 | ||
363 | if (data[DCB_NUMTCS_ATTR_ALL]) | 364 | if (data[DCB_NUMTCS_ATTR_ALL]) |
364 | getall = 1; | 365 | getall = 1; |
@@ -372,36 +373,34 @@ static int dcbnl_getnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, | |||
372 | ret = nla_put_u8(skb, i, value); | 373 | ret = nla_put_u8(skb, i, value); |
373 | if (ret) { | 374 | if (ret) { |
374 | nla_nest_cancel(skb, nest); | 375 | nla_nest_cancel(skb, nest); |
375 | ret = -EINVAL; | 376 | return ret; |
376 | goto err_out; | ||
377 | } | 377 | } |
378 | } else { | 378 | } else |
379 | goto err_out; | 379 | return -EINVAL; |
380 | } | ||
381 | } | 380 | } |
382 | nla_nest_end(skb, nest); | 381 | nla_nest_end(skb, nest); |
383 | 382 | ||
384 | return 0; | 383 | return 0; |
385 | err_out: | ||
386 | return ret; | ||
387 | } | 384 | } |
388 | 385 | ||
389 | static int dcbnl_setnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, | 386 | static int dcbnl_setnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, |
390 | u32 seq, struct nlattr **tb, struct sk_buff *skb) | 387 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
391 | { | 388 | { |
392 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1]; | 389 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1]; |
393 | int ret = -EINVAL; | 390 | int ret; |
394 | u8 value; | 391 | u8 value; |
395 | int i; | 392 | int i; |
396 | 393 | ||
397 | if (!tb[DCB_ATTR_NUMTCS] || !netdev->dcbnl_ops->setnumtcs) | 394 | if (!tb[DCB_ATTR_NUMTCS]) |
398 | return ret; | 395 | return -EINVAL; |
396 | |||
397 | if (!netdev->dcbnl_ops->setnumtcs) | ||
398 | return -EOPNOTSUPP; | ||
399 | 399 | ||
400 | ret = nla_parse_nested(data, DCB_NUMTCS_ATTR_MAX, tb[DCB_ATTR_NUMTCS], | 400 | ret = nla_parse_nested(data, DCB_NUMTCS_ATTR_MAX, tb[DCB_ATTR_NUMTCS], |
401 | dcbnl_numtcs_nest); | 401 | dcbnl_numtcs_nest); |
402 | |||
403 | if (ret) | 402 | if (ret) |
404 | return -EINVAL; | 403 | return ret; |
405 | 404 | ||
406 | for (i = DCB_NUMTCS_ATTR_ALL+1; i <= DCB_NUMTCS_ATTR_MAX; i++) { | 405 | for (i = DCB_NUMTCS_ATTR_ALL+1; i <= DCB_NUMTCS_ATTR_MAX; i++) { |
407 | if (data[i] == NULL) | 406 | if (data[i] == NULL) |
@@ -421,7 +420,7 @@ static int dcbnl_getpfcstate(struct net_device *netdev, struct nlmsghdr *nlh, | |||
421 | u32 seq, struct nlattr **tb, struct sk_buff *skb) | 420 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
422 | { | 421 | { |
423 | if (!netdev->dcbnl_ops->getpfcstate) | 422 | if (!netdev->dcbnl_ops->getpfcstate) |
424 | return -EINVAL; | 423 | return -EOPNOTSUPP; |
425 | 424 | ||
426 | return nla_put_u8(skb, DCB_ATTR_PFC_STATE, | 425 | return nla_put_u8(skb, DCB_ATTR_PFC_STATE, |
427 | netdev->dcbnl_ops->getpfcstate(netdev)); | 426 | netdev->dcbnl_ops->getpfcstate(netdev)); |
@@ -432,9 +431,12 @@ static int dcbnl_setpfcstate(struct net_device *netdev, struct nlmsghdr *nlh, | |||
432 | { | 431 | { |
433 | u8 value; | 432 | u8 value; |
434 | 433 | ||
435 | if (!tb[DCB_ATTR_PFC_STATE] || !netdev->dcbnl_ops->setpfcstate) | 434 | if (!tb[DCB_ATTR_PFC_STATE]) |
436 | return -EINVAL; | 435 | return -EINVAL; |
437 | 436 | ||
437 | if (!netdev->dcbnl_ops->setpfcstate) | ||
438 | return -EOPNOTSUPP; | ||
439 | |||
438 | value = nla_get_u8(tb[DCB_ATTR_PFC_STATE]); | 440 | value = nla_get_u8(tb[DCB_ATTR_PFC_STATE]); |
439 | 441 | ||
440 | netdev->dcbnl_ops->setpfcstate(netdev, value); | 442 | netdev->dcbnl_ops->setpfcstate(netdev, value); |
@@ -449,27 +451,26 @@ static int dcbnl_getapp(struct net_device *netdev, struct nlmsghdr *nlh, | |||
449 | struct nlattr *app_tb[DCB_APP_ATTR_MAX + 1]; | 451 | struct nlattr *app_tb[DCB_APP_ATTR_MAX + 1]; |
450 | u16 id; | 452 | u16 id; |
451 | u8 up, idtype; | 453 | u8 up, idtype; |
452 | int ret = -EINVAL; | 454 | int ret; |
453 | 455 | ||
454 | if (!tb[DCB_ATTR_APP]) | 456 | if (!tb[DCB_ATTR_APP]) |
455 | goto out; | 457 | return -EINVAL; |
456 | 458 | ||
457 | ret = nla_parse_nested(app_tb, DCB_APP_ATTR_MAX, tb[DCB_ATTR_APP], | 459 | ret = nla_parse_nested(app_tb, DCB_APP_ATTR_MAX, tb[DCB_ATTR_APP], |
458 | dcbnl_app_nest); | 460 | dcbnl_app_nest); |
459 | if (ret) | 461 | if (ret) |
460 | goto out; | 462 | return ret; |
461 | 463 | ||
462 | ret = -EINVAL; | ||
463 | /* all must be non-null */ | 464 | /* all must be non-null */ |
464 | if ((!app_tb[DCB_APP_ATTR_IDTYPE]) || | 465 | if ((!app_tb[DCB_APP_ATTR_IDTYPE]) || |
465 | (!app_tb[DCB_APP_ATTR_ID])) | 466 | (!app_tb[DCB_APP_ATTR_ID])) |
466 | goto out; | 467 | return -EINVAL; |
467 | 468 | ||
468 | /* either by eth type or by socket number */ | 469 | /* either by eth type or by socket number */ |
469 | idtype = nla_get_u8(app_tb[DCB_APP_ATTR_IDTYPE]); | 470 | idtype = nla_get_u8(app_tb[DCB_APP_ATTR_IDTYPE]); |
470 | if ((idtype != DCB_APP_IDTYPE_ETHTYPE) && | 471 | if ((idtype != DCB_APP_IDTYPE_ETHTYPE) && |
471 | (idtype != DCB_APP_IDTYPE_PORTNUM)) | 472 | (idtype != DCB_APP_IDTYPE_PORTNUM)) |
472 | goto out; | 473 | return -EINVAL; |
473 | 474 | ||
474 | id = nla_get_u16(app_tb[DCB_APP_ATTR_ID]); | 475 | id = nla_get_u16(app_tb[DCB_APP_ATTR_ID]); |
475 | 476 | ||
@@ -485,7 +486,7 @@ static int dcbnl_getapp(struct net_device *netdev, struct nlmsghdr *nlh, | |||
485 | 486 | ||
486 | app_nest = nla_nest_start(skb, DCB_ATTR_APP); | 487 | app_nest = nla_nest_start(skb, DCB_ATTR_APP); |
487 | if (!app_nest) | 488 | if (!app_nest) |
488 | goto out; | 489 | return -EMSGSIZE; |
489 | 490 | ||
490 | ret = nla_put_u8(skb, DCB_APP_ATTR_IDTYPE, idtype); | 491 | ret = nla_put_u8(skb, DCB_APP_ATTR_IDTYPE, idtype); |
491 | if (ret) | 492 | if (ret) |
@@ -501,59 +502,57 @@ static int dcbnl_getapp(struct net_device *netdev, struct nlmsghdr *nlh, | |||
501 | 502 | ||
502 | nla_nest_end(skb, app_nest); | 503 | nla_nest_end(skb, app_nest); |
503 | 504 | ||
504 | goto out; | 505 | return 0; |
505 | 506 | ||
506 | out_cancel: | 507 | out_cancel: |
507 | nla_nest_cancel(skb, app_nest); | 508 | nla_nest_cancel(skb, app_nest); |
508 | out: | ||
509 | return ret; | 509 | return ret; |
510 | } | 510 | } |
511 | 511 | ||
512 | static int dcbnl_setapp(struct net_device *netdev, struct nlmsghdr *nlh, | 512 | static int dcbnl_setapp(struct net_device *netdev, struct nlmsghdr *nlh, |
513 | u32 seq, struct nlattr **tb, struct sk_buff *skb) | 513 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
514 | { | 514 | { |
515 | int err, ret = -EINVAL; | 515 | int ret; |
516 | u16 id; | 516 | u16 id; |
517 | u8 up, idtype; | 517 | u8 up, idtype; |
518 | struct nlattr *app_tb[DCB_APP_ATTR_MAX + 1]; | 518 | struct nlattr *app_tb[DCB_APP_ATTR_MAX + 1]; |
519 | 519 | ||
520 | if (!tb[DCB_ATTR_APP]) | 520 | if (!tb[DCB_ATTR_APP]) |
521 | goto out; | 521 | return -EINVAL; |
522 | 522 | ||
523 | ret = nla_parse_nested(app_tb, DCB_APP_ATTR_MAX, tb[DCB_ATTR_APP], | 523 | ret = nla_parse_nested(app_tb, DCB_APP_ATTR_MAX, tb[DCB_ATTR_APP], |
524 | dcbnl_app_nest); | 524 | dcbnl_app_nest); |
525 | if (ret) | 525 | if (ret) |
526 | goto out; | 526 | return ret; |
527 | 527 | ||
528 | ret = -EINVAL; | ||
529 | /* all must be non-null */ | 528 | /* all must be non-null */ |
530 | if ((!app_tb[DCB_APP_ATTR_IDTYPE]) || | 529 | if ((!app_tb[DCB_APP_ATTR_IDTYPE]) || |
531 | (!app_tb[DCB_APP_ATTR_ID]) || | 530 | (!app_tb[DCB_APP_ATTR_ID]) || |
532 | (!app_tb[DCB_APP_ATTR_PRIORITY])) | 531 | (!app_tb[DCB_APP_ATTR_PRIORITY])) |
533 | goto out; | 532 | return -EINVAL; |
534 | 533 | ||
535 | /* either by eth type or by socket number */ | 534 | /* either by eth type or by socket number */ |
536 | idtype = nla_get_u8(app_tb[DCB_APP_ATTR_IDTYPE]); | 535 | idtype = nla_get_u8(app_tb[DCB_APP_ATTR_IDTYPE]); |
537 | if ((idtype != DCB_APP_IDTYPE_ETHTYPE) && | 536 | if ((idtype != DCB_APP_IDTYPE_ETHTYPE) && |
538 | (idtype != DCB_APP_IDTYPE_PORTNUM)) | 537 | (idtype != DCB_APP_IDTYPE_PORTNUM)) |
539 | goto out; | 538 | return -EINVAL; |
540 | 539 | ||
541 | id = nla_get_u16(app_tb[DCB_APP_ATTR_ID]); | 540 | id = nla_get_u16(app_tb[DCB_APP_ATTR_ID]); |
542 | up = nla_get_u8(app_tb[DCB_APP_ATTR_PRIORITY]); | 541 | up = nla_get_u8(app_tb[DCB_APP_ATTR_PRIORITY]); |
543 | 542 | ||
544 | if (netdev->dcbnl_ops->setapp) { | 543 | if (netdev->dcbnl_ops->setapp) { |
545 | err = netdev->dcbnl_ops->setapp(netdev, idtype, id, up); | 544 | ret = netdev->dcbnl_ops->setapp(netdev, idtype, id, up); |
546 | } else { | 545 | } else { |
547 | struct dcb_app app; | 546 | struct dcb_app app; |
548 | app.selector = idtype; | 547 | app.selector = idtype; |
549 | app.protocol = id; | 548 | app.protocol = id; |
550 | app.priority = up; | 549 | app.priority = up; |
551 | err = dcb_setapp(netdev, &app); | 550 | ret = dcb_setapp(netdev, &app); |
552 | } | 551 | } |
553 | 552 | ||
554 | ret = nla_put_u8(skb, DCB_ATTR_APP, ret); | 553 | ret = nla_put_u8(skb, DCB_ATTR_APP, ret); |
555 | dcbnl_cee_notify(netdev, RTM_SETDCB, DCB_CMD_SAPP, seq, 0); | 554 | dcbnl_cee_notify(netdev, RTM_SETDCB, DCB_CMD_SAPP, seq, 0); |
556 | out: | 555 | |
557 | return ret; | 556 | return ret; |
558 | } | 557 | } |
559 | 558 | ||
@@ -564,26 +563,27 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
564 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; | 563 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; |
565 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; | 564 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; |
566 | u8 prio, pgid, tc_pct, up_map; | 565 | u8 prio, pgid, tc_pct, up_map; |
567 | int ret = -EINVAL; | 566 | int ret; |
568 | int getall = 0; | 567 | int getall = 0; |
569 | int i; | 568 | int i; |
570 | 569 | ||
571 | if (!tb[DCB_ATTR_PG_CFG] || | 570 | if (!tb[DCB_ATTR_PG_CFG]) |
572 | !netdev->dcbnl_ops->getpgtccfgtx || | 571 | return -EINVAL; |
572 | |||
573 | if (!netdev->dcbnl_ops->getpgtccfgtx || | ||
573 | !netdev->dcbnl_ops->getpgtccfgrx || | 574 | !netdev->dcbnl_ops->getpgtccfgrx || |
574 | !netdev->dcbnl_ops->getpgbwgcfgtx || | 575 | !netdev->dcbnl_ops->getpgbwgcfgtx || |
575 | !netdev->dcbnl_ops->getpgbwgcfgrx) | 576 | !netdev->dcbnl_ops->getpgbwgcfgrx) |
576 | return ret; | 577 | return -EOPNOTSUPP; |
577 | 578 | ||
578 | ret = nla_parse_nested(pg_tb, DCB_PG_ATTR_MAX, | 579 | ret = nla_parse_nested(pg_tb, DCB_PG_ATTR_MAX, |
579 | tb[DCB_ATTR_PG_CFG], dcbnl_pg_nest); | 580 | tb[DCB_ATTR_PG_CFG], dcbnl_pg_nest); |
580 | |||
581 | if (ret) | 581 | if (ret) |
582 | goto err_out; | 582 | return ret; |
583 | 583 | ||
584 | pg_nest = nla_nest_start(skb, DCB_ATTR_PG_CFG); | 584 | pg_nest = nla_nest_start(skb, DCB_ATTR_PG_CFG); |
585 | if (!pg_nest) | 585 | if (!pg_nest) |
586 | goto err_out; | 586 | return -EMSGSIZE; |
587 | 587 | ||
588 | if (pg_tb[DCB_PG_ATTR_TC_ALL]) | 588 | if (pg_tb[DCB_PG_ATTR_TC_ALL]) |
589 | getall = 1; | 589 | getall = 1; |
@@ -674,7 +674,6 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
674 | i - DCB_PG_ATTR_BW_ID_0, &tc_pct); | 674 | i - DCB_PG_ATTR_BW_ID_0, &tc_pct); |
675 | } | 675 | } |
676 | ret = nla_put_u8(skb, i, tc_pct); | 676 | ret = nla_put_u8(skb, i, tc_pct); |
677 | |||
678 | if (ret) | 677 | if (ret) |
679 | goto err_pg; | 678 | goto err_pg; |
680 | } | 679 | } |
@@ -687,9 +686,8 @@ err_param: | |||
687 | nla_nest_cancel(skb, param_nest); | 686 | nla_nest_cancel(skb, param_nest); |
688 | err_pg: | 687 | err_pg: |
689 | nla_nest_cancel(skb, pg_nest); | 688 | nla_nest_cancel(skb, pg_nest); |
690 | err_out: | 689 | |
691 | ret = -EINVAL; | 690 | return -EMSGSIZE; |
692 | return ret; | ||
693 | } | 691 | } |
694 | 692 | ||
695 | static int dcbnl_pgtx_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, | 693 | static int dcbnl_pgtx_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
@@ -709,9 +707,12 @@ static int dcbnl_setstate(struct net_device *netdev, struct nlmsghdr *nlh, | |||
709 | { | 707 | { |
710 | u8 value; | 708 | u8 value; |
711 | 709 | ||
712 | if (!tb[DCB_ATTR_STATE] || !netdev->dcbnl_ops->setstate) | 710 | if (!tb[DCB_ATTR_STATE]) |
713 | return -EINVAL; | 711 | return -EINVAL; |
714 | 712 | ||
713 | if (!netdev->dcbnl_ops->setstate) | ||
714 | return -EOPNOTSUPP; | ||
715 | |||
715 | value = nla_get_u8(tb[DCB_ATTR_STATE]); | 716 | value = nla_get_u8(tb[DCB_ATTR_STATE]); |
716 | 717 | ||
717 | return nla_put_u8(skb, DCB_ATTR_STATE, | 718 | return nla_put_u8(skb, DCB_ATTR_STATE, |
@@ -723,17 +724,20 @@ static int dcbnl_setpfccfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
723 | { | 724 | { |
724 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1]; | 725 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1]; |
725 | int i; | 726 | int i; |
726 | int ret = -EINVAL; | 727 | int ret; |
727 | u8 value; | 728 | u8 value; |
728 | 729 | ||
729 | if (!tb[DCB_ATTR_PFC_CFG] || !netdev->dcbnl_ops->setpfccfg) | 730 | if (!tb[DCB_ATTR_PFC_CFG]) |
730 | return ret; | 731 | return -EINVAL; |
732 | |||
733 | if (!netdev->dcbnl_ops->setpfccfg) | ||
734 | return -EOPNOTSUPP; | ||
731 | 735 | ||
732 | ret = nla_parse_nested(data, DCB_PFC_UP_ATTR_MAX, | 736 | ret = nla_parse_nested(data, DCB_PFC_UP_ATTR_MAX, |
733 | tb[DCB_ATTR_PFC_CFG], | 737 | tb[DCB_ATTR_PFC_CFG], |
734 | dcbnl_pfc_up_nest); | 738 | dcbnl_pfc_up_nest); |
735 | if (ret) | 739 | if (ret) |
736 | goto err; | 740 | return ret; |
737 | 741 | ||
738 | for (i = DCB_PFC_UP_ATTR_0; i <= DCB_PFC_UP_ATTR_7; i++) { | 742 | for (i = DCB_PFC_UP_ATTR_0; i <= DCB_PFC_UP_ATTR_7; i++) { |
739 | if (data[i] == NULL) | 743 | if (data[i] == NULL) |
@@ -744,17 +748,18 @@ static int dcbnl_setpfccfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
744 | } | 748 | } |
745 | 749 | ||
746 | return nla_put_u8(skb, DCB_ATTR_PFC_CFG, 0); | 750 | return nla_put_u8(skb, DCB_ATTR_PFC_CFG, 0); |
747 | err: | ||
748 | return ret; | ||
749 | } | 751 | } |
750 | 752 | ||
751 | static int dcbnl_setall(struct net_device *netdev, struct nlmsghdr *nlh, | 753 | static int dcbnl_setall(struct net_device *netdev, struct nlmsghdr *nlh, |
752 | u32 seq, struct nlattr **tb, struct sk_buff *skb) | 754 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
753 | { | 755 | { |
754 | int ret = -EINVAL; | 756 | int ret; |
755 | 757 | ||
756 | if (!tb[DCB_ATTR_SET_ALL] || !netdev->dcbnl_ops->setall) | 758 | if (!tb[DCB_ATTR_SET_ALL]) |
757 | return ret; | 759 | return -EINVAL; |
760 | |||
761 | if (!netdev->dcbnl_ops->setall) | ||
762 | return -EOPNOTSUPP; | ||
758 | 763 | ||
759 | ret = nla_put_u8(skb, DCB_ATTR_SET_ALL, | 764 | ret = nla_put_u8(skb, DCB_ATTR_SET_ALL, |
760 | netdev->dcbnl_ops->setall(netdev)); | 765 | netdev->dcbnl_ops->setall(netdev)); |
@@ -769,24 +774,26 @@ static int __dcbnl_pg_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
769 | { | 774 | { |
770 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; | 775 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; |
771 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; | 776 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; |
772 | int ret = -EINVAL; | 777 | int ret; |
773 | int i; | 778 | int i; |
774 | u8 pgid; | 779 | u8 pgid; |
775 | u8 up_map; | 780 | u8 up_map; |
776 | u8 prio; | 781 | u8 prio; |
777 | u8 tc_pct; | 782 | u8 tc_pct; |
778 | 783 | ||
779 | if (!tb[DCB_ATTR_PG_CFG] || | 784 | if (!tb[DCB_ATTR_PG_CFG]) |
780 | !netdev->dcbnl_ops->setpgtccfgtx || | 785 | return -EINVAL; |
786 | |||
787 | if (!netdev->dcbnl_ops->setpgtccfgtx || | ||
781 | !netdev->dcbnl_ops->setpgtccfgrx || | 788 | !netdev->dcbnl_ops->setpgtccfgrx || |
782 | !netdev->dcbnl_ops->setpgbwgcfgtx || | 789 | !netdev->dcbnl_ops->setpgbwgcfgtx || |
783 | !netdev->dcbnl_ops->setpgbwgcfgrx) | 790 | !netdev->dcbnl_ops->setpgbwgcfgrx) |
784 | return ret; | 791 | return -EOPNOTSUPP; |
785 | 792 | ||
786 | ret = nla_parse_nested(pg_tb, DCB_PG_ATTR_MAX, | 793 | ret = nla_parse_nested(pg_tb, DCB_PG_ATTR_MAX, |
787 | tb[DCB_ATTR_PG_CFG], dcbnl_pg_nest); | 794 | tb[DCB_ATTR_PG_CFG], dcbnl_pg_nest); |
788 | if (ret) | 795 | if (ret) |
789 | goto err; | 796 | return ret; |
790 | 797 | ||
791 | for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) { | 798 | for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) { |
792 | if (!pg_tb[i]) | 799 | if (!pg_tb[i]) |
@@ -795,7 +802,7 @@ static int __dcbnl_pg_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
795 | ret = nla_parse_nested(param_tb, DCB_TC_ATTR_PARAM_MAX, | 802 | ret = nla_parse_nested(param_tb, DCB_TC_ATTR_PARAM_MAX, |
796 | pg_tb[i], dcbnl_tc_param_nest); | 803 | pg_tb[i], dcbnl_tc_param_nest); |
797 | if (ret) | 804 | if (ret) |
798 | goto err; | 805 | return ret; |
799 | 806 | ||
800 | pgid = DCB_ATTR_VALUE_UNDEFINED; | 807 | pgid = DCB_ATTR_VALUE_UNDEFINED; |
801 | prio = DCB_ATTR_VALUE_UNDEFINED; | 808 | prio = DCB_ATTR_VALUE_UNDEFINED; |
@@ -848,10 +855,8 @@ static int __dcbnl_pg_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
848 | } | 855 | } |
849 | } | 856 | } |
850 | 857 | ||
851 | ret = nla_put_u8(skb, (dir ? DCB_CMD_PGRX_SCFG : DCB_CMD_PGTX_SCFG), 0); | 858 | return nla_put_u8(skb, |
852 | 859 | (dir ? DCB_CMD_PGRX_SCFG : DCB_CMD_PGTX_SCFG), 0); | |
853 | err: | ||
854 | return ret; | ||
855 | } | 860 | } |
856 | 861 | ||
857 | static int dcbnl_pgtx_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, | 862 | static int dcbnl_pgtx_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
@@ -873,23 +878,25 @@ static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
873 | struct nlattr *bcn_tb[DCB_BCN_ATTR_MAX + 1]; | 878 | struct nlattr *bcn_tb[DCB_BCN_ATTR_MAX + 1]; |
874 | u8 value_byte; | 879 | u8 value_byte; |
875 | u32 value_integer; | 880 | u32 value_integer; |
876 | int ret = -EINVAL; | 881 | int ret; |
877 | bool getall = false; | 882 | bool getall = false; |
878 | int i; | 883 | int i; |
879 | 884 | ||
880 | if (!tb[DCB_ATTR_BCN] || !netdev->dcbnl_ops->getbcnrp || | 885 | if (!tb[DCB_ATTR_BCN]) |
886 | return -EINVAL; | ||
887 | |||
888 | if (!netdev->dcbnl_ops->getbcnrp || | ||
881 | !netdev->dcbnl_ops->getbcncfg) | 889 | !netdev->dcbnl_ops->getbcncfg) |
882 | return ret; | 890 | return -EOPNOTSUPP; |
883 | 891 | ||
884 | ret = nla_parse_nested(bcn_tb, DCB_BCN_ATTR_MAX, | 892 | ret = nla_parse_nested(bcn_tb, DCB_BCN_ATTR_MAX, |
885 | tb[DCB_ATTR_BCN], dcbnl_bcn_nest); | 893 | tb[DCB_ATTR_BCN], dcbnl_bcn_nest); |
886 | |||
887 | if (ret) | 894 | if (ret) |
888 | goto err_out; | 895 | return ret; |
889 | 896 | ||
890 | bcn_nest = nla_nest_start(skb, DCB_ATTR_BCN); | 897 | bcn_nest = nla_nest_start(skb, DCB_ATTR_BCN); |
891 | if (!bcn_nest) | 898 | if (!bcn_nest) |
892 | goto err_out; | 899 | return -EMSGSIZE; |
893 | 900 | ||
894 | if (bcn_tb[DCB_BCN_ATTR_ALL]) | 901 | if (bcn_tb[DCB_BCN_ATTR_ALL]) |
895 | getall = true; | 902 | getall = true; |
@@ -922,8 +929,6 @@ static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
922 | 929 | ||
923 | err_bcn: | 930 | err_bcn: |
924 | nla_nest_cancel(skb, bcn_nest); | 931 | nla_nest_cancel(skb, bcn_nest); |
925 | err_out: | ||
926 | ret = -EINVAL; | ||
927 | return ret; | 932 | return ret; |
928 | } | 933 | } |
929 | 934 | ||
@@ -932,19 +937,22 @@ static int dcbnl_bcn_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
932 | { | 937 | { |
933 | struct nlattr *data[DCB_BCN_ATTR_MAX + 1]; | 938 | struct nlattr *data[DCB_BCN_ATTR_MAX + 1]; |
934 | int i; | 939 | int i; |
935 | int ret = -EINVAL; | 940 | int ret; |
936 | u8 value_byte; | 941 | u8 value_byte; |
937 | u32 value_int; | 942 | u32 value_int; |
938 | 943 | ||
939 | if (!tb[DCB_ATTR_BCN] || !netdev->dcbnl_ops->setbcncfg || | 944 | if (!tb[DCB_ATTR_BCN]) |
945 | return -EINVAL; | ||
946 | |||
947 | if (!netdev->dcbnl_ops->setbcncfg || | ||
940 | !netdev->dcbnl_ops->setbcnrp) | 948 | !netdev->dcbnl_ops->setbcnrp) |
941 | return ret; | 949 | return -EOPNOTSUPP; |
942 | 950 | ||
943 | ret = nla_parse_nested(data, DCB_BCN_ATTR_MAX, | 951 | ret = nla_parse_nested(data, DCB_BCN_ATTR_MAX, |
944 | tb[DCB_ATTR_BCN], | 952 | tb[DCB_ATTR_BCN], |
945 | dcbnl_pfc_up_nest); | 953 | dcbnl_pfc_up_nest); |
946 | if (ret) | 954 | if (ret) |
947 | goto err; | 955 | return ret; |
948 | 956 | ||
949 | for (i = DCB_BCN_ATTR_RP_0; i <= DCB_BCN_ATTR_RP_7; i++) { | 957 | for (i = DCB_BCN_ATTR_RP_0; i <= DCB_BCN_ATTR_RP_7; i++) { |
950 | if (data[i] == NULL) | 958 | if (data[i] == NULL) |
@@ -962,9 +970,7 @@ static int dcbnl_bcn_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, | |||
962 | i, value_int); | 970 | i, value_int); |
963 | } | 971 | } |
964 | 972 | ||
965 | ret = nla_put_u8(skb, DCB_ATTR_BCN, 0); | 973 | return nla_put_u8(skb, DCB_ATTR_BCN, 0); |
966 | err: | ||
967 | return ret; | ||
968 | } | 974 | } |
969 | 975 | ||
970 | static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb, | 976 | static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb, |
@@ -1030,20 +1036,21 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) | |||
1030 | struct dcb_app_type *itr; | 1036 | struct dcb_app_type *itr; |
1031 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; | 1037 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; |
1032 | int dcbx; | 1038 | int dcbx; |
1033 | int err = -EMSGSIZE; | 1039 | int err; |
1034 | 1040 | ||
1035 | if (nla_put_string(skb, DCB_ATTR_IFNAME, netdev->name)) | 1041 | if (nla_put_string(skb, DCB_ATTR_IFNAME, netdev->name)) |
1036 | goto nla_put_failure; | 1042 | return -EMSGSIZE; |
1043 | |||
1037 | ieee = nla_nest_start(skb, DCB_ATTR_IEEE); | 1044 | ieee = nla_nest_start(skb, DCB_ATTR_IEEE); |
1038 | if (!ieee) | 1045 | if (!ieee) |
1039 | goto nla_put_failure; | 1046 | return -EMSGSIZE; |
1040 | 1047 | ||
1041 | if (ops->ieee_getets) { | 1048 | if (ops->ieee_getets) { |
1042 | struct ieee_ets ets; | 1049 | struct ieee_ets ets; |
1043 | err = ops->ieee_getets(netdev, &ets); | 1050 | err = ops->ieee_getets(netdev, &ets); |
1044 | if (!err && | 1051 | if (!err && |
1045 | nla_put(skb, DCB_ATTR_IEEE_ETS, sizeof(ets), &ets)) | 1052 | nla_put(skb, DCB_ATTR_IEEE_ETS, sizeof(ets), &ets)) |
1046 | goto nla_put_failure; | 1053 | return -EMSGSIZE; |
1047 | } | 1054 | } |
1048 | 1055 | ||
1049 | if (ops->ieee_getmaxrate) { | 1056 | if (ops->ieee_getmaxrate) { |
@@ -1053,7 +1060,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) | |||
1053 | err = nla_put(skb, DCB_ATTR_IEEE_MAXRATE, | 1060 | err = nla_put(skb, DCB_ATTR_IEEE_MAXRATE, |
1054 | sizeof(maxrate), &maxrate); | 1061 | sizeof(maxrate), &maxrate); |
1055 | if (err) | 1062 | if (err) |
1056 | goto nla_put_failure; | 1063 | return -EMSGSIZE; |
1057 | } | 1064 | } |
1058 | } | 1065 | } |
1059 | 1066 | ||
@@ -1062,12 +1069,12 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) | |||
1062 | err = ops->ieee_getpfc(netdev, &pfc); | 1069 | err = ops->ieee_getpfc(netdev, &pfc); |
1063 | if (!err && | 1070 | if (!err && |
1064 | nla_put(skb, DCB_ATTR_IEEE_PFC, sizeof(pfc), &pfc)) | 1071 | nla_put(skb, DCB_ATTR_IEEE_PFC, sizeof(pfc), &pfc)) |
1065 | goto nla_put_failure; | 1072 | return -EMSGSIZE; |
1066 | } | 1073 | } |
1067 | 1074 | ||
1068 | app = nla_nest_start(skb, DCB_ATTR_IEEE_APP_TABLE); | 1075 | app = nla_nest_start(skb, DCB_ATTR_IEEE_APP_TABLE); |
1069 | if (!app) | 1076 | if (!app) |
1070 | goto nla_put_failure; | 1077 | return -EMSGSIZE; |
1071 | 1078 | ||
1072 | spin_lock(&dcb_lock); | 1079 | spin_lock(&dcb_lock); |
1073 | list_for_each_entry(itr, &dcb_app_list, list) { | 1080 | list_for_each_entry(itr, &dcb_app_list, list) { |
@@ -1076,7 +1083,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) | |||
1076 | &itr->app); | 1083 | &itr->app); |
1077 | if (err) { | 1084 | if (err) { |
1078 | spin_unlock(&dcb_lock); | 1085 | spin_unlock(&dcb_lock); |
1079 | goto nla_put_failure; | 1086 | return -EMSGSIZE; |
1080 | } | 1087 | } |
1081 | } | 1088 | } |
1082 | } | 1089 | } |
@@ -1095,7 +1102,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) | |||
1095 | err = ops->ieee_peer_getets(netdev, &ets); | 1102 | err = ops->ieee_peer_getets(netdev, &ets); |
1096 | if (!err && | 1103 | if (!err && |
1097 | nla_put(skb, DCB_ATTR_IEEE_PEER_ETS, sizeof(ets), &ets)) | 1104 | nla_put(skb, DCB_ATTR_IEEE_PEER_ETS, sizeof(ets), &ets)) |
1098 | goto nla_put_failure; | 1105 | return -EMSGSIZE; |
1099 | } | 1106 | } |
1100 | 1107 | ||
1101 | if (ops->ieee_peer_getpfc) { | 1108 | if (ops->ieee_peer_getpfc) { |
@@ -1103,7 +1110,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) | |||
1103 | err = ops->ieee_peer_getpfc(netdev, &pfc); | 1110 | err = ops->ieee_peer_getpfc(netdev, &pfc); |
1104 | if (!err && | 1111 | if (!err && |
1105 | nla_put(skb, DCB_ATTR_IEEE_PEER_PFC, sizeof(pfc), &pfc)) | 1112 | nla_put(skb, DCB_ATTR_IEEE_PEER_PFC, sizeof(pfc), &pfc)) |
1106 | goto nla_put_failure; | 1113 | return -EMSGSIZE; |
1107 | } | 1114 | } |
1108 | 1115 | ||
1109 | if (ops->peer_getappinfo && ops->peer_getapptable) { | 1116 | if (ops->peer_getappinfo && ops->peer_getapptable) { |
@@ -1112,20 +1119,17 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) | |||
1112 | DCB_ATTR_IEEE_APP_UNSPEC, | 1119 | DCB_ATTR_IEEE_APP_UNSPEC, |
1113 | DCB_ATTR_IEEE_APP); | 1120 | DCB_ATTR_IEEE_APP); |
1114 | if (err) | 1121 | if (err) |
1115 | goto nla_put_failure; | 1122 | return -EMSGSIZE; |
1116 | } | 1123 | } |
1117 | 1124 | ||
1118 | nla_nest_end(skb, ieee); | 1125 | nla_nest_end(skb, ieee); |
1119 | if (dcbx >= 0) { | 1126 | if (dcbx >= 0) { |
1120 | err = nla_put_u8(skb, DCB_ATTR_DCBX, dcbx); | 1127 | err = nla_put_u8(skb, DCB_ATTR_DCBX, dcbx); |
1121 | if (err) | 1128 | if (err) |
1122 | goto nla_put_failure; | 1129 | return -EMSGSIZE; |
1123 | } | 1130 | } |
1124 | 1131 | ||
1125 | return 0; | 1132 | return 0; |
1126 | |||
1127 | nla_put_failure: | ||
1128 | return err; | ||
1129 | } | 1133 | } |
1130 | 1134 | ||
1131 | static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev, | 1135 | static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev, |
@@ -1137,13 +1141,13 @@ static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev, | |||
1137 | struct nlattr *pg = nla_nest_start(skb, i); | 1141 | struct nlattr *pg = nla_nest_start(skb, i); |
1138 | 1142 | ||
1139 | if (!pg) | 1143 | if (!pg) |
1140 | goto nla_put_failure; | 1144 | return -EMSGSIZE; |
1141 | 1145 | ||
1142 | for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) { | 1146 | for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) { |
1143 | struct nlattr *tc_nest = nla_nest_start(skb, i); | 1147 | struct nlattr *tc_nest = nla_nest_start(skb, i); |
1144 | 1148 | ||
1145 | if (!tc_nest) | 1149 | if (!tc_nest) |
1146 | goto nla_put_failure; | 1150 | return -EMSGSIZE; |
1147 | 1151 | ||
1148 | pgid = DCB_ATTR_VALUE_UNDEFINED; | 1152 | pgid = DCB_ATTR_VALUE_UNDEFINED; |
1149 | prio = DCB_ATTR_VALUE_UNDEFINED; | 1153 | prio = DCB_ATTR_VALUE_UNDEFINED; |
@@ -1161,7 +1165,7 @@ static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev, | |||
1161 | nla_put_u8(skb, DCB_TC_ATTR_PARAM_UP_MAPPING, up_map) || | 1165 | nla_put_u8(skb, DCB_TC_ATTR_PARAM_UP_MAPPING, up_map) || |
1162 | nla_put_u8(skb, DCB_TC_ATTR_PARAM_STRICT_PRIO, prio) || | 1166 | nla_put_u8(skb, DCB_TC_ATTR_PARAM_STRICT_PRIO, prio) || |
1163 | nla_put_u8(skb, DCB_TC_ATTR_PARAM_BW_PCT, tc_pct)) | 1167 | nla_put_u8(skb, DCB_TC_ATTR_PARAM_BW_PCT, tc_pct)) |
1164 | goto nla_put_failure; | 1168 | return -EMSGSIZE; |
1165 | nla_nest_end(skb, tc_nest); | 1169 | nla_nest_end(skb, tc_nest); |
1166 | } | 1170 | } |
1167 | 1171 | ||
@@ -1175,13 +1179,10 @@ static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev, | |||
1175 | ops->getpgbwgcfgtx(dev, i - DCB_PG_ATTR_BW_ID_0, | 1179 | ops->getpgbwgcfgtx(dev, i - DCB_PG_ATTR_BW_ID_0, |
1176 | &tc_pct); | 1180 | &tc_pct); |
1177 | if (nla_put_u8(skb, i, tc_pct)) | 1181 | if (nla_put_u8(skb, i, tc_pct)) |
1178 | goto nla_put_failure; | 1182 | return -EMSGSIZE; |
1179 | } | 1183 | } |
1180 | nla_nest_end(skb, pg); | 1184 | nla_nest_end(skb, pg); |
1181 | return 0; | 1185 | return 0; |
1182 | |||
1183 | nla_put_failure: | ||
1184 | return -EMSGSIZE; | ||
1185 | } | 1186 | } |
1186 | 1187 | ||
1187 | static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev) | 1188 | static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev) |
@@ -1380,10 +1381,10 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlmsghdr *nlh, | |||
1380 | { | 1381 | { |
1381 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; | 1382 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; |
1382 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; | 1383 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; |
1383 | int err = -EOPNOTSUPP; | 1384 | int err; |
1384 | 1385 | ||
1385 | if (!ops) | 1386 | if (!ops) |
1386 | return err; | 1387 | return -EOPNOTSUPP; |
1387 | 1388 | ||
1388 | if (!tb[DCB_ATTR_IEEE]) | 1389 | if (!tb[DCB_ATTR_IEEE]) |
1389 | return -EINVAL; | 1390 | return -EINVAL; |
@@ -1455,7 +1456,7 @@ static int dcbnl_ieee_del(struct net_device *netdev, struct nlmsghdr *nlh, | |||
1455 | { | 1456 | { |
1456 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; | 1457 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; |
1457 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; | 1458 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; |
1458 | int err = -EOPNOTSUPP; | 1459 | int err; |
1459 | 1460 | ||
1460 | if (!ops) | 1461 | if (!ops) |
1461 | return -EOPNOTSUPP; | 1462 | return -EOPNOTSUPP; |
@@ -1687,10 +1688,12 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
1687 | 1688 | ||
1688 | netdev = dev_get_by_name(&init_net, nla_data(tb[DCB_ATTR_IFNAME])); | 1689 | netdev = dev_get_by_name(&init_net, nla_data(tb[DCB_ATTR_IFNAME])); |
1689 | if (!netdev) | 1690 | if (!netdev) |
1690 | return -EINVAL; | 1691 | return -ENODEV; |
1691 | 1692 | ||
1692 | if (!netdev->dcbnl_ops) | 1693 | if (!netdev->dcbnl_ops) { |
1693 | goto errout; | 1694 | ret = -EOPNOTSUPP; |
1695 | goto out; | ||
1696 | } | ||
1694 | 1697 | ||
1695 | reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, pid, nlh->nlmsg_seq, | 1698 | reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, pid, nlh->nlmsg_seq, |
1696 | nlh->nlmsg_flags, &reply_nlh); | 1699 | nlh->nlmsg_flags, &reply_nlh); |