rtnetlink.c (6b16f5d12202a23d875915349cc031c07fe1b3ec) rtnetlink.c (4f91da26c81145f255cb153152ffed70014b1c41)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Routing netlink socket interface: protocol independent part.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 950 unchanged lines hidden (view full) ---

959 else
960 return port_self_size;
961}
962
963static size_t rtnl_xdp_size(void)
964{
965 size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP */
966 nla_total_size(1) + /* XDP_ATTACHED */
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Routing netlink socket interface: protocol independent part.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 950 unchanged lines hidden (view full) ---

959 else
960 return port_self_size;
961}
962
963static size_t rtnl_xdp_size(void)
964{
965 size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP */
966 nla_total_size(1) + /* XDP_ATTACHED */
967 nla_total_size(4); /* XDP_PROG_ID */
967 nla_total_size(4) + /* XDP_PROG_ID */
968 nla_total_size(4); /* XDP_<mode>_PROG_ID */
968
969 return xdp_size;
970}
971
972static noinline size_t if_nlmsg_size(const struct net_device *dev,
973 u32 ext_filter_mask)
974{
975 return NLMSG_ALIGN(sizeof(struct ifinfomsg))

--- 397 unchanged lines hidden (view full) ---

1373 __dev_xdp_query(dev, ops->ndo_bpf, &xdp);
1374 *prog_id = xdp.prog_id;
1375
1376 return xdp.prog_attached;
1377}
1378
1379static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
1380{
969
970 return xdp_size;
971}
972
973static noinline size_t if_nlmsg_size(const struct net_device *dev,
974 u32 ext_filter_mask)
975{
976 return NLMSG_ALIGN(sizeof(struct ifinfomsg))

--- 397 unchanged lines hidden (view full) ---

1374 __dev_xdp_query(dev, ops->ndo_bpf, &xdp);
1375 *prog_id = xdp.prog_id;
1376
1377 return xdp.prog_attached;
1378}
1379
1380static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
1381{
1382 u32 prog_attr, prog_id;
1381 struct nlattr *xdp;
1383 struct nlattr *xdp;
1382 u32 prog_id;
1383 int err;
1384 int err;
1385 u8 mode;
1384
1385 xdp = nla_nest_start(skb, IFLA_XDP);
1386 if (!xdp)
1387 return -EMSGSIZE;
1388
1386
1387 xdp = nla_nest_start(skb, IFLA_XDP);
1388 if (!xdp)
1389 return -EMSGSIZE;
1390
1389 err = nla_put_u8(skb, IFLA_XDP_ATTACHED,
1390 rtnl_xdp_attached_mode(dev, &prog_id));
1391 mode = rtnl_xdp_attached_mode(dev, &prog_id);
1392 err = nla_put_u8(skb, IFLA_XDP_ATTACHED, mode);
1391 if (err)
1392 goto err_cancel;
1393
1394 if (prog_id) {
1395 err = nla_put_u32(skb, IFLA_XDP_PROG_ID, prog_id);
1396 if (err)
1397 goto err_cancel;
1393 if (err)
1394 goto err_cancel;
1395
1396 if (prog_id) {
1397 err = nla_put_u32(skb, IFLA_XDP_PROG_ID, prog_id);
1398 if (err)
1399 goto err_cancel;
1400
1401 switch (mode) {
1402 case XDP_ATTACHED_DRV:
1403 prog_attr = IFLA_XDP_DRV_PROG_ID;
1404 break;
1405 case XDP_ATTACHED_SKB:
1406 prog_attr = IFLA_XDP_SKB_PROG_ID;
1407 break;
1408 case XDP_ATTACHED_HW:
1409 prog_attr = IFLA_XDP_HW_PROG_ID;
1410 break;
1411 case XDP_ATTACHED_NONE:
1412 default:
1413 err = -EINVAL;
1414 goto err_cancel;
1415 }
1416
1417 err = nla_put_u32(skb, prog_attr, prog_id);
1418 if (err)
1419 goto err_cancel;
1398 }
1399
1400 nla_nest_end(skb, xdp);
1401 return 0;
1402
1403err_cancel:
1404 nla_nest_cancel(skb, xdp);
1405 return err;

--- 3378 unchanged lines hidden ---
1420 }
1421
1422 nla_nest_end(skb, xdp);
1423 return 0;
1424
1425err_cancel:
1426 nla_nest_cancel(skb, xdp);
1427 return err;

--- 3378 unchanged lines hidden ---