In preparation for support of simultaneous driver and hardware XDP support add per-mode attributes. The catch-all IFLA_XDP_PROG_ID will still be reported, but user space can now also access the program ID in a new IFLA_XDP_<mode>_PROG_ID attribute.
Unified · Split
| @@ -928,6 +928,9 @@ enum { · 927 unmodified lines | |||
| 928 | IFLA_XDP_ATTACHED, | 928 | IFLA_XDP_ATTACHED, |
| 929 | IFLA_XDP_FLAGS, | 929 | IFLA_XDP_FLAGS, |
| 930 | IFLA_XDP_PROG_ID, | 930 | IFLA_XDP_PROG_ID, |
| 931 | IFLA_XDP_DRV_PROG_ID, | ||
| 932 | IFLA_XDP_SKB_PROG_ID, | ||
| 933 | IFLA_XDP_HW_PROG_ID, | ||
| 931 | __IFLA_XDP_MAX, | 934 | __IFLA_XDP_MAX, |
| 932 | }; | 935 | }; |
| 933 | 936 | ||
| @@ -964,7 +964,8 @@ static size_t rtnl_xdp_size(void) · 963 unmodified lines | |||
| 964 | { | 964 | { |
| 965 | size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP */ | 965 | size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP */ |
| 966 | nla_total_size(1) + /* XDP_ATTACHED */ | 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 | ||
| 969 | return xdp_size; | 970 | return xdp_size; |
| 970 | } | 971 | } |
| @@ -1378,16 +1379,17 @@ static u8 rtnl_xdp_attached_mode(struct net_device *dev, u32 *prog_id) · 407 unmodified lines | |||
| 1378 | 1379 | ||
| 1379 | static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) | 1380 | static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) |
| 1380 | { | 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 | 1386 | ||
| 1385 | xdp = nla_nest_start(skb, IFLA_XDP); | 1387 | xdp = nla_nest_start(skb, IFLA_XDP); |
| 1386 | if (!xdp) | 1388 | if (!xdp) |
| 1387 | return -EMSGSIZE; | 1389 | return -EMSGSIZE; |
| 1388 | 1390 | ||
| 1389 | err = nla_put_u8(skb, IFLA_XDP_ATTACHED, | 1391 | mode = rtnl_xdp_attached_mode(dev, &prog_id); |
| 1390 | rtnl_xdp_attached_mode(dev, &prog_id)); | 1392 | err = nla_put_u8(skb, IFLA_XDP_ATTACHED, mode); |
| 1391 | if (err) | 1393 | if (err) |
| 1392 | goto err_cancel; | 1394 | goto err_cancel; |
| 1393 | 1395 | ||
| @@ -1395,6 +1397,26 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) · 1 unmodified line | |||
| 1395 | err = nla_put_u32(skb, IFLA_XDP_PROG_ID, prog_id); | 1397 | err = nla_put_u32(skb, IFLA_XDP_PROG_ID, prog_id); |
| 1396 | if (err) | 1398 | if (err) |
| 1397 | goto err_cancel; | 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 | } | 1420 | } |
| 1399 | 1421 | ||
| 1400 | nla_nest_end(skb, xdp); | 1422 | nla_nest_end(skb, xdp); |