can: fix WARN_ON dump in net/core/rtnetlink.c:rtmsg_ifinfo()

On older kernels, e.g. 2.6.27, a WARN_ON dump in rtmsg_ifinfo()
is thrown when the CAN device is registered due to insufficient
skb space, as reported by various users. This patch adds the
rtnl_link_ops "get_size" to fix the problem. I think this patch
is required for more recent kernels as well, even if no WARN_ON
dumps are triggered. Maybe we also need "get_xstats_size" for
the CAN xstats.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Wolfgang Grandegger and committed by David S. Miller 53a0ef86 6755aeba

+17
+17
drivers/net/can/dev.c
··· 589 589 return 0; 590 590 } 591 591 592 + static size_t can_get_size(const struct net_device *dev) 593 + { 594 + struct can_priv *priv = netdev_priv(dev); 595 + size_t size; 596 + 597 + size = nla_total_size(sizeof(u32)); /* IFLA_CAN_STATE */ 598 + size += sizeof(struct can_ctrlmode); /* IFLA_CAN_CTRLMODE */ 599 + size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ 600 + size += sizeof(struct can_bittiming); /* IFLA_CAN_BITTIMING */ 601 + size += sizeof(struct can_clock); /* IFLA_CAN_CLOCK */ 602 + if (priv->bittiming_const) /* IFLA_CAN_BITTIMING_CONST */ 603 + size += sizeof(struct can_bittiming_const); 604 + 605 + return size; 606 + } 607 + 592 608 static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) 593 609 { 594 610 struct can_priv *priv = netdev_priv(dev); ··· 655 639 .setup = can_setup, 656 640 .newlink = can_newlink, 657 641 .changelink = can_changelink, 642 + .get_size = can_get_size, 658 643 .fill_info = can_fill_info, 659 644 .fill_xstats = can_fill_xstats, 660 645 };