Skip to contentSkip to conversation

xen/netback: fix build warning

PATCH In review Juergen Gross 4 participants 7 messages Dec 7, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/netback: fix build warning

Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") introduced a (valid) build warning.

Fix it.

Fixes ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")
---
 drivers/net/xen-netback/netback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xen-netback/netback.c +1 -1
index 054ac0e897f6..bf627af723bf 100644
@@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue,
 	const bool sharedslot = nr_frags &&
 				frag_get_pending_idx(&shinfo->frags[0]) ==
 				    copy_pending_idx(skb, copy_count(skb) - 1);
-	int i, err;
+	int i, err = 0;
 
 	for (i = 0; i < copy_count(skb); i++) {
 		int newerr;
Signature · 1 line
2.35.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Juergen Gross

Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") introduced a (valid) build warning.

Fix it.

Fixes ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")

drivers/net/xen-netback/netback.c static int xenvif_tx_check_gop(struct xenvif_queue *queue, · line 536

Quoted 11 lines
drivers/net/xen-netback/netback.c +1 -1
@@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue,
 	const bool sharedslot = nr_frags &&
 				frag_get_pending_idx(&shinfo->frags[0]) ==
 				    copy_pending_idx(skb, copy_count(skb) - 1);
-	int i, err;
+	int i, err = 0;
 
 	for (i = 0; i < copy_count(skb); i++) {
 		int newerr;

I'm afraid other logic (below here) is now slightly wrong as well, in particular

				/* If the mapping of the first frag was OK, but
				 * the header's copy failed, and they are
				 * sharing a slot, send an error
				 */
				if (i == 0 && !first_shinfo && sharedslot)
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_ERROR);
				else
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_OKAY);

which looks to be intended to deal with _only_ failure of the one shared part of the header, whereas "err" now can indicate an error on any earlier part as well.

Jan

#2 lore raw
Quoted 37 lines · Jan Beulich
Quoted 7 lines · Juergen Gross

Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") introduced a (valid) build warning.

Fix it.

Fixes ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")

drivers/net/xen-netback/netback.c static int xenvif_tx_check_gop(struct xenvif_queue *queue, · line 536

Quoted 11 lines
drivers/net/xen-netback/netback.c +1 -1
@@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue,
  	const bool sharedslot = nr_frags &&
  				frag_get_pending_idx(&shinfo->frags[0]) ==
  				    copy_pending_idx(skb, copy_count(skb) - 1);
-	int i, err;
+	int i, err = 0;
 
  	for (i = 0; i < copy_count(skb); i++) {
  		int newerr;

I'm afraid other logic (below here) is now slightly wrong as well, in particular

				/* If the mapping of the first frag was OK, but
				 * the header's copy failed, and they are
				 * sharing a slot, send an error
				 */
				if (i == 0 && !first_shinfo && sharedslot)
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_ERROR);
				else
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_OKAY);
Quoted 3 lines

which looks to be intended to deal with _only_ failure of the one shared part of the header, whereas "err" now can indicate an error on any earlier part as well.

The comment at the end of that loop seems to imply this is the desired behavior:

		/* Remember the error: invalidate all subsequent fragments. */
		err = newerr;
	}

Juergen

#3 lore raw
Quoted 42 lines · Juergen Gross
Quoted 37 lines · Jan Beulich
Quoted 7 lines · Juergen Gross

Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") introduced a (valid) build warning.

Fix it.

Fixes ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")

drivers/net/xen-netback/netback.c static int xenvif_tx_check_gop(struct xenvif_queue *queue, · line 536

Quoted 11 lines
drivers/net/xen-netback/netback.c +1 -1
@@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue,
  	const bool sharedslot = nr_frags &&
  				frag_get_pending_idx(&shinfo->frags[0]) ==
  				    copy_pending_idx(skb, copy_count(skb) - 1);
-	int i, err;
+	int i, err = 0;
 
  	for (i = 0; i < copy_count(skb); i++) {
  		int newerr;

I'm afraid other logic (below here) is now slightly wrong as well, in particular

				/* If the mapping of the first frag was OK, but
				 * the header's copy failed, and they are
				 * sharing a slot, send an error
				 */
				if (i == 0 && !first_shinfo && sharedslot)
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_ERROR);
				else
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_OKAY);
Quoted 3 lines

