<div dir="ltr">Hi Andrei,<div><br></div><div>I have created a draft pull request: <a href="https://github.com/checkpoint-restore/criu/pull/1044">https://github.com/checkpoint-restore/criu/pull/1044</a>.</div><div><br></div><div>I await your kind feedback.</div><div><br></div><div>Thank you,</div><div>Abhishek.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 23, 2020 at 1:32 PM Abhishek Vijeev <<a href="mailto:abhishek.vijeev@gmail.com">abhishek.vijeev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Andrei,<div><br></div><div>Thank you for your response.</div><div><br></div><div>I will take into account all your suggestions and submit a consolidated pull request </div><div>with these changes after implementing a test for BPF map files.</div><div><br></div><div>Thank you,</div><div>Abhishek.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 23, 2020 at 8:58 AM Andrei Vagin <<a href="mailto:avagin@gmail.com" target="_blank">avagin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">You need to implement a test for BPF map files.<br>
<br>
You can look at the existing tests as examples:<br>
<a href="https://github.com/checkpoint-restore/criu/tree/criu-dev/test/zdtm/static" rel="noreferrer" target="_blank">https://github.com/checkpoint-restore/criu/tree/criu-dev/test/zdtm/static</a><br>
<br>
Thanks,<br>
Andrei<br>
<br>
On Wed, Apr 22, 2020 at 12:57:41AM +0530, Abhishek Vijeev wrote:<br>
> ---<br>
> criu/proc_parse.c | 81 ++++++++++++++++++++++++++++++++++++++++<br>
> images/bpfmap-file.proto | 6 +--<br>
> 2 files changed, 84 insertions(+), 3 deletions(-)<br>
> <br>
> diff --git a/criu/proc_parse.c b/criu/proc_parse.c<br>
> index 4a22700a..46d6afd6 100644<br>
> --- a/criu/proc_parse.c<br>
> +++ b/criu/proc_parse.c<br>
> @@ -1683,6 +1683,73 @@ nodata:<br>
> goto parse_err;<br>
> }<br>
> <br>
> +static int parse_bpfmap(struct bfd *f, char *str, BpfmapFileEntry *bpf)<br>
> +{<br>
> + /*<br>
> + * Format is<br>
> + * map_type: 3<br>
> + * key_size: 4<br>
> + * value_size: 4<br>
> + * max_entries: 4<br>
> + * map_flags: 0x0<br>
> + * memlock: 4096<br>
> + * map_id: 10<br>
> + * frozen: 0<br>
> + */<br>
> +<br>
> + if (sscanf(str, "map_type: %u", &bpf->map_type) != 1)<br>
> + goto parse_err;<br>
> +<br>
> + str = breadline(f);<br>
> + if (IS_ERR_OR_NULL(str))<br>
> + goto nodata;<br>
> + if (sscanf(str, "key_size: %u", &bpf->key_size) != 1)<br>
> + goto parse_err;<br>
> +<br>
> + str = breadline(f);<br>
> + if (IS_ERR_OR_NULL(str))<br>
> + goto nodata;<br>
> + if (sscanf(str, "value_size: %u", &bpf->value_size) != 1)<br>
> + goto parse_err;<br>
> +<br>
> + str = breadline(f);<br>
> + if (IS_ERR_OR_NULL(str))<br>
> + goto nodata;<br>
> + if (sscanf(str, "max_entries: %u", &bpf->max_entries) != 1)<br>
> + goto parse_err;<br>
> +<br>
> + str = breadline(f);<br>
> + if (IS_ERR_OR_NULL(str))<br>
> + goto nodata;<br>
> + if (sscanf(str, "map_flags: %lu", &bpf->map_flags) != 1)<br>
> + goto parse_err;<br>
> +<br>
> + str = breadline(f);<br>
> + if (IS_ERR_OR_NULL(str))<br>
> + goto nodata;<br>
> + if (sscanf(str, "memlock: %lu", &bpf->memlock) != 1)<br>
> + goto parse_err;<br>
> +<br>
> + str = breadline(f);<br>
> + if (IS_ERR_OR_NULL(str))<br>
> + goto nodata;<br>
> + if (sscanf(str, "map_id: %u", &bpf->map_id) != 1)<br>
> + goto parse_err;<br>
> +<br>
> + str = breadline(f);<br>
> + if (IS_ERR_OR_NULL(str))<br>
> + goto nodata;<br>
> + if (sscanf(str, "frozen: %d", &bpf->frozen) != 1)<br>
> + goto parse_err;<br>
> + return 0;<br>
> +<br>
> +parse_err:<br>
> + return -1;<br>
> +nodata:<br>
> + pr_err("No data left in proc file while parsing bpfmap\n");<br>
> + goto parse_err;<br>
> +}<br>
> +<br>
> #define fdinfo_field(str, field) !strncmp(str, field":", sizeof(field))<br>
> <br>
> static int parse_file_lock_buf(char *buf, struct file_lock *fl,<br>
> @@ -2015,6 +2082,20 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type, void *arg)<br>
> entry_met = true;<br>
> continue;<br>
> }<br>
> + if (fdinfo_field(str, "map_type")) {<br>
> +<br>
> + BpfmapFileEntry *bpf = arg;<br>
> +<br>
> + if (type != FD_TYPES__BPFMAP)<br>
> + goto parse_err;<br>
> +<br>
> + ret = parse_bpfmap(&f, str, bpf);<br>
> + if (ret)<br>
> + goto parse_err;<br>
> +<br>
> + entry_met = true;<br>
> + continue;<br>
> + }<br>
> }<br>
> <br>
> exit_code = 0;<br>
> diff --git a/images/bpfmap-file.proto b/images/bpfmap-file.proto<br>
> index a21c032c..9f0b8593 100644<br>
> --- a/images/bpfmap-file.proto<br>
> +++ b/images/bpfmap-file.proto<br>
> @@ -15,9 +15,9 @@ message bpfmap_file_entry {<br>
> required uint32 max_entries = 10;<br>
> <br>
> optional sint32 mnt_id = 11 [default = -1];<br>
> - optional uint64 map_flags = 12;<br>
> - optional uint64 memlock = 13;<br>
> - optional bool frozen = 14;<br>
> + required uint64 map_flags = 12;<br>
> + required uint64 memlock = 13;<br>
> + required bool frozen = 14;<br>
> <br>
> <br>
> }<br>
> \ No newline at end of file<br>
> -- <br>
> 2.17.1<br>
> <br>
> _______________________________________________<br>
> CRIU mailing list<br>
> <a href="mailto:CRIU@openvz.org" target="_blank">CRIU@openvz.org</a><br>
> <a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/mailman/listinfo/criu</a><br>
</blockquote></div>
</blockquote></div>