diff options
author | Thomas Graf <tgraf@suug.ch> | 2012-06-12 22:54:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-13 18:46:34 -0400 |
commit | 7be994138b188387691322921c08e19bddf6d3c5 (patch) | |
tree | 8feb79621dd688e80573a8b5ebc3703e613086af /net/dcb | |
parent | 33a03aadb52fa05d28aba6d8f0c03c7b3b905897 (diff) |
dcbnl: Shorten all command handling functions
Allocating and sending the skb in dcb_doit() allows for much
shorter and cleaner command handling functions.
The huge switch statement is replaced with an array based definition
of the handling function and reply message type.
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 | 722 |
1 files changed, 172 insertions, 550 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 5520e431b072..5e392b85d48d 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c | |||
@@ -261,27 +261,20 @@ err: | |||
261 | return ret; | 261 | return ret; |
262 | } | 262 | } |
263 | 263 | ||
264 | static int dcbnl_getstate(struct net_device *netdev, struct nlattr **tb, | 264 | static int dcbnl_getstate(struct net_device *netdev, struct nlmsghdr *nlh, |
265 | u32 pid, u32 seq, u16 flags) | 265 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
266 | { | 266 | { |
267 | int ret = -EINVAL; | ||
268 | |||
269 | /* if (!tb[DCB_ATTR_STATE] || !netdev->dcbnl_ops->getstate) */ | 267 | /* if (!tb[DCB_ATTR_STATE] || !netdev->dcbnl_ops->getstate) */ |
270 | if (!netdev->dcbnl_ops->getstate) | 268 | if (!netdev->dcbnl_ops->getstate) |
271 | return ret; | 269 | return -EINVAL; |
272 | |||
273 | ret = dcbnl_reply(netdev->dcbnl_ops->getstate(netdev), RTM_GETDCB, | ||
274 | DCB_CMD_GSTATE, DCB_ATTR_STATE, pid, seq, flags); | ||
275 | 270 | ||
276 | return ret; | 271 | return nla_put_u8(skb, DCB_ATTR_STATE, |
272 | netdev->dcbnl_ops->getstate(netdev)); | ||
277 | } | 273 | } |
278 | 274 | ||
279 | static int dcbnl_getpfccfg(struct net_device *netdev, struct nlattr **tb, | 275 | static int dcbnl_getpfccfg(struct net_device *netdev, struct nlmsghdr *nlh, |
280 | u32 pid, u32 seq, u16 flags) | 276 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
281 | { | 277 | { |
282 | struct sk_buff *dcbnl_skb; | ||
283 | struct nlmsghdr *nlh; | ||
284 | struct dcbmsg *dcb; | ||
285 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1], *nest; | 278 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1], *nest; |
286 | u8 value; | 279 | u8 value; |
287 | int ret = -EINVAL; | 280 | int ret = -EINVAL; |
@@ -295,19 +288,9 @@ static int dcbnl_getpfccfg(struct net_device *netdev, struct nlattr **tb, | |||
295 | tb[DCB_ATTR_PFC_CFG], | 288 | tb[DCB_ATTR_PFC_CFG], |
296 | dcbnl_pfc_up_nest); | 289 | dcbnl_pfc_up_nest); |
297 | if (ret) | 290 | if (ret) |
298 | goto err_out; | 291 | goto err; |
299 | |||
300 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
301 | if (!dcbnl_skb) | ||
302 | goto err_out; | ||
303 | |||
304 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
305 | |||
306 | dcb = NLMSG_DATA(nlh); | ||
307 | dcb->dcb_family = AF_UNSPEC; | ||
308 | dcb->cmd = DCB_CMD_PFC_GCFG; | ||
309 | 292 | ||
310 | nest = nla_nest_start(dcbnl_skb, DCB_ATTR_PFC_CFG); | 293 | nest = nla_nest_start(skb, DCB_ATTR_PFC_CFG); |
311 | if (!nest) | 294 | if (!nest) |
312 | goto err; | 295 | goto err; |
313 | 296 | ||
@@ -320,76 +303,35 @@ static int dcbnl_getpfccfg(struct net_device *netdev, struct nlattr **tb, | |||
320 | 303 | ||
321 | netdev->dcbnl_ops->getpfccfg(netdev, i - DCB_PFC_UP_ATTR_0, | 304 | netdev->dcbnl_ops->getpfccfg(netdev, i - DCB_PFC_UP_ATTR_0, |
322 | &value); | 305 | &value); |
323 | ret = nla_put_u8(dcbnl_skb, i, value); | 306 | ret = nla_put_u8(skb, i, value); |
324 | |||
325 | if (ret) { | 307 | if (ret) { |
326 | nla_nest_cancel(dcbnl_skb, nest); | 308 | nla_nest_cancel(skb, nest); |
327 | goto err; | 309 | goto err; |
328 | } | 310 | } |
329 | } | 311 | } |
330 | nla_nest_end(dcbnl_skb, nest); | 312 | nla_nest_end(skb, nest); |
331 | |||
332 | nlmsg_end(dcbnl_skb, nlh); | ||
333 | |||
334 | ret = rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
335 | if (ret) | ||
336 | goto err_out; | ||
337 | 313 | ||
338 | return 0; | 314 | return 0; |
339 | nlmsg_failure: | ||
340 | err: | 315 | err: |
341 | kfree_skb(dcbnl_skb); | ||
342 | err_out: | ||
343 | return -EINVAL; | 316 | return -EINVAL; |
344 | } | 317 | } |
345 | 318 | ||
346 | static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlattr **tb, | 319 | static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlmsghdr *nlh, |
347 | u32 pid, u32 seq, u16 flags) | 320 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
348 | { | 321 | { |
349 | struct sk_buff *dcbnl_skb; | ||
350 | struct nlmsghdr *nlh; | ||
351 | struct dcbmsg *dcb; | ||
352 | u8 perm_addr[MAX_ADDR_LEN]; | 322 | u8 perm_addr[MAX_ADDR_LEN]; |
353 | int ret = -EINVAL; | ||
354 | 323 | ||
355 | if (!netdev->dcbnl_ops->getpermhwaddr) | 324 | if (!netdev->dcbnl_ops->getpermhwaddr) |
356 | return ret; | 325 | return -EINVAL; |
357 | |||
358 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
359 | if (!dcbnl_skb) | ||
360 | goto err_out; | ||
361 | |||
362 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
363 | |||
364 | dcb = NLMSG_DATA(nlh); | ||
365 | dcb->dcb_family = AF_UNSPEC; | ||
366 | dcb->cmd = DCB_CMD_GPERM_HWADDR; | ||
367 | 326 | ||
368 | netdev->dcbnl_ops->getpermhwaddr(netdev, perm_addr); | 327 | netdev->dcbnl_ops->getpermhwaddr(netdev, perm_addr); |
369 | 328 | ||
370 | ret = nla_put(dcbnl_skb, DCB_ATTR_PERM_HWADDR, sizeof(perm_addr), | 329 | return nla_put(skb, DCB_ATTR_PERM_HWADDR, sizeof(perm_addr), perm_addr); |
371 | perm_addr); | ||
372 | |||
373 | nlmsg_end(dcbnl_skb, nlh); | ||
374 | |||
375 | ret = rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
376 | if (ret) | ||
377 | goto err_out; | ||
378 | |||
379 | return 0; | ||
380 | |||
381 | nlmsg_failure: | ||
382 | kfree_skb(dcbnl_skb); | ||
383 | err_out: | ||
384 | return -EINVAL; | ||
385 | } | 330 | } |
386 | 331 | ||
387 | static int dcbnl_getcap(struct net_device *netdev, struct nlattr **tb, | 332 | static int dcbnl_getcap(struct net_device *netdev, struct nlmsghdr *nlh, |
388 | u32 pid, u32 seq, u16 flags) | 333 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
389 | { | 334 | { |
390 | struct sk_buff *dcbnl_skb; | ||
391 | struct nlmsghdr *nlh; | ||
392 | struct dcbmsg *dcb; | ||
393 | struct nlattr *data[DCB_CAP_ATTR_MAX + 1], *nest; | 335 | struct nlattr *data[DCB_CAP_ATTR_MAX + 1], *nest; |
394 | u8 value; | 336 | u8 value; |
395 | int ret = -EINVAL; | 337 | int ret = -EINVAL; |
@@ -404,19 +346,9 @@ static int dcbnl_getcap(struct net_device *netdev, struct nlattr **tb, | |||
404 | if (ret) | 346 | if (ret) |
405 | goto err_out; | 347 | goto err_out; |
406 | 348 | ||
407 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 349 | nest = nla_nest_start(skb, DCB_ATTR_CAP); |
408 | if (!dcbnl_skb) | ||
409 | goto err_out; | ||
410 | |||
411 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
412 | |||
413 | dcb = NLMSG_DATA(nlh); | ||
414 | dcb->dcb_family = AF_UNSPEC; | ||
415 | dcb->cmd = DCB_CMD_GCAP; | ||
416 | |||
417 | nest = nla_nest_start(dcbnl_skb, DCB_ATTR_CAP); | ||
418 | if (!nest) | 350 | if (!nest) |
419 | goto err; | 351 | goto err_out; |
420 | 352 | ||
421 | if (data[DCB_CAP_ATTR_ALL]) | 353 | if (data[DCB_CAP_ATTR_ALL]) |
422 | getall = 1; | 354 | getall = 1; |
@@ -426,36 +358,23 @@ static int dcbnl_getcap(struct net_device *netdev, struct nlattr **tb, | |||
426 | continue; | 358 | continue; |
427 | 359 | ||
428 | if (!netdev->dcbnl_ops->getcap(netdev, i, &value)) { | 360 | if (!netdev->dcbnl_ops->getcap(netdev, i, &value)) { |
429 | ret = nla_put_u8(dcbnl_skb, i, value); | 361 | ret = nla_put_u8(skb, i, value); |
430 | |||
431 | if (ret) { | 362 | if (ret) { |
432 | nla_nest_cancel(dcbnl_skb, nest); | 363 | nla_nest_cancel(skb, nest); |
433 | goto err; | 364 | goto err_out; |
434 | } | 365 | } |
435 | } | 366 | } |
436 | } | 367 | } |
437 | nla_nest_end(dcbnl_skb, nest); | 368 | nla_nest_end(skb, nest); |
438 | |||
439 | nlmsg_end(dcbnl_skb, nlh); | ||
440 | |||
441 | ret = rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
442 | if (ret) | ||
443 | goto err_out; | ||
444 | 369 | ||
445 | return 0; | 370 | return 0; |
446 | nlmsg_failure: | ||
447 | err: | ||
448 | kfree_skb(dcbnl_skb); | ||
449 | err_out: | 371 | err_out: |
450 | return -EINVAL; | 372 | return -EINVAL; |
451 | } | 373 | } |
452 | 374 | ||
453 | static int dcbnl_getnumtcs(struct net_device *netdev, struct nlattr **tb, | 375 | static int dcbnl_getnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, |
454 | u32 pid, u32 seq, u16 flags) | 376 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
455 | { | 377 | { |
456 | struct sk_buff *dcbnl_skb; | ||
457 | struct nlmsghdr *nlh; | ||
458 | struct dcbmsg *dcb; | ||
459 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1], *nest; | 378 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1], *nest; |
460 | u8 value; | 379 | u8 value; |
461 | int ret = -EINVAL; | 380 | int ret = -EINVAL; |
@@ -472,22 +391,10 @@ static int dcbnl_getnumtcs(struct net_device *netdev, struct nlattr **tb, | |||
472 | goto err_out; | 391 | goto err_out; |
473 | } | 392 | } |
474 | 393 | ||
475 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 394 | nest = nla_nest_start(skb, DCB_ATTR_NUMTCS); |
476 | if (!dcbnl_skb) { | ||
477 | ret = -EINVAL; | ||
478 | goto err_out; | ||
479 | } | ||
480 | |||
481 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
482 | |||
483 | dcb = NLMSG_DATA(nlh); | ||
484 | dcb->dcb_family = AF_UNSPEC; | ||
485 | dcb->cmd = DCB_CMD_GNUMTCS; | ||
486 | |||
487 | nest = nla_nest_start(dcbnl_skb, DCB_ATTR_NUMTCS); | ||
488 | if (!nest) { | 395 | if (!nest) { |
489 | ret = -EINVAL; | 396 | ret = -EINVAL; |
490 | goto err; | 397 | goto err_out; |
491 | } | 398 | } |
492 | 399 | ||
493 | if (data[DCB_NUMTCS_ATTR_ALL]) | 400 | if (data[DCB_NUMTCS_ATTR_ALL]) |
@@ -499,37 +406,25 @@ static int dcbnl_getnumtcs(struct net_device *netdev, struct nlattr **tb, | |||
499 | 406 | ||
500 | ret = netdev->dcbnl_ops->getnumtcs(netdev, i, &value); | 407 | ret = netdev->dcbnl_ops->getnumtcs(netdev, i, &value); |
501 | if (!ret) { | 408 | if (!ret) { |
502 | ret = nla_put_u8(dcbnl_skb, i, value); | 409 | ret = nla_put_u8(skb, i, value); |
503 | |||
504 | if (ret) { | 410 | if (ret) { |
505 | nla_nest_cancel(dcbnl_skb, nest); | 411 | nla_nest_cancel(skb, nest); |
506 | ret = -EINVAL; | 412 | ret = -EINVAL; |
507 | goto err; | 413 | goto err_out; |
508 | } | 414 | } |
509 | } else { | 415 | } else { |
510 | goto err; | 416 | goto err_out; |
511 | } | 417 | } |
512 | } | 418 | } |
513 | nla_nest_end(dcbnl_skb, nest); | 419 | nla_nest_end(skb, nest); |
514 | |||
515 | nlmsg_end(dcbnl_skb, nlh); | ||
516 | |||
517 | ret = rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
518 | if (ret) { | ||
519 | ret = -EINVAL; | ||
520 | goto err_out; | ||
521 | } | ||
522 | 420 | ||
523 | return 0; | 421 | return 0; |
524 | nlmsg_failure: | ||
525 | err: | ||
526 | kfree_skb(dcbnl_skb); | ||
527 | err_out: | 422 | err_out: |
528 | return ret; | 423 | return ret; |
529 | } | 424 | } |
530 | 425 | ||
531 | static int dcbnl_setnumtcs(struct net_device *netdev, struct nlattr **tb, | 426 | static int dcbnl_setnumtcs(struct net_device *netdev, struct nlmsghdr *nlh, |
532 | u32 pid, u32 seq, u16 flags) | 427 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
533 | { | 428 | { |
534 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1]; | 429 | struct nlattr *data[DCB_NUMTCS_ATTR_MAX + 1]; |
535 | int ret = -EINVAL; | 430 | int ret = -EINVAL; |
@@ -542,10 +437,8 @@ static int dcbnl_setnumtcs(struct net_device *netdev, struct nlattr **tb, | |||
542 | ret = nla_parse_nested(data, DCB_NUMTCS_ATTR_MAX, tb[DCB_ATTR_NUMTCS], | 437 | ret = nla_parse_nested(data, DCB_NUMTCS_ATTR_MAX, tb[DCB_ATTR_NUMTCS], |
543 | dcbnl_numtcs_nest); | 438 | dcbnl_numtcs_nest); |
544 | 439 | ||
545 | if (ret) { | 440 | if (ret) |
546 | ret = -EINVAL; | 441 | return -EINVAL; |
547 | goto err; | ||
548 | } | ||
549 | 442 | ||
550 | for (i = DCB_NUMTCS_ATTR_ALL+1; i <= DCB_NUMTCS_ATTR_MAX; i++) { | 443 | for (i = DCB_NUMTCS_ATTR_ALL+1; i <= DCB_NUMTCS_ATTR_MAX; i++) { |
551 | if (data[i] == NULL) | 444 | if (data[i] == NULL) |
@@ -554,59 +447,41 @@ static int dcbnl_setnumtcs(struct net_device *netdev, struct nlattr **tb, | |||
554 | value = nla_get_u8(data[i]); | 447 | value = nla_get_u8(data[i]); |
555 | 448 | ||
556 | ret = netdev->dcbnl_ops->setnumtcs(netdev, i, value); | 449 | ret = netdev->dcbnl_ops->setnumtcs(netdev, i, value); |
557 | |||
558 | if (ret) | 450 | if (ret) |
559 | goto operr; | 451 | break; |
560 | } | 452 | } |
561 | 453 | ||
562 | operr: | 454 | return nla_put_u8(skb, DCB_ATTR_NUMTCS, !!ret); |
563 | ret = dcbnl_reply(!!ret, RTM_SETDCB, DCB_CMD_SNUMTCS, | ||
564 | DCB_ATTR_NUMTCS, pid, seq, flags); | ||
565 | |||
566 | err: | ||
567 | return ret; | ||
568 | } | 455 | } |
569 | 456 | ||
570 | static int dcbnl_getpfcstate(struct net_device *netdev, struct nlattr **tb, | 457 | static int dcbnl_getpfcstate(struct net_device *netdev, struct nlmsghdr *nlh, |
571 | u32 pid, u32 seq, u16 flags) | 458 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
572 | { | 459 | { |
573 | int ret = -EINVAL; | ||
574 | |||
575 | if (!netdev->dcbnl_ops->getpfcstate) | 460 | if (!netdev->dcbnl_ops->getpfcstate) |
576 | return ret; | 461 | return -EINVAL; |
577 | |||
578 | ret = dcbnl_reply(netdev->dcbnl_ops->getpfcstate(netdev), RTM_GETDCB, | ||
579 | DCB_CMD_PFC_GSTATE, DCB_ATTR_PFC_STATE, | ||
580 | pid, seq, flags); | ||
581 | 462 | ||
582 | return ret; | 463 | return nla_put_u8(skb, DCB_ATTR_PFC_STATE, |
464 | netdev->dcbnl_ops->getpfcstate(netdev)); | ||
583 | } | 465 | } |
584 | 466 | ||
585 | static int dcbnl_setpfcstate(struct net_device *netdev, struct nlattr **tb, | 467 | static int dcbnl_setpfcstate(struct net_device *netdev, struct nlmsghdr *nlh, |
586 | u32 pid, u32 seq, u16 flags) | 468 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
587 | { | 469 | { |
588 | int ret = -EINVAL; | ||
589 | u8 value; | 470 | u8 value; |
590 | 471 | ||
591 | if (!tb[DCB_ATTR_PFC_STATE] || !netdev->dcbnl_ops->setpfcstate) | 472 | if (!tb[DCB_ATTR_PFC_STATE] || !netdev->dcbnl_ops->setpfcstate) |
592 | return ret; | 473 | return -EINVAL; |
593 | 474 | ||
594 | value = nla_get_u8(tb[DCB_ATTR_PFC_STATE]); | 475 | value = nla_get_u8(tb[DCB_ATTR_PFC_STATE]); |
595 | 476 | ||
596 | netdev->dcbnl_ops->setpfcstate(netdev, value); | 477 | netdev->dcbnl_ops->setpfcstate(netdev, value); |
597 | 478 | ||
598 | ret = dcbnl_reply(0, RTM_SETDCB, DCB_CMD_PFC_SSTATE, DCB_ATTR_PFC_STATE, | 479 | return nla_put_u8(skb, DCB_ATTR_PFC_STATE, 0); |
599 | pid, seq, flags); | ||
600 | |||
601 | return ret; | ||
602 | } | 480 | } |
603 | 481 | ||
604 | static int dcbnl_getapp(struct net_device *netdev, struct nlattr **tb, | 482 | static int dcbnl_getapp(struct net_device *netdev, struct nlmsghdr *nlh, |
605 | u32 pid, u32 seq, u16 flags) | 483 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
606 | { | 484 | { |
607 | struct sk_buff *dcbnl_skb; | ||
608 | struct nlmsghdr *nlh; | ||
609 | struct dcbmsg *dcb; | ||
610 | struct nlattr *app_nest; | 485 | struct nlattr *app_nest; |
611 | struct nlattr *app_tb[DCB_APP_ATTR_MAX + 1]; | 486 | struct nlattr *app_tb[DCB_APP_ATTR_MAX + 1]; |
612 | u16 id; | 487 | u16 id; |
@@ -645,51 +520,34 @@ static int dcbnl_getapp(struct net_device *netdev, struct nlattr **tb, | |||
645 | up = dcb_getapp(netdev, &app); | 520 | up = dcb_getapp(netdev, &app); |
646 | } | 521 | } |
647 | 522 | ||
648 | /* send this back */ | 523 | app_nest = nla_nest_start(skb, DCB_ATTR_APP); |
649 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
650 | if (!dcbnl_skb) | ||
651 | goto out; | ||
652 | |||
653 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
654 | dcb = NLMSG_DATA(nlh); | ||
655 | dcb->dcb_family = AF_UNSPEC; | ||
656 | dcb->cmd = DCB_CMD_GAPP; | ||
657 | |||
658 | app_nest = nla_nest_start(dcbnl_skb, DCB_ATTR_APP); | ||
659 | if (!app_nest) | 524 | if (!app_nest) |
660 | goto out_cancel; | 525 | goto out; |
661 | 526 | ||
662 | ret = nla_put_u8(dcbnl_skb, DCB_APP_ATTR_IDTYPE, idtype); | 527 | ret = nla_put_u8(skb, DCB_APP_ATTR_IDTYPE, idtype); |
663 | if (ret) | 528 | if (ret) |
664 | goto out_cancel; | 529 | goto out_cancel; |
665 | 530 | ||
666 | ret = nla_put_u16(dcbnl_skb, DCB_APP_ATTR_ID, id); | 531 | ret = nla_put_u16(skb, DCB_APP_ATTR_ID, id); |
667 | if (ret) | 532 | if (ret) |
668 | goto out_cancel; | 533 | goto out_cancel; |
669 | 534 | ||
670 | ret = nla_put_u8(dcbnl_skb, DCB_APP_ATTR_PRIORITY, up); | 535 | ret = nla_put_u8(skb, DCB_APP_ATTR_PRIORITY, up); |
671 | if (ret) | 536 | if (ret) |
672 | goto out_cancel; | 537 | goto out_cancel; |
673 | 538 | ||
674 | nla_nest_end(dcbnl_skb, app_nest); | 539 | nla_nest_end(skb, app_nest); |
675 | nlmsg_end(dcbnl_skb, nlh); | ||
676 | |||
677 | ret = rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
678 | if (ret) | ||
679 | goto nlmsg_failure; | ||
680 | 540 | ||
681 | goto out; | 541 | goto out; |
682 | 542 | ||
683 | out_cancel: | 543 | out_cancel: |
684 | nla_nest_cancel(dcbnl_skb, app_nest); | 544 | nla_nest_cancel(skb, app_nest); |
685 | nlmsg_failure: | ||
686 | kfree_skb(dcbnl_skb); | ||
687 | out: | 545 | out: |
688 | return ret; | 546 | return ret; |
689 | } | 547 | } |
690 | 548 | ||
691 | static int dcbnl_setapp(struct net_device *netdev, struct nlattr **tb, | 549 | static int dcbnl_setapp(struct net_device *netdev, struct nlmsghdr *nlh, |
692 | u32 pid, u32 seq, u16 flags) | 550 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
693 | { | 551 | { |
694 | int err, ret = -EINVAL; | 552 | int err, ret = -EINVAL; |
695 | u16 id; | 553 | u16 id; |
@@ -730,19 +588,15 @@ static int dcbnl_setapp(struct net_device *netdev, struct nlattr **tb, | |||
730 | err = dcb_setapp(netdev, &app); | 588 | err = dcb_setapp(netdev, &app); |
731 | } | 589 | } |
732 | 590 | ||
733 | ret = dcbnl_reply(err, RTM_SETDCB, DCB_CMD_SAPP, DCB_ATTR_APP, | 591 | ret = nla_put_u8(skb, DCB_ATTR_APP, ret); |
734 | pid, seq, flags); | ||
735 | dcbnl_cee_notify(netdev, RTM_SETDCB, DCB_CMD_SAPP, seq, 0); | 592 | dcbnl_cee_notify(netdev, RTM_SETDCB, DCB_CMD_SAPP, seq, 0); |
736 | out: | 593 | out: |
737 | return ret; | 594 | return ret; |
738 | } | 595 | } |
739 | 596 | ||
740 | static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlattr **tb, | 597 | static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
741 | u32 pid, u32 seq, u16 flags, int dir) | 598 | struct nlattr **tb, struct sk_buff *skb, int dir) |
742 | { | 599 | { |
743 | struct sk_buff *dcbnl_skb; | ||
744 | struct nlmsghdr *nlh; | ||
745 | struct dcbmsg *dcb; | ||
746 | struct nlattr *pg_nest, *param_nest, *data; | 600 | struct nlattr *pg_nest, *param_nest, *data; |
747 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; | 601 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; |
748 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; | 602 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; |
@@ -764,19 +618,9 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlattr **tb, | |||
764 | if (ret) | 618 | if (ret) |
765 | goto err_out; | 619 | goto err_out; |
766 | 620 | ||
767 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 621 | pg_nest = nla_nest_start(skb, DCB_ATTR_PG_CFG); |
768 | if (!dcbnl_skb) | ||
769 | goto err_out; | ||
770 | |||
771 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
772 | |||
773 | dcb = NLMSG_DATA(nlh); | ||
774 | dcb->dcb_family = AF_UNSPEC; | ||
775 | dcb->cmd = (dir) ? DCB_CMD_PGRX_GCFG : DCB_CMD_PGTX_GCFG; | ||
776 | |||
777 | pg_nest = nla_nest_start(dcbnl_skb, DCB_ATTR_PG_CFG); | ||
778 | if (!pg_nest) | 622 | if (!pg_nest) |
779 | goto err; | 623 | goto err_out; |
780 | 624 | ||
781 | if (pg_tb[DCB_PG_ATTR_TC_ALL]) | 625 | if (pg_tb[DCB_PG_ATTR_TC_ALL]) |
782 | getall = 1; | 626 | getall = 1; |
@@ -794,7 +638,7 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlattr **tb, | |||
794 | if (ret) | 638 | if (ret) |
795 | goto err_pg; | 639 | goto err_pg; |
796 | 640 | ||
797 | param_nest = nla_nest_start(dcbnl_skb, i); | 641 | param_nest = nla_nest_start(skb, i); |
798 | if (!param_nest) | 642 | if (!param_nest) |
799 | goto err_pg; | 643 | goto err_pg; |
800 | 644 | ||
@@ -817,33 +661,33 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlattr **tb, | |||
817 | 661 | ||
818 | if (param_tb[DCB_TC_ATTR_PARAM_PGID] || | 662 | if (param_tb[DCB_TC_ATTR_PARAM_PGID] || |
819 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { | 663 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { |
820 | ret = nla_put_u8(dcbnl_skb, | 664 | ret = nla_put_u8(skb, |
821 | DCB_TC_ATTR_PARAM_PGID, pgid); | 665 | DCB_TC_ATTR_PARAM_PGID, pgid); |
822 | if (ret) | 666 | if (ret) |
823 | goto err_param; | 667 | goto err_param; |
824 | } | 668 | } |
825 | if (param_tb[DCB_TC_ATTR_PARAM_UP_MAPPING] || | 669 | if (param_tb[DCB_TC_ATTR_PARAM_UP_MAPPING] || |
826 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { | 670 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { |
827 | ret = nla_put_u8(dcbnl_skb, | 671 | ret = nla_put_u8(skb, |
828 | DCB_TC_ATTR_PARAM_UP_MAPPING, up_map); | 672 | DCB_TC_ATTR_PARAM_UP_MAPPING, up_map); |
829 | if (ret) | 673 | if (ret) |
830 | goto err_param; | 674 | goto err_param; |
831 | } | 675 | } |
832 | if (param_tb[DCB_TC_ATTR_PARAM_STRICT_PRIO] || | 676 | if (param_tb[DCB_TC_ATTR_PARAM_STRICT_PRIO] || |
833 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { | 677 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { |
834 | ret = nla_put_u8(dcbnl_skb, | 678 | ret = nla_put_u8(skb, |
835 | DCB_TC_ATTR_PARAM_STRICT_PRIO, prio); | 679 | DCB_TC_ATTR_PARAM_STRICT_PRIO, prio); |
836 | if (ret) | 680 | if (ret) |
837 | goto err_param; | 681 | goto err_param; |
838 | } | 682 | } |
839 | if (param_tb[DCB_TC_ATTR_PARAM_BW_PCT] || | 683 | if (param_tb[DCB_TC_ATTR_PARAM_BW_PCT] || |
840 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { | 684 | param_tb[DCB_TC_ATTR_PARAM_ALL]) { |
841 | ret = nla_put_u8(dcbnl_skb, DCB_TC_ATTR_PARAM_BW_PCT, | 685 | ret = nla_put_u8(skb, DCB_TC_ATTR_PARAM_BW_PCT, |
842 | tc_pct); | 686 | tc_pct); |
843 | if (ret) | 687 | if (ret) |
844 | goto err_param; | 688 | goto err_param; |
845 | } | 689 | } |
846 | nla_nest_end(dcbnl_skb, param_nest); | 690 | nla_nest_end(skb, param_nest); |
847 | } | 691 | } |
848 | 692 | ||
849 | if (pg_tb[DCB_PG_ATTR_BW_ID_ALL]) | 693 | if (pg_tb[DCB_PG_ATTR_BW_ID_ALL]) |
@@ -866,66 +710,53 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlattr **tb, | |||
866 | netdev->dcbnl_ops->getpgbwgcfgtx(netdev, | 710 | netdev->dcbnl_ops->getpgbwgcfgtx(netdev, |
867 | i - DCB_PG_ATTR_BW_ID_0, &tc_pct); | 711 | i - DCB_PG_ATTR_BW_ID_0, &tc_pct); |
868 | } | 712 | } |
869 | ret = nla_put_u8(dcbnl_skb, i, tc_pct); | 713 | ret = nla_put_u8(skb, i, tc_pct); |
870 | 714 | ||
871 | if (ret) | 715 | if (ret) |
872 | goto err_pg; | 716 | goto err_pg; |
873 | } | 717 | } |
874 | 718 | ||
875 | nla_nest_end(dcbnl_skb, pg_nest); | 719 | nla_nest_end(skb, pg_nest); |
876 | |||
877 | nlmsg_end(dcbnl_skb, nlh); | ||
878 | |||
879 | ret = rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
880 | if (ret) | ||
881 | goto err_out; | ||
882 | 720 | ||
883 | return 0; | 721 | return 0; |
884 | 722 | ||
885 | err_param: | 723 | err_param: |
886 | nla_nest_cancel(dcbnl_skb, param_nest); | 724 | nla_nest_cancel(skb, param_nest); |
887 | err_pg: | 725 | err_pg: |
888 | nla_nest_cancel(dcbnl_skb, pg_nest); | 726 | nla_nest_cancel(skb, pg_nest); |
889 | nlmsg_failure: | ||
890 | err: | ||
891 | kfree_skb(dcbnl_skb); | ||
892 | err_out: | 727 | err_out: |
893 | ret = -EINVAL; | 728 | ret = -EINVAL; |
894 | return ret; | 729 | return ret; |
895 | } | 730 | } |
896 | 731 | ||
897 | static int dcbnl_pgtx_getcfg(struct net_device *netdev, struct nlattr **tb, | 732 | static int dcbnl_pgtx_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
898 | u32 pid, u32 seq, u16 flags) | 733 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
899 | { | 734 | { |
900 | return __dcbnl_pg_getcfg(netdev, tb, pid, seq, flags, 0); | 735 | return __dcbnl_pg_getcfg(netdev, nlh, tb, skb, 0); |
901 | } | 736 | } |
902 | 737 | ||
903 | static int dcbnl_pgrx_getcfg(struct net_device *netdev, struct nlattr **tb, | 738 | static int dcbnl_pgrx_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
904 | u32 pid, u32 seq, u16 flags) | 739 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
905 | { | 740 | { |
906 | return __dcbnl_pg_getcfg(netdev, tb, pid, seq, flags, 1); | 741 | return __dcbnl_pg_getcfg(netdev, nlh, tb, skb, 1); |
907 | } | 742 | } |
908 | 743 | ||
909 | static int dcbnl_setstate(struct net_device *netdev, struct nlattr **tb, | 744 | static int dcbnl_setstate(struct net_device *netdev, struct nlmsghdr *nlh, |
910 | u32 pid, u32 seq, u16 flags) | 745 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
911 | { | 746 | { |
912 | int ret = -EINVAL; | ||
913 | u8 value; | 747 | u8 value; |
914 | 748 | ||
915 | if (!tb[DCB_ATTR_STATE] || !netdev->dcbnl_ops->setstate) | 749 | if (!tb[DCB_ATTR_STATE] || !netdev->dcbnl_ops->setstate) |
916 | return ret; | 750 | return -EINVAL; |
917 | 751 | ||
918 | value = nla_get_u8(tb[DCB_ATTR_STATE]); | 752 | value = nla_get_u8(tb[DCB_ATTR_STATE]); |
919 | 753 | ||
920 | ret = dcbnl_reply(netdev->dcbnl_ops->setstate(netdev, value), | 754 | return nla_put_u8(skb, DCB_ATTR_STATE, |
921 | RTM_SETDCB, DCB_CMD_SSTATE, DCB_ATTR_STATE, | 755 | netdev->dcbnl_ops->setstate(netdev, value)); |
922 | pid, seq, flags); | ||
923 | |||
924 | return ret; | ||
925 | } | 756 | } |
926 | 757 | ||
927 | static int dcbnl_setpfccfg(struct net_device *netdev, struct nlattr **tb, | 758 | static int dcbnl_setpfccfg(struct net_device *netdev, struct nlmsghdr *nlh, |
928 | u32 pid, u32 seq, u16 flags) | 759 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
929 | { | 760 | { |
930 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1]; | 761 | struct nlattr *data[DCB_PFC_UP_ATTR_MAX + 1]; |
931 | int i; | 762 | int i; |
@@ -949,29 +780,29 @@ static int dcbnl_setpfccfg(struct net_device *netdev, struct nlattr **tb, | |||
949 | data[i]->nla_type - DCB_PFC_UP_ATTR_0, value); | 780 | data[i]->nla_type - DCB_PFC_UP_ATTR_0, value); |
950 | } | 781 | } |
951 | 782 | ||
952 | ret = dcbnl_reply(0, RTM_SETDCB, DCB_CMD_PFC_SCFG, DCB_ATTR_PFC_CFG, | 783 | return nla_put_u8(skb, DCB_ATTR_PFC_CFG, 0); |
953 | pid, seq, flags); | ||
954 | err: | 784 | err: |
955 | return ret; | 785 | return ret; |
956 | } | 786 | } |
957 | 787 | ||
958 | static int dcbnl_setall(struct net_device *netdev, struct nlattr **tb, | 788 | static int dcbnl_setall(struct net_device *netdev, struct nlmsghdr *nlh, |
959 | u32 pid, u32 seq, u16 flags) | 789 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
960 | { | 790 | { |
961 | int ret = -EINVAL; | 791 | int ret = -EINVAL; |
962 | 792 | ||
963 | if (!tb[DCB_ATTR_SET_ALL] || !netdev->dcbnl_ops->setall) | 793 | if (!tb[DCB_ATTR_SET_ALL] || !netdev->dcbnl_ops->setall) |
964 | return ret; | 794 | return ret; |
965 | 795 | ||
966 | ret = dcbnl_reply(netdev->dcbnl_ops->setall(netdev), RTM_SETDCB, | 796 | ret = nla_put_u8(skb, DCB_ATTR_SET_ALL, |
967 | DCB_CMD_SET_ALL, DCB_ATTR_SET_ALL, pid, seq, flags); | 797 | netdev->dcbnl_ops->setall(netdev)); |
968 | dcbnl_cee_notify(netdev, RTM_SETDCB, DCB_CMD_SET_ALL, seq, 0); | 798 | dcbnl_cee_notify(netdev, RTM_SETDCB, DCB_CMD_SET_ALL, seq, 0); |
969 | 799 | ||
970 | return ret; | 800 | return ret; |
971 | } | 801 | } |
972 | 802 | ||
973 | static int __dcbnl_pg_setcfg(struct net_device *netdev, struct nlattr **tb, | 803 | static int __dcbnl_pg_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
974 | u32 pid, u32 seq, u16 flags, int dir) | 804 | u32 seq, struct nlattr **tb, struct sk_buff *skb, |
805 | int dir) | ||
975 | { | 806 | { |
976 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; | 807 | struct nlattr *pg_tb[DCB_PG_ATTR_MAX + 1]; |
977 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; | 808 | struct nlattr *param_tb[DCB_TC_ATTR_PARAM_MAX + 1]; |
@@ -1054,32 +885,27 @@ static int __dcbnl_pg_setcfg(struct net_device *netdev, struct nlattr **tb, | |||
1054 | } | 885 | } |
1055 | } | 886 | } |
1056 | 887 | ||
1057 | ret = dcbnl_reply(0, RTM_SETDCB, | 888 | ret = nla_put_u8(skb, (dir ? DCB_CMD_PGRX_SCFG : DCB_CMD_PGTX_SCFG), 0); |
1058 | (dir ? DCB_CMD_PGRX_SCFG : DCB_CMD_PGTX_SCFG), | ||
1059 | DCB_ATTR_PG_CFG, pid, seq, flags); | ||
1060 | 889 | ||
1061 | err: | 890 | err: |
1062 | return ret; | 891 | return ret; |
1063 | } | 892 | } |
1064 | 893 | ||
1065 | static int dcbnl_pgtx_setcfg(struct net_device *netdev, struct nlattr **tb, | 894 | static int dcbnl_pgtx_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
1066 | u32 pid, u32 seq, u16 flags) | 895 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1067 | { | 896 | { |
1068 | return __dcbnl_pg_setcfg(netdev, tb, pid, seq, flags, 0); | 897 | return __dcbnl_pg_setcfg(netdev, nlh, seq, tb, skb, 0); |
1069 | } | 898 | } |
1070 | 899 | ||
1071 | static int dcbnl_pgrx_setcfg(struct net_device *netdev, struct nlattr **tb, | 900 | static int dcbnl_pgrx_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
1072 | u32 pid, u32 seq, u16 flags) | 901 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1073 | { | 902 | { |
1074 | return __dcbnl_pg_setcfg(netdev, tb, pid, seq, flags, 1); | 903 | return __dcbnl_pg_setcfg(netdev, nlh, seq, tb, skb, 1); |
1075 | } | 904 | } |
1076 | 905 | ||
1077 | static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlattr **tb, | 906 | static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
1078 | u32 pid, u32 seq, u16 flags) | 907 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1079 | { | 908 | { |
1080 | struct sk_buff *dcbnl_skb; | ||
1081 | struct nlmsghdr *nlh; | ||
1082 | struct dcbmsg *dcb; | ||
1083 | struct nlattr *bcn_nest; | 909 | struct nlattr *bcn_nest; |
1084 | struct nlattr *bcn_tb[DCB_BCN_ATTR_MAX + 1]; | 910 | struct nlattr *bcn_tb[DCB_BCN_ATTR_MAX + 1]; |
1085 | u8 value_byte; | 911 | u8 value_byte; |
@@ -1098,19 +924,9 @@ static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlattr **tb, | |||
1098 | if (ret) | 924 | if (ret) |
1099 | goto err_out; | 925 | goto err_out; |
1100 | 926 | ||
1101 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 927 | bcn_nest = nla_nest_start(skb, DCB_ATTR_BCN); |
1102 | if (!dcbnl_skb) | ||
1103 | goto err_out; | ||
1104 | |||
1105 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
1106 | |||
1107 | dcb = NLMSG_DATA(nlh); | ||
1108 | dcb->dcb_family = AF_UNSPEC; | ||
1109 | dcb->cmd = DCB_CMD_BCN_GCFG; | ||
1110 | |||
1111 | bcn_nest = nla_nest_start(dcbnl_skb, DCB_ATTR_BCN); | ||
1112 | if (!bcn_nest) | 928 | if (!bcn_nest) |
1113 | goto err; | 929 | goto err_out; |
1114 | 930 | ||
1115 | if (bcn_tb[DCB_BCN_ATTR_ALL]) | 931 | if (bcn_tb[DCB_BCN_ATTR_ALL]) |
1116 | getall = true; | 932 | getall = true; |
@@ -1121,7 +937,7 @@ static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlattr **tb, | |||
1121 | 937 | ||
1122 | netdev->dcbnl_ops->getbcnrp(netdev, i - DCB_BCN_ATTR_RP_0, | 938 | netdev->dcbnl_ops->getbcnrp(netdev, i - DCB_BCN_ATTR_RP_0, |
1123 | &value_byte); | 939 | &value_byte); |
1124 | ret = nla_put_u8(dcbnl_skb, i, value_byte); | 940 | ret = nla_put_u8(skb, i, value_byte); |
1125 | if (ret) | 941 | if (ret) |
1126 | goto err_bcn; | 942 | goto err_bcn; |
1127 | } | 943 | } |
@@ -1132,33 +948,24 @@ static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlattr **tb, | |||
1132 | 948 | ||
1133 | netdev->dcbnl_ops->getbcncfg(netdev, i, | 949 | netdev->dcbnl_ops->getbcncfg(netdev, i, |
1134 | &value_integer); | 950 | &value_integer); |
1135 | ret = nla_put_u32(dcbnl_skb, i, value_integer); | 951 | ret = nla_put_u32(skb, i, value_integer); |
1136 | if (ret) | 952 | if (ret) |
1137 | goto err_bcn; | 953 | goto err_bcn; |
1138 | } | 954 | } |
1139 | 955 | ||
1140 | nla_nest_end(dcbnl_skb, bcn_nest); | 956 | nla_nest_end(skb, bcn_nest); |
1141 | |||
1142 | nlmsg_end(dcbnl_skb, nlh); | ||
1143 | |||
1144 | ret = rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
1145 | if (ret) | ||
1146 | goto err_out; | ||
1147 | 957 | ||
1148 | return 0; | 958 | return 0; |
1149 | 959 | ||
1150 | err_bcn: | 960 | err_bcn: |
1151 | nla_nest_cancel(dcbnl_skb, bcn_nest); | 961 | nla_nest_cancel(skb, bcn_nest); |
1152 | nlmsg_failure: | ||
1153 | err: | ||
1154 | kfree_skb(dcbnl_skb); | ||
1155 | err_out: | 962 | err_out: |
1156 | ret = -EINVAL; | 963 | ret = -EINVAL; |
1157 | return ret; | 964 | return ret; |
1158 | } | 965 | } |
1159 | 966 | ||
1160 | static int dcbnl_bcn_setcfg(struct net_device *netdev, struct nlattr **tb, | 967 | static int dcbnl_bcn_setcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
1161 | u32 pid, u32 seq, u16 flags) | 968 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1162 | { | 969 | { |
1163 | struct nlattr *data[DCB_BCN_ATTR_MAX + 1]; | 970 | struct nlattr *data[DCB_BCN_ATTR_MAX + 1]; |
1164 | int i; | 971 | int i; |
@@ -1192,8 +999,7 @@ static int dcbnl_bcn_setcfg(struct net_device *netdev, struct nlattr **tb, | |||
1192 | i, value_int); | 999 | i, value_int); |
1193 | } | 1000 | } |
1194 | 1001 | ||
1195 | ret = dcbnl_reply(0, RTM_SETDCB, DCB_CMD_BCN_SCFG, DCB_ATTR_BCN, | 1002 | ret = nla_put_u8(skb, DCB_ATTR_BCN, 0); |
1196 | pid, seq, flags); | ||
1197 | err: | 1003 | err: |
1198 | return ret; | 1004 | return ret; |
1199 | } | 1005 | } |
@@ -1618,8 +1424,8 @@ EXPORT_SYMBOL(dcbnl_cee_notify); | |||
1618 | * No attempt is made to reconcile the case where only part of the | 1424 | * No attempt is made to reconcile the case where only part of the |
1619 | * cmd can be completed. | 1425 | * cmd can be completed. |
1620 | */ | 1426 | */ |
1621 | static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb, | 1427 | static int dcbnl_ieee_set(struct net_device *netdev, struct nlmsghdr *nlh, |
1622 | u32 pid, u32 seq, u16 flags) | 1428 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1623 | { | 1429 | { |
1624 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; | 1430 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; |
1625 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; | 1431 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; |
@@ -1677,54 +1483,24 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb, | |||
1677 | } | 1483 | } |
1678 | 1484 | ||
1679 | err: | 1485 | err: |
1680 | dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_SET, DCB_ATTR_IEEE, | 1486 | err = nla_put_u8(skb, DCB_ATTR_IEEE, err); |
1681 | pid, seq, flags); | ||
1682 | dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0); | 1487 | dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0); |
1683 | return err; | 1488 | return err; |
1684 | } | 1489 | } |
1685 | 1490 | ||
1686 | static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb, | 1491 | static int dcbnl_ieee_get(struct net_device *netdev, struct nlmsghdr *nlh, |
1687 | u32 pid, u32 seq, u16 flags) | 1492 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1688 | { | 1493 | { |
1689 | struct net *net = dev_net(netdev); | ||
1690 | struct sk_buff *skb; | ||
1691 | struct nlmsghdr *nlh; | ||
1692 | struct dcbmsg *dcb; | ||
1693 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; | 1494 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; |
1694 | int err; | ||
1695 | 1495 | ||
1696 | if (!ops) | 1496 | if (!ops) |
1697 | return -EOPNOTSUPP; | 1497 | return -EOPNOTSUPP; |
1698 | 1498 | ||
1699 | skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 1499 | return dcbnl_ieee_fill(skb, netdev); |
1700 | if (!skb) | ||
1701 | return -ENOBUFS; | ||
1702 | |||
1703 | nlh = nlmsg_put(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
1704 | if (nlh == NULL) { | ||
1705 | nlmsg_free(skb); | ||
1706 | return -EMSGSIZE; | ||
1707 | } | ||
1708 | |||
1709 | dcb = NLMSG_DATA(nlh); | ||
1710 | dcb->dcb_family = AF_UNSPEC; | ||
1711 | dcb->cmd = DCB_CMD_IEEE_GET; | ||
1712 | |||
1713 | err = dcbnl_ieee_fill(skb, netdev); | ||
1714 | |||
1715 | if (err < 0) { | ||
1716 | nlmsg_cancel(skb, nlh); | ||
1717 | kfree_skb(skb); | ||
1718 | } else { | ||
1719 | nlmsg_end(skb, nlh); | ||
1720 | err = rtnl_unicast(skb, net, pid); | ||
1721 | } | ||
1722 | |||
1723 | return err; | ||
1724 | } | 1500 | } |
1725 | 1501 | ||
1726 | static int dcbnl_ieee_del(struct net_device *netdev, struct nlattr **tb, | 1502 | static int dcbnl_ieee_del(struct net_device *netdev, struct nlmsghdr *nlh, |
1727 | u32 pid, u32 seq, u16 flags) | 1503 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1728 | { | 1504 | { |
1729 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; | 1505 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; |
1730 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; | 1506 | struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; |
@@ -1761,32 +1537,26 @@ static int dcbnl_ieee_del(struct net_device *netdev, struct nlattr **tb, | |||
1761 | } | 1537 | } |
1762 | 1538 | ||
1763 | err: | 1539 | err: |
1764 | dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_DEL, DCB_ATTR_IEEE, | 1540 | err = nla_put_u8(skb, DCB_ATTR_IEEE, err); |
1765 | pid, seq, flags); | ||
1766 | dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_DEL, seq, 0); | 1541 | dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_DEL, seq, 0); |
1767 | return err; | 1542 | return err; |
1768 | } | 1543 | } |
1769 | 1544 | ||
1770 | 1545 | ||
1771 | /* DCBX configuration */ | 1546 | /* DCBX configuration */ |
1772 | static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb, | 1547 | static int dcbnl_getdcbx(struct net_device *netdev, struct nlmsghdr *nlh, |
1773 | u32 pid, u32 seq, u16 flags) | 1548 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1774 | { | 1549 | { |
1775 | int ret; | ||
1776 | |||
1777 | if (!netdev->dcbnl_ops->getdcbx) | 1550 | if (!netdev->dcbnl_ops->getdcbx) |
1778 | return -EOPNOTSUPP; | 1551 | return -EOPNOTSUPP; |
1779 | 1552 | ||
1780 | ret = dcbnl_reply(netdev->dcbnl_ops->getdcbx(netdev), RTM_GETDCB, | 1553 | return nla_put_u8(skb, DCB_ATTR_DCBX, |
1781 | DCB_CMD_GDCBX, DCB_ATTR_DCBX, pid, seq, flags); | 1554 | netdev->dcbnl_ops->getdcbx(netdev)); |
1782 | |||
1783 | return ret; | ||
1784 | } | 1555 | } |
1785 | 1556 | ||
1786 | static int dcbnl_setdcbx(struct net_device *netdev, struct nlattr **tb, | 1557 | static int dcbnl_setdcbx(struct net_device *netdev, struct nlmsghdr *nlh, |
1787 | u32 pid, u32 seq, u16 flags) | 1558 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1788 | { | 1559 | { |
1789 | int ret; | ||
1790 | u8 value; | 1560 | u8 value; |
1791 | 1561 | ||
1792 | if (!netdev->dcbnl_ops->setdcbx) | 1562 | if (!netdev->dcbnl_ops->setdcbx) |
@@ -1797,19 +1567,13 @@ static int dcbnl_setdcbx(struct net_device *netdev, struct nlattr **tb, | |||
1797 | 1567 | ||
1798 | value = nla_get_u8(tb[DCB_ATTR_DCBX]); | 1568 | value = nla_get_u8(tb[DCB_ATTR_DCBX]); |
1799 | 1569 | ||
1800 | ret = dcbnl_reply(netdev->dcbnl_ops->setdcbx(netdev, value), | 1570 | return nla_put_u8(skb, DCB_ATTR_DCBX, |
1801 | RTM_SETDCB, DCB_CMD_SDCBX, DCB_ATTR_DCBX, | 1571 | netdev->dcbnl_ops->setdcbx(netdev, value)); |
1802 | pid, seq, flags); | ||
1803 | |||
1804 | return ret; | ||
1805 | } | 1572 | } |
1806 | 1573 | ||
1807 | static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlattr **tb, | 1574 | static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
1808 | u32 pid, u32 seq, u16 flags) | 1575 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1809 | { | 1576 | { |
1810 | struct sk_buff *dcbnl_skb; | ||
1811 | struct nlmsghdr *nlh; | ||
1812 | struct dcbmsg *dcb; | ||
1813 | struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1], *nest; | 1577 | struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1], *nest; |
1814 | u8 value; | 1578 | u8 value; |
1815 | int ret, i; | 1579 | int ret, i; |
@@ -1824,25 +1588,11 @@ static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlattr **tb, | |||
1824 | ret = nla_parse_nested(data, DCB_FEATCFG_ATTR_MAX, tb[DCB_ATTR_FEATCFG], | 1588 | ret = nla_parse_nested(data, DCB_FEATCFG_ATTR_MAX, tb[DCB_ATTR_FEATCFG], |
1825 | dcbnl_featcfg_nest); | 1589 | dcbnl_featcfg_nest); |
1826 | if (ret) | 1590 | if (ret) |
1827 | goto err_out; | 1591 | return ret; |
1828 | |||
1829 | dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
1830 | if (!dcbnl_skb) { | ||
1831 | ret = -ENOBUFS; | ||
1832 | goto err_out; | ||
1833 | } | ||
1834 | |||
1835 | nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
1836 | |||
1837 | dcb = NLMSG_DATA(nlh); | ||
1838 | dcb->dcb_family = AF_UNSPEC; | ||
1839 | dcb->cmd = DCB_CMD_GFEATCFG; | ||
1840 | 1592 | ||
1841 | nest = nla_nest_start(dcbnl_skb, DCB_ATTR_FEATCFG); | 1593 | nest = nla_nest_start(skb, DCB_ATTR_FEATCFG); |
1842 | if (!nest) { | 1594 | if (!nest) |
1843 | ret = -EMSGSIZE; | 1595 | return -EMSGSIZE; |
1844 | goto nla_put_failure; | ||
1845 | } | ||
1846 | 1596 | ||
1847 | if (data[DCB_FEATCFG_ATTR_ALL]) | 1597 | if (data[DCB_FEATCFG_ATTR_ALL]) |
1848 | getall = 1; | 1598 | getall = 1; |
@@ -1853,28 +1603,21 @@ static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlattr **tb, | |||
1853 | 1603 | ||
1854 | ret = netdev->dcbnl_ops->getfeatcfg(netdev, i, &value); | 1604 | ret = netdev->dcbnl_ops->getfeatcfg(netdev, i, &value); |
1855 | if (!ret) | 1605 | if (!ret) |
1856 | ret = nla_put_u8(dcbnl_skb, i, value); | 1606 | ret = nla_put_u8(skb, i, value); |
1857 | 1607 | ||
1858 | if (ret) { | 1608 | if (ret) { |
1859 | nla_nest_cancel(dcbnl_skb, nest); | 1609 | nla_nest_cancel(skb, nest); |
1860 | goto nla_put_failure; | 1610 | goto nla_put_failure; |
1861 | } | 1611 | } |
1862 | } | 1612 | } |
1863 | nla_nest_end(dcbnl_skb, nest); | 1613 | nla_nest_end(skb, nest); |
1864 | |||
1865 | nlmsg_end(dcbnl_skb, nlh); | ||
1866 | 1614 | ||
1867 | return rtnl_unicast(dcbnl_skb, &init_net, pid); | ||
1868 | nla_put_failure: | 1615 | nla_put_failure: |
1869 | nlmsg_cancel(dcbnl_skb, nlh); | ||
1870 | nlmsg_failure: | ||
1871 | kfree_skb(dcbnl_skb); | ||
1872 | err_out: | ||
1873 | return ret; | 1616 | return ret; |
1874 | } | 1617 | } |
1875 | 1618 | ||
1876 | static int dcbnl_setfeatcfg(struct net_device *netdev, struct nlattr **tb, | 1619 | static int dcbnl_setfeatcfg(struct net_device *netdev, struct nlmsghdr *nlh, |
1877 | u32 pid, u32 seq, u16 flags) | 1620 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1878 | { | 1621 | { |
1879 | struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1]; | 1622 | struct nlattr *data[DCB_FEATCFG_ATTR_MAX + 1]; |
1880 | int ret, i; | 1623 | int ret, i; |
@@ -1904,50 +1647,21 @@ static int dcbnl_setfeatcfg(struct net_device *netdev, struct nlattr **tb, | |||
1904 | goto err; | 1647 | goto err; |
1905 | } | 1648 | } |
1906 | err: | 1649 | err: |
1907 | dcbnl_reply(ret, RTM_SETDCB, DCB_CMD_SFEATCFG, DCB_ATTR_FEATCFG, | 1650 | ret = nla_put_u8(skb, DCB_ATTR_FEATCFG, ret); |
1908 | pid, seq, flags); | ||
1909 | 1651 | ||
1910 | return ret; | 1652 | return ret; |
1911 | } | 1653 | } |
1912 | 1654 | ||
1913 | /* Handle CEE DCBX GET commands. */ | 1655 | /* Handle CEE DCBX GET commands. */ |
1914 | static int dcbnl_cee_get(struct net_device *netdev, struct nlattr **tb, | 1656 | static int dcbnl_cee_get(struct net_device *netdev, struct nlmsghdr *nlh, |
1915 | u32 pid, u32 seq, u16 flags) | 1657 | u32 seq, struct nlattr **tb, struct sk_buff *skb) |
1916 | { | 1658 | { |
1917 | struct net *net = dev_net(netdev); | ||
1918 | struct sk_buff *skb; | ||
1919 | struct nlmsghdr *nlh; | ||
1920 | struct dcbmsg *dcb; | ||
1921 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; | 1659 | const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; |
1922 | int err; | ||
1923 | 1660 | ||
1924 | if (!ops) | 1661 | if (!ops) |
1925 | return -EOPNOTSUPP; | 1662 | return -EOPNOTSUPP; |
1926 | 1663 | ||
1927 | skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 1664 | return dcbnl_cee_fill(skb, netdev); |
1928 | if (!skb) | ||
1929 | return -ENOBUFS; | ||
1930 | |||
1931 | nlh = nlmsg_put(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); | ||
1932 | if (nlh == NULL) { | ||
1933 | nlmsg_free(skb); | ||
1934 | return -EMSGSIZE; | ||
1935 | } | ||
1936 | |||
1937 | dcb = NLMSG_DATA(nlh); | ||
1938 | dcb->dcb_family = AF_UNSPEC; | ||
1939 | dcb->cmd = DCB_CMD_CEE_GET; | ||
1940 | |||
1941 | err = dcbnl_cee_fill(skb, netdev); | ||
1942 | |||
1943 | if (err < 0) { | ||
1944 | nlmsg_cancel(skb, nlh); | ||
1945 | nlmsg_free(skb); | ||
1946 | } else { | ||
1947 | nlmsg_end(skb, nlh); | ||
1948 | err = rtnl_unicast(skb, net, pid); | ||
1949 | } | ||
1950 | return err; | ||
1951 | } | 1665 | } |
1952 | 1666 | ||
1953 | struct reply_func { | 1667 | struct reply_func { |
@@ -1960,7 +1674,33 @@ struct reply_func { | |||
1960 | }; | 1674 | }; |
1961 | 1675 | ||
1962 | static const struct reply_func reply_funcs[DCB_CMD_MAX+1] = { | 1676 | static const struct reply_func reply_funcs[DCB_CMD_MAX+1] = { |
1963 | /* FIXME: add reply defs */ | 1677 | [DCB_CMD_GSTATE] = { RTM_GETDCB, dcbnl_getstate }, |
1678 | [DCB_CMD_SSTATE] = { RTM_SETDCB, dcbnl_setstate }, | ||
1679 | [DCB_CMD_PFC_GCFG] = { RTM_GETDCB, dcbnl_getpfccfg }, | ||
1680 | [DCB_CMD_PFC_SCFG] = { RTM_SETDCB, dcbnl_setpfccfg }, | ||
1681 | [DCB_CMD_GPERM_HWADDR] = { RTM_GETDCB, dcbnl_getperm_hwaddr }, | ||
1682 | [DCB_CMD_GCAP] = { RTM_GETDCB, dcbnl_getcap }, | ||
1683 | [DCB_CMD_GNUMTCS] = { RTM_GETDCB, dcbnl_getnumtcs }, | ||
1684 | [DCB_CMD_SNUMTCS] = { RTM_SETDCB, dcbnl_setnumtcs }, | ||
1685 | [DCB_CMD_PFC_GSTATE] = { RTM_GETDCB, dcbnl_getpfcstate }, | ||
1686 | [DCB_CMD_PFC_SSTATE] = { RTM_SETDCB, dcbnl_setpfcstate }, | ||
1687 | [DCB_CMD_GAPP] = { RTM_GETDCB, dcbnl_getapp }, | ||
1688 | [DCB_CMD_SAPP] = { RTM_SETDCB, dcbnl_setapp }, | ||
1689 | [DCB_CMD_PGTX_GCFG] = { RTM_GETDCB, dcbnl_pgtx_getcfg }, | ||
1690 | [DCB_CMD_PGTX_SCFG] = { RTM_SETDCB, dcbnl_pgtx_setcfg }, | ||
1691 | [DCB_CMD_PGRX_GCFG] = { RTM_GETDCB, dcbnl_pgrx_getcfg }, | ||
1692 | [DCB_CMD_PGRX_SCFG] = { RTM_SETDCB, dcbnl_pgrx_setcfg }, | ||
1693 | [DCB_CMD_SET_ALL] = { RTM_SETDCB, dcbnl_setall }, | ||
1694 | [DCB_CMD_BCN_GCFG] = { RTM_GETDCB, dcbnl_bcn_getcfg }, | ||
1695 | [DCB_CMD_BCN_SCFG] = { RTM_SETDCB, dcbnl_bcn_setcfg }, | ||
1696 | [DCB_CMD_IEEE_GET] = { RTM_GETDCB, dcbnl_ieee_get }, | ||
1697 | [DCB_CMD_IEEE_SET] = { RTM_SETDCB, dcbnl_ieee_set }, | ||
1698 | [DCB_CMD_IEEE_DEL] = { RTM_SETDCB, dcbnl_ieee_del }, | ||
1699 | [DCB_CMD_GDCBX] = { RTM_GETDCB, dcbnl_getdcbx }, | ||
1700 | [DCB_CMD_SDCBX] = { RTM_SETDCB, dcbnl_setdcbx }, | ||
1701 | [DCB_CMD_GFEATCFG] = { RTM_GETDCB, dcbnl_getfeatcfg }, | ||
1702 | [DCB_CMD_SFEATCFG] = { RTM_SETDCB, dcbnl_setfeatcfg }, | ||
1703 | [DCB_CMD_CEE_GET] = { RTM_GETDCB, dcbnl_cee_get }, | ||
1964 | }; | 1704 | }; |
1965 | 1705 | ||
1966 | static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 1706 | static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
@@ -2017,124 +1757,6 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
2017 | nlmsg_end(reply_skb, reply_nlh); | 1757 | nlmsg_end(reply_skb, reply_nlh); |
2018 | 1758 | ||
2019 | ret = rtnl_unicast(reply_skb, &init_net, pid); | 1759 | ret = rtnl_unicast(reply_skb, &init_net, pid); |
2020 | if (ret) | ||
2021 | goto out; | ||
2022 | |||
2023 | switch (dcb->cmd) { | ||
2024 | case DCB_CMD_GSTATE: | ||
2025 | ret = dcbnl_getstate(netdev, tb, pid, nlh->nlmsg_seq, | ||
2026 | nlh->nlmsg_flags); | ||
2027 | goto out; | ||
2028 | case DCB_CMD_PFC_GCFG: | ||
2029 | ret = dcbnl_getpfccfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2030 | nlh->nlmsg_flags); | ||
2031 | goto out; | ||
2032 | case DCB_CMD_GPERM_HWADDR: | ||
2033 | ret = dcbnl_getperm_hwaddr(netdev, tb, pid, nlh->nlmsg_seq, | ||
2034 | nlh->nlmsg_flags); | ||
2035 | goto out; | ||
2036 | case DCB_CMD_PGTX_GCFG: | ||
2037 | ret = dcbnl_pgtx_getcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2038 | nlh->nlmsg_flags); | ||
2039 | goto out; | ||
2040 | case DCB_CMD_PGRX_GCFG: | ||
2041 | ret = dcbnl_pgrx_getcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2042 | nlh->nlmsg_flags); | ||
2043 | goto out; | ||
2044 | case DCB_CMD_BCN_GCFG: | ||
2045 | ret = dcbnl_bcn_getcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2046 | nlh->nlmsg_flags); | ||
2047 | goto out; | ||
2048 | case DCB_CMD_SSTATE: | ||
2049 | ret = dcbnl_setstate(netdev, tb, pid, nlh->nlmsg_seq, | ||
2050 | nlh->nlmsg_flags); | ||
2051 | goto out; | ||
2052 | case DCB_CMD_PFC_SCFG: | ||
2053 | ret = dcbnl_setpfccfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2054 | nlh->nlmsg_flags); | ||
2055 | goto out; | ||
2056 | |||
2057 | case DCB_CMD_SET_ALL: | ||
2058 | ret = dcbnl_setall(netdev, tb, pid, nlh->nlmsg_seq, | ||
2059 | nlh->nlmsg_flags); | ||
2060 | goto out; | ||
2061 | case DCB_CMD_PGTX_SCFG: | ||
2062 | ret = dcbnl_pgtx_setcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2063 | nlh->nlmsg_flags); | ||
2064 | goto out; | ||
2065 | case DCB_CMD_PGRX_SCFG: | ||
2066 | ret = dcbnl_pgrx_setcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2067 | nlh->nlmsg_flags); | ||
2068 | goto out; | ||
2069 | case DCB_CMD_GCAP: | ||
2070 | ret = dcbnl_getcap(netdev, tb, pid, nlh->nlmsg_seq, | ||
2071 | nlh->nlmsg_flags); | ||
2072 | goto out; | ||
2073 | case DCB_CMD_GNUMTCS: | ||
2074 | ret = dcbnl_getnumtcs(netdev, tb, pid, nlh->nlmsg_seq, | ||
2075 | nlh->nlmsg_flags); | ||
2076 | goto out; | ||
2077 | case DCB_CMD_SNUMTCS: | ||
2078 | ret = dcbnl_setnumtcs(netdev, tb, pid, nlh->nlmsg_seq, | ||
2079 | nlh->nlmsg_flags); | ||
2080 | goto out; | ||
2081 | case DCB_CMD_PFC_GSTATE: | ||
2082 | ret = dcbnl_getpfcstate(netdev, tb, pid, nlh->nlmsg_seq, | ||
2083 | nlh->nlmsg_flags); | ||
2084 | goto out; | ||
2085 | case DCB_CMD_PFC_SSTATE: | ||
2086 | ret = dcbnl_setpfcstate(netdev, tb, pid, nlh->nlmsg_seq, | ||
2087 | nlh->nlmsg_flags); | ||
2088 | goto out; | ||
2089 | case DCB_CMD_BCN_SCFG: | ||
2090 | ret = dcbnl_bcn_setcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2091 | nlh->nlmsg_flags); | ||
2092 | goto out; | ||
2093 | case DCB_CMD_GAPP: | ||
2094 | ret = dcbnl_getapp(netdev, tb, pid, nlh->nlmsg_seq, | ||
2095 | nlh->nlmsg_flags); | ||
2096 | goto out; | ||
2097 | case DCB_CMD_SAPP: | ||
2098 | ret = dcbnl_setapp(netdev, tb, pid, nlh->nlmsg_seq, | ||
2099 | nlh->nlmsg_flags); | ||
2100 | goto out; | ||
2101 | case DCB_CMD_IEEE_SET: | ||
2102 | ret = dcbnl_ieee_set(netdev, tb, pid, nlh->nlmsg_seq, | ||
2103 | nlh->nlmsg_flags); | ||
2104 | goto out; | ||
2105 | case DCB_CMD_IEEE_GET: | ||
2106 | ret = dcbnl_ieee_get(netdev, tb, pid, nlh->nlmsg_seq, | ||
2107 | nlh->nlmsg_flags); | ||
2108 | goto out; | ||
2109 | case DCB_CMD_IEEE_DEL: | ||
2110 | ret = dcbnl_ieee_del(netdev, tb, pid, nlh->nlmsg_seq, | ||
2111 | nlh->nlmsg_flags); | ||
2112 | goto out; | ||
2113 | case DCB_CMD_GDCBX: | ||
2114 | ret = dcbnl_getdcbx(netdev, tb, pid, nlh->nlmsg_seq, | ||
2115 | nlh->nlmsg_flags); | ||
2116 | goto out; | ||
2117 | case DCB_CMD_SDCBX: | ||
2118 | ret = dcbnl_setdcbx(netdev, tb, pid, nlh->nlmsg_seq, | ||
2119 | nlh->nlmsg_flags); | ||
2120 | goto out; | ||
2121 | case DCB_CMD_GFEATCFG: | ||
2122 | ret = dcbnl_getfeatcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2123 | nlh->nlmsg_flags); | ||
2124 | goto out; | ||
2125 | case DCB_CMD_SFEATCFG: | ||
2126 | ret = dcbnl_setfeatcfg(netdev, tb, pid, nlh->nlmsg_seq, | ||
2127 | nlh->nlmsg_flags); | ||
2128 | goto out; | ||
2129 | case DCB_CMD_CEE_GET: | ||
2130 | ret = dcbnl_cee_get(netdev, tb, pid, nlh->nlmsg_seq, | ||
2131 | nlh->nlmsg_flags); | ||
2132 | goto out; | ||
2133 | default: | ||
2134 | goto errout; | ||
2135 | } | ||
2136 | errout: | ||
2137 | ret = -EINVAL; | ||
2138 | out: | 1760 | out: |
2139 | dev_put(netdev); | 1761 | dev_put(netdev); |
2140 | return ret; | 1762 | return ret; |