On Wed, Sep 25, 2019 at 8:47 AM Július Milan <Julius.Milan@xxxxxxxxxxxxx> wrote: > > Hi folks > > > > I am stuck with proper cleanup of AF_XDP socket. Not sure if I am doing something wrong or is it a bug. > > I create xdp socket, then I remove it and then I am trying to create it again and got EBUSY from bind syscall > > of xsk_socket__create. > > > > My cleanup looks like this: > > xsk_socket__delete(); > > xsk_umem__delete(); > > bpf_set_link_xdp_fd(ifindex, -1, opt_xdp_flags); > > > > Attaching simple test case. It’s just reduced and modified xdpsock_user.c form kernel samples. > > Tested on kernel v5.3 4d856f72c10ecb060868ed10ff1b1453943fc6c8 and related libbpf. There are a couple of fixes related to cleanup. Can you make sure your kernel has these patches commit 0402acd683c678874df6bdbc23530ca07ea19353 Author: Björn Töpel <bjorn.topel@xxxxxxxxx> Date: Thu Aug 15 11:30:13 2019 +0200 xsk: remove AF_XDP socket from map when the socket is released And libbpf has commit 5750902a6e9bc6adb77da8257c0e34db2bfdebb2 Author: Björn Töpel <bjorn.topel@xxxxxxxxx> Date: Tue Apr 30 14:45:36 2019 +0200 libbpf: proper XSKMAP cleanup commit 0e6741f092979535d159d5a851f12c88bfb7cb9a Author: Björn Töpel <bjorn.topel@xxxxxxxxx> Date: Tue Apr 30 14:45:35 2019 +0200 libbpf: fix invalid munmap call Thanks William