From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net-next] libbpf: add function to setup XDP Date: Sat, 9 Dec 2017 09:34:46 -0700 Message-ID: <446f0215-542c-d482-109b-20149a7ff28f@gmail.com> References: <20171209144315.25890-1-eric@regit.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net To: Eric Leblond , netdev@vger.kernel.org Return-path: Received: from mail-pg0-f65.google.com ([74.125.83.65]:40753 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbdLIQes (ORCPT ); Sat, 9 Dec 2017 11:34:48 -0500 In-Reply-To: <20171209144315.25890-1-eric@regit.org> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 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; > + } > +