On 04/23, Jakub Kicinski wrote:
> On Tue, 23 Apr 2019 16:22:00 -0700, Stanislav Fomichev wrote:
> > +static int query_flow_dissector(struct bpf_attach_info *attach_info)
> > +{
> > +   __u32 prog_ids[1] = {0};
> > +   __u32 prog_cnt = ARRAY_SIZE(prog_ids);
> > +   __u32 attach_flags;
> > +   int fd;
> > +   int err;
> 
> reverse christmas tree, please :)
> 
> Move the init into the code if necessary.
Ack, initialization didn't let me do that. But I think I can drop it, I
don't look prog_cnt in the syscall, maybe I should :-/

> > +   fd = open("/proc/self/ns/net", O_RDONLY);
> > +   if (fd < 0) {
> > +           p_err("can't open /proc/self/ns/net: %d",
> > +                 strerror(errno));
> > +           return -1;
> > +   }
> > +   err = bpf_prog_query(fd, BPF_FLOW_DISSECTOR, 0,
> > +                        &attach_flags, prog_ids, &prog_cnt);
> > +   close(fd);
> > +   if (err) {
> > +           if (errno == EINVAL) {
> > +                   /* Older kernel's don't support querying
> > +                    * flow dissector programs.
> > +                    */
> > +                   return 0;
> > +           }
> > +           p_err("can't query prog: %s", strerror(errno));
> > +           return -1;
> > +   }
> > +
> > +   if (prog_cnt == 1)
> > +           attach_info->flow_dissector_id = prog_ids[0];
> 
> So the count can only be 0 or 1?  Hm.
Yes, its either attached or not; there is nothing like prog_array.

> > +   return 0;
> > +}

Reply via email to