By improving the BPF_LINK_UPDATE command of bpf(), it should allow you to conveniently switch between different struct_ops on a single bpf_link. This would enable smoother transitions from one struct_ops to another. The struct_ops maps passing along with BPF_LINK_UPDATE should have the BPF_F_LINK flag.
Showing the changes to include/uapi (1 of 6 files). Show all
Unified · Split
| @@ -1555,12 +1555,23 @@ union bpf_attr { · 1554 unmodified lines | ||
| 1555 | 1555 | |
| 1556 | 1556 | struct { /* struct used by BPF_LINK_UPDATE command */ |
| 1557 | 1557 | __u32 link_fd; /* link fd */ |
| 1558 | − /* new program fd to update link with */ | |
| 1559 | − __u32 new_prog_fd; | |
| 1558 | + union { | |
| 1559 | + /* new program fd to update link with */ | |
| 1560 | + __u32 new_prog_fd; | |
| 1561 | + /* new struct_ops map fd to update link with */ | |
| 1562 | + __u32 new_map_fd; | |
| 1563 | + }; | |
| 1560 | 1564 | __u32 flags; /* extra flags */ |
| 1561 | − /* expected link's program fd; is specified only if | |
| 1562 | − * BPF_F_REPLACE flag is set in flags */ | |
| 1563 | − __u32 old_prog_fd; | |
| 1565 | + union { | |
| 1566 | + /* expected link's program fd; is specified only if | |
| 1567 | + * BPF_F_REPLACE flag is set in flags. | |
| 1568 | + */ | |
| 1569 | + __u32 old_prog_fd; | |
| 1570 | + /* expected link's map fd; is specified only | |
| 1571 | + * if BPF_F_REPLACE flag is set. | |
| 1572 | + */ | |
| 1573 | + __u32 old_map_fd; | |
| 1574 | + }; | |
| 1564 | 1575 | } link_update; |
| 1565 | 1576 | |
| 1566 | 1577 | struct { |