Commit 6eaf53ca7bdae4506dbe6f0daaa93656f092383e

Authored by Thomas Graf
Committed by Marc Kleine-Budde
1 parent 061a5c316b

can: gw: Don't bump nlmsg_len manually

nlmsg_end() will take care of this when we finalize the message.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Tested-by: Oliver Hartkopp <socketcan@hartkopp.net>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Showing 1 changed file with 1 additions and 26 deletions Side-by-side Diff

... ... @@ -462,15 +462,11 @@
462 462 if (gwj->handled_frames) {
463 463 if (nla_put_u32(skb, CGW_HANDLED, gwj->handled_frames) < 0)
464 464 goto cancel;
465   - else
466   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(u32));
467 465 }
468 466  
469 467 if (gwj->dropped_frames) {
470 468 if (nla_put_u32(skb, CGW_DROPPED, gwj->dropped_frames) < 0)
471 469 goto cancel;
472   - else
473   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(u32));
474 470 }
475 471  
476 472 /* check non default settings of attributes */
... ... @@ -480,8 +476,6 @@
480 476 mb.modtype = gwj->mod.modtype.and;
481 477 if (nla_put(skb, CGW_MOD_AND, sizeof(mb), &mb) < 0)
482 478 goto cancel;
483   - else
484   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
485 479 }
486 480  
487 481 if (gwj->mod.modtype.or) {
... ... @@ -489,8 +483,6 @@
489 483 mb.modtype = gwj->mod.modtype.or;
490 484 if (nla_put(skb, CGW_MOD_OR, sizeof(mb), &mb) < 0)
491 485 goto cancel;
492   - else
493   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
494 486 }
495 487  
496 488 if (gwj->mod.modtype.xor) {
... ... @@ -498,8 +490,6 @@
498 490 mb.modtype = gwj->mod.modtype.xor;
499 491 if (nla_put(skb, CGW_MOD_XOR, sizeof(mb), &mb) < 0)
500 492 goto cancel;
501   - else
502   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
503 493 }
504 494  
505 495 if (gwj->mod.modtype.set) {
506 496  
507 497  
... ... @@ -507,26 +497,18 @@
507 497 mb.modtype = gwj->mod.modtype.set;
508 498 if (nla_put(skb, CGW_MOD_SET, sizeof(mb), &mb) < 0)
509 499 goto cancel;
510   - else
511   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
512 500 }
513 501  
514 502 if (gwj->mod.csumfunc.crc8) {
515 503 if (nla_put(skb, CGW_CS_CRC8, CGW_CS_CRC8_LEN,
516 504 &gwj->mod.csum.crc8) < 0)
517 505 goto cancel;
518   - else
519   - nlh->nlmsg_len += NLA_HDRLEN + \
520   - NLA_ALIGN(CGW_CS_CRC8_LEN);
521 506 }
522 507  
523 508 if (gwj->mod.csumfunc.xor) {
524 509 if (nla_put(skb, CGW_CS_XOR, CGW_CS_XOR_LEN,
525 510 &gwj->mod.csum.xor) < 0)
526 511 goto cancel;
527   - else
528   - nlh->nlmsg_len += NLA_HDRLEN + \
529   - NLA_ALIGN(CGW_CS_XOR_LEN);
530 512 }
531 513  
532 514 if (gwj->gwtype == CGW_TYPE_CAN_CAN) {
533 515  
534 516  
535 517  
... ... @@ -535,23 +517,16 @@
535 517 if (nla_put(skb, CGW_FILTER, sizeof(struct can_filter),
536 518 &gwj->ccgw.filter) < 0)
537 519 goto cancel;
538   - else
539   - nlh->nlmsg_len += NLA_HDRLEN +
540   - NLA_ALIGN(sizeof(struct can_filter));
541 520 }
542 521  
543 522 if (nla_put_u32(skb, CGW_SRC_IF, gwj->ccgw.src_idx) < 0)
544 523 goto cancel;
545   - else
546   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(u32));
547 524  
548 525 if (nla_put_u32(skb, CGW_DST_IF, gwj->ccgw.dst_idx) < 0)
549 526 goto cancel;
550   - else
551   - nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(u32));
552 527 }
553 528  
554   - return skb->len;
  529 + return nlmsg_end(skb, nlh);
555 530  
556 531 cancel:
557 532 nlmsg_cancel(skb, nlh);