History

net: fix installing orphaned programs

When netdevice with offloaded BPF programs is destroyed the programs are orphaned and removed from the program IDA - their IDs get released (the programs may remain accessible via existing open file descriptors and pinned files). After IDs are released they are set to 0. This confuses dev_change_xdp_fd() because it compares the __dev_xdp_query() result where 0 means no program with prog->aux->id where 0 means orphaned. dev_change_xdp_fd() would have incorrectly returned success even though it had not installed the program. Since drivers already catch this case via bpf_offload_dev_match() let them handle this case. The error message drivers produce in this case ("program loaded for a different device") is in fact correct as the orphaned program must had to be loaded for a different device.

Jakub Kicinski committed 7 years ago

Commit aefc3e71 parent 41aa29a1 file · +2 −1Browse files

Unified · Split

net/core/dev.c+2−1
@@ -8421,7 +8421,8 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, · 8420 unmodified lines
84218421 return -EINVAL;
84228422 }
84238423
8424− if (prog->aux->id == prog_id) {
8424+ /* prog->aux->id may be 0 for orphaned device-bound progs */
8425+ if (prog->aux->id && prog->aux->id == prog_id) {
84258426 bpf_prog_put(prog);
84268427 return 0;
84278428 }

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