Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkpoint/restore support for bpf-map fd #777

Closed
rst0git opened this issue Sep 7, 2019 · 0 comments
Closed

checkpoint/restore support for bpf-map fd #777

rst0git opened this issue Sep 7, 2019 · 0 comments

Comments

@rst0git
Copy link
Member

rst0git commented Sep 7, 2019

We need to add support for checkpoint/restore of bpf-map file descriptors.

This is a simple example of how to open such file descriptor:

#include <stdio.h>
#include <unistd.h>
#include <linux/bpf.h>
#include <sys/syscall.h>

static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
			  unsigned int size)
{
	return syscall(__NR_bpf, cmd, attr, size);
}

int bpf_create_map(enum bpf_map_type map_type,
		   unsigned int key_size,
		   unsigned int value_size,
		   unsigned int max_entries)
{
	union bpf_attr attr = {
	  .map_type    = map_type,
	  .key_size    = key_size,
	  .value_size  = value_size,
	  .max_entries = max_entries
	};

	return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}

int main()
{
	int fd = bpf_create_map(BPF_MAP_TYPE_PROG_ARRAY, sizeof(int), sizeof(int), 4);
	printf("bpf-map fd: %d\n", fd);
	getchar();
	return 0;
}

When trying to checkpoint this process CRIU fails with:

Error (criu/files-ext.c:95): Can't dump file 3 of that type [600] (anon anon_inode:bpf-map)
...
Error (criu/cr-dump.c:1754): Dumping FAILED.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants