History

xdp: add per mode attributes for attached programs

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.

Jakub Kicinski committed 8 years ago

Commit 4f91da21 parent 9c48b1d2 files · +29 −4Browse files

Unified · Split

2 files
  1. include/uapi/linux/if_link.h +3 −0
  2. net/core/rtnetlink.c +26 −4
include/uapi/linux/if_link.h+3−0
@@ -928,6 +928,9 @@ enum { · 927 unmodified lines
928928 IFLA_XDP_ATTACHED,
929929 IFLA_XDP_FLAGS,
930930 IFLA_XDP_PROG_ID,
931+ IFLA_XDP_DRV_PROG_ID,
932+ IFLA_XDP_SKB_PROG_ID,
933+ IFLA_XDP_HW_PROG_ID,
931934 __IFLA_XDP_MAX,
932935 };
933936
net/core/rtnetlink.c+26−4
@@ -964,7 +964,8 @@ static size_t rtnl_xdp_size(void) · 963 unmodified lines
964964 {
965965 size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP */
966966 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 */
968969
969970 return xdp_size;
970971 }
@@ -1378,16 +1379,17 @@ static u8 rtnl_xdp_attached_mode(struct net_device *dev, u32 *prog_id) · 407 unmodified lines
13781379
13791380 static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
13801381 {
1382+ u32 prog_attr, prog_id;
13811383 struct nlattr *xdp;
1382− u32 prog_id;
13831384 int err;
1385+ u8 mode;
13841386
13851387 xdp = nla_nest_start(skb, IFLA_XDP);
13861388 if (!xdp)
13871389 return -EMSGSIZE;
13881390
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);
13911393 if (err)
13921394 goto err_cancel;
13931395
@@ -1395,6 +1397,26 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) · 1 unmodified line
13951397 err = nla_put_u32(skb, IFLA_XDP_PROG_ID, prog_id);
13961398 if (err)
13971399 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;
13981420 }
13991421
14001422 nla_nest_end(skb, xdp);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t