Skip to content

Commit 24cea38

Browse files
committed
nat64-bpf: Use logging helpers and add verbose option
Use the newly-added logging helpers from logging.h and add a -v option to increase the effective log level. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
1 parent f27c7c2 commit 24cea38

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

nat64-bpf/nat64.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <libmnl/libmnl.h>
2121
#include <linux/rtnetlink.h>
2222

23+
#include "logging.h"
24+
2325
#include "nat64.h"
2426
#include "nat64_kern.skel.h"
2527

@@ -34,6 +36,7 @@ static const struct option long_options[] = {
3436
{ "v6-prefix", required_argument, NULL, '6' }, // v6 prefix to use for nat64
3537
{ "v4-prefix", required_argument, NULL, '4' }, // v4 prefix to use for nat64
3638
{ "timeout", required_argument, NULL, 't' }, // Address mapping timeout interval in s
39+
{ "verbose", required_argument, NULL, 'v' }, // verbose logging
3740
{ 0, 0, NULL, 0 }
3841
};
3942

@@ -85,7 +88,7 @@ static int parse_arguments(int argc, char *argv[], struct nat64_user_config *con
8588
config->c.v6_prefix.s6_addr[2] = 0xff;
8689
config->c.v6_prefix.s6_addr[3] = 0x9b;
8790

88-
while ((opt = getopt_long(argc, argv, "i:6:4:t:a:hu", long_options,
91+
while ((opt = getopt_long(argc, argv, "i:6:4:t:a:huv", long_options,
8992
NULL)) != -1) {
9093
switch (opt) {
9194
case 'i':
@@ -161,6 +164,9 @@ static int parse_arguments(int argc, char *argv[], struct nat64_user_config *con
161164
case 'u':
162165
config->unload = true;
163166
break;
167+
case 'v':
168+
increase_log_level();
169+
break;
164170
default:
165171
fprintf(stderr, "Unknown option %s\n", argv[optind]);
166172
return -EINVAL;
@@ -362,6 +368,8 @@ int main(int argc, char *argv[])
362368
DECLARE_LIBBPF_OPTS(bpf_tc_opts, attach_egress);
363369
DECLARE_LIBBPF_OPTS(bpf_tc_opts, attach_ingress);
364370

371+
init_lib_logging();
372+
365373
err = parse_arguments(argc, argv, &cfg);
366374
if (err)
367375
return EXIT_FAILURE;

0 commit comments

Comments
 (0)