Skip to contentSkip to conversation

i40e: Log error for oversized MTU on device

PATCH New Eryk Rybak 2 participants 4 messages Jan 14, 2021 – Feb 10, 2021

Subsystems (2)
lore
Share & tools
lore

Eryk Rybak

author
#0 lore raw

PATCH v2 1/1 i40e: Log error for oversized MTU on device

When attempting to link XDP prog with MTU larger than supported, user is not informed why XDP linking fails. Adding proper error message: "MTU too large to enable XDP".
Due to the lack of support for non-static variables in netlinks extended ACK feature, additional information has been added to dmesg to better inform about invalid MTU setting.

---
v2: add dmesg trace, change commit message

 drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +9 -4
index 2a7e116..0ea04cb 100644
@@ -12933,9 +12933,10 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb,
  * i40e_xdp_setup - add/remove an XDP program
  * @vsi: VSI to changed
  * @prog: XDP program
+ * @extack: netlink extended ack
  **/
-static int i40e_xdp_setup(struct i40e_vsi *vsi,
-			  struct bpf_prog *prog)
+static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog,
+			  struct netlink_ext_ack *extack)
 {
 	int frame_size = vsi->netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
 	struct i40e_pf *pf = vsi->back;
@@ -12944,8 +12945,12 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi,
 	int i;
 
 	/* Don't allow frames that span over multiple buffers */
-	if (frame_size > vsi->rx_buf_len)
+	if (frame_size > vsi->rx_buf_len) {
+		NL_SET_ERR_MSG_MOD(extack, "MTU too large to enable XDP");
+		dev_info(&pf->pdev->dev,
+			 "MTU of %u bytes is too large to enable XDP (maximum: %u bytes)\n", vsi->netdev->mtu, vsi->rx_buf_len);
 		return -EINVAL;
+	}
 
 	/* When turning XDP on->off/off->on we reset and rebuild the rings. */
 	need_reset = (i40e_enabled_xdp_vsi(vsi) != !!prog);
@@ -13254,7 +13259,7 @@ static int i40e_xdp(struct net_device *dev,
 
 	switch (xdp->command) {
 	case XDP_SETUP_PROG:
-		return i40e_xdp_setup(vsi, xdp->prog);
+		return i40e_xdp_setup(vsi, xdp->prog, xdp->extack);
 	case XDP_SETUP_XSK_POOL:
 		return i40e_xsk_pool_setup(vsi, xdp->xsk.pool,
 					   xdp->xsk.queue_id);

base-commit: 3fac2a7d07287daca672479f02d4849c27bc7806

Signature · 7 lines
2.20.1

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Sowackiego 173 | 80-298 Gdask | Sd Rejonowy Gdask Pnoc | VII Wydzia Gospodarczy Krajowego Rejestru Sdowego - KRS 101882 | NIP 957-07-52-316 | Kapita zakadowy 200.000 PLN.
Ta wiadomo wraz z zacznikami jest przeznaczona dla okrelonego adresata i moe zawiera informacje poufne. W razie przypadkowego otrzymania tej wiadomoci, prosimy o powiadomienie nadawcy oraz trwae jej usunicie; jakiekolwiek przegldanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
#1 lore raw

PATCH v2 1/1 i40e: Log error for oversized MTU on device

Quoted 37 lines · Eryk Rybak

When attempting to link XDP prog with MTU larger than supported, user is not informed why XDP linking fails. Adding proper error message: "MTU too large to enable XDP".
Due to the lack of support for non-static variables in netlinks extended ACK feature, additional information has been added to dmesg to better inform about invalid MTU setting.

---
v2: add dmesg trace, change commit message

 drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -2
index 2a7e116..0ea04cb 100644
@@ -12933,9 +12933,10 @@ static netdev_features_t
 i40e_features_check(struct sk_buff *skb,
  * i40e_xdp_setup - add/remove an XDP program
  * @vsi: VSI to changed
  * @prog: XDP program
+ * @extack: netlink extended ack
  **/
-static int i40e_xdp_setup(struct i40e_vsi *vsi,
-			  struct bpf_prog *prog)
+static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog
 *prog,
+			  struct netlink_ext_ack *extack)
 {

int frame_size = vsi->netdev->mtu + ETH_HLEN + ETH_FCS_LEN +
VLAN_HLEN;

drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
 	struct i40e_pf *pf = vsi->back;
@@ -12944,8 +12945,12 @@ static int i40e_xdp_setup(struct i40e_vsi
 *vsi,

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_xdp_setup(struct i40e_vsi · line 12954

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -1
 	int i;
 
 	/* Don't allow frames that span over multiple buffers */
-	if (frame_size > vsi->rx_buf_len)
+	if (frame_size > vsi->rx_buf_len) {
+		NL_SET_ERR_MSG_MOD(extack, "MTU too large to enable
 XDP");
+		dev_info(&pf->pdev->dev,
+			 "MTU of %u bytes is too large to enable XDP
 (maximum: %u bytes)\n", vsi->netdev->mtu, vsi->rx_buf_len);

This is over 100 char, I've already fixed it up though so no need to resend.

#2 lore raw

PATCH v2 1/1 i40e: Log error for oversized MTU on device

In reply to Eryk Rybak
Quoted 16 lines

From: Intel-wired-lan <[email protected]> On Behalf Of Eryk Rybak
Sent: Thursday, January 14, 2021 9:47 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Rybak, Eryk Roch <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v2] i40e: Log error for oversized MTU on device

When attempting to link XDP prog with MTU larger than supported, user is not informed why XDP linking fails. Adding proper error message: "MTU too large to enable XDP".
Due to the lack of support for non-static variables in netlinks extended ACK feature, additional information has been added to dmesg to better inform about invalid MTU setting.

Quoted 7 lines

---
v2: add dmesg trace, change commit message drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++++----

 1 file changed, 9 insertions(+), 4 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#3 lore raw

PATCH v2 1/1 i40e: Log error for oversized MTU on device

In reply to Eryk Rybak
Quoted 16 lines

From: Intel-wired-lan <[email protected]> On Behalf Of Eryk Rybak
Sent: Thursday, January 14, 2021 9:47 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Rybak, Eryk Roch <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v2] i40e: Log error for oversized MTU on device

When attempting to link XDP prog with MTU larger than supported, user is not informed why XDP linking fails. Adding proper error message: "MTU too large to enable XDP".
Due to the lack of support for non-static variables in netlinks extended ACK feature, additional information has been added to dmesg to better inform about invalid MTU setting.

Quoted 7 lines

---
v2: add dmesg trace, change commit message drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++++----

 1 file changed, 9 insertions(+), 4 deletions(-)