lkml.org 
[lkml]   [2017]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next] libbpf: add function to setup XDP
From
Date
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;
> + }
> +

\
 
 \ /
  Last update: 2017-12-09 17:35    [W:1.300 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site