Patch "ice: allow hot-swapping XDP programs" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ice: allow hot-swapping XDP programs

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ice-allow-hot-swapping-xdp-programs.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 78f85b7cd897ab9a40f4700136d90bbcf30f2e41
Author: Maciej Fijalkowski <maciej.fijalkowski@xxxxxxxxx>
Date:   Thu Jun 15 13:33:26 2023 +0200

    ice: allow hot-swapping XDP programs
    
    [ Upstream commit 469748429ac81f0a6a344637fc9d3b1d16a9f3d8 ]
    
    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@xxxxxxxxx>
    Acked-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
    Reviewed-by: Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>
    Tested-by: Chandan Kumar Rout <chandanx.rout@xxxxxxxxx> (A Contingent Worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@xxxxxxxxx>
    Stable-dep-of: 04c7e14e5b0b ("ice: do not bring the VSI up, if it was down before the XDP setup")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index cd9bcc3536fb..1973b032fe05 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2633,11 +2633,11 @@ static void ice_vsi_assign_bpf_prog(struct ice_vsi *vsi, struct bpf_prog *prog)
 	int i;
 
 	old_prog = xchg(&vsi->xdp_prog, prog);
-	if (old_prog)
-		bpf_prog_put(old_prog);
-
 	ice_for_each_rxq(vsi, i)
 		WRITE_ONCE(vsi->rx_rings[i]->xdp_prog, vsi->xdp_prog);
+
+	if (old_prog)
+		bpf_prog_put(old_prog);
 }
 
 /**
@@ -2917,6 +2917,12 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
 		return -EOPNOTSUPP;
 	}
 
+	/* hot swap progs and avoid toggling link */
+	if (ice_is_xdp_ena_vsi(vsi) == !!prog) {
+		ice_vsi_assign_bpf_prog(vsi, prog);
+		return 0;
+	}
+
 	/* need to stop netdev while setting up the program for Rx rings */
 	if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
 		ret = ice_down(vsi);
@@ -2947,13 +2953,6 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
 		xdp_ring_err = ice_realloc_zc_buf(vsi, false);
 		if (xdp_ring_err)
 			NL_SET_ERR_MSG_MOD(extack, "Freeing XDP Rx resources failed");
-	} else {
-		/* safe to call even when prog == vsi->xdp_prog as
-		 * dev_xdp_install in net/core/dev.c incremented prog's
-		 * refcount so corresponding bpf_prog_put won't cause
-		 * underflow
-		 */
-		ice_vsi_assign_bpf_prog(vsi, prog);
 	}
 
 	if (if_running)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux