ice: allow hot-swapping XDP programs
authorMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Thu, 15 Jun 2023 11:33:26 +0000 (13:33 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 22 Jun 2023 17:27:55 +0000 (10:27 -0700)
commit469748429ac81f0a6a344637fc9d3b1d16a9f3d8
treeaf7f8b3f11f821410dc45439241667bb301fab61
parenta734c43caa4d9a08da521be1a2135cadf1510e75
ice: allow hot-swapping XDP programs

Currently ice driver's .ndo_bpf callback brings interface down and up
independently of XDP resources' presence. This is only needed when
either these resources have to be configured or removed. It means that
if one is switching XDP programs on-the-fly with running traffic,
packets will be dropped.

To avoid this, compare early on ice_xdp_setup_prog() state of incoming
bpf_prog pointer vs the bpf_prog pointer that is already assigned to
VSI. Do the swap in case VSI has bpf_prog and incoming one are non-NULL.

Lastly, while at it, put old bpf_prog *after* the update of Rx ring's
bpf_prog pointer. In theory previous code could expose us to a state
where Rx ring's bpf_prog would still be referring to old_prog that got
released with earlier bpf_prog_put().

Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_main.c