forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/can/vxcan.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * vxcan.c - Virtual CAN Tunnel for cross namespace communication
34 *
....@@ -6,18 +7,6 @@
67 * for network interface pairs in a common and established way.
78 *
89 * Copyright (c) 2017 Oliver Hartkopp <socketcan@hartkopp.net>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the version 2 of the GNU General Public License
12
- * as published by the Free Software Foundation
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
2110 */
2211
2312 #include <linux/module.h>
....@@ -29,6 +18,7 @@
2918 #include <linux/can/dev.h>
3019 #include <linux/can/skb.h>
3120 #include <linux/can/vxcan.h>
21
+#include <linux/can/can-ml.h>
3222 #include <linux/slab.h>
3323 #include <net/rtnetlink.h>
3424
....@@ -151,14 +141,19 @@
151141
152142 static void vxcan_setup(struct net_device *dev)
153143 {
144
+ struct can_ml_priv *can_ml;
145
+
154146 dev->type = ARPHRD_CAN;
155147 dev->mtu = CANFD_MTU;
156148 dev->hard_header_len = 0;
157149 dev->addr_len = 0;
158150 dev->tx_queue_len = 0;
159
- dev->flags = (IFF_NOARP|IFF_ECHO);
151
+ dev->flags = IFF_NOARP;
160152 dev->netdev_ops = &vxcan_netdev_ops;
161153 dev->needs_free_netdev = true;
154
+
155
+ can_ml = netdev_priv(dev) + ALIGN(sizeof(struct vxcan_priv), NETDEV_ALIGN);
156
+ can_set_ml_priv(dev, can_ml);
162157 }
163158
164159 /* forward declaration for rtnl_create_link() */
....@@ -184,12 +179,7 @@
184179
185180 nla_peer = data[VXCAN_INFO_PEER];
186181 ifmp = nla_data(nla_peer);
187
- err = rtnl_nla_parse_ifla(peer_tb,
188
- nla_data(nla_peer) +
189
- sizeof(struct ifinfomsg),
190
- nla_len(nla_peer) -
191
- sizeof(struct ifinfomsg),
192
- NULL);
182
+ err = rtnl_nla_parse_ifinfomsg(peer_tb, nla_peer, extack);
193183 if (err < 0)
194184 return err;
195185
....@@ -209,7 +199,7 @@
209199 return PTR_ERR(peer_net);
210200
211201 peer = rtnl_create_link(peer_net, ifname, name_assign_type,
212
- &vxcan_link_ops, tbp);
202
+ &vxcan_link_ops, tbp, extack);
213203 if (IS_ERR(peer)) {
214204 put_net(peer_net);
215205 return PTR_ERR(peer);
....@@ -294,7 +284,7 @@
294284
295285 static struct rtnl_link_ops vxcan_link_ops = {
296286 .kind = DRV_NAME,
297
- .priv_size = sizeof(struct vxcan_priv),
287
+ .priv_size = ALIGN(sizeof(struct vxcan_priv), NETDEV_ALIGN) + sizeof(struct can_ml_priv),
298288 .setup = vxcan_setup,
299289 .newlink = vxcan_newlink,
300290 .dellink = vxcan_dellink,