Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751580AbdLIQev (ORCPT ); Sat, 9 Dec 2017 11:34:51 -0500 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 X-Google-Smtp-Source: AGs4zMaJVjDiAozoeUIv5plwRU5RKlwNkr8QoWwYzIWR+Osz7iktIkNDC6HgrzkQFh9ejFiN5pGaPw== Subject: Re: [PATCH net-next] libbpf: add function to setup XDP To: Eric Leblond , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net References: <20171209144315.25890-1-eric@regit.org> From: David Ahern Message-ID: <446f0215-542c-d482-109b-20149a7ff28f@gmail.com> Date: Sat, 9 Dec 2017 09:34:46 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171209144315.25890-1-eric@regit.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1012 Lines: 30 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; > + } > +