From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Magnus Karlsson <magnus.karlsson@gmail.com>
Cc: <magnus.karlsson@intel.com>, <bjorn@kernel.org>, <ast@kernel.org>,
<daniel@iogearbox.net>, <netdev@vger.kernel.org>,
<jonathan.lemon@gmail.com>, <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf 1/3] selftests/xsk: print correct payload for packet dump
Date: Tue, 15 Nov 2022 13:29:26 +0100 [thread overview]
Message-ID: <Y3OGJv2lym4u86C/@boxer> (raw)
In-Reply-To: <20221115080538.18503-2-magnus.karlsson@gmail.com>
On Tue, Nov 15, 2022 at 09:05:36AM +0100, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
>
> Print the correct payload when the packet dump option is selected. The
> network to host conversion was forgotten and the payload was
> erronously declared to be an int instead of an unsigned int. Changed
> the loop index i too, as it does not need to be an int and was
> declared on the same row.
>
> The printout looks something like this after the fix:
>
> DEBUG>> L2: dst mac: 000A569EEE62
> DEBUG>> L2: src mac: 000A569EEE61
> DEBUG>> L3: ip_hdr->ihl: 05
> DEBUG>> L3: ip_hdr->saddr: 192.168.100.161
> DEBUG>> L3: ip_hdr->daddr: 192.168.100.162
> DEBUG>> L4: udp_hdr->src: 2121
> DEBUG>> L4: udp_hdr->dst: 2020
> DEBUG>> L5: payload: 4
> ---------------------------------------
Above would be helpful if previous output was included as well but not a
big deal i guess.
>
> Fixes: facb7cb2e909 ("selftests/bpf: Xsk selftests - SKB POLL, NOPOLL")
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
> tools/testing/selftests/bpf/xskxceiver.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> index 681a5db80dae..51e693318b3f 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.c
> +++ b/tools/testing/selftests/bpf/xskxceiver.c
> @@ -767,7 +767,7 @@ static void pkt_dump(void *pkt, u32 len)
> struct ethhdr *ethhdr;
> struct udphdr *udphdr;
> struct iphdr *iphdr;
> - int payload, i;
> + u32 payload, i;
>
> ethhdr = pkt;
> iphdr = pkt + sizeof(*ethhdr);
> @@ -792,7 +792,7 @@ static void pkt_dump(void *pkt, u32 len)
> fprintf(stdout, "DEBUG>> L4: udp_hdr->src: %d\n", ntohs(udphdr->source));
> fprintf(stdout, "DEBUG>> L4: udp_hdr->dst: %d\n", ntohs(udphdr->dest));
> /*extract L5 frame */
> - payload = *((uint32_t *)(pkt + PKT_HDR_SIZE));
> + payload = ntohl(*((u32 *)(pkt + PKT_HDR_SIZE)));
>
> fprintf(stdout, "DEBUG>> L5: payload: %d\n", payload);
> fprintf(stdout, "---------------------------------------\n");
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-11-15 12:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 8:05 [PATCH bpf 0/3] selftests/xsk: three small fixes Magnus Karlsson
2022-11-15 8:05 ` [PATCH bpf 1/3] selftests/xsk: print correct payload for packet dump Magnus Karlsson
2022-11-15 12:29 ` Maciej Fijalkowski [this message]
2022-11-15 12:40 ` Magnus Karlsson
2022-11-22 10:42 ` Maciej Fijalkowski
2022-11-15 8:05 ` [PATCH bpf 2/3] selftests/xsk: do not close unused file descriptors Magnus Karlsson
2022-11-15 8:05 ` [PATCH bpf 3/3] selftests/xsk: print correct error codes when exiting Magnus Karlsson
2022-11-15 12:30 ` [PATCH bpf 0/3] selftests/xsk: three small fixes Maciej Fijalkowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y3OGJv2lym4u86C/@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jonathan.lemon@gmail.com \
--cc=magnus.karlsson@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.