Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbdL1BBD (ORCPT ); Wed, 27 Dec 2017 20:01:03 -0500 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]:46477 "EHLO tama500.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752016AbdL1BBB (ORCPT ); Wed, 27 Dec 2017 20:01:01 -0500 Subject: Re: [PATCH 1/4] libbpf: add function to setup XDP References: <20171227022730.y27gwva2u2ilyrul@ast-mbp> <20171227180229.1926-1-eric@regit.org> <20171227180229.1926-2-eric@regit.org> From: Toshiaki Makita Message-ID: <94dcaa45-70e0-09bf-ea14-e7cf764b0ee0@lab.ntt.co.jp> Date: Thu, 28 Dec 2017 09:59:58 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20171227180229.1926-2-eric@regit.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit To: Eric Leblond , Alexei Starovoitov Cc: netdev@vger.kernel.org, daniel@iogearbox.net, linux-kernel@vger.kernel.org X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 671 Lines: 33 On 2017/12/28 3:02, Eric Leblond wrote: > Most of the code is taken from set_link_xdp_fd() in bpf_load.c and > slightly modified to be library compliant. > > Signed-off-by: Eric Leblond > --- ... > +int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) ... > + if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) { > + ret = -errno; > + goto cleanup; > + } > + > + addrlen = sizeof(sa); > + if (getsockname(sock, (struct sockaddr *)&sa, &addrlen) < 0) { > + ret = errno; forgot to prepend '-'? > + goto cleanup; > + } > + > + if (addrlen != sizeof(sa)) { > + ret = errno; errno is not set? > + goto cleanup; > + } -- Toshiaki Makita