diff options
Diffstat (limited to 'samples/bpf/sampleip_user.c')
| -rw-r--r-- | samples/bpf/sampleip_user.c | 11 | 
1 files changed, 9 insertions, 2 deletions
diff --git a/samples/bpf/sampleip_user.c b/samples/bpf/sampleip_user.c index 921c505bb567..9283f47844fb 100644 --- a/samples/bpf/sampleip_user.c +++ b/samples/bpf/sampleip_user.c @@ -21,10 +21,10 @@  #define DEFAULT_FREQ	99  #define DEFAULT_SECS	5  #define MAX_IPS		8192 -#define PAGE_OFFSET	0xffff880000000000  static int map_fd;  static int nr_cpus; +static long _text_addr;  static void usage(void)  { @@ -108,7 +108,7 @@ static void print_ip_map(int fd)  	/* sort and print */  	qsort(counts, max, sizeof(struct ipcount), count_cmp);  	for (i = 0; i < max; i++) { -		if (counts[i].ip > PAGE_OFFSET) { +		if (counts[i].ip > _text_addr) {  			sym = ksym_search(counts[i].ip);  			if (!sym) {  				printf("ksym not found. Is kallsyms loaded?\n"); @@ -169,6 +169,13 @@ int main(int argc, char **argv)  		return 2;  	} +	/* used to determine whether the address is kernel space */ +	_text_addr = ksym_get_addr("_text"); +	if (!_text_addr) { +		fprintf(stderr, "ERROR: no '_text' in /proc/kallsyms\n"); +		return 3; +	} +  	/* create perf FDs for each CPU */  	nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);  	links = calloc(nr_cpus, sizeof(struct bpf_link *));  |