which looks to be intended to deal with _only_ failure of the one shared part of the header, whereas "err" now can indicate an error on any earlier part as well.

Quoted 6 lines

The comment at the end of that loop seems to imply this is the desired behavior:

		/* Remember the error: invalidate all subsequent fragments. */
		err = newerr;
	}

This says "subsequent", whereas I was describing a situation where e.g. the first piece of header copying failed, the 2nd (shared part) succeeded, and the mapping of the rest of the shared part also succeeded. At the very least the comment in the code fragment I did quote then has become stale. Furthermore, if "all subsequent" really meant all, then in the new first loop this isn't followed either - an error response is sent only for the pieces where copying failed.

Jan

#4 lore raw
Quoted 50 lines · Jan Beulich
Quoted 42 lines · Juergen Gross
Quoted 37 lines · Jan Beulich
Quoted 7 lines · Juergen Gross

Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") introduced a (valid) build warning.

Fix it.

Fixes ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")

drivers/net/xen-netback/netback.c static int xenvif_tx_check_gop(struct xenvif_queue *queue, · line 536

Quoted 11 lines
drivers/net/xen-netback/netback.c +1 -1
@@ -530,7 +530,7 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue,
   	const bool sharedslot = nr_frags &&
   				frag_get_pending_idx(&shinfo->frags[0]) ==
   				    copy_pending_idx(skb, copy_count(skb) - 1);
-	int i, err;
+	int i, err = 0;
 
   	for (i = 0; i < copy_count(skb); i++) {
   		int newerr;

I'm afraid other logic (below here) is now slightly wrong as well, in particular

				/* If the mapping of the first frag was OK, but
				 * the header's copy failed, and they are
				 * sharing a slot, send an error
				 */
				if (i == 0 && !first_shinfo && sharedslot)
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_ERROR);
				else
					xenvif_idx_release(queue, pending_idx,
							   XEN_NETIF_RSP_OKAY);
Quoted 3 lines

which looks to be intended to deal with _only_ failure of the one shared part of the header, whereas "err" now can indicate an error on any earlier part as well.

Quoted 6 lines

The comment at the end of that loop seems to imply this is the desired behavior:

		/* Remember the error: invalidate all subsequent fragments. */
		err = newerr;
	}
Quoted 7 lines

This says "subsequent", whereas I was describing a situation where e.g. the first piece of header copying failed, the 2nd (shared part) succeeded, and the mapping of the rest of the shared part also succeeded. At the very least the comment in the code fragment I did quote then has become stale. Furthermore, if "all subsequent" really meant all, then in the new first loop this isn't followed either - an error response is sent only for the pieces where copying failed.

Having stared at the code for quite some time now, I think there is some room for confusion: "invalidating" the frags seems not to be the same as setting the related idx to have an error.

XEN_NETIF_RSP_ERROR seems to be set only for the idx which really had an error, while if any of them had one, all idx-es must be unmapped, have a status set, and returned to the frontend.

And I think the code is doing this quite fine.

The comments _could_ need some improvements, though.

And some more restructuring could help, too (at least I think that the "goto check_frags" is a rather clumsy construct - I'd prefer splitting xenvif_tx_check_gop() into some helper functions and a rather small body calling those with e.g. different shinfo values).

Juergen

Reviewed-by on v1 1/1
#5 lore raw
In reply to Juergen Gross
Quoted 9 lines

From: Xen-devel <[email protected]> on behalf of Juergen Gross <[email protected]>
Sent: Wednesday, December 7, 2022 7:23 AM
To: [email protected] <[email protected]>; [email protected] <[email protected]>
Cc: Juergen Gross <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH] xen/netback: fix build warning

Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in
the non-linear area") introduced a (valid) build warning.

Quoted 4 lines

Fix it.

Fixes ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")
Tested-by on v1 1/1
#6 lore raw
In reply to Juergen Gross
Quoted 8 lines · Juergen Gross

Commit ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area") introduced a (valid) build warning.

Fix it.

Fixes ad7f402ae4f4 ("xen/netback: Ensure protocol headers don't fall in the non-linear area")

I applied ad7f402ae4f4 to 5.15.y and 5.4.y and it broke networking with my driver domains. The frontend failed to DHCP an address and it didn't look like any packets were getting through. This patch fixed networking with 5.15.y and 5.4.y.

I think the commit message is worth expanding that this is more than just a build warning.

Thanks,
Jason