iplink: communicate ifindex for xdp offload
When xdpoffload option is used, communicate the ifindex down to the kernel to trigger device-specific load. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
eb91c55731
commit
4f2eb14f71
|
|
@ -631,8 +631,8 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
|
||||||
bool offload = strcmp(*argv, "xdpoffload") == 0;
|
bool offload = strcmp(*argv, "xdpoffload") == 0;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (xdp_parse(&argc, &argv, req, generic, drv,
|
if (xdp_parse(&argc, &argv, req, dev_index,
|
||||||
offload))
|
generic, drv, offload))
|
||||||
exit(-1);
|
exit(-1);
|
||||||
} else if (strcmp(*argv, "netns") == 0) {
|
} else if (strcmp(*argv, "netns") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ static int xdp_delete(struct xdp_req *xdp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic,
|
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, __u32 ifindex,
|
||||||
bool drv, bool offload)
|
bool generic, bool drv, bool offload)
|
||||||
{
|
{
|
||||||
struct bpf_cfg_in cfg = {
|
struct bpf_cfg_in cfg = {
|
||||||
.type = BPF_PROG_TYPE_XDP,
|
.type = BPF_PROG_TYPE_XDP,
|
||||||
|
|
@ -60,6 +60,12 @@ int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic,
|
||||||
.req = req,
|
.req = req,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (offload) {
|
||||||
|
if (!ifindex)
|
||||||
|
incomplete_command();
|
||||||
|
cfg.ifindex = ifindex;
|
||||||
|
}
|
||||||
|
|
||||||
if (!force)
|
if (!force)
|
||||||
xdp.flags |= XDP_FLAGS_UPDATE_IF_NOEXIST;
|
xdp.flags |= XDP_FLAGS_UPDATE_IF_NOEXIST;
|
||||||
if (generic)
|
if (generic)
|
||||||
|
|
|
||||||
4
ip/xdp.h
4
ip/xdp.h
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic,
|
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, __u32 ifindex,
|
||||||
bool drv, bool offload);
|
bool generic, bool drv, bool offload);
|
||||||
void xdp_dump(FILE *fp, struct rtattr *tb, bool link, bool details);
|
void xdp_dump(FILE *fp, struct rtattr *tb, bool link, bool details);
|
||||||
|
|
||||||
#endif /* __XDP__ */
|
#endif /* __XDP__ */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue