On 12/9/17 7:43 AM, Eric Leblond wrote:
> +     /* started nested attribute for XDP */
> +     nla = (struct nlattr *)(((char *)&req)
> +                             + NLMSG_ALIGN(req.nh.nlmsg_len));
> +     nla->nla_type = NLA_F_NESTED | 43/*IFLA_XDP*/;

as a part of the move into libbpf can the magic numbers be replaced by
the names directly and there as a comment?

There are more below.


> +     nla->nla_len = NLA_HDRLEN;
> +
> +     /* add XDP fd */
> +     nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len);
> +     nla_xdp->nla_type = 1/*IFLA_XDP_FD*/;
> +     nla_xdp->nla_len = NLA_HDRLEN + sizeof(int);
> +     memcpy((char *)nla_xdp + NLA_HDRLEN, &fd, sizeof(fd));
> +     nla->nla_len += nla_xdp->nla_len;
> +
> +     /* if user passed in any flags, add those too */
> +     if (flags) {
> +             nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len);
> +             nla_xdp->nla_type = 3/*IFLA_XDP_FLAGS*/;
> +             nla_xdp->nla_len = NLA_HDRLEN + sizeof(flags);
> +             memcpy((char *)nla_xdp + NLA_HDRLEN, &flags, sizeof(flags));
> +             nla->nla_len += nla_xdp->nla_len;
> +     }
> +

Reply via email to