diff options
author | Andy Gospodarek <andy@greyhouse.net> | 2017-05-11 15:52:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-11 21:43:30 -0400 |
commit | ad990dbe6d3ac3af1f5f4484b1126b9fc601e98a (patch) | |
tree | dd21487768f0a759ea6c2432c58e4a459fc9e183 /samples/bpf/cookie_uid_helper_example.c | |
parent | d2be3667f3769b3c60aa294ef7f2b03d1b16559c (diff) |
samples/bpf: run cleanup routines when receiving SIGTERM
Shahid Habib noticed that when xdp1 was killed from a different console the xdp
program was not cleaned-up properly in the kernel and it continued to forward
traffic.
Most of the applications in samples/bpf cleanup properly, but only when getting
SIGINT. Since kill defaults to using SIGTERM, add support to cleanup when the
application receives either SIGINT or SIGTERM.
Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
Reported-by: Shahid Habib <shahid.habib@broadcom.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/cookie_uid_helper_example.c')
-rw-r--r-- | samples/bpf/cookie_uid_helper_example.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/samples/bpf/cookie_uid_helper_example.c b/samples/bpf/cookie_uid_helper_example.c index b08ab4e88929..9d751e209f31 100644 --- a/samples/bpf/cookie_uid_helper_example.c +++ b/samples/bpf/cookie_uid_helper_example.c @@ -306,7 +306,9 @@ int main(int argc, char *argv[]) prog_attach_iptables(argv[2]); if (cfg_test_traffic) { if (signal(SIGINT, finish) == SIG_ERR) - error(1, errno, "register handler failed"); + error(1, errno, "register SIGINT handler failed"); + if (signal(SIGTERM, finish) == SIG_ERR) + error(1, errno, "register SIGTERM handler failed"); while (!test_finish) { print_table(); printf("\n"); |