aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2012-07-05 08:19:55 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2012-07-10 16:33:40 -0400
commit6eaf53ca7bdae4506dbe6f0daaa93656f092383e (patch)
tree65b7d256328b7f01e742ac51dda7b0db163918ba
parent061a5c316b6526dbc729049a16243ec27937cc31 (diff)
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>
-rw-r--r--net/can/gw.c27
1 files changed, 1 insertions, 26 deletions
diff --git a/net/can/gw.c b/net/can/gw.c
index b41acf25668f..a3ff980a1754 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -462,15 +462,11 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
462 if (gwj->handled_frames) { 462 if (gwj->handled_frames) {
463 if (nla_put_u32(skb, CGW_HANDLED, gwj->handled_frames) < 0) 463 if (nla_put_u32(skb, CGW_HANDLED, gwj->handled_frames) < 0)
464 goto cancel; 464 goto cancel;
465 else
466 nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(u32));
467 } 465 }
468 466
469 if (gwj->dropped_frames) { 467 if (gwj->dropped_frames) {
470 if (nla_put_u32(skb, CGW_DROPPED, gwj->dropped_frames) < 0) 468 if (nla_put_u32(skb, CGW_DROPPED, gwj->dropped_frames) < 0)
471 goto cancel; 469 goto cancel;
472 else
473 nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(u32));
474 } 470 }
475 471
476 /* check non default settings of attributes */ 472 /* check non default settings of attributes */
@@ -480,8 +476,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
480 mb.modtype = gwj->mod.modtype.and; 476 mb.modtype = gwj->mod.modtype.and;
481 if (nla_put(skb, CGW_MOD_AND, sizeof(mb), &mb) < 0) 477 if (nla_put(skb, CGW_MOD_AND, sizeof(mb), &mb) < 0)
482 goto cancel; 478 goto cancel;
483 else
484 nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
485 } 479 }
486 480
487 if (gwj->mod.modtype.or) { 481 if (gwj->mod.modtype.or) {
@@ -489,8 +483,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
489 mb.modtype = gwj->mod.modtype.or; 483 mb.modtype = gwj->mod.modtype.or;
490 if (nla_put(skb, CGW_MOD_OR, sizeof(mb), &mb) < 0) 484 if (nla_put(skb, CGW_MOD_OR, sizeof(mb), &mb) < 0)
491 goto cancel; 485 goto cancel;
492 else
493 nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
494 } 486 }
495 487
496 if (gwj->mod.modtype.xor) { 488 if (gwj->mod.modtype.xor) {
@@ -498,8 +490,6 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
498 mb.modtype = gwj->mod.modtype.xor; 490 mb.modtype = gwj->mod.modtype.xor;
499 if (nla_put(skb, CGW_MOD_XOR, sizeof(mb), &mb) < 0) 491 if (nla_put(skb, CGW_MOD_XOR, sizeof(mb), &mb) < 0)
500 goto cancel; 492 goto cancel;
501 else
502 nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
503 } 493 }
504 494
505 if (gwj->mod.modtype.set) { 495 if (gwj->mod.modtype.set) {
@@ -507,26 +497,18 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
507 mb.modtype = gwj->mod.modtype.set; 497 mb.modtype = gwj->mod.modtype.set;
508 if (nla_put(skb, CGW_MOD_SET, sizeof(mb), &mb) < 0) 498 if (nla_put(skb, CGW_MOD_SET, sizeof(mb), &mb) < 0)
509 goto cancel; 499 goto cancel;
510 else
511 nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(mb));
512 } 500 }
513 501
514 if (gwj->mod.csumfunc.crc8) { 502 if (gwj->mod.csumfunc.crc8) {
515 if (nla_put(skb, CGW_CS_CRC8, CGW_CS_CRC8_LEN, 503 if (nla_put(skb, CGW_CS_CRC8, CGW_CS_CRC8_LEN,
516 &gwj->mod.csum.crc8) < 0) 504 &gwj->mod.csum.crc8) < 0)
517 goto cancel; 505 goto cancel;
518 else
519 nlh->nlmsg_len += NLA_HDRLEN + \
520 NLA_ALIGN(CGW_CS_CRC8_LEN);
521 } 506 }
522 507
523 if (gwj->mod.csumfunc.xor) { 508 if (gwj->mod.csumfunc.xor) {
524 if (nla_put(skb, CGW_CS_XOR, CGW_CS_XOR_LEN, 509 if (nla_put(skb, CGW_CS_XOR, CGW_CS_XOR_LEN,
525 &gwj->mod.csum.xor) < 0) 510 &gwj->mod.csum.xor) < 0)
526 goto cancel; 511 goto cancel;
527 else
528 nlh->nlmsg_len += NLA_HDRLEN + \
529 NLA_ALIGN(CGW_CS_XOR_LEN);
530 } 512 }
531 513
532 if (gwj->gwtype == CGW_TYPE_CAN_CAN) { 514 if (gwj->gwtype == CGW_TYPE_CAN_CAN) {
@@ -535,23 +517,16 @@ static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
535 if (nla_put(skb, CGW_FILTER, sizeof(struct can_filter), 517 if (nla_put(skb, CGW_FILTER, sizeof(struct can_filter),
536 &gwj->ccgw.filter) < 0) 518 &gwj->ccgw.filter) < 0)
537 goto cancel; 519 goto cancel;
538 else
539 nlh->nlmsg_len += NLA_HDRLEN +
540 NLA_ALIGN(sizeof(struct can_filter));
541 } 520 }
542 521
543 if (nla_put_u32(skb, CGW_SRC_IF, gwj->ccgw.src_idx) < 0) 522 if (nla_put_u32(skb, CGW_SRC_IF, gwj->ccgw.src_idx) < 0)
544 goto cancel; 523 goto cancel;
545 else
546 nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(sizeof(u32));
547 524
548 if (nla_put_u32(skb, CGW_DST_IF, gwj->ccgw.dst_idx) < 0) 525 if (nla_put_u32(skb, CGW_DST_IF, gwj->ccgw.dst_idx) < 0)
549 goto cancel; 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
556cancel: 531cancel:
557 nlmsg_cancel(skb, nlh); 532 nlmsg_cancel(skb, nlh);