Skip to content

Commit

Permalink
samples: bpf: user proper argument index
Browse files Browse the repository at this point in the history
Use optind as index for argv instead of a hardcoded value.
When the program has options this leads to improper parameter handling.

Fixes: dc378a1 ("samples: bpf: get ifindex from ifname")
Signed-off-by: Ioana Ciornei <[email protected]>
Acked-by: Matteo Croce <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
IoanaCiornei authored and borkmann committed Jan 10, 2019
1 parent e3ca63d commit 11b36ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion samples/bpf/xdp1_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int main(int argc, char **argv)
return 1;
}

ifindex = if_nametoindex(argv[1]);
ifindex = if_nametoindex(argv[optind]);
if (!ifindex) {
perror("if_nametoindex");
return 1;
Expand Down

0 comments on commit 11b36ab

Please sign in to comment